@descope/user-profile-widget 0.0.53 → 0.0.55
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/esm/index.js +2 -2
- 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.0.
|
|
3
|
+
* @descope/user-profile-widget v0.0.55
|
|
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,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function 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(...o)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,o)||(t=o,n=e(...o)),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 o=e(n);return o[t]=!0,o}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}function f(e){this.message=e}c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,f.prototype=new Error,f.prototype.name="InvalidCharacterError";var g="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new f("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,r=0,s="";o=t.charAt(r++);~o&&(n=i%4?64*n+o:o,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function m(e){this.message=e}function v(e,t){if("string"!=typeof e)throw new m("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(g(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return g(t)}}(e.split(".")[n]))}catch(e){throw new m("Invalid token specified: "+e.message)}}m.prototype=new Error,m.prototype.name="InvalidTokenError";var b="/v1/auth/accesskey/exchange",y="/v1/auth/otp/verify",w="/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",j="/v1/auth/magiclink/verify",x="/v1/auth/magiclink/signin",C="/v1/auth/magiclink/signup",E={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},A="/v1/auth/magiclink/signup-in",O="/v1/auth/enchantedlink/verify",U="/v1/auth/enchantedlink/signin",R="/v1/auth/enchantedlink/signup",M="/v1/auth/enchantedlink/pending-session",T={email:"/v1/auth/enchantedlink/update/email"},_="/v1/auth/enchantedlink/signup-in",P="/v1/auth/oauth/authorize",W="/v1/auth/oauth/exchange",L="v1/auth/oauth/native/start",$="v1/auth/oauth/native/finish",D="/v1/auth/saml/authorize",N="/v1/auth/saml/exchange",q="/v1/auth/totp/verify",F="/v1/auth/totp/signup",z="/v1/auth/totp/update",H="/v1/auth/notp/whatsapp/signin",V="/v1/auth/notp/whatsapp/signup",K="/v1/auth/notp/whatsapp/signup-in",B="/v1/auth/notp/pending-session",J={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},X={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Y={start:"/v1/auth/webauthn/signup-in/start"},Z={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},G="/v1/auth/password/signup",Q="/v1/auth/password/signin",ee="/v1/auth/password/reset",te="/v1/auth/password/update",ne="/v1/auth/password/replace",oe="/v1/auth/password/policy",ie="/v1/auth/refresh",re="/v1/auth/tenant/select",se="/v1/auth/logout",ae="/v1/auth/logoutall",le="/v1/auth/me",ce="/v1/auth/me/history",de="/v1/flow/start",ue="/v1/flow/next";const he="<region>",pe=`https://api.${he}descope.com`,fe=6e5,ge="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")}};var ve;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(ve||(ve={}));const be=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),ye=e=>void 0===e?void 0:JSON.stringify(e),we=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},ke=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>me().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return me().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,s),l=async o=>{var s;const l=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:c,body:d,headers:u,queryParams:h,method:p,token:f}=l,g={headers:be(we(t,f),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.18.2"},(null==n?void 0:n.baseHeaders)||{},u),method:p,body:ye(d)};null!==r&&(g.credentials=r||"include");const m=await a((({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(he,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){r=`${r}?`;const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${t}=${n[t]}${o===e.length-1?"":"&"}`}))}return r})({path:c,baseUrl:e,queryParams:h,projectId:t}),g);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==m?void 0:m.clone()),null==i?void 0:i.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,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(e,{headers:t,queryParams:n,token:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:ve.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>l({path:e,headers:n,queryParams:o,body:t,method:ve.post,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>l({path:e,headers:n,queryParams:o,body:t,method:ve.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:ve.delete,token:o}),hooks:i}};var Ie=429;function Se(e,t,n){var o;let i=je(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[ge])===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function je(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return v(e)}function xe(e){const{exp:t}=je(e);return(new Date).getTime()/1e3>t}function Ce(e){let t=je(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Ee(e,t){return Se(e,t,"permissions")}function Ae(e,t){return Se(e,t,"roles")}const Oe=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Ue(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=t?t(r):r:(i.error=r,o.status===Ie&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Re=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Me=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Te=e=>t=>e.test(t),_e=Te(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Pe=Te(/^\+[1-9]{1}[0-9]{3,14}$/),We=Re(_e,'"{val}" is not a valid email'),Le=Re(Pe,'"{val}" is not a valid phone number'),$e=Re((1,e=>e.length>=1),"Minimum length is 1");const De=Re((e=>"string"==typeof e),"Input is not a string"),Ne=Re((e=>void 0===e),"Input is defined"),qe=(Fe=[De(),Ne()],"Input is not a string or undefined",(e="Input is not a string or undefined")=>t=>{const n=Fe.filter((e=>e(t)));return!(n.length<Fe.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var Fe;const ze=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Me(...e).validate(n[t]))),t(...n)),He=e=>[De(`"${e}" must be a string`)],Ve=e=>[De(`"${e}" must be a string`),$e(`"${e}" must not be empty`)],Ke=e=>[De(`"${e}" must be a string`),We()],Be=e=>[De(`"${e}" must be a string`),Le()],Je=ze(Ve("accessKey")),Xe=e=>({exchange:Je(((t,n)=>Ue(e.post(b,{loginOptions:n},{token:t}))))}),Ye=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),Ze=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||fe,fe)});var Ge,Qe;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(Ge||(Ge={})),function(e){e.email="email"}(Qe||(Qe={}));const et=Object.assign(Object.assign({},Ge),Qe);var tt;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(tt||(tt={}));const nt=Ve("loginId"),ot=ze(Ve("token")),it=ze(nt),rt=ze(Ve("pendingRef")),st=ze(nt,Ke("email")),at=e=>({verify:ot((t=>Ue(e.post(O,{token:t})))),signIn:it(((t,n,o,i)=>Ue(e.post(Oe(U,et.email),{loginId:t,URI:n,loginOptions:o},{token:i})))),signUpOrIn:it(((t,n,o)=>Ue(e.post(Oe(_,et.email),{loginId:t,URI:n,loginOptions:o})))),signUp:it(((t,n,o,i)=>Ue(e.post(Oe(R,et.email),{loginId:t,URI:n,user:o,loginOptions:i})))),waitForSession:rt(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ze(n);let s;const a=setInterval((async()=>{const n=await e.post(M,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Ue(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:st(((t,n,o,i,r)=>Ue(e.post(T.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),lt=ze(Ve("flowId")),ct=ze(Ve("executionId"),Ve("stepId"),Ve("interactionId")),dt=e=>({start:lt(((t,n,o,i,r,s,a)=>Ue(e.post(de,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:ct(((t,n,o,i,r,s)=>Ue(e.post(ue,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),ut=Ve("loginId"),ht=ze(Ve("token")),pt=ze(ut),ft=ze(ut,Be("phone")),gt=ze(ut,Ke("email")),mt=Object.keys(et).filter((e=>e!==Ge.voice)),vt=e=>({verify:ht((t=>Ue(e.post(j,{token:t})))),signIn:mt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,o,i,r)=>Ue(e.post(Oe(x,n),{loginId:t,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:mt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,o,i,r)=>Ue(e.post(Oe(C,n),{loginId:t,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:mt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pt(((t,o,i)=>Ue(e.post(Oe(A,n),{loginId:t,URI:o,loginOptions:i}))))})),{}),update:{email:gt(((t,n,o,i,r)=>Ue(e.post(E.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Ge).filter((e=>e!==Ge.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ft(((t,o,i,r,s)=>Ue(e.post(Oe(E.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var bt;!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"}(bt||(bt={}));const yt=ze(Ve("code")),wt=e=>({start:Object.assign(((t,n,o,i)=>Ue(e.post(P,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:i}))),Object.keys(bt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i)=>Ue(e.post(P,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i}))})),{})),exchange:yt((t=>Ue(e.post(W,{code:t})))),startNative:(t,n)=>Ue(e.post(L,{provider:t,loginOptions:n})),finishNative:(t,n,o,i,r)=>Ue(e.post($,{provider:t,stateId:n,user:o,code:i,idToken:r}))}),kt=Ve("loginId"),It=ze(kt,Ve("code")),St=ze(kt),jt=ze(kt,Be("phone")),xt=ze(kt,Ke("email")),Ct=e=>({verify:Object.keys(et).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:It(((t,o)=>Ue(e.post(Oe(y,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(et).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:St(((t,o,i)=>Ue(e.post(Oe(w,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(et).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:St(((t,o,i)=>Ue(e.post(Oe(k,n),{loginId:t,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(et).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:St(((t,o)=>Ue(e.post(Oe(S,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:xt(((t,n,o,i)=>Ue(e.post(I.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Ge).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jt(((t,o,i,r)=>Ue(e.post(Oe(I.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),Et=ze(Ve("tenant")),At=ze(Ve("code")),Ot=e=>({start:Et(((t,n,o,i)=>Ue(e.post(D,o||{},{queryParams:{tenant:t,redirectURL:n},token:i})))),exchange:At((t=>Ue(e.post(N,{code:t}))))}),Ut=Ve("loginId"),Rt=ze(Ut,Ve("code")),Mt=ze(Ut),Tt=ze(Ut),_t=e=>({signUp:Mt(((t,n)=>Ue(e.post(F,{loginId:t,user:n})))),verify:Rt(((t,n,o,i)=>Ue(e.post(q,{loginId:t,code:n,loginOptions:o},{token:i})))),update:Tt(((t,n)=>Ue(e.post(z,{loginId:t},{token:n}))))}),Pt=Ve("loginId"),Wt=Ve("newPassword"),Lt=ze(Pt,Ve("password")),$t=ze(Pt),Dt=ze(Pt,Wt),Nt=ze(Pt,Ve("oldPassword"),Wt),qt=e=>({signUp:Lt(((t,n,o,i)=>Ue(e.post(G,{loginId:t,password:n,user:o,loginOptions:i})))),signIn:Lt(((t,n,o)=>Ue(e.post(Q,{loginId:t,password:n,loginOptions:o})))),sendReset:$t(((t,n,o)=>Ue(e.post(ee,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Dt(((t,n,o)=>Ue(e.post(te,{loginId:t,newPassword:n},{token:o})))),replace:Nt(((t,n,o)=>Ue(e.post(ne,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>Ue(e.get(oe))}),Ft=He("loginId"),zt=Ve("loginId"),Ht=Ve("origin"),Vt=ze(zt,Ht,Ve("name")),Kt=ze(zt,Ht),Bt=ze(Ft,Ht),Jt=ze(zt,Ht,Ve("token")),Xt=ze(Ve("transactionId"),Ve("response")),Yt=e=>({signUp:{start:Vt(((t,n,o)=>Ue(e.post(J.start,{user:{loginId:t,name:o},origin:n})))),finish:Xt(((t,n)=>Ue(e.post(J.finish,{transactionId:t,response:n}))))},signIn:{start:Bt(((t,n,o,i)=>Ue(e.post(X.start,{loginId:t,origin:n,loginOptions:o},{token:i})))),finish:Xt(((t,n)=>Ue(e.post(X.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Kt(((t,n)=>Ue(e.post(Y.start,{loginId:t,origin:n}))))},update:{start:Jt(((t,n,o)=>Ue(e.post(Z.start,{loginId:t,origin:n},{token:o})))),finish:Xt(((t,n)=>Ue(e.post(Z.finish,{transactionId:t,response:n}))))}}),Zt=He("loginId"),Gt=ze(Zt),Qt=ze(Ve("pendingRef")),en=e=>({signUpOrIn:Gt(((t,n)=>Ue(e.post(K,{loginId:t,loginOptions:n})))),signUp:Gt(((t,n,o)=>Ue(e.post(V,{loginId:t,user:n,loginOptions:o})))),signIn:Gt(((t,n,o)=>Ue(e.post(H,{loginId:t,loginOptions:n},{token:o})))),waitForSession:Qt(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ze(n);let s;const a=setInterval((async()=>{const n=await e.post(B,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Ue(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),tn=ze(Ve("token")),nn=ze([qe('"token" must be string or undefined')]);var on,rn=ze([("projectId",on=Ve("projectId"),Re(((e,t)=>n=>Me(...t).validate(((e,t,n)=>{const o=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=o.length;let r=0,s=e===Object(e)?e:void 0;for(;null!=s&&r<i;)s=s[o[r++]];return r&&r===i&&void 0!==s?s:void 0})(n,e)))("projectId",on))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=ke({baseUrl:n||pe,projectId:e,logger:t,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Xe(a),otp:Ct(a),magicLink:vt(a),enchantedLink:at(a),oauth:wt(a),saml:Ot(a),totp:_t(a),notp:en(a),webauthn:Yt(a),password:qt(a),flow:dt(a),refresh:nn((e=>Ue(a.post(ie,{},{token:e})))),selectTenant:ze([De("tenantId")],[qe('"token" must be string or undefined')])(((e,t)=>Ue(a.post(re,{tenant:e},{token:t})))),logout:nn((e=>Ue(a.post(se,{},{token:e})))),logoutAll:nn((e=>Ue(a.post(ae,{},{token:e})))),me:nn((e=>Ue(a.get(le,{token:e})))),history:nn((e=>Ue(a.get(ce,{token:e})))),isJwtExpired:tn(xe),getTenants:tn(Ce),getJwtPermissions:tn(Ee),getJwtRoles:tn(Ae),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);(await Promise.allSettled(null==i?void 0:i.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))})),sn=Object.assign(rn,{DeliveryMethods:et});
|
|
5
|
+
this["descope-user-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function 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(...o)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,o)||(t=o,n=e(...o)),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 o=e(n);return o[t]=!0,o}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}function f(e){this.message=e}c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,f.prototype=new Error,f.prototype.name="InvalidCharacterError";var g="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new f("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,r=0,s="";o=t.charAt(r++);~o&&(n=i%4?64*n+o:o,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function m(e){this.message=e}function v(e,t){if("string"!=typeof e)throw new m("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(g(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return g(t)}}(e.split(".")[n]))}catch(e){throw new m("Invalid token specified: "+e.message)}}m.prototype=new Error,m.prototype.name="InvalidTokenError";var b="/v1/auth/accesskey/exchange",y="/v1/auth/otp/verify",w="/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",j="/v1/auth/magiclink/verify",x="/v1/auth/magiclink/signin",C="/v1/auth/magiclink/signup",E={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},A="/v1/auth/magiclink/signup-in",O="/v1/auth/enchantedlink/verify",U="/v1/auth/enchantedlink/signin",R="/v1/auth/enchantedlink/signup",M="/v1/auth/enchantedlink/pending-session",T={email:"/v1/auth/enchantedlink/update/email"},_="/v1/auth/enchantedlink/signup-in",P="/v1/auth/oauth/authorize",W="/v1/auth/oauth/exchange",L="v1/auth/oauth/native/start",$="v1/auth/oauth/native/finish",D="/v1/auth/saml/authorize",N="/v1/auth/saml/exchange",q="/v1/auth/totp/verify",F="/v1/auth/totp/signup",z="/v1/auth/totp/update",H="/v1/auth/notp/whatsapp/signin",V="/v1/auth/notp/whatsapp/signup",K="/v1/auth/notp/whatsapp/signup-in",B="/v1/auth/notp/pending-session",J={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},X={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Y={start:"/v1/auth/webauthn/signup-in/start"},Z={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},G="/v1/auth/password/signup",Q="/v1/auth/password/signin",ee="/v1/auth/password/reset",te="/v1/auth/password/update",ne="/v1/auth/password/replace",oe="/v1/auth/password/policy",ie="/v1/auth/refresh",re="/v1/auth/tenant/select",se="/v1/auth/logout",ae="/v1/auth/logoutall",le="/v1/auth/me",ce="/v1/auth/me/history",de="/v1/flow/start",ue="/v1/flow/next";const he="<region>",pe=`https://api.${he}descope.com`,fe=6e5,ge="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")}};var ve;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(ve||(ve={}));const be=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(he,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){r=`${r}?`;const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${t}=${n[t]}${o===e.length-1?"":"&"}`}))}return r},ye=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),we=e=>void 0===e?void 0:JSON.stringify(e),ke=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Ie=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>me().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return me().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,s),l=async o=>{var s;const l=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:c,body:d,headers:u,queryParams:h,method:p,token:f}=l,g={headers:ye(ke(t,f),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.19.0"},(null==n?void 0:n.baseHeaders)||{},u),method:p,body:we(d)};null!==r&&(g.credentials=r||"include");const m=await a(be({path:c,baseUrl:e,queryParams:h,projectId:t}),g);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==m?void 0:m.clone()),null==i?void 0:i.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,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(e,{headers:t,queryParams:n,token:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:ve.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>l({path:e,headers:n,queryParams:o,body:t,method:ve.post,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>l({path:e,headers:n,queryParams:o,body:t,method:ve.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:ve.delete,token:o}),hooks:i,buildUrl:(n,o)=>be({projectId:t,baseUrl:e,path:n,queryParams:o})}};var Se=429;function je(e,t,n){var o;let i=xe(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[ge])===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function xe(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return v(e)}function Ce(e){const{exp:t}=xe(e);return(new Date).getTime()/1e3>t}function Ee(e){let t=xe(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Ae(e,t){return je(e,t,"permissions")}function Oe(e,t){return je(e,t,"roles")}const Ue=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Re(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=t?t(r):r:(i.error=r,o.status===Se&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Me=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Te=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),_e=e=>t=>e.test(t),Pe=_e(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),We=_e(/^\+[1-9]{1}[0-9]{3,14}$/),Le=Me(Pe,'"{val}" is not a valid email'),$e=Me(We,'"{val}" is not a valid phone number'),De=Me((1,e=>e.length>=1),"Minimum length is 1");const Ne=Me((e=>"string"==typeof e),"Input is not a string"),qe=Me((e=>void 0===e),"Input is defined"),Fe=(ze=[Ne(),qe()],"Input is not a string or undefined",(e="Input is not a string or undefined")=>t=>{const n=ze.filter((e=>e(t)));return!(n.length<ze.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var ze;const He=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Te(...e).validate(n[t]))),t(...n)),Ve=e=>[Ne(`"${e}" must be a string`)],Ke=e=>[Ne(`"${e}" must be a string`),De(`"${e}" must not be empty`)],Be=e=>[Ne(`"${e}" must be a string`),Le()],Je=e=>[Ne(`"${e}" must be a string`),$e()],Xe=He(Ke("accessKey")),Ye=e=>({exchange:Xe(((t,n)=>Re(e.post(b,{loginOptions:n},{token:t}))))}),Ze=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),Ge=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||fe,fe)});var Qe,et;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(Qe||(Qe={})),function(e){e.email="email"}(et||(et={}));const tt=Object.assign(Object.assign({},Qe),et);var nt;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(nt||(nt={}));const ot=Ke("loginId"),it=He(Ke("token")),rt=He(ot),st=He(Ke("pendingRef")),at=He(ot,Be("email")),lt=e=>({verify:it((t=>Re(e.post(O,{token:t})))),signIn:rt(((t,n,o,i)=>Re(e.post(Ue(U,tt.email),{loginId:t,URI:n,loginOptions:o},{token:i})))),signUpOrIn:rt(((t,n,o)=>Re(e.post(Ue(_,tt.email),{loginId:t,URI:n,loginOptions:o})))),signUp:rt(((t,n,o,i)=>Re(e.post(Ue(R,tt.email),{loginId:t,URI:n,user:o,loginOptions:i})))),waitForSession:st(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ge(n);let s;const a=setInterval((async()=>{const n=await e.post(M,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Re(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:at(((t,n,o,i,r)=>Re(e.post(T.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),ct=He(Ke("flowId")),dt=He(Ke("executionId"),Ke("stepId"),Ke("interactionId")),ut=e=>({start:ct(((t,n,o,i,r,s,a)=>Re(e.post(de,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:dt(((t,n,o,i,r,s)=>Re(e.post(ue,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),ht=Ke("loginId"),pt=He(Ke("token")),ft=He(ht),gt=He(ht,Je("phone")),mt=He(ht,Be("email")),vt=Object.keys(tt).filter((e=>e!==Qe.voice)),bt=e=>({verify:pt((t=>Re(e.post(j,{token:t})))),signIn:vt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ft(((t,o,i,r)=>Re(e.post(Ue(x,n),{loginId:t,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:vt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ft(((t,o,i,r)=>Re(e.post(Ue(C,n),{loginId:t,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:vt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ft(((t,o,i)=>Re(e.post(Ue(A,n),{loginId:t,URI:o,loginOptions:i}))))})),{}),update:{email:mt(((t,n,o,i,r)=>Re(e.post(E.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Qe).filter((e=>e!==Qe.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:gt(((t,o,i,r,s)=>Re(e.post(Ue(E.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var yt;!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"}(yt||(yt={}));const wt=He(Ke("code")),kt=e=>({start:Object.assign(((t,n,o,i)=>Re(e.post(P,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:i}))),Object.keys(yt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i)=>Re(e.post(P,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i}))})),{})),exchange:wt((t=>Re(e.post(W,{code:t})))),startNative:(t,n)=>Re(e.post(L,{provider:t,loginOptions:n})),finishNative:(t,n,o,i,r)=>Re(e.post($,{provider:t,stateId:n,user:o,code:i,idToken:r}))}),It=Ke("loginId"),St=He(It,Ke("code")),jt=He(It),xt=He(It,Je("phone")),Ct=He(It,Be("email")),Et=e=>({verify:Object.keys(tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:St(((t,o)=>Re(e.post(Ue(y,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jt(((t,o,i)=>Re(e.post(Ue(w,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jt(((t,o,i)=>Re(e.post(Ue(k,n),{loginId:t,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jt(((t,o)=>Re(e.post(Ue(S,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:Ct(((t,n,o,i)=>Re(e.post(I.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Qe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:xt(((t,o,i,r)=>Re(e.post(Ue(I.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),At=He(Ke("tenant")),Ot=He(Ke("code")),Ut=e=>({start:At(((t,n,o,i)=>Re(e.post(D,o||{},{queryParams:{tenant:t,redirectURL:n},token:i})))),exchange:Ot((t=>Re(e.post(N,{code:t}))))}),Rt=Ke("loginId"),Mt=He(Rt,Ke("code")),Tt=He(Rt),_t=He(Rt),Pt=e=>({signUp:Tt(((t,n)=>Re(e.post(F,{loginId:t,user:n})))),verify:Mt(((t,n,o,i)=>Re(e.post(q,{loginId:t,code:n,loginOptions:o},{token:i})))),update:_t(((t,n)=>Re(e.post(z,{loginId:t},{token:n}))))}),Wt=Ke("loginId"),Lt=Ke("newPassword"),$t=He(Wt,Ke("password")),Dt=He(Wt),Nt=He(Wt,Lt),qt=He(Wt,Ke("oldPassword"),Lt),Ft=e=>({signUp:$t(((t,n,o,i)=>Re(e.post(G,{loginId:t,password:n,user:o,loginOptions:i})))),signIn:$t(((t,n,o)=>Re(e.post(Q,{loginId:t,password:n,loginOptions:o})))),sendReset:Dt(((t,n,o)=>Re(e.post(ee,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Nt(((t,n,o)=>Re(e.post(te,{loginId:t,newPassword:n},{token:o})))),replace:qt(((t,n,o)=>Re(e.post(ne,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>Re(e.get(oe))}),zt=Ve("loginId"),Ht=Ke("loginId"),Vt=Ke("origin"),Kt=He(Ht,Vt,Ke("name")),Bt=He(Ht,Vt),Jt=He(zt,Vt),Xt=He(Ht,Vt,Ke("token")),Yt=He(Ke("transactionId"),Ke("response")),Zt=e=>({signUp:{start:Kt(((t,n,o)=>Re(e.post(J.start,{user:{loginId:t,name:o},origin:n})))),finish:Yt(((t,n)=>Re(e.post(J.finish,{transactionId:t,response:n}))))},signIn:{start:Jt(((t,n,o,i)=>Re(e.post(X.start,{loginId:t,origin:n,loginOptions:o},{token:i})))),finish:Yt(((t,n)=>Re(e.post(X.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Bt(((t,n)=>Re(e.post(Y.start,{loginId:t,origin:n}))))},update:{start:Xt(((t,n,o)=>Re(e.post(Z.start,{loginId:t,origin:n},{token:o})))),finish:Yt(((t,n)=>Re(e.post(Z.finish,{transactionId:t,response:n}))))}}),Gt=Ve("loginId"),Qt=He(Gt),en=He(Ke("pendingRef")),tn=e=>({signUpOrIn:Qt(((t,n)=>Re(e.post(K,{loginId:t,loginOptions:n})))),signUp:Qt(((t,n,o)=>Re(e.post(V,{loginId:t,user:n,loginOptions:o})))),signIn:Qt(((t,n,o)=>Re(e.post(H,{loginId:t,loginOptions:n},{token:o})))),waitForSession:en(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ge(n);let s;const a=setInterval((async()=>{const n=await e.post(B,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Re(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),nn=He(Ke("token")),on=He([Fe('"token" must be string or undefined')]);var rn,sn=He([("projectId",rn=Ke("projectId"),Me(((e,t)=>n=>Te(...t).validate(((e,t,n)=>{const o=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=o.length;let r=0,s=e===Object(e)?e:void 0;for(;null!=s&&r<i;)s=s[o[r++]];return r&&r===i&&void 0!==s?s:void 0})(n,e)))("projectId",rn))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=Ie({baseUrl:n||pe,projectId:e,logger:t,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Ye(a),otp:Et(a),magicLink:bt(a),enchantedLink:lt(a),oauth:kt(a),saml:Ut(a),totp:Pt(a),notp:tn(a),webauthn:Zt(a),password:Ft(a),flow:ut(a),refresh:on((e=>Re(a.post(ie,{},{token:e})))),selectTenant:He([Ne("tenantId")],[Fe('"token" must be string or undefined')])(((e,t)=>Re(a.post(re,{tenant:e},{token:t})))),logout:on((e=>Re(a.post(se,{},{token:e})))),logoutAll:on((e=>Re(a.post(ae,{},{token:e})))),me:on((e=>Re(a.get(le,{token:e})))),history:on((e=>Re(a.get(ce,{token:e})))),isJwtExpired:nn(Ce),getTenants:nn(Ee),getJwtPermissions:nn(Ae),getJwtRoles:nn(Oe),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);(await Promise.allSettled(null==i?void 0:i.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))})),an=Object.assign(sn,{DeliveryMethods:tt});
|
|
6
6
|
/*! js-cookie v3.0.5 | MIT */
|
|
7
|
-
function an(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var ln=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=an({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",an({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,an({},this.attributes,t))},withConverter:function(t){return e(an({},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 cn={default:"endpoint"},dn="Blocked by CSP",un="The endpoint parameter is not a valid URL",hn="Failed to load the JS script of the agent",pn="9319";function fn(e,t){var n,o,i,r,s=[],a=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),100,3e3,r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===dn||s===un)n.exclude(),r=0;else if(s===pn)n.exclude();else if(s===hn){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+o()-Date.now()]}]),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,o=function(t){return s.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(s.length>=5)throw e;var t=c(n,e);if(!t)throw e;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return d(i)}))}))};return d(l).then((function(e){return[e,s]}))}var gn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",mn=gn;function vn(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:gn,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.9.6"):e}))}(String(e),t)}))}(l,s);return fn(e,bn)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===pn?new Error(hn):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function bn(e){return function(e,t,n,o){var i,r=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return Promise.resolve().then(t).then((function(e){return l(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(l(),i)return function(){throw new Error(dn)}();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(un);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(hn))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)})).then(yn)}function yn(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(pn);return n}const wn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},kn=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||{}},In=async e=>{const t=await kn(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Sn="undefined"!=typeof localStorage,jn=(e,t)=>Sn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),xn=e=>Sn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Cn=e=>Sn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),En=(...e)=>{console.debug(...e)},An="undefined"!=typeof window,On=Math.pow(2,31)-1,Un="DS",Rn="DSR";function Mn(e=""){return xn(`${e}${Rn}`)||""}function Tn(e=""){Cn(`${e}${Rn}`),Cn(`${e}${Un}`),ln.remove(Un)}const _n=An&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Pn="fp",Wn=(e=!1)=>{const t=localStorage.getItem(Pn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Ln=async(e,t=_n)=>{try{if(Wn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=vn({apiKey:e,endpoint:[o.toString(),cn],scriptUrlPattern:[r,mn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({vsid:e,vrid:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(Pn,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},$n=e=>{const t=Wn(!0);return t&&e.body&&(e.body.fpData=t),e},Dn="dls_last_user_login_id",Nn="dls_last_user_display_name",qn=()=>xn(Dn),Fn=()=>xn(Nn),zn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=qn(),r=Fn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},Hn=e=>async(...t)=>{const n=await e(...t);return Cn(Dn),Cn(Nn),n};function Vn(){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 Kn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Gn(n.publicKey.challenge),n.publicKey.user.id=Gn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Gn(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Qn(n.rawId),type:n.type,response:{attestationObject:Qn(n.response.attestationObject),clientDataJSON:Qn(n.response.clientDataJSON)}});var n}async function Bn(e){const t=Yn(e);return Zn(await navigator.credentials.get(t))}async function Jn(e,t){const n=Yn(e);return n.signal=t.signal,n.mediation="conditional",Zn(await navigator.credentials.get(n))}async function Xn(e=!1){if(!An)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 Yn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Gn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Gn(e.id)})),n}function Zn(e){return JSON.stringify({id:e.id,rawId:Qn(e.rawId),type:e.type,response:{authenticatorData:Qn(e.response.authenticatorData),clientDataJSON:Qn(e.response.clientDataJSON),signature:Qn(e.response.signature),userHandle:e.response.userHandle?Qn(e.response.userHandle):void 0}})}function Gn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Qn(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var eo,to=(eo=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const i=await Kn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await Bn(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await Kn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Bn(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const i=await Kn(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Kn,get:Bn,isSupported:Xn,conditional:Jn}}),(...e)=>{const t=eo(...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 no=e=>({async oneTap(t,n,o,i){const r=null!=t?t:"google",s=await e.oauth.startNative(r,o);if(!s.ok)return s;const{clientId:a,stateId:l,nonce:c}=s.data,d=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 o,s;d.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(s=null==n?void 0:n.use_fedcm_for_prompt)||void 0===s||s,client_id:a,callback:n=>{t(e.oauth.finishNative(r,l,"","",n.credential))},nonce:c})),d.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==i||i())}))}))}});var oo=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Xn(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const io=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return An?(o&&i&&Ln(o).catch((()=>null)),e(wn(r,{beforeRequest:$n}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),e(r))}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);if(!o)return e(i);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,l;An&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(En("Expiration time passed, refreshing session"),c.refresh(Mn()||l))}));const c=e(wn(i,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await kn(t);if(401===(null==t?void 0:t.status))En("Received 401, canceling all timers"),r();else if(o){if(a=(e=>{try{const t=v(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(o),!a)return void En("Could not extract expiration time from session token");l=n;let e=((i=a)?i.getTime()-(new Date).getTime():0)-2e4;e>On&&(En(`Timeout is too large (${e}ms), setting it to ${On}ms`),e=On),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});En(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{En("Refreshing session due to timer"),c.refresh(Mn()||n)}),e)}var i}}));return Ye(c,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return En("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.11.14"},t.baseHeaders)}))),(e=>t=>{const n=Vn(),o=Vn(),i=e(wn(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),o.pub(null);else{const e=await In(t);e&&o.pub(e);const{sessionJwt:i}=await kn(t);i&&n.pub(i)}}})),r=Ye(i,["logout","logoutAll"],(e=>async(...t)=>{const i=await e(...t);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0}=n,i=t(n,["storeLastAuthenticatedUser"]);if(!o)return Object.assign(e(i),{getLastUserLoginId:qn,getLastUserDisplayName:Fn});const r=e(wn(i,{afterRequest:async(e,t)=>{var n;const o=await In(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((e=>{jn(Dn,e)})(i),(e=>{jn(Nn,e)})(r))}}));let s=Ye(r,["flow.start"],zn);return s=Ye(s,["logout","logoutAll"],Hn),Object.assign(s,{getLastUserLoginId:qn,getLastUserDisplayName:Fn})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!An)return o&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),e(s);const a=e(wn(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||Mn(l)})),afterRequest:async(e,n)=>{const o=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?o||Tn(r):((e={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=e,s=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&jn(`${o}${Rn}`,i),r&&(n?function(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(t){const r=new Date(1e3*i),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);ln.set(e,t,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(Un,r,s):jn(`${o}${Un}`,r))})(await kn(n),i,r)}}));var l;const c=Ye(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return Tn(e),o})(r));return Object.assign(c,{getRefreshToken:()=>Mn(r),getSessionToken:()=>function(e=""){return ln.get(Un)||xn(`${e}${Un}`)||""}(r)})}))(((...e)=>{const t=sn(...e);return Object.assign(Object.assign({},t),{flow:oo(t),webauthn:to(t),fedcm:no(t)})})),ro="undefined"!=typeof localStorage,so=ro&&localStorage.getItem("base.content.url")||"",ao="config.json",lo="base.ui.components.url",co=ro&&localStorage.getItem(lo)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",uo=ro&&localStorage.getItem(lo)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",ho="descope-login-flow",po="code",fo="ra-challenge",go="ra-callback",mo="ra-backup-callback",vo="ra-initiator",bo="data-exclude-field",yo="dls_last_auth",wo="state_id",ko="saml_idp_state_id",Io="saml_idp_username",So="descope_idp_initiated",jo="sso_app_id",xo="oidc_login_hint",Co="data-type",Eo="poll",Ao="webauthnCreate",Oo="submit",Uo="polling",Ro=["descope-multi-select-combo-box","descope-text-area"];var Mo;function To(e){return new URLSearchParams(window.location.search).get(e)}function _o(e){if(window.history.replaceState&&To(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 Po(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 Wo({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(so||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.toString()}function Lo(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Mo.forward:n<o?Mo.backward:void 0}!function(e){e.backward="backward",e.forward="forward"}(Mo||(Mo={}));const $o=()=>{const[e="",t=""]=(To(ho)||"").split("_");return{executionId:e,stepId:t}};function Do(){_o(ho)}const No=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),qo=e=>{let t,n;return(...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}},Fo=(e,t,n,o,i,r)=>e&&!t&&e&&!n&&!o&&e&&!i&&e&&!r,zo=e=>null==e?void 0:e.submit(),Ho=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Vo=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};var Ko,Bo,Jo,Xo;function Yo(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Yo(r,s))return!1}else if(r!==s)return!1}return!0}class Zo{constructor(e={},{updateOnlyOnChange:t=!0}={}){Ko.set(this,void 0),Bo.set(this,{}),Jo.set(this,0),Xo.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,Ko,"f")):e,n=Object.assign(Object.assign({},o(this,Ko,"f")),t);if(!o(this,Xo,"f")||!Yo(o(this,Ko,"f"),n)){const e=o(this,Ko,"f");i(this,Ko,n,"f"),Object.freeze(o(this,Ko,"f")),setTimeout((()=>{Object.values(o(this,Bo,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,Ko,e,"f"),i(this,Xo,t,"f")}get current(){return Object.assign({},o(this,Ko,"f"))}subscribe(e){return i(this,Jo,o(this,Jo,"f")+1,"f"),o(this,Bo,"f")[o(this,Jo,"f")]=e,o(this,Jo,"f").toString()}unsubscribe(e){const t=!!o(this,Bo,"f")[e];return t&&delete o(this,Bo,"f")[e],t}unsubscribeAll(){return i(this,Bo,{},"f"),!0}}Ko=new WeakMap,Bo=new WeakMap,Jo=new WeakMap,Xo=new WeakMap;const Go=["disabled"],Qo=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${bo}])`)).forEach((e=>{e.value=n}))}))},ei=(e,t)=>e.replace(/{{(.+?)}}/g,((e,n)=>{return o=t,n.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),o);var o})),ti=(e,t,n)=>{e.querySelectorAll(`[${Co}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},ni=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},oi=qo((()=>n(void 0,void 0,void 0,(function*(){var e,t,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=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)))),r=(()=>{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(100,n=i,o=r,new Promise(((e,t)=>{let i=!1;const r=setTimeout((()=>{i=!0,void 0!==o?e(o):t(new Error("Promise timed out after 100 ms"))}),100);n.then((t=>{i||(clearTimeout(r),e(t))})).catch((e=>{i||(clearTimeout(r),t(e))}))})))}catch(e){return console.error("Conditional login check failed",e),!1}})))),ii={"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 ri(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(yo)))}catch(e){}return t}const si="dls_ab_testing_id",ai=document.createElement("template");var li,ci,di,ui,hi,pi,fi,gi,mi,vi,bi,yi,wi,ki,Ii,Si,ji,xi,Ci,Ei,Ai,Oi,Ui,Ri,Mi,Ti,_i,Pi,Wi,Li,$i,Di,Ni,qi,Fi,zi,Hi,Vi,Ki,Bi,Ji,Xi,Yi,Zi,Gi,Qi,er,tr,nr,or,ir,rr;ai.innerHTML='\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n display: block;\n\t\t}\n\n\t\t#wc-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#wc-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<div id="wc-root"></div>\n\t';class sr extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","validate-on-blur"]}constructor(e){super(),li.add(this),this.logger=console,ci.set(this,!1),this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,li,"m",Wi).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},di.set(this,new Zo({deferredRedirect:!1})),ui.set(this,new Zo),hi.set(this,{}),this.getComponentsContext=()=>o(this,hi,"f"),this.nextRequestStatus=new Zo({isLoading:!1}),pi.set(this,void 0),fi.set(this,{popstate:o(this,li,"m",wi).bind(this),visibilitychange:o(this,li,"m",ki).bind(this),componentsContext:o(this,li,"m",Mi).bind(this)}),gi.set(this,void 0),Ci.set(this,qo((()=>n(this,void 0,void 0,(function*(){const e=Wo({projectId:this.projectId,filename:ao,baseUrl:this.baseStaticUrl});try{const{body:t,headers:n}=yield Po(e,"json");return{projectConfig:t,executionContext:{geo:n["x-geo"]}}}catch(e){return{isMissingConfig:!0}}}))))),Ai.set(this,void 0),i(this,gi,e,"f"),o(this,li,"m",mi).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get baseUrl(){return this.getAttribute("base-url")||void 0}get baseStaticUrl(){return this.getAttribute("base-static-url")}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 theme(){var e,t;const n=this.getAttribute("theme");return"os"===n?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":n||"light"}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 storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{const t=JSON.parse(e);return Object.fromEntries(Object.keys(t).map((e=>"string"!=typeof t[e]?[e,t[e]]:[e,{value:t[e]}])).flatMap((([e,t])=>[[e,t],[`form.${e}`,t]])))}catch(e){return{}}})(this.getAttribute("form"))}get formConfigValues(){return e=this.formConfig,"value",Object.fromEntries(Object.entries(e).map((([e,t])=>[e,t.value])));var e}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:e}=yield o(this,Ci,"f").call(this);return e}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,Ci,"f").call(this);return e}))}getFlowConfig(){var e,t;return n(this,void 0,void 0,(function*(){const n=yield this.getProjectConfig(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,ui,"f").subscribe(o(this,li,"m",Pi).bind(this)),o(this,ui,"f").update({isDebug:this.debug}),o(this,li,"m",vi).call(this))return void o(this,li,"m",bi).call(this);if(o(this,li,"m",yi).call(this),i(this,Ai,o(this,li,"m",Ei).call(this),"f"),yield o(this,li,"m",ji).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 o(this,Ci,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,li,"m",Oi).call(this),yield o(this,li,"m",Di).call(this),yield o(this,li,"m",Ui).call(this),o(this,li,"m",Li).call(this);const{executionId:e,stepId:t,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,descopeIdpInitiated:f,ssoAppId:g,oidcLoginHint:m}=(()=>{const{executionId:e,stepId:t}=$o();(e||t)&&Do();const n=To("t")||void 0;n&&_o("t");const o=To(po)||void 0;o&&_o(po);const i=To("err")||void 0;i&&_o("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:To(fo),redirectAuthCallbackUrl:To(go),redirectAuthBackupCallbackUri:To(mo),redirectAuthInitiator:To(vo)};(r||s||a||l)&&(_o(fo),_o(go),_o(mo),_o(vo));const c=To(wo);c&&_o(wo);const d=To(ko);d&&_o(ko);const u=To(Io);d&&_o(Io);const h=To(So);h&&_o(So);const p=To(jo);p&&_o(jo);const f=To(xo);return f&&_o(xo),{executionId:e,stepId:t,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,oidcIdpStateId:c,samlIdpStateId:d,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:f}})();window.addEventListener("popstate",o(this,fi,"f").popstate),window.addEventListener("components-context",o(this,fi,"f").componentsContext),window.addEventListener("visibilitychange",o(this,fi,"f").visibilitychange),o(this,di,"f").subscribe(o(this,li,"m",Si).bind(this)),o(this,di,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:t,executionId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,descopeIdpInitiated:f,ssoAppId:g,oidcLoginHint:m}),i(this,ci,!0,"f")}}))}disconnectedCallback(){o(this,di,"f").unsubscribeAll(),o(this,ui,"f").unsubscribeAll(),o(this,li,"m",_i).call(this),window.removeEventListener("popstate",o(this,fi,"f").popstate),window.removeEventListener("visibilitychange",o(this,fi,"f").visibilitychange),window.removeEventListener("components-context",o(this,fi,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,ci,"f")&&t!==n&&sr.observedAttributes.includes(e)){o(this,li,"m",yi).call(this);const i=null===t;o(this,di,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,Do()),{[No(e)]:n,stepId:r,executionId:s}})),o(this,ui,"f").update({isDebug:this.debug})}}}ci=new WeakMap,di=new WeakMap,ui=new WeakMap,hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,Ci=new WeakMap,Ai=new WeakMap,li=new WeakSet,mi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ai.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},vi=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},bi=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)},yi=function(){const e=["base-url","tenant","theme","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","preview","storage-prefix","form","client","validate-on-blur"];if(sr.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[No(t)])throw Error(`${t} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},wi=function(){const{stepId:e,executionId:t}=$o();o(this,di,"f").update({stepId:e,executionId:t})},ki=function(){document.hidden||setTimeout((()=>{o(this,di,"f").update({deferredRedirect:!1})}),300)},Ii=function(e,t){this.sdk=io(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser},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)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Si=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,li,"m",Ii).call(this,t,n)}o(this,gi,"f").call(this,e)}))},ji=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,Ci,"f").call(this)).isMissingConfig&&(yield o(this,li,"m",xi).call(this))}))},xi=function(){return n(this,void 0,void 0,(function*(){const e=Wo({projectId:this.projectId,filename:ao,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield Po(e,"json"),!0}catch(e){return!1}}))},Ei=function(){return n(this,void 0,void 0,(function*(){const e=Wo({projectId:this.projectId,filename:"theme.json",baseUrl:this.baseStaticUrl});try{const{body:t}=yield Po(e,"json");return t}catch(e){return void this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},Oi=function(){var e,t;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,Ci,"f").call(this),i=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;i&&Object.values(i).forEach((e=>(e=>{if(!e)return;const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url)))}))},Ui=function(){return n(this,void 0,void 0,(function*(){yield o(this,li,"m",Ri).call(this),yield o(this,li,"m",Ti).call(this)}))},Ri=function(){var e,t,i,r;return n(this,void 0,void 0,(function*(){const n=document.createElement("style"),s=yield o(this,Ai,"f");n.innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(t=null==s?void 0:s.dark)||void 0===t?void 0:t.globals)||"");const a=yield sr.descopeUI;(null==a?void 0:a.componentsThemeManager)&&!a.componentsThemeManager.hasThemes&&(a.componentsThemeManager.themes={light:null===(i=null==s?void 0:s.light)||void 0===i?void 0:i.components,dark:null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.components}),this.shadowRoot.appendChild(n)}))},Mi=function(e){i(this,hi,Object.assign(Object.assign({},o(this,hi,"f")),e.detail),"f")},Ti=function(){return n(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield sr.descopeUI;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},_i=function(){var e;null===(e=o(this,pi,"f"))||void 0===e||e.remove(),i(this,pi,null,"f")},Pi=function({isDebug:e}){return n(this,void 0,void 0,(function*(){e?(i(this,pi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,pi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return nc})),document.body.appendChild(o(this,pi,"f"))):o(this,li,"m",_i).call(this)}))},Wi=function(e,t){var n;e&&this.debug&&(null===(n=o(this,pi,"f"))||void 0===n||n.updateData({title:e,description:t}))},Li=function(){this.rootElement.onkeydown=e=>{var t,n,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Ro.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},$i=function(){var e,t;return n(this,void 0,void 0,(function*(){return(null===(t=null===(e=yield o(this,Ci,"f").call(this))||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")}))},Di=function(){return n(this,void 0,void 0,(function*(){sr.descopeUI?this.loggerWrapper.debug("DescopeUI is already loading, probably multiple flows are running on the same page"):sr.descopeUI=new Promise((e=>{if(globalThis.DescopeUI)return void e(globalThis.DescopeUI);const t=e=>{const t=document.createElement("script");return t.id="load-descope-ui",t.src=e,t},i=(e,t)=>e.replace("<version>",t),r=(t,n)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${t.src}"`),n()};t.addEventListener("load",(()=>{globalThis.DescopeUI||o(),e(globalThis.DescopeUI)})),t.addEventListener("error",o)};(()=>{n(this,void 0,void 0,(function*(){const n=yield o(this,li,"m",$i).call(this),s=t(i(co,n));r(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const o=t(i(uo,n));r(o,(()=>{e(void 0)})),document.body.append(o)})),document.body.append(s)}))})()}))}))},sr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.15.1"}};class ar extends sr{static set sdkConfigOverrides(e){sr.sdkConfigOverrides=e}constructor(){const e=new Zo;super(e.update.bind(e)),Ni.add(this),this.stepState=new Zo({},{updateOnlyOnChange:!1}),qi.set(this,void 0),Fi.set(this,null),zi.set(this,((e,t,r,s,a)=>{r===Eo&&i(this,qi,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;const i=yield this.sdk.flow.next(e,t,Uo,s,a,{});o(this,Vi,"f").call(this,i);const{action:r}=null!==(n=null==i?void 0:i.data)&&void 0!==n?n:{};o(this,zi,"f").call(this,e,t,r,s,a)}))),2e3),"f")})),Hi.set(this,(()=>{clearTimeout(o(this,qi,"f")),i(this,qi,null,"f")})),Vi.set(this,(e=>{var t,n,i,r,s,a,l,c,d;if(!(null==e?void 0:e.ok)){o(this,Ni,"m",ir).call(this,"error",null==e?void 0:e.error);const a=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,l=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.statusText}`;return void this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorMessage)||l)}const u=null===(c=null===(l=null===(a=e.data)||void 0===a?void 0:a.screen)||void 0===l?void 0:l.state)||void 0===c?void 0:c.errorText;(null===(d=e.data)||void 0===d?void 0:d.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${u?`${u} - `:""}${e.data.error.message}`):u&&this.loggerWrapper.error(u);const{status:h,authInfo:p,lastAuth:f}=e.data;if("completed"===h)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&ro&&localStorage.setItem(yo,JSON.stringify(e))}(f),void o(this,Ni,"m",ir).call(this,"success",p);const{executionId:g,stepId:m,stepName:v,action:b,screen:y,redirect:w,openInNewTabUrl:k,webauthn:I,error:S,samlIdpResponse:j}=e.data;b!==Eo?(this.loggerWrapper.info(`Step "${v||`#${m}`}" is ${h}`,"",{screen:y,status:h,stepId:m,stepName:v,action:b,error:S}),this.flowState.update({stepId:m,executionId:g,action:b,redirectTo:null==w?void 0:w.url,openInNewTabUrl:k,screenId:null==y?void 0:y.id,screenState:null==y?void 0:y.state,webauthnTransactionId:null==I?void 0:I.transactionId,webauthnOptions:null==I?void 0:I.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState})):this.flowState.update({action:b})})),Ki.set(this,qo((()=>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)}}))))),er.set(this,Vo(((e,t)=>n(this,void 0,void 0,(function*(){if("true"===e.getAttribute("formnovalidate")||o(this,Ni,"m",Yi).call(this)){const i=null==e?void 0:e.getAttribute("id");o(this,Ni,"m",Gi).call(this,e);const r=yield o(this,Ni,"m",Zi).call(this),s=(n=e,Array.from((null==n?void 0:n.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),c=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield t(i,c.version,d.componentsVersion,l);o(this,Vi,"f").call(this,u),o(this,Ni,"m",Qi).call(this,r)}var n}))))),this.flowState=e}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var t,o;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield e.connectedCallback.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=o(this,Fi,"f"))||void 0===e||e.abort(),i(this,Fi,null,"f")}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n,o=navigator.language;o&&"zh-TW"!==o&&(o=o.split("-")[0]);const i=(e||o||"").toLowerCase();return(yield this.getTargetLocales()).includes(i)&&(n=`${t}-${i}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield Po(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 Po(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,t,r){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:n,flowId:l,tenant:c,stepId:d,executionId:u,action:h,screenId:p,screenState:f,redirectTo:g,openInNewTabUrl:m,redirectUrl:v,token:b,code:y,exchangeError:w,webauthnTransactionId:k,webauthnOptions:I,redirectAuthCodeChallenge:S,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:x,redirectAuthInitiator:C,oidcIdpStateId:E,locale:A,samlIdpStateId:O,samlIdpUsername:U,descopeIdpInitiated:R,samlIdpResponseUrl:M,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:_,ssoAppId:P,oidcLoginHint:W}=e;let L,$;const D=(()=>{const e=localStorage.getItem(si);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(si,e.toString()),e}return Number(e)})(),N=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),F=yield this.getProjectConfig(),z=j&&S?{callbackUrl:j,codeChallenge:S,backupCallbackUri:x}:void 0;if(!u&&(q.fingerprintEnabled&&q.fingerprintKey?yield Ln(q.fingerprintKey,this.baseUrl):localStorage.removeItem(Pn),q.conditions?({startScreenId:L,conditionInteractionId:$}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=ii[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:N,code:y,token:b,abTestingKey:D},q.conditions)):q.condition?({startScreenId:L,conditionInteractionId:$}=((e,t)=>{var n;const o=null===(n=ii[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(q.condition,{loginId:N,code:y,token:b,abTestingKey:D})):L=q.startScreenId,!Fo(L,E,O,U,P,W))){const e=yield this.sdk.flow.start(l,Object.assign(Object.assign({tenant:c,redirectAuth:z,oidcIdpStateId:E,samlIdpStateId:O,samlIdpUsername:U,ssoAppId:P,oidcLoginHint:W,client:this.client},v&&{redirectUrl:v}),{lastAuth:ri(N),abTestingKey:D}),$,"",q.version,F.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),y?{exchangeCode:y,idpInitiated:!0}:{}),R&&{idpInitiated:!0}),b?{token:b}:{}),W?{externalId:W}:{}));return o(this,Vi,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0,token:void 0}))}if(u&&(r("token")&&b||r("code")&&y||r("exchangeError")&&w)){const e=yield this.sdk.flow.next(u,d,Oo,q.version,F.componentsVersion,{token:b,exchangeCode:y,exchangeError:w});return o(this,Vi,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if("loadForm"===h&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>r(e)))){if(!M||!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})(M,T,_||"",zo)}if("redirect"===h&&(r("redirectTo")||r("deferredRedirect")))return g?"android"===C&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(g):void this.loggerWrapper.error("Did not get redirect url");if(h===Ao||"webauthnGet"===h){if(!k||!I)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=o(this,Fi,"f"))||void 0===a||a.abort(),i(this,Fi,null,"f");try{e=h===Ao?yield this.sdk.webauthn.helpers.create(I):yield this.sdk.webauthn.helpers.get(I)}catch(n){"InvalidStateError"===n.name?this.loggerWrapper.warn("WebAuthn operation failed",n.message):"NotAllowedError"!==n.name&&this.loggerWrapper.error(n.message),t=n.name}const r=yield this.sdk.flow.next(u,d,Oo,q.version,F.componentsVersion,{transactionId:k,response:e,failure:t});o(this,Vi,"f").call(this,r)}if(o(this,zi,"f").call(this,u,d,h,q.version,F.componentsVersion),!p&&!L)return void this.loggerWrapper.warn("No screen was found to show");const H=L||p,V=yield this.getHtmlFilenameWithLocale(A,H),K={direction:Lo(d,t.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.formConfigValues),null==f?void 0:f.form),lastAuth:{loginId:N,name:this.sdk.getLastUserDisplayName()||N}}),htmlUrl:Wo({projectId:n,filename:`${H}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:V&&Wo({projectId:n,filename:V,baseUrl:this.baseStaticUrl}),samlIdpUsername:U,oidcLoginHint:W,openInNewTabUrl:m},B=ri(N);Fo(L,E,O,U,P,W)?K.next=(e,t,n,o)=>this.sdk.flow.start(l,Object.assign({tenant:c,redirectAuth:z,oidcIdpStateId:E,samlIdpStateId:O,samlIdpUsername:U,ssoAppId:P,oidcLoginHint:W,lastAuth:B,preview:this.preview,abTestingKey:D,client:this.client},v&&{redirectUrl:v}),$,e,t,n,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),y&&{exchangeCode:y,idpInitiated:!0}),R&&{idpInitiated:!0}),b&&{token:b})):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(K.next=(...e)=>this.sdk.flow.next(u,d,...e)),this.stepState.update(K)}))}loadDescopeUiComponents(e){return n(this,void 0,void 0,(function*(){const t=yield sr.descopeUI;if(!t)return;const o=(e=>[...Array.from(e.querySelectorAll("*")).reduce(((e,t)=>t.tagName.startsWith("DESCOPE-")?e.add(t.tagName.toLocaleLowerCase()):e),new Set)])(e);yield Promise.all(o.map((e=>n(this,void 0,void 0,(function*(){if(!customElements.get(e))if(t[e])try{return yield t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`${e} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)})))))}))}onStepChange(e,t){var i,r;return n(this,void 0,void 0,(function*(){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.content);this.sdk.webauthn.helpers.isSupported()?yield o(this,Ni,"m",Xi).call(this,p,c):p.querySelectorAll(`descope-button[${Co}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),((e,t,n,o,i,r)=>{var s,a;let l=null==t?void 0:t.errorText;try{l=(null==i?void 0:i({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(`[${Co}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",l),ti(e,"totp-link",null===(s=null==t?void 0:t.totp)||void 0===s?void 0:s.provisionUrl),ti(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=>{e.textContent=ei(e.textContent,t)}))})(e,t),((e,t,n)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const i=t[o];Object.keys(i).forEach((t=>{let o=i[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,n,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=ei(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])=>{Go.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)})(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(p,g);const m=()=>n(this,void 0,void 0,(function*(){var e,n;yield f;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(e=null==d?void 0:d.totp)||void 0===e?void 0:e.image,ni(r,"descope-totp-image",s),((e,t)=>{ni(e,"descope-notp-image",t)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((e,t)=>{Qo(e,null==t?void 0:t.inputs),Qo(e,null==t?void 0:t.form)})(this.rootElement,d);const e=this.rootElement.querySelectorAll("descope-password"),t=this.rootElement.querySelectorAll("descope-new-password");document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),[...e,...t].forEach((e=>o(this,Ni,"m",Ji).call(this,e)))}));const a=!t.htmlUrl;if(((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(e=>{this.rootElement.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}))}))}))})(),o(this,Ni,"m",nr).call(this,c),a&&o(this,Ni,"m",ir).call(this,"ready",{}),o(this,Ni,"m",ir).call(this,"page-updated",{}),this.rootElement.querySelector(`[${Co}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),n=yield c(Uo,e.version,t.componentsVersion,{});o(this,Vi,"f").call(this,n)}u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,Ni,"m",or).call(this,m,l):m()}))}}qi=new WeakMap,Fi=new WeakMap,zi=new WeakMap,Hi=new WeakMap,Vi=new WeakMap,Ki=new WeakMap,er=new WeakMap,Ni=new WeakSet,Bi=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)}))}},Ji=function(e){e&&"true"===e.getAttribute("external-input")&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),o=`input-${e.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),e.appendChild(i),t.setAttribute("slot",o),this.appendChild(t)}))},Xi=function(e,t){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,Fi,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield oi())){const{options:e,transactionId:r}=(yield o(this,Ki,"f").call(this))||{};if(e&&r){o(this,Ni,"m",Bi).call(this,s),i(this,Fi,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(e,o(this,Fi,"f")).then((e=>n(this,void 0,void 0,(function*(){const n=yield t(s.id,a.version,l.componentsVersion,{transactionId:r,response:e});o(this,Vi,"f").call(this,n)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},Yi=function(){return Array.from(this.shadowRoot.querySelectorAll("*[name]")).every((e=>{var t,n;return"slot"===e.localName||(null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e))}))},Zi=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${bo}])`));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})),{})}))},Gi=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},Qi=function(e={}){var t,n;const o=Ho(e,["externalId","email","phone"]),i=Ho(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},tr=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))&&o(this,er,"f").call(this,t,e)}))}))},nr=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((t=>{t.onclick=()=>{o(this,er,"f").call(this,t,e)}})),o(this,Ni,"m",tr).call(this,e)},or=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===Mo.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")},ir=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",ar);let lr=class{constructor(e,t){rr.set(this,void 0),this.nodeName="",i(this,rr,e,"f"),this.logger=t.logger}get asyncEle(){return(async(e,t)=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,rr,"f"))}get ele(){var e,t;const n="function"==typeof o(this,rr,"f")?o(this,rr,"f").call(this):o(this,rr,"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("no element for driver ",this.constructor.name,new Error),null)}};rr=new WeakMap;class cr extends lr{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 dr;class ur extends lr{constructor(){super(...arguments),dr.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=""),o(this,dr,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,dr,"f").content.cloneNode(!0)))}setContent(e){i(this,dr,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}dr=new WeakMap;let hr=class extends lr{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()}};class pr extends lr{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)}}}let fr=class extends lr{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)}}};class gr extends lr{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 mr extends lr{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)}}}var vr=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),br=()=>Math.random().toString(36).substring(7).split("").join("."),yr={INIT:`@@redux/INIT${br()}`,REPLACE:`@@redux/REPLACE${br()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${br()}`};function wr(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 kr(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 Ir(e){let t=typeof e;return t=kr(e),t}function Sr(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Ir(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: '${Ir(n)}'`);return n(Sr)(e,t)}let o=e,i=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 i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Ir(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(!wr(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Ir(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: '${Ir(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=o(i,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:yr.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: '${Ir(e)}`);o=e,h({type:yr.REPLACE})},[vr]: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: '${Ir(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[vr](){return this}}}}}function jr(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function xr(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&jr(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:yr.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:yr.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 '${yr.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 o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===yr.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!wr(e))return`The ${r} has unexpected type of "${Ir(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===yr.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: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&jr(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],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||o.length!==Object.keys(e).length,s?a:e}}function Cr(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Er(e){return wr(e)&&"type"in e&&"string"==typeof e.type}var Ar=Symbol.for("immer-nothing"),Or=Symbol.for("immer-draftable"),Ur=Symbol.for("immer-state"),Rr=[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 Mr(e,...t){{const n=Rr[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Tr=Object.getPrototypeOf;function _r(e){return!!e&&!!e[Ur]}function Pr(e){return!!e&&(Lr(e)||Array.isArray(e)||!!e[Or]||!!e.constructor?.[Or]||Fr(e)||zr(e))}var Wr=Object.prototype.constructor.toString();function Lr(e){if(!e||"object"!=typeof e)return!1;const t=Tr(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)===Wr}function $r(e,t){0===Dr(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Dr(e){const t=e[Ur];return t?t.type_:Array.isArray(e)?1:Fr(e)?2:zr(e)?3:0}function Nr(e,t){return 2===Dr(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function qr(e,t,n){const o=Dr(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function Fr(e){return e instanceof Map}function zr(e){return e instanceof Set}function Hr(e){return e.copy_||e.base_}function Vr(e,t){if(Fr(e))return new Map(e);if(zr(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Lr(e)){if(!Tr(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ur];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(Tr(e),n)}function Kr(e,t=!1){return Jr(e)||_r(e)||!Pr(e)||(Dr(e)>1&&(e.set=e.add=e.clear=e.delete=Br),Object.freeze(e),t&&$r(e,((e,t)=>Kr(t,!0)))),e}function Br(){Mr(2)}function Jr(e){return Object.isFrozen(e)}var Xr,Yr={};function Zr(e){const t=Yr[e];return t||Mr(0,e),t}function Gr(){return Xr}function Qr(e,t){t&&(Zr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function es(e){ts(e),e.drafts_.forEach(os),e.drafts_=null}function ts(e){e===Xr&&(Xr=e.parent_)}function ns(e){return Xr={drafts_:[],parent_:Xr,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function os(e){const t=e[Ur];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function is(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ur].modified_&&(es(t),Mr(4)),Pr(e)&&(e=rs(t,e),t.parent_||as(t,e)),t.patches_&&Zr("Patches").generateReplacementPatches_(n[Ur].base_,e,t.patches_,t.inversePatches_)):e=rs(t,n,[]),es(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ar?e:void 0}function rs(e,t,n){if(Jr(t))return t;const o=t[Ur];if(!o)return $r(t,((i,r)=>ss(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return as(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),$r(i,((i,s)=>ss(e,o,t,i,s,n,r))),as(e,t,!1),n&&e.patches_&&Zr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function ss(e,t,n,o,i,r,s){if(i===n&&Mr(5),_r(i)){const s=rs(e,i,r&&t&&3!==t.type_&&!Nr(t.assigned_,o)?r.concat(o):void 0);if(qr(n,o,s),!_r(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(Pr(i)&&!Jr(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;rs(e,i),t&&t.scope_.parent_||as(e,i)}}function as(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Kr(t,n)}var ls={get(e,t){if(t===Ur)return e;const n=Hr(e);if(!Nr(n,t))return function(e,t,n){const o=us(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!Pr(o)?o:o===ds(e.base_,t)?(ps(e),e.copy_[t]=fs(o,e)):o},has:(e,t)=>t in Hr(e),ownKeys:e=>Reflect.ownKeys(Hr(e)),set(e,t,n){const o=us(Hr(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=ds(Hr(e),t),i=o?.[Ur];if(i&&i.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,o)&&(void 0!==n||Nr(e.base_,t)))return!0;ps(e),hs(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!==ds(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,ps(e),hs(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Hr(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Mr(11)},getPrototypeOf:e=>Tr(e.base_),setPrototypeOf(){Mr(12)}},cs={};function ds(e,t){const n=e[Ur];return(n?Hr(n):e)[t]}function us(e,t){if(!(t in e))return;let n=Tr(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Tr(n)}}function hs(e){e.modified_||(e.modified_=!0,e.parent_&&hs(e.parent_))}function ps(e){e.copy_||(e.copy_=Vr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}$r(ls,((e,t)=>{cs[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),cs.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Mr(13),cs.set.call(this,e,t,void 0)},cs.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Mr(14),ls.set.call(this,e[0],t,n,e[0])};function fs(e,t){const n=Fr(e)?Zr("MapSet").proxyMap_(e,t):zr(e)?Zr("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Gr(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=ls;n&&(i=[o],r=cs);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Gr()).drafts_.push(n),n}function gs(e){return _r(e)||Mr(10,e),ms(e)}function ms(e){if(!Pr(e)||Jr(e))return e;const t=e[Ur];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Vr(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Vr(e,!0);return $r(n,((e,t)=>{qr(n,e,ms(t))})),t&&(t.finalized_=!1),n}var vs=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 o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&Mr(6),void 0!==n&&"function"!=typeof n&&Mr(7),Pr(e)){const i=ns(this),r=fs(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?es(i):ts(i)}return Qr(i,n),is(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Ar&&(o=void 0),this.autoFreeze_&&Kr(o,!0),n){const t=[],i=[];Zr("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Mr(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Pr(e)||Mr(8),_r(e)&&(e=gs(e));const t=ns(this),n=fs(e,void 0);return n[Ur].isManual_=!0,ts(t),n}finishDraft(e,t){const n=e&&e[Ur];n&&n.isManual_||Mr(9);const{scope_:o}=n;return Qr(o,t),is(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Zr("Patches").applyPatches_;return _r(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},bs=vs.produce;vs.produceWithPatches.bind(vs),vs.setAutoFreeze.bind(vs),vs.setUseStrictShallowCopy.bind(vs),vs.applyPatches.bind(vs),vs.createDraft.bind(vs),vs.finishDraft.bind(vs);var ys=(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})}}},ws=(e,t,n)=>{const{memoize:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);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})}},ks={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Is=e=>Array.isArray(e)?e:[e];function Ss(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 js(e,t){const n=[],{length:o}=e;for(let i=0;i<o;i++)n.push(e[i].apply(null,t));return n}var xs="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Cs=0,Es=1;function As(){return{s:Cs,v:void 0,o:null,p:null}}function Os(e,t={}){let n=As();const{resultEqualityCheck:o}=t;let i,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 o=e.get(n);void 0===o?(t=As(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=As(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===Es?l=t.v:(l=e.apply(null,arguments),r++),a.s=Es,o){const e=i?.deref?.()??i;null!=e&&o(e,l)&&(l=e,0!==r&&r--);i="object"==typeof l&&null!==l||"function"==typeof l?new xs(l):l}return a.v=l,l}return s.clearCache=()=>{n=As(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Us(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,i=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=Os,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Is(c),f=Is(u),g=Ss(e),m=l((function(){return o++,s.apply(null,arguments)}),...p);let v=!0;const b=d((function(){i++;const e=js(g,arguments);t=m.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...ks,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ys},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:ws}}})(v,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=js(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}v&&(v=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:m,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Rs=Us(Os),Ms=Object.assign(((e,t=Rs)=>{!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,o)=>(e[n[o]]=t,e)),{})))}),{withTypes:()=>Ms});function Ts(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var _s=Ts(),Ps=Ts;((...e)=>{const t=Us(...e)})(Os);var Ws="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Cr:Cr.apply(null,arguments)},Ls=e=>e&&"function"==typeof e.match;function $s(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Er(t)&&t.type===e,n}function Ds(e){return"function"==typeof e&&"type"in e&&Ls(e)}function Ns(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 qs=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 Fs(e){return Pr(e)?bs(e,(()=>{})):e}function zs(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Hs(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Vs(e,t,n){const o=Ks(e,t,n);return{detectMutations:()=>Bs(e,t,o,n)}}function Ks(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=Ks(e,t,n[i],s))}}return r}function Bs(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let i in l){const s=r?r+"."+i:i;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Bs(e,t,n.children[i],o[i],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Js(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||wr(e)}function Xs(e,t="",n=Js,o,i=[],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!=o?o(e):Object.entries(e),l=i.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Xs(c,a,n,o,i,r),s))return s}return r&&Ys(e)&&r.add(e),!1}function Ys(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Ys(t))return!1;return!0}function Zs(e){return"boolean"==typeof e}var Gs=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new qs;if(t&&(Zs(t)?r.push(_s):r.push(Ps(t.extraArgument))),n){let e={};Zs(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=Hs,ignoredPaths:i,warnAfter:r=32}=e;const s=Vs.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>l=>{const c=Ns(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),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(o=e(),n=i.detectMutations(),i=s(o),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(o){let e={};Zs(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=Js,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["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(!Er(u))return c(u);const h=c(u),p=Ns(s,"SerializableStateInvariantMiddleware");return l||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=Xs(u,"",t,n,i,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 o=Xs(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;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(i){let e={};Zs(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Ds}=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},Qs=e=>t=>{setTimeout(t,e)},ea="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Qs(10),ta=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new qs(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let i=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?ea:"callback"===e.type?e.queueNotification:Qs(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,l(c))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function na(e){const t=Gs(),{reducer:n,middleware:o,devTools:i=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!wr(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=xr(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(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=Cr;i&&(c=Ws({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);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:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Cr(...a)(i.dispatch),{...i,dispatch:r}}}(...l),u=ta(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 Sr(a,r,c(...h))}function oa(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)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,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function ia(...e){return t=>e.some((e=>((e,t)=>Ls(e)?e.match(t):e(t))(e,t)))}var ra=["name","message","stack","code"],sa=class{constructor(e,t){this.payload=e,this.meta=t}_type},aa=class{constructor(e,t){this.payload=e,this.meta=t}_type},la=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of ra)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},ca=(()=>{function e(e,t,n){const o=$s(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=$s(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=$s(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||la)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,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(i(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 sa(e,t),fulfillWithValue:(e,t)=>new aa(e,t)})).then((t=>{if(t instanceof sa)throw t;return t instanceof aa?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof sa?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(da)})}}),{pending:i,rejected:r,fulfilled:o,settled:ia(r,o),typePrefix:e})}return e.withTypes=()=>e,e})();function da(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var ua=Symbol.for("rtk-slice-createasyncthunk");function ha(e,t){return`${e}/${t}`}function pa(e,t,n,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var fa=function({creators:e}={}){const t=e?.asyncThunk?.[ua];return function(e){const{name:n,reducerPath:o=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 i=("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(i),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=[],o]="function"==typeof e.extraReducers?oa(e.extraReducers):[e.extraReducers],i={...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,[o,i,r]=oa(t);if(function(e){return"function"==typeof e}(e))n=()=>Fs(e());else{const t=Fs(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...i.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(_r(e)){const o=n(e,t);return void 0===o?e:o}if(Pr(e))return bs(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:ha(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?$s(e,s):$s(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)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=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.exposeCaseReducer(t,{fulfilled:s||ga,pending:a||ga,rejected:l||ga,settled:c||ga})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,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=zs(d,this,{insert:()=>new WeakMap});return zs(n,t,{insert:()=>{const n={};for(const[o,i]of Object.entries(e.selectors??{}))n[o]=pa(this,i,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 o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function ga(){}var ma="listenerMiddleware";$s(`${ma}/add`),$s(`${ma}/removeAll`),$s(`${ma}/remove`);const va=["error","warn","info","debug"],ba=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,console))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return va.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),ya="undefined"!=typeof localStorage,wa=ya&&localStorage.getItem("base.content.url")||"",ka=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Ia=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)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),Sa=l((e=>{var t,n;const i=r(ba,Ia)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),ja=e=>t=>{var n,i,s;const a=r(ba,Ia,Sa)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",i).bind(this))}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),l.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e))))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};ja.missingAttrValidator=ka;const xa=l((e=>{const t=r(ja({"project-id":ka}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Ca=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")}}));const Ea=l((e=>{const t=r(ba,xa,Ca)(e);return class extends t{async fetchStaticResource(e,t){const n=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(wa||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.toString()}({projectId:this.projectId,filename:e,baseUrl:this.baseStaticUrl}),o=await fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:await o[t](),headers:Object.fromEntries(o.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),Aa=l((e=>{var t,n,s;const a=r(Ea)(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 o(this,t,"f")||i(this,t,o(this,n,"f").call(this),"f"),o(this,t,"f")}},t=new WeakMap,n=new WeakMap,s})),Oa=l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(Ia,ba)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(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)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return sl})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),Ua="load-descope-ui",Ra="base.ui.components.url",Ma=ya&&localStorage.getItem(Ra)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Ta=ya&&localStorage.getItem(Ra)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",_a=e=>{const t=document.createElement("script");return t.id=e,t},Pa=(e,t)=>e.replace("<version>",t),Wa=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g;const m=r(ba,Aa)(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 o(this,h,"f")||i(this,h,o(this,t,"m",f).call(this),"f"),o(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=>o(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=o(this,n,"f"),i=o(this,s,"f");e[t]=[],e[i]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[i].push(t)}})},c=async function(e,n){this.logger.debug("Trying to load DescopeUI from a fallback URL");const i=_a("load-descope-ui-fallback-script");document.body.append(i),i.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${i.src}"`)))})),i.addEventListener("load",(()=>{n.forEach((e=>e()))})),i.src=Pa(Ta,await o(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[o(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),o(this,t,"m",c).call(this,e[o(this,n,"f")],e[o(this,s,"f")])})),e.addEventListener("load",(()=>{e[o(this,s,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${Ua}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=_a(Ua);document.body.append(e),o(this,t,"m",l).call(this,e),o(this,t,"m",d).call(this,e),e.src=Pa(Ma,await o(this,t,"m",a).call(this))}return document.getElementById(Ua)},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),o(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})),La="content-root",$a="root",Da=l((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${$a}, #${La} {\n height: 100%;\n }\n #${$a} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${$a}">\n <div id="${La}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(La),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById($a)}})),Na="descope-modal",qa=l((e=>{var t,n;const i=r(Ia,Da,Wa)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ur{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Na);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Na]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),Fa="descope-notification";l((e=>{var t,n;const i=r(Ia,Da,Wa)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends hr{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(Fa);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(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([Fa])}},t=new WeakMap,n}));const za=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Ha=l((e=>{var t,n,s,a,l,c,d,u,h;const p=r(ja({theme:za}),Ea,Ia,Wa,Aa,Da,Sa)(e);return h=class extends p{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}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"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this),o(this,t,"m",c).call(this),o(this,t,"m",d).call(this),o(this,t,"m",u).call(this),this.observeAttributes(["theme"],(()=>{o(this,t,"m",d).call(this),o(this,t,"m",u).call(this)}))}},n=new WeakMap,t=new WeakSet,s=async function(){try{const{body:e}=await this.fetchStaticResource("theme.json","json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(Ra))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(Ra),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({},t.light.components),e.light.components),e.dark.components=Object.assign(Object.assign({},t.dark.components),e.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")}},a=function(){return o(this,n,"f")||(i(this,n,o(this,t,"m",s).call(this),"f"),o(this,n,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,n,"f")},l=async function(){var e,n;const i=await o(this,t,"a",a);if(!i)return;const r=document.createElement("style");r.innerText=((null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.globals)||"")+((null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.globals)||""),this.shadowRoot.appendChild(r)},c=async function(){var e,n;const i=Object.assign({},await o(this,t,"a",a));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config,o=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;o&&Object.values(o).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))}))},u=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)},h})),Va=e=>l((t=>{const n=fa(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(ba)(t)){constructor(...e){super(...e);const t=na({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{da(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=(e=>e))=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(ba(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 Ka=l((e=>class extends e{get baseStaticUrl(){return this.getAttribute("base-static-url")}})),Ba=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Ja,Xa,Ya,Za,Ga,Qa,el,tl,nl,ol;const il=document.createElement("template");il.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 rl extends HTMLElement{constructor(){var e;super(),Ja.add(this),Xa.set(this,new 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(o(this,c,"f")):e,n=Object.assign(Object.assign({},o(this,c,"f")),t);if(!o(this,h,"f")||!p(o(this,c,"f"),n)){const e=o(this,c,"f");i(this,c,n,"f"),Object.freeze(o(this,c,"f")),setTimeout((()=>{Object.values(o(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,c,e,"f"),i(this,h,t,"f")}get current(){return Object.assign({},o(this,c,"f"))}subscribe(e){return i(this,u,o(this,u,"f")+1,"f"),o(this,d,"f")[o(this,u,"f")]=e,o(this,u,"f").toString()}unsubscribe(e){const t=!!o(this,d,"f")[e];return t&&delete o(this,d,"f")[e],t}unsubscribeAll(){return i(this,d,{},"f"),!0}}({messages:[]})),Ya.set(this,void 0),Za.set(this,void 0),Ga.set(this,void 0),Qa.set(this,{resize:o(this,Ja,"m",ol).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(il.content.cloneNode(!0)),i(this,Ya,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Za,o(this,Ya,"f").querySelector(".content"),"f"),i(this,Ga,o(this,Ya,"f").querySelector(".header"),"f")}updateData(e){o(this,Xa,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Ba(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(o(this,Ya,"f"),o(this,Ga,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Qa,"f").resize),(e=o(this,Ya,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,Ya,"f").onresize=o(this,Ja,"m",nl).bind(this),o(this,Xa,"f").subscribe(o(this,Ja,"m",el).bind(this))}disconnectedCallback(){o(this,Xa,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Qa,"f").resize)}}Xa=new WeakMap,Ya=new WeakMap,Za=new WeakMap,Ga=new WeakMap,Qa=new WeakMap,Ja=new WeakSet,el=function(e){o(this,Ja,"m",tl).call(this,e),o(this,Ja,"m",nl).call(this)},tl=function(e){o(this,Za,"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("")},nl=function(){o(this,Za,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},ol=function(){const[e,t]=Ba(o(this,Ya,"f"),Number.parseInt(o(this,Ya,"f").style.left,10),Number.parseInt(o(this,Ya,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Ya,"f").style.top=`${t}px`,o(this,Ya,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",rl);var sl=Object.freeze({__proto__:null});const al=e=>e.me.data,ll=Rs(al,(e=>e.picture)),cl=Rs(al,(e=>e.email)),dl=Rs(al,(e=>e.verifiedEmail)),ul=Rs(al,(e=>e.name)),hl=Rs(al,(e=>e.phone)),pl=Rs(al,(e=>e.verifiedPhone)),fl=Rs(al,(e=>e.webauthn));Rs(al,(e=>e.password));const gl=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)}))}))},ml=ca("users/me",((e,{extra:{api:t}})=>t.user.me())),vl=gl(ml)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(bl=e=>e.me,{onFulfilled:e=>{bl(e).loading=!1},onPending:e=>{bl(e).loading=!0,bl(e).error=null},onRejected:(e,t)=>{bl(e).loading=!1,bl(e).error=t.error}}));var bl;const yl={action:ml,reducer:vl},wl=ca("users/logout",((e,{extra:{api:t}})=>t.user.logout())),kl={action:wl,reducer:gl(wl)({})},Il={me:{loading:!1,error:null,data:{}}},Sl={me:"/v1/auth/me"},jl=()=>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})}))})),xl=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return jl();const o=yield e.get(Sl.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)})))(o),o.json()}))}),Cl=l((e=>{var t,s,a,l;const c=r(xa,Sa,ba,Ca)(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 o(this,s,"f")||o(this,t,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,o)=>{const i=io(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.0.53"}}));return{user:Object.assign(Object.assign({},xl({httpClient:i.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):i.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},l})),El=l((e=>{const t=r(Va({name:"widget",initialState:Il,reducers:{},extraReducers:e=>{yl.reducer(e),kl.reducer(e)},asyncActions:{getMe:yl.action,logout:kl.action}}),Ia,ba,Cl)(e);return class extends t{constructor(...e){super(...e),this.state=Il,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Al=l((e=>{const t=r(Ea,ja({"widget-id":ja.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}))}}})),Ol=l((e=>{var t,i,a;return a=class extends(r(ba,Ia,Wa,Da,Al,El)(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}});var r;return n(this,void 0,void 0,(function*(){yield null===(r=e.init)||void 0===r?void 0:r.call(this),yield Promise.all([this.actions.getMe(),o(this,t,"m",i).call(this)]),this.onWidgetRootReady()}))}},t=new WeakSet,i=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})),Ul=(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 Rl(e){return new URLSearchParams(window.location.search).get(e)}const Ml=l((e=>{var t,s,l,c,d,u,h,p,f;return f=class extends(r(El,ba,Ol,qa,Ka)(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}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",u).call(this),o(this,t,"m",c).call(this),o(this,h,"f").call(this,ll(this.state)),o(this,p,"f").call(this,ul(this.state)),this.subscribe(o(this,h,"f").bind(this),ll),this.subscribe(o(this,p,"f").bind(this),ul)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(){i(this,s,this.createModal({"data-id":"update-pic"}),"f"),i(this,l,new mr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",d).bind(this),o(this,t,"m",d).call(this)},d=function(){o(this,s,"f").setContent(Ul({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new pr((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{o(this,s,"f").open()}))},f})),Tl=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,v,b;return b=class extends(r(El,ba,Ol,qa)(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}))),v.set(this,a((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",p).call(this),o(this,m,"f").call(this,cl(this.state)),o(this,v,"f").call(this,dl(this.state)),this.subscribe(o(this,m,"f").bind(this),cl),this.subscribe(o(this,v,"f").bind(this),dl)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-email"}),"f"),i(this,l,new mr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Ul({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},p=function(){i(this,c,this.createModal({"data-id":"delete-email"}),"f"),i(this,d,new mr((()=>{var e;return null===(e=o(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,c,"f").afterClose=o(this,t,"m",f).bind(this),o(this,t,"m",f).call(this)},f=function(){o(this,c,"f").setContent(Ul({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new fr((()=>{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((()=>{o(this,s,"f").open()})),this.emailUserAttr.onDeleteClick((()=>{o(this,c,"f").open()}))},b})),_l=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,v;return v=class extends(r(El,ba,Ol,qa)(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}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",p).call(this),o(this,m,"f").call(this,ul(this.state)),this.subscribe(o(this,m,"f").bind(this),ul)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-name"}),"f"),i(this,l,new mr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Ul({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},p=function(){i(this,c,this.createModal({"data-id":"delete-name"}),"f"),i(this,d,new mr((()=>{var e;return null===(e=o(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,c,"f").afterClose=o(this,t,"m",f).bind(this),o(this,t,"m",f).call(this)},f=function(){o(this,c,"f").setContent(Ul({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new fr((()=>{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((()=>{o(this,s,"f").open()})),this.nameUserAttr.onDeleteClick((()=>{o(this,c,"f").open()}))},v})),Pl=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,v,b;return b=class extends(r(El,ba,Ol,qa)(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}))),v.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",p).call(this),o(this,m,"f").call(this,hl(this.state)),o(this,v,"f").call(this,pl(this.state)),this.subscribe(o(this,m,"f").bind(this),hl),this.subscribe(o(this,v,"f").bind(this),pl)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-phone"}),"f"),i(this,l,new mr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Ul({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},p=function(){i(this,c,this.createModal({"data-id":"delete-phone"}),"f"),i(this,d,new mr((()=>{var e;return null===(e=o(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,c,"f").afterClose=o(this,t,"m",f).bind(this),o(this,t,"m",f).call(this)},f=function(){o(this,c,"f").setContent(Ul({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new fr((()=>{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((()=>{o(this,s,"f").open()})),this.phoneUserAttr.onDeleteClick((()=>{o(this,c,"f").open()}))},b})),Wl=l((e=>{var t,s,l,c,d,u,h,p;return p=class extends(r(El,ba,Ol,qa)(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}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",u).call(this),o(this,t,"m",c).call(this),o(this,h,"f").call(this,fl(this.state)),this.subscribe(o(this,h,"f").bind(this),fl)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,t=new WeakSet,c=function(){i(this,s,this.createModal({"data-id":"passkey"}),"f"),i(this,l,new mr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",d).bind(this),o(this,t,"m",d).call(this)},d=function(){o(this,s,"f").setContent(Ul({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new gr((()=>{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((()=>{o(this,s,"f").open()}))},p})),Ll=l((e=>{var t,s,a,l,c,d,u;return u=class extends(r(El,ba,Ol,qa)(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}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",d).call(this),o(this,t,"m",l).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){i(this,s,this.createModal({"data-id":"password"}),"f"),i(this,a,new mr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",c).bind(this),o(this,t,"m",c).call(this)},c=function(){o(this,s,"f").setContent(Ul({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,a,"f").onSuccess((()=>{o(this,s,"f").close()}))},d=function(){this.passwordUserAuthMethod=new gr((()=>{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((()=>{o(this,s,"f").open()}))},u})),$l=l((e=>{var t,i,s;return s=class extends(r(El,ba,Ol,qa)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var r;return n(this,void 0,void 0,(function*(){yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),o(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){this.logout=new cr((()=>{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})),Dl="widget-flow",Nl=l((e=>{var t,i,s;return s=class extends(r(Ia,qa,El,ba)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});var r;return n(this,void 0,void 0,(function*(){yield null===(r=e.init)||void 0===r?void 0:r.call(this);const n=Rl(Dl);n&&(!function(e){if(window.history.replaceState&&Rl(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())}}(Dl),o(this,t,"m",i).call(this,n))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(Ul({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl}));const n=new mr((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger});n.onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),ql=l((e=>class extends(r(Oa,Ha,Nl,Tl,Ml,_l,Pl,Wl,Ll,$l)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return n(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Fl=r((e=>class extends(ql(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return n(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),ar.sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.0.53"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",Fl);const zl=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Hl,Vl,Kl,Bl,Jl,Xl,Yl,Zl,Gl,Ql;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 tc extends HTMLElement{constructor(){super(),Hl.add(this),Vl.set(this,new Zo({messages:[]})),Kl.set(this,void 0),Bl.set(this,void 0),Jl.set(this,void 0),Xl.set(this,{resize:o(this,Hl,"m",Ql).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ec.content.cloneNode(!0)),i(this,Kl,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Bl,o(this,Kl,"f").querySelector(".content"),"f"),i(this,Jl,o(this,Kl,"f").querySelector(".header"),"f")}updateData(e){o(this,Vl,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=zl(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(o(this,Kl,"f"),o(this,Jl,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Xl,"f").resize),(e=o(this,Kl,"f")).onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight},o(this,Kl,"f").onresize=o(this,Hl,"m",Gl).bind(this),o(this,Vl,"f").subscribe(o(this,Hl,"m",Yl).bind(this))}disconnectedCallback(){o(this,Vl,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Xl,"f").resize)}}Vl=new WeakMap,Kl=new WeakMap,Bl=new WeakMap,Jl=new WeakMap,Xl=new WeakMap,Hl=new WeakSet,Yl=function(e){o(this,Hl,"m",Zl).call(this,e),o(this,Hl,"m",Gl).call(this)},Zl=function(e){o(this,Bl,"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("")},Gl=function(){o(this,Bl,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Ql=function(){const[e,t]=zl(o(this,Kl,"f"),Number.parseInt(o(this,Kl,"f").style.left,10),Number.parseInt(o(this,Kl,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Kl,"f").style.top=`${t}px`,o(this,Kl,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",tc);var nc=Object.freeze({__proto__:null,default:tc});return Fl}();
|
|
7
|
+
function ln(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var cn=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=ln({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",ln({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,ln({},this.attributes,t))},withConverter:function(t){return e(ln({},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 dn={default:"endpoint"},un="Blocked by CSP",hn="The endpoint parameter is not a valid URL",pn="Failed to load the JS script of the agent",fn="9319";function gn(e,t){var n,o,i,r,s=[],a=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),100,3e3,r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===un||s===hn)n.exclude(),r=0;else if(s===fn)n.exclude();else if(s===pn){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+o()-Date.now()]}]),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,o=function(t){return s.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(s.length>=5)throw e;var t=c(n,e);if(!t)throw e;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return d(i)}))}))};return d(l).then((function(e){return[e,s]}))}var mn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",vn=mn;function bn(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:mn,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.9.6"):e}))}(String(e),t)}))}(l,s);return gn(e,yn)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===fn?new Error(pn):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function yn(e){return function(e,t,n,o){var i,r=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return Promise.resolve().then(t).then((function(e){return l(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(l(),i)return function(){throw new Error(un)}();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(hn);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(pn))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)})).then(wn)}function wn(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(fn);return n}const kn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},In=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||{}},Sn=async e=>{const t=await In(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},jn="undefined"!=typeof localStorage,xn=(e,t)=>jn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Cn=e=>jn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),En=e=>jn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),An=(...e)=>{console.debug(...e)},On="undefined"!=typeof window,Un=Math.pow(2,31)-1,Rn="DS",Mn="DSR";function Tn(e=""){return Cn(`${e}${Mn}`)||""}function _n(e=""){En(`${e}${Mn}`),En(`${e}${Rn}`),cn.remove(Rn)}const Pn=On&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Wn="fp",Ln=(e=!1)=>{const t=localStorage.getItem(Wn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},$n=async(e,t=Pn)=>{try{if(Ln())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=bn({apiKey:e,endpoint:[o.toString(),dn],scriptUrlPattern:[r,vn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({vsid:e,vrid:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(Wn,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Dn=e=>{const t=Ln(!0);return t&&e.body&&(e.body.fpData=t),e},Nn="dls_last_user_login_id",qn="dls_last_user_display_name",Fn=()=>Cn(Nn),zn=()=>Cn(qn),Hn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=Fn(),r=zn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},Vn=e=>async(...t)=>{const n=await e(...t);return En(Nn),En(qn),n};function Kn(){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 Bn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Qn(n.publicKey.challenge),n.publicKey.user.id=Qn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Qn(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:eo(n.rawId),type:n.type,response:{attestationObject:eo(n.response.attestationObject),clientDataJSON:eo(n.response.clientDataJSON)}});var n}async function Jn(e){const t=Zn(e);return Gn(await navigator.credentials.get(t))}async function Xn(e,t){const n=Zn(e);return n.signal=t.signal,n.mediation="conditional",Gn(await navigator.credentials.get(n))}async function Yn(e=!1){if(!On)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 Zn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Qn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Qn(e.id)})),n}function Gn(e){return JSON.stringify({id:e.id,rawId:eo(e.rawId),type:e.type,response:{authenticatorData:eo(e.response.authenticatorData),clientDataJSON:eo(e.response.clientDataJSON),signature:eo(e.response.signature),userHandle:e.response.userHandle?eo(e.response.userHandle):void 0}})}function Qn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function eo(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var to,no=(to=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const i=await Bn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await Jn(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await Bn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Jn(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const i=await Bn(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Bn,get:Jn,isSupported:Yn,conditional:Xn}}),(...e)=>{const t=to(...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 oo=e=>({async oneTap(t,n,o,i){const r=null!=t?t:"google",s=await e.oauth.startNative(r,o);if(!s.ok)return s;const{clientId:a,stateId:l,nonce:c}=s.data,d=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 o,s;d.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(s=null==n?void 0:n.use_fedcm_for_prompt)||void 0===s||s,client_id:a,callback:n=>{t(e.oauth.finishNative(r,l,"","",n.credential))},nonce:c})),d.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==i||i())}))}))}});var io=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Yn(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const ro=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return On?(o&&i&&$n(o).catch((()=>null)),e(kn(r,{beforeRequest:Dn}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),e(r))}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);if(!o)return e(i);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,l;On&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(An("Expiration time passed, refreshing session"),c.refresh(Tn()||l))}));const c=e(kn(i,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await In(t);if(401===(null==t?void 0:t.status))An("Received 401, canceling all timers"),r();else if(o){if(a=(e=>{try{const t=v(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(o),!a)return void An("Could not extract expiration time from session token");l=n;let e=((i=a)?i.getTime()-(new Date).getTime():0)-2e4;e>Un&&(An(`Timeout is too large (${e}ms), setting it to ${Un}ms`),e=Un),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});An(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{An("Refreshing session due to timer"),c.refresh(Tn()||n)}),e)}var i}}));return Ze(c,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return An("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.11.16"},t.baseHeaders)}))),(e=>t=>{const n=Kn(),o=Kn(),i=e(kn(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),o.pub(null);else{const e=await Sn(t);e&&o.pub(e);const{sessionJwt:i}=await In(t);i&&n.pub(i)}}})),r=Ze(i,["logout","logoutAll"],(e=>async(...t)=>{const i=await e(...t);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0}=n,i=t(n,["storeLastAuthenticatedUser"]);if(!o)return Object.assign(e(i),{getLastUserLoginId:Fn,getLastUserDisplayName:zn});const r=e(kn(i,{afterRequest:async(e,t)=>{var n;const o=await Sn(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((e=>{xn(Nn,e)})(i),(e=>{xn(qn,e)})(r))}}));let s=Ze(r,["flow.start"],Hn);return s=Ze(s,["logout","logoutAll"],Vn),Object.assign(s,{getLastUserLoginId:Fn,getLastUserDisplayName:zn})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!On)return o&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),e(s);const a=e(kn(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||Tn(l)})),afterRequest:async(e,n)=>{const o=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?o||_n(r):((e={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=e,s=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&xn(`${o}${Mn}`,i),r&&(n?function(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(t){const r=new Date(1e3*i),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);cn.set(e,t,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(Rn,r,s):xn(`${o}${Rn}`,r))})(await In(n),i,r)}}));var l;const c=Ze(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return _n(e),o})(r));return Object.assign(c,{getRefreshToken:()=>Tn(r),getSessionToken:()=>function(e=""){return cn.get(Rn)||Cn(`${e}${Rn}`)||""}(r)})}))(((...e)=>{const t=an(...e);return Object.assign(Object.assign({},t),{flow:io(t),webauthn:no(t),fedcm:oo(t)})})),so="undefined"!=typeof localStorage,ao=so&&localStorage.getItem("base.content.url")||"",lo="config.json",co="base.ui.components.url",uo=so&&localStorage.getItem(co)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",ho=so&&localStorage.getItem(co)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",po="descope-login-flow",fo="code",go="ra-challenge",mo="ra-callback",vo="ra-backup-callback",bo="ra-initiator",yo="data-exclude-field",wo="dls_last_auth",ko="state_id",Io="saml_idp_state_id",So="saml_idp_username",jo="descope_idp_initiated",xo="sso_app_id",Co="oidc_login_hint",Eo="data-type",Ao="poll",Oo="webauthnCreate",Uo="submit",Ro="polling",Mo=["descope-multi-select-combo-box","descope-text-area"];var To;function _o(e){return new URLSearchParams(window.location.search).get(e)}function Po(e){if(window.history.replaceState&&_o(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function Wo(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 Lo({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(ao||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.toString()}function $o(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?To.forward:n<o?To.backward:void 0}!function(e){e.backward="backward",e.forward="forward"}(To||(To={}));const Do=()=>{const[e="",t=""]=(_o(po)||"").split("_");return{executionId:e,stepId:t}};function No(){Po(po)}const qo=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Fo=e=>{let t,n;return(...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}},zo=(e,t,n,o,i,r)=>e&&!t&&e&&!n&&!o&&e&&!i&&e&&!r,Ho=e=>null==e?void 0:e.submit(),Vo=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Ko=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};var Bo,Jo,Xo,Yo;function Zo(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Zo(r,s))return!1}else if(r!==s)return!1}return!0}class Go{constructor(e={},{updateOnlyOnChange:t=!0}={}){Bo.set(this,void 0),Jo.set(this,{}),Xo.set(this,0),Yo.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,Bo,"f")):e,n=Object.assign(Object.assign({},o(this,Bo,"f")),t);if(!o(this,Yo,"f")||!Zo(o(this,Bo,"f"),n)){const e=o(this,Bo,"f");i(this,Bo,n,"f"),Object.freeze(o(this,Bo,"f")),setTimeout((()=>{Object.values(o(this,Jo,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,Bo,e,"f"),i(this,Yo,t,"f")}get current(){return Object.assign({},o(this,Bo,"f"))}subscribe(e){return i(this,Xo,o(this,Xo,"f")+1,"f"),o(this,Jo,"f")[o(this,Xo,"f")]=e,o(this,Xo,"f").toString()}unsubscribe(e){const t=!!o(this,Jo,"f")[e];return t&&delete o(this,Jo,"f")[e],t}unsubscribeAll(){return i(this,Jo,{},"f"),!0}}Bo=new WeakMap,Jo=new WeakMap,Xo=new WeakMap,Yo=new WeakMap;const Qo=["disabled"],ei=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${yo}])`)).forEach((e=>{e.value=n}))}))},ti=(e,t)=>e.replace(/{{(.+?)}}/g,((e,n)=>{return o=t,n.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),o);var o})),ni=(e,t,n)=>{e.querySelectorAll(`[${Eo}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},oi=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},ii=Fo((()=>n(void 0,void 0,void 0,(function*(){var e,t,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=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)))),r=(()=>{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(100,n=i,o=r,new Promise(((e,t)=>{let i=!1;const r=setTimeout((()=>{i=!0,void 0!==o?e(o):t(new Error("Promise timed out after 100 ms"))}),100);n.then((t=>{i||(clearTimeout(r),e(t))})).catch((e=>{i||(clearTimeout(r),t(e))}))})))}catch(e){return console.error("Conditional login check failed",e),!1}})))),ri={"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 si(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(wo)))}catch(e){}return t}const ai="dls_ab_testing_id",li=document.createElement("template");var ci,di,ui,hi,pi,fi,gi,mi,vi,bi,yi,wi,ki,Ii,Si,ji,xi,Ci,Ei,Ai,Oi,Ui,Ri,Mi,Ti,_i,Pi,Wi,Li,$i,Di,Ni,qi,Fi,zi,Hi,Vi,Ki,Bi,Ji,Xi,Yi,Zi,Gi,Qi,er,tr,nr,or,ir,rr,sr;li.innerHTML='\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n display: block;\n\t\t}\n\n\t\t#wc-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#wc-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<div id="wc-root"></div>\n\t';class ar extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","validate-on-blur"]}constructor(e){super(),ci.add(this),this.logger=console,di.set(this,!1),this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,ci,"m",Li).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)}},ui.set(this,new Go({deferredRedirect:!1})),hi.set(this,new Go),pi.set(this,{}),this.getComponentsContext=()=>o(this,pi,"f"),this.nextRequestStatus=new Go({isLoading:!1}),fi.set(this,void 0),gi.set(this,{popstate:o(this,ci,"m",ki).bind(this),visibilitychange:o(this,ci,"m",Ii).bind(this),componentsContext:o(this,ci,"m",Ti).bind(this)}),mi.set(this,void 0),Ei.set(this,Fo((()=>n(this,void 0,void 0,(function*(){const e=Lo({projectId:this.projectId,filename:lo,baseUrl:this.baseStaticUrl});try{const{body:t,headers:n}=yield Wo(e,"json");return{projectConfig:t,executionContext:{geo:n["x-geo"]}}}catch(e){return{isMissingConfig:!0}}}))))),Oi.set(this,void 0),i(this,mi,e,"f"),o(this,ci,"m",vi).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get baseUrl(){return this.getAttribute("base-url")||void 0}get baseStaticUrl(){return this.getAttribute("base-static-url")}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 theme(){var e,t;const n=this.getAttribute("theme");return"os"===n?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":n||"light"}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 storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{const t=JSON.parse(e);return Object.fromEntries(Object.keys(t).map((e=>"string"!=typeof t[e]?[e,t[e]]:[e,{value:t[e]}])).flatMap((([e,t])=>[[e,t],[`form.${e}`,t]])))}catch(e){return{}}})(this.getAttribute("form"))}get formConfigValues(){return e=this.formConfig,"value",Object.fromEntries(Object.entries(e).map((([e,t])=>[e,t.value])));var e}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:e}=yield o(this,Ei,"f").call(this);return e}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,Ei,"f").call(this);return e}))}getFlowConfig(){var e,t;return n(this,void 0,void 0,(function*(){const n=yield this.getProjectConfig(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,hi,"f").subscribe(o(this,ci,"m",Wi).bind(this)),o(this,hi,"f").update({isDebug:this.debug}),o(this,ci,"m",bi).call(this))return void o(this,ci,"m",yi).call(this);if(o(this,ci,"m",wi).call(this),i(this,Oi,o(this,ci,"m",Ai).call(this),"f"),yield o(this,ci,"m",xi).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 o(this,Ei,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,ci,"m",Ui).call(this),yield o(this,ci,"m",Ni).call(this),yield o(this,ci,"m",Ri).call(this),o(this,ci,"m",$i).call(this);const{executionId:e,stepId:t,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,descopeIdpInitiated:f,ssoAppId:g,oidcLoginHint:m}=(()=>{const{executionId:e,stepId:t}=Do();(e||t)&&No();const n=_o("t")||void 0;n&&Po("t");const o=_o(fo)||void 0;o&&Po(fo);const i=_o("err")||void 0;i&&Po("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:_o(go),redirectAuthCallbackUrl:_o(mo),redirectAuthBackupCallbackUri:_o(vo),redirectAuthInitiator:_o(bo)};(r||s||a||l)&&(Po(go),Po(mo),Po(vo),Po(bo));const c=_o(ko);c&&Po(ko);const d=_o(Io);d&&Po(Io);const u=_o(So);d&&Po(So);const h=_o(jo);h&&Po(jo);const p=_o(xo);p&&Po(xo);const f=_o(Co);return f&&Po(Co),{executionId:e,stepId:t,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,oidcIdpStateId:c,samlIdpStateId:d,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:f}})();window.addEventListener("popstate",o(this,gi,"f").popstate),window.addEventListener("components-context",o(this,gi,"f").componentsContext),window.addEventListener("visibilitychange",o(this,gi,"f").visibilitychange),o(this,ui,"f").subscribe(o(this,ci,"m",ji).bind(this)),o(this,ui,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:t,executionId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,oidcIdpStateId:u,samlIdpStateId:h,samlIdpUsername:p,descopeIdpInitiated:f,ssoAppId:g,oidcLoginHint:m}),i(this,di,!0,"f")}}))}disconnectedCallback(){o(this,ui,"f").unsubscribeAll(),o(this,hi,"f").unsubscribeAll(),o(this,ci,"m",Pi).call(this),window.removeEventListener("popstate",o(this,gi,"f").popstate),window.removeEventListener("visibilitychange",o(this,gi,"f").visibilitychange),window.removeEventListener("components-context",o(this,gi,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,di,"f")&&t!==n&&ar.observedAttributes.includes(e)){o(this,ci,"m",wi).call(this);const i=null===t;o(this,ui,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,No()),{[qo(e)]:n,stepId:r,executionId:s}})),o(this,hi,"f").update({isDebug:this.debug})}}}di=new WeakMap,ui=new WeakMap,hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,mi=new WeakMap,Ei=new WeakMap,Oi=new WeakMap,ci=new WeakSet,vi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(li.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},bi=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},yi=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)},wi=function(){const e=["base-url","tenant","theme","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","preview","storage-prefix","form","client","validate-on-blur"];if(ar.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[qo(t)])throw Error(`${t} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},ki=function(){const{stepId:e,executionId:t}=Do();o(this,ui,"f").update({stepId:e,executionId:t})},Ii=function(){document.hidden||setTimeout((()=>{o(this,ui,"f").update({deferredRedirect:!1})}),300)},Si=function(e,t){this.sdk=ro(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser},ar.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)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},ji=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,ci,"m",Si).call(this,t,n)}o(this,mi,"f").call(this,e)}))},xi=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,Ei,"f").call(this)).isMissingConfig&&(yield o(this,ci,"m",Ci).call(this))}))},Ci=function(){return n(this,void 0,void 0,(function*(){const e=Lo({projectId:this.projectId,filename:lo,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield Wo(e,"json"),!0}catch(e){return!1}}))},Ai=function(){return n(this,void 0,void 0,(function*(){const e=Lo({projectId:this.projectId,filename:"theme.json",baseUrl:this.baseStaticUrl});try{const{body:t}=yield Wo(e,"json");return t}catch(e){return void this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},Ui=function(){var e,t;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,Ei,"f").call(this),i=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;i&&Object.values(i).forEach((e=>(e=>{if(!e)return;const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url)))}))},Ri=function(){return n(this,void 0,void 0,(function*(){yield o(this,ci,"m",Mi).call(this),yield o(this,ci,"m",_i).call(this)}))},Mi=function(){var e,t,i,r;return n(this,void 0,void 0,(function*(){const n=document.createElement("style"),s=yield o(this,Oi,"f");n.innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(t=null==s?void 0:s.dark)||void 0===t?void 0:t.globals)||"");const a=yield ar.descopeUI;(null==a?void 0:a.componentsThemeManager)&&!a.componentsThemeManager.hasThemes&&(a.componentsThemeManager.themes={light:null===(i=null==s?void 0:s.light)||void 0===i?void 0:i.components,dark:null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.components}),this.shadowRoot.appendChild(n)}))},Ti=function(e){i(this,pi,Object.assign(Object.assign({},o(this,pi,"f")),e.detail),"f")},_i=function(){return n(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield ar.descopeUI;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},Pi=function(){var e;null===(e=o(this,fi,"f"))||void 0===e||e.remove(),i(this,fi,null,"f")},Wi=function({isDebug:e}){return n(this,void 0,void 0,(function*(){e?(i(this,fi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,fi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return oc})),document.body.appendChild(o(this,fi,"f"))):o(this,ci,"m",Pi).call(this)}))},Li=function(e,t){var n;e&&this.debug&&(null===(n=o(this,fi,"f"))||void 0===n||n.updateData({title:e,description:t}))},$i=function(){this.rootElement.onkeydown=e=>{var t,n,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Mo.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},Di=function(){var e,t;return n(this,void 0,void 0,(function*(){return(null===(t=null===(e=yield o(this,Ei,"f").call(this))||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")}))},Ni=function(){return n(this,void 0,void 0,(function*(){ar.descopeUI?this.loggerWrapper.debug("DescopeUI is already loading, probably multiple flows are running on the same page"):ar.descopeUI=new Promise((e=>{if(globalThis.DescopeUI)return void e(globalThis.DescopeUI);const t=e=>{const t=document.createElement("script");return t.id="load-descope-ui",t.src=e,t},i=(e,t)=>e.replace("<version>",t),r=(t,n)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${t.src}"`),n()};t.addEventListener("load",(()=>{globalThis.DescopeUI||o(),e(globalThis.DescopeUI)})),t.addEventListener("error",o)};(()=>{n(this,void 0,void 0,(function*(){const n=yield o(this,ci,"m",Di).call(this),s=t(i(uo,n));r(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const o=t(i(ho,n));r(o,(()=>{e(void 0)})),document.body.append(o)})),document.body.append(s)}))})()}))}))},ar.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.15.3"}};class lr extends ar{static set sdkConfigOverrides(e){ar.sdkConfigOverrides=e}constructor(){const e=new Go;super(e.update.bind(e)),qi.add(this),this.stepState=new Go({},{updateOnlyOnChange:!1}),Fi.set(this,void 0),zi.set(this,null),Hi.set(this,((e,t,r,s,a)=>{r===Ao&&i(this,Fi,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;const i=yield this.sdk.flow.next(e,t,Ro,s,a,{});o(this,Ki,"f").call(this,i);const{action:r}=null!==(n=null==i?void 0:i.data)&&void 0!==n?n:{};o(this,Hi,"f").call(this,e,t,r,s,a)}))),2e3),"f")})),Vi.set(this,(()=>{clearTimeout(o(this,Fi,"f")),i(this,Fi,null,"f")})),Ki.set(this,(e=>{var t,n,i,r,s,a,l,c,d;if(!(null==e?void 0:e.ok)){o(this,qi,"m",rr).call(this,"error",null==e?void 0:e.error);const a=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,l=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.statusText}`;return void this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorMessage)||l)}const u=null===(c=null===(l=null===(a=e.data)||void 0===a?void 0:a.screen)||void 0===l?void 0:l.state)||void 0===c?void 0:c.errorText;(null===(d=e.data)||void 0===d?void 0:d.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${u?`${u} - `:""}${e.data.error.message}`):u&&this.loggerWrapper.error(u);const{status:h,authInfo:p,lastAuth:f}=e.data;if("completed"===h)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&so&&localStorage.setItem(wo,JSON.stringify(e))}(f),void o(this,qi,"m",rr).call(this,"success",p);const{executionId:g,stepId:m,stepName:v,action:b,screen:y,redirect:w,openInNewTabUrl:k,webauthn:I,error:S,samlIdpResponse:j}=e.data;b!==Ao?(this.loggerWrapper.info(`Step "${v||`#${m}`}" is ${h}`,"",{screen:y,status:h,stepId:m,stepName:v,action:b,error:S}),this.flowState.update({stepId:m,executionId:g,action:b,redirectTo:null==w?void 0:w.url,openInNewTabUrl:k,screenId:null==y?void 0:y.id,screenState:null==y?void 0:y.state,webauthnTransactionId:null==I?void 0:I.transactionId,webauthnOptions:null==I?void 0:I.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState})):this.flowState.update({action:b})})),Bi.set(this,Fo((()=>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)}}))))),tr.set(this,Ko(((e,t)=>n(this,void 0,void 0,(function*(){if("true"===e.getAttribute("formnovalidate")||o(this,qi,"m",Zi).call(this)){const i=null==e?void 0:e.getAttribute("id");o(this,qi,"m",Qi).call(this,e);const r=yield o(this,qi,"m",Gi).call(this),s=(n=e,Array.from((null==n?void 0:n.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),c=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield t(i,c.version,d.componentsVersion,l);o(this,Ki,"f").call(this,u),o(this,qi,"m",er).call(this,r)}var n}))))),this.flowState=e}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var t,o;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield e.connectedCallback.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=o(this,zi,"f"))||void 0===e||e.abort(),i(this,zi,null,"f")}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n,o=navigator.language;o&&"zh-TW"!==o&&(o=o.split("-")[0]);const i=(e||o||"").toLowerCase();return(yield this.getTargetLocales()).includes(i)&&(n=`${t}-${i}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield Wo(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 Wo(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,t,r){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:n,flowId:l,tenant:c,stepId:d,executionId:u,action:h,screenId:p,screenState:f,redirectTo:g,openInNewTabUrl:m,redirectUrl:v,token:b,code:y,exchangeError:w,webauthnTransactionId:k,webauthnOptions:I,redirectAuthCodeChallenge:S,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:x,redirectAuthInitiator:C,oidcIdpStateId:E,locale:A,samlIdpStateId:O,samlIdpUsername:U,descopeIdpInitiated:R,samlIdpResponseUrl:M,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:_,ssoAppId:P,oidcLoginHint:W}=e;let L,$;const D=(()=>{const e=localStorage.getItem(ai);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(ai,e.toString()),e}return Number(e)})(),N=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),F=yield this.getProjectConfig(),z=j&&S?{callbackUrl:j,codeChallenge:S,backupCallbackUri:x}:void 0;if(!u&&(q.fingerprintEnabled&&q.fingerprintKey?yield $n(q.fingerprintKey,this.baseUrl):localStorage.removeItem(Wn),q.conditions?({startScreenId:L,conditionInteractionId:$}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=ri[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:N,code:y,token:b,abTestingKey:D},q.conditions)):q.condition?({startScreenId:L,conditionInteractionId:$}=((e,t)=>{var n;const o=null===(n=ri[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(q.condition,{loginId:N,code:y,token:b,abTestingKey:D})):L=q.startScreenId,!zo(L,E,O,U,P,W))){const e=yield this.sdk.flow.start(l,Object.assign(Object.assign({tenant:c,redirectAuth:z,oidcIdpStateId:E,samlIdpStateId:O,samlIdpUsername:U,ssoAppId:P,oidcLoginHint:W,client:this.client},v&&{redirectUrl:v}),{lastAuth:si(N),abTestingKey:D}),$,"",q.version,F.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),y?{exchangeCode:y,idpInitiated:!0}:{}),R&&{idpInitiated:!0}),b?{token:b}:{}),W?{externalId:W}:{}));return o(this,Ki,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0,token:void 0}))}if(u&&(r("token")&&b||r("code")&&y||r("exchangeError")&&w)){const e=yield this.sdk.flow.next(u,d,Uo,q.version,F.componentsVersion,{token:b,exchangeCode:y,exchangeError:w});return o(this,Ki,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if("loadForm"===h&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>r(e)))){if(!M||!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})(M,T,_||"",Ho)}if("redirect"===h&&(r("redirectTo")||r("deferredRedirect")))return g?"android"===C&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(g):void this.loggerWrapper.error("Did not get redirect url");if(h===Oo||"webauthnGet"===h){if(!k||!I)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=o(this,zi,"f"))||void 0===a||a.abort(),i(this,zi,null,"f");try{e=h===Oo?yield this.sdk.webauthn.helpers.create(I):yield this.sdk.webauthn.helpers.get(I)}catch(n){"InvalidStateError"===n.name?this.loggerWrapper.warn("WebAuthn operation failed",n.message):"NotAllowedError"!==n.name&&this.loggerWrapper.error(n.message),t=n.name}const r=yield this.sdk.flow.next(u,d,Uo,q.version,F.componentsVersion,{transactionId:k,response:e,failure:t});o(this,Ki,"f").call(this,r)}if(o(this,Hi,"f").call(this,u,d,h,q.version,F.componentsVersion),!p&&!L)return void this.loggerWrapper.warn("No screen was found to show");const H=L||p,V=yield this.getHtmlFilenameWithLocale(A,H),K={direction:$o(d,t.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.formConfigValues),null==f?void 0:f.form),lastAuth:{loginId:N,name:this.sdk.getLastUserDisplayName()||N}}),htmlUrl:Lo({projectId:n,filename:`${H}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:V&&Lo({projectId:n,filename:V,baseUrl:this.baseStaticUrl}),samlIdpUsername:U,oidcLoginHint:W,openInNewTabUrl:m},B=si(N);zo(L,E,O,U,P,W)?K.next=(e,t,n,o)=>this.sdk.flow.start(l,Object.assign({tenant:c,redirectAuth:z,oidcIdpStateId:E,samlIdpStateId:O,samlIdpUsername:U,ssoAppId:P,oidcLoginHint:W,lastAuth:B,preview:this.preview,abTestingKey:D,client:this.client},v&&{redirectUrl:v}),$,e,t,n,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),y&&{exchangeCode:y,idpInitiated:!0}),R&&{idpInitiated:!0}),b&&{token:b})):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(K.next=(...e)=>this.sdk.flow.next(u,d,...e)),this.stepState.update(K)}))}loadDescopeUiComponents(e){return n(this,void 0,void 0,(function*(){const t=yield ar.descopeUI;if(!t)return;const o=(e=>[...Array.from(e.querySelectorAll("*")).reduce(((e,t)=>t.tagName.startsWith("DESCOPE-")?e.add(t.tagName.toLocaleLowerCase()):e),new Set)])(e);yield Promise.all(o.map((e=>n(this,void 0,void 0,(function*(){if(!customElements.get(e))if(t[e])try{return yield t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`${e} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)})))))}))}onStepChange(e,t){var i,r;return n(this,void 0,void 0,(function*(){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.content);this.sdk.webauthn.helpers.isSupported()?yield o(this,qi,"m",Yi).call(this,p,c):p.querySelectorAll(`descope-button[${Eo}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),((e,t,n,o,i,r)=>{var s,a;let l=null==t?void 0:t.errorText;try{l=(null==i?void 0:i({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(`[${Eo}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",l),ni(e,"totp-link",null===(s=null==t?void 0:t.totp)||void 0===s?void 0:s.provisionUrl),ni(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=>{e.textContent=ti(e.textContent,t)}))})(e,t),((e,t,n)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const i=t[o];Object.keys(i).forEach((t=>{let o=i[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,n,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=ti(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])=>{Qo.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)})(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(p,g);const m=()=>n(this,void 0,void 0,(function*(){var e,n;yield f;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(e=null==d?void 0:d.totp)||void 0===e?void 0:e.image,oi(r,"descope-totp-image",s),((e,t)=>{oi(e,"descope-notp-image",t)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((e,t)=>{ei(e,null==t?void 0:t.inputs),ei(e,null==t?void 0:t.form)})(this.rootElement,d);const e=this.rootElement.querySelectorAll("descope-password"),t=this.rootElement.querySelectorAll("descope-new-password");document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),[...e,...t].forEach((e=>o(this,qi,"m",Xi).call(this,e)))}));const a=!t.htmlUrl;if(((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(e=>{this.rootElement.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}))}))}))})(),o(this,qi,"m",or).call(this,c),a&&o(this,qi,"m",rr).call(this,"ready",{}),o(this,qi,"m",rr).call(this,"page-updated",{}),this.rootElement.querySelector(`[${Eo}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),n=yield c(Ro,e.version,t.componentsVersion,{});o(this,Ki,"f").call(this,n)}u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,qi,"m",ir).call(this,m,l):m()}))}}Fi=new WeakMap,zi=new WeakMap,Hi=new WeakMap,Vi=new WeakMap,Ki=new WeakMap,Bi=new WeakMap,tr=new WeakMap,qi=new WeakSet,Ji=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)}))}},Xi=function(e){e&&"true"===e.getAttribute("external-input")&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),o=`input-${e.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),e.appendChild(i),t.setAttribute("slot",o),this.appendChild(t)}))},Yi=function(e,t){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,zi,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield ii())){const{options:e,transactionId:r}=(yield o(this,Bi,"f").call(this))||{};if(e&&r){o(this,qi,"m",Ji).call(this,s),i(this,zi,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(e,o(this,zi,"f")).then((e=>n(this,void 0,void 0,(function*(){const n=yield t(s.id,a.version,l.componentsVersion,{transactionId:r,response:e});o(this,Ki,"f").call(this,n)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},Zi=function(){return Array.from(this.shadowRoot.querySelectorAll("*[name]")).every((e=>{var t,n;return"slot"===e.localName||(null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e))}))},Gi=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${yo}])`));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})),{})}))},Qi=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},er=function(e={}){var t,n;const o=Vo(e,["externalId","email","phone"]),i=Vo(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},nr=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))&&o(this,tr,"f").call(this,t,e)}))}))},or=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((t=>{t.onclick=()=>{o(this,tr,"f").call(this,t,e)}})),o(this,qi,"m",nr).call(this,e)},ir=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===To.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")},rr=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",lr);let cr=class{constructor(e,t){sr.set(this,void 0),this.nodeName="",i(this,sr,e,"f"),this.logger=t.logger}get asyncEle(){return(async(e,t)=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,sr,"f"))}get ele(){var e,t;const n="function"==typeof o(this,sr,"f")?o(this,sr,"f").call(this):o(this,sr,"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("no element for driver ",this.constructor.name,new Error),null)}};sr=new WeakMap;class dr extends cr{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 ur;class hr extends cr{constructor(){super(...arguments),ur.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=""),o(this,ur,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,ur,"f").content.cloneNode(!0)))}setContent(e){i(this,ur,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}ur=new WeakMap;let pr=class extends cr{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()}};class fr extends cr{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)}}}let gr=class extends cr{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)}}};class mr extends cr{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 vr extends cr{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)}}}var br=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),yr=()=>Math.random().toString(36).substring(7).split("").join("."),wr={INIT:`@@redux/INIT${yr()}`,REPLACE:`@@redux/REPLACE${yr()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${yr()}`};function kr(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 Ir(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 Sr(e){let t=typeof e;return t=Ir(e),t}function jr(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Sr(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: '${Sr(n)}'`);return n(jr)(e,t)}let o=e,i=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 i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Sr(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(!kr(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Sr(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: '${Sr(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=o(i,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:wr.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: '${Sr(e)}`);o=e,h({type:wr.REPLACE})},[br]: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: '${Sr(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[br](){return this}}}}}function xr(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Cr(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&xr(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:wr.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:wr.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 '${wr.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 o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===wr.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!kr(e))return`The ${r} has unexpected type of "${Sr(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===wr.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: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&xr(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],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||o.length!==Object.keys(e).length,s?a:e}}function Er(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Ar(e){return kr(e)&&"type"in e&&"string"==typeof e.type}var Or=Symbol.for("immer-nothing"),Ur=Symbol.for("immer-draftable"),Rr=Symbol.for("immer-state"),Mr=[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 Tr(e,...t){{const n=Mr[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var _r=Object.getPrototypeOf;function Pr(e){return!!e&&!!e[Rr]}function Wr(e){return!!e&&($r(e)||Array.isArray(e)||!!e[Ur]||!!e.constructor?.[Ur]||zr(e)||Hr(e))}var Lr=Object.prototype.constructor.toString();function $r(e){if(!e||"object"!=typeof e)return!1;const t=_r(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)===Lr}function Dr(e,t){0===Nr(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Nr(e){const t=e[Rr];return t?t.type_:Array.isArray(e)?1:zr(e)?2:Hr(e)?3:0}function qr(e,t){return 2===Nr(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Fr(e,t,n){const o=Nr(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function zr(e){return e instanceof Map}function Hr(e){return e instanceof Set}function Vr(e){return e.copy_||e.base_}function Kr(e,t){if(zr(e))return new Map(e);if(Hr(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&$r(e)){if(!_r(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Rr];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(_r(e),n)}function Br(e,t=!1){return Xr(e)||Pr(e)||!Wr(e)||(Nr(e)>1&&(e.set=e.add=e.clear=e.delete=Jr),Object.freeze(e),t&&Dr(e,((e,t)=>Br(t,!0)))),e}function Jr(){Tr(2)}function Xr(e){return Object.isFrozen(e)}var Yr,Zr={};function Gr(e){const t=Zr[e];return t||Tr(0,e),t}function Qr(){return Yr}function es(e,t){t&&(Gr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ts(e){ns(e),e.drafts_.forEach(is),e.drafts_=null}function ns(e){e===Yr&&(Yr=e.parent_)}function os(e){return Yr={drafts_:[],parent_:Yr,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function is(e){const t=e[Rr];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function rs(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Rr].modified_&&(ts(t),Tr(4)),Wr(e)&&(e=ss(t,e),t.parent_||ls(t,e)),t.patches_&&Gr("Patches").generateReplacementPatches_(n[Rr].base_,e,t.patches_,t.inversePatches_)):e=ss(t,n,[]),ts(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Or?e:void 0}function ss(e,t,n){if(Xr(t))return t;const o=t[Rr];if(!o)return Dr(t,((i,r)=>as(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return ls(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),Dr(i,((i,s)=>as(e,o,t,i,s,n,r))),ls(e,t,!1),n&&e.patches_&&Gr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function as(e,t,n,o,i,r,s){if(i===n&&Tr(5),Pr(i)){const s=ss(e,i,r&&t&&3!==t.type_&&!qr(t.assigned_,o)?r.concat(o):void 0);if(Fr(n,o,s),!Pr(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(Wr(i)&&!Xr(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ss(e,i),t&&t.scope_.parent_||ls(e,i)}}function ls(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Br(t,n)}var cs={get(e,t){if(t===Rr)return e;const n=Vr(e);if(!qr(n,t))return function(e,t,n){const o=hs(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!Wr(o)?o:o===us(e.base_,t)?(fs(e),e.copy_[t]=gs(o,e)):o},has:(e,t)=>t in Vr(e),ownKeys:e=>Reflect.ownKeys(Vr(e)),set(e,t,n){const o=hs(Vr(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=us(Vr(e),t),i=o?.[Rr];if(i&&i.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,o)&&(void 0!==n||qr(e.base_,t)))return!0;fs(e),ps(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!==us(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,fs(e),ps(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Vr(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Tr(11)},getPrototypeOf:e=>_r(e.base_),setPrototypeOf(){Tr(12)}},ds={};function us(e,t){const n=e[Rr];return(n?Vr(n):e)[t]}function hs(e,t){if(!(t in e))return;let n=_r(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=_r(n)}}function ps(e){e.modified_||(e.modified_=!0,e.parent_&&ps(e.parent_))}function fs(e){e.copy_||(e.copy_=Kr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Dr(cs,((e,t)=>{ds[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ds.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Tr(13),ds.set.call(this,e,t,void 0)},ds.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Tr(14),cs.set.call(this,e[0],t,n,e[0])};function gs(e,t){const n=zr(e)?Gr("MapSet").proxyMap_(e,t):Hr(e)?Gr("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Qr(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=cs;n&&(i=[o],r=ds);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Qr()).drafts_.push(n),n}function ms(e){return Pr(e)||Tr(10,e),vs(e)}function vs(e){if(!Wr(e)||Xr(e))return e;const t=e[Rr];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Kr(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Kr(e,!0);return Dr(n,((e,t)=>{Fr(n,e,vs(t))})),t&&(t.finalized_=!1),n}var bs=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 o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&Tr(6),void 0!==n&&"function"!=typeof n&&Tr(7),Wr(e)){const i=os(this),r=gs(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?ts(i):ns(i)}return es(i,n),rs(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Or&&(o=void 0),this.autoFreeze_&&Br(o,!0),n){const t=[],i=[];Gr("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Tr(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Wr(e)||Tr(8),Pr(e)&&(e=ms(e));const t=os(this),n=gs(e,void 0);return n[Rr].isManual_=!0,ns(t),n}finishDraft(e,t){const n=e&&e[Rr];n&&n.isManual_||Tr(9);const{scope_:o}=n;return es(o,t),rs(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Gr("Patches").applyPatches_;return Pr(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},ys=bs.produce;bs.produceWithPatches.bind(bs),bs.setAutoFreeze.bind(bs),bs.setUseStrictShallowCopy.bind(bs),bs.applyPatches.bind(bs),bs.createDraft.bind(bs),bs.finishDraft.bind(bs);var ws=(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})}}},ks=(e,t,n)=>{const{memoize:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);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})}},Is={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Ss=e=>Array.isArray(e)?e:[e];function js(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 xs(e,t){const n=[],{length:o}=e;for(let i=0;i<o;i++)n.push(e[i].apply(null,t));return n}var Cs="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Es=0,As=1;function Os(){return{s:Es,v:void 0,o:null,p:null}}function Us(e,t={}){let n=Os();const{resultEqualityCheck:o}=t;let i,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 o=e.get(n);void 0===o?(t=Os(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=Os(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===As?l=t.v:(l=e.apply(null,arguments),r++),a.s=As,o){const e=i?.deref?.()??i;null!=e&&o(e,l)&&(l=e,0!==r&&r--);i="object"==typeof l&&null!==l||"function"==typeof l?new Cs(l):l}return a.v=l,l}return s.clearCache=()=>{n=Os(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Rs(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,i=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=Us,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Ss(c),f=Ss(u),g=js(e),m=l((function(){return o++,s.apply(null,arguments)}),...p);let v=!0;const b=d((function(){i++;const e=xs(g,arguments);t=m.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Is,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ws},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:ks}}})(v,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=xs(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}v&&(v=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:m,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Ms=Rs(Us),Ts=Object.assign(((e,t=Ms)=>{!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,o)=>(e[n[o]]=t,e)),{})))}),{withTypes:()=>Ts});function _s(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var Ps=_s(),Ws=_s;((...e)=>{const t=Rs(...e)})(Us);var Ls="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Er:Er.apply(null,arguments)},$s=e=>e&&"function"==typeof e.match;function Ds(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Ar(t)&&t.type===e,n}function Ns(e){return"function"==typeof e&&"type"in e&&$s(e)}function qs(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 Fs=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 zs(e){return Wr(e)?ys(e,(()=>{})):e}function Hs(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Vs(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Ks(e,t,n){const o=Bs(e,t,n);return{detectMutations:()=>Js(e,t,o,n)}}function Bs(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=Bs(e,t,n[i],s))}}return r}function Js(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let i in l){const s=r?r+"."+i:i;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Js(e,t,n.children[i],o[i],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Xs(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||kr(e)}function Ys(e,t="",n=Xs,o,i=[],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!=o?o(e):Object.entries(e),l=i.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Ys(c,a,n,o,i,r),s))return s}return r&&Zs(e)&&r.add(e),!1}function Zs(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Zs(t))return!1;return!0}function Gs(e){return"boolean"==typeof e}var Qs=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new Fs;if(t&&(Gs(t)?r.push(Ps):r.push(Ws(t.extraArgument))),n){let e={};Gs(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=Vs,ignoredPaths:i,warnAfter:r=32}=e;const s=Ks.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>l=>{const c=qs(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),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(o=e(),n=i.detectMutations(),i=s(o),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(o){let e={};Gs(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=Xs,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["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(!Ar(u))return c(u);const h=c(u),p=qs(s,"SerializableStateInvariantMiddleware");return l||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=Ys(u,"",t,n,i,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 o=Ys(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;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(i){let e={};Gs(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Ns}=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},ea=e=>t=>{setTimeout(t,e)},ta="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:ea(10),na=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Fs(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let i=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?ta:"callback"===e.type?e.queueNotification:ea(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,l(c))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function oa(e){const t=Qs(),{reducer:n,middleware:o,devTools:i=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!kr(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=Cr(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(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=Er;i&&(c=Ls({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);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:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Er(...a)(i.dispatch),{...i,dispatch:r}}}(...l),u=na(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 jr(a,r,c(...h))}function ia(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)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,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function ra(...e){return t=>e.some((e=>((e,t)=>$s(e)?e.match(t):e(t))(e,t)))}var sa=["name","message","stack","code"],aa=class{constructor(e,t){this.payload=e,this.meta=t}_type},la=class{constructor(e,t){this.payload=e,this.meta=t}_type},ca=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of sa)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},da=(()=>{function e(e,t,n){const o=Ds(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Ds(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ds(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||ca)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,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(i(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 aa(e,t),fulfillWithValue:(e,t)=>new la(e,t)})).then((t=>{if(t instanceof aa)throw t;return t instanceof la?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof aa?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(ua)})}}),{pending:i,rejected:r,fulfilled:o,settled:ra(r,o),typePrefix:e})}return e.withTypes=()=>e,e})();function ua(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var ha=Symbol.for("rtk-slice-createasyncthunk");function pa(e,t){return`${e}/${t}`}function fa(e,t,n,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var ga=function({creators:e}={}){const t=e?.asyncThunk?.[ha];return function(e){const{name:n,reducerPath:o=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 i=("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(i),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=[],o]="function"==typeof e.extraReducers?ia(e.extraReducers):[e.extraReducers],i={...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,[o,i,r]=ia(t);if(function(e){return"function"==typeof e}(e))n=()=>zs(e());else{const t=zs(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...i.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(Pr(e)){const o=n(e,t);return void 0===o?e:o}if(Wr(e))return ys(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:pa(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Ds(e,s):Ds(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)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=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.exposeCaseReducer(t,{fulfilled:s||ma,pending:a||ma,rejected:l||ma,settled:c||ma})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,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=Hs(d,this,{insert:()=>new WeakMap});return Hs(n,t,{insert:()=>{const n={};for(const[o,i]of Object.entries(e.selectors??{}))n[o]=fa(this,i,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 o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function ma(){}var va="listenerMiddleware";Ds(`${va}/add`),Ds(`${va}/removeAll`),Ds(`${va}/remove`);const ba=["error","warn","info","debug"],ya=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,console))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return ba.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),wa="undefined"!=typeof localStorage,ka=wa&&localStorage.getItem("base.content.url")||"",Ia=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Sa=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)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),ja=l((e=>{var t,n;const i=r(ya,Sa)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),xa=e=>t=>{var n,i,s;const a=r(ya,Sa,ja)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",i).bind(this))}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),l.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e))))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};xa.missingAttrValidator=Ia;const Ca=l((e=>{const t=r(xa({"project-id":Ia}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Ea=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")}}));const Aa=l((e=>{const t=r(ya,Ca,Ea)(e);return class extends t{async fetchStaticResource(e,t){const n=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(ka||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.toString()}({projectId:this.projectId,filename:e,baseUrl:this.baseStaticUrl}),o=await fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:await o[t](),headers:Object.fromEntries(o.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),Oa=l((e=>{var t,n,s;const a=r(Aa)(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 o(this,t,"f")||i(this,t,o(this,n,"f").call(this),"f"),o(this,t,"f")}},t=new WeakMap,n=new WeakMap,s})),Ua=l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(Sa,ya)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(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)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return al})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),Ra="load-descope-ui",Ma="base.ui.components.url",Ta=wa&&localStorage.getItem(Ma)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",_a=wa&&localStorage.getItem(Ma)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Pa=e=>{const t=document.createElement("script");return t.id=e,t},Wa=(e,t)=>e.replace("<version>",t),La=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g;const m=r(ya,Oa)(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 o(this,h,"f")||i(this,h,o(this,t,"m",f).call(this),"f"),o(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=>o(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=o(this,n,"f"),i=o(this,s,"f");e[t]=[],e[i]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[i].push(t)}})},c=async function(e,n){this.logger.debug("Trying to load DescopeUI from a fallback URL");const i=Pa("load-descope-ui-fallback-script");document.body.append(i),i.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${i.src}"`)))})),i.addEventListener("load",(()=>{n.forEach((e=>e()))})),i.src=Wa(_a,await o(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[o(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),o(this,t,"m",c).call(this,e[o(this,n,"f")],e[o(this,s,"f")])})),e.addEventListener("load",(()=>{e[o(this,s,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${Ra}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=Pa(Ra);document.body.append(e),o(this,t,"m",l).call(this,e),o(this,t,"m",d).call(this,e),e.src=Wa(Ta,await o(this,t,"m",a).call(this))}return document.getElementById(Ra)},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),o(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})),$a="content-root",Da="root",Na=l((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Da}, #${$a} {\n height: 100%;\n }\n #${Da} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Da}">\n <div id="${$a}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById($a),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Da)}})),qa="descope-modal",Fa=l((e=>{var t,n;const i=r(Sa,Na,La)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends hr{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(qa);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([qa]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),za="descope-notification";l((e=>{var t,n;const i=r(Sa,Na,La)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends pr{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(za);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(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([za])}},t=new WeakMap,n}));const Ha=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Va=l((e=>{var t,n,s,a,l,c,d,u,h;const p=r(xa({theme:Ha}),Aa,Sa,La,Oa,Na,ja)(e);return h=class extends p{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}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"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this),o(this,t,"m",c).call(this),o(this,t,"m",d).call(this),o(this,t,"m",u).call(this),this.observeAttributes(["theme"],(()=>{o(this,t,"m",d).call(this),o(this,t,"m",u).call(this)}))}},n=new WeakMap,t=new WeakSet,s=async function(){try{const{body:e}=await this.fetchStaticResource("theme.json","json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(Ma))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(Ma),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({},t.light.components),e.light.components),e.dark.components=Object.assign(Object.assign({},t.dark.components),e.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")}},a=function(){return o(this,n,"f")||(i(this,n,o(this,t,"m",s).call(this),"f"),o(this,n,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,n,"f")},l=async function(){var e,n;const i=await o(this,t,"a",a);if(!i)return;const r=document.createElement("style");r.innerText=((null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.globals)||"")+((null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.globals)||""),this.shadowRoot.appendChild(r)},c=async function(){var e,n;const i=Object.assign({},await o(this,t,"a",a));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config,o=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;o&&Object.values(o).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))}))},u=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)},h})),Ka=e=>l((t=>{const n=ga(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(ya)(t)){constructor(...e){super(...e);const t=oa({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{ua(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=(e=>e))=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(ya(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 Ba=l((e=>class extends e{get baseStaticUrl(){return this.getAttribute("base-static-url")}})),Ja=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Xa,Ya,Za,Ga,Qa,el,tl,nl,ol,il;const rl=document.createElement("template");rl.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 sl extends HTMLElement{constructor(){var e;super(),Xa.add(this),Ya.set(this,new 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(o(this,c,"f")):e,n=Object.assign(Object.assign({},o(this,c,"f")),t);if(!o(this,h,"f")||!p(o(this,c,"f"),n)){const e=o(this,c,"f");i(this,c,n,"f"),Object.freeze(o(this,c,"f")),setTimeout((()=>{Object.values(o(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,c,e,"f"),i(this,h,t,"f")}get current(){return Object.assign({},o(this,c,"f"))}subscribe(e){return i(this,u,o(this,u,"f")+1,"f"),o(this,d,"f")[o(this,u,"f")]=e,o(this,u,"f").toString()}unsubscribe(e){const t=!!o(this,d,"f")[e];return t&&delete o(this,d,"f")[e],t}unsubscribeAll(){return i(this,d,{},"f"),!0}}({messages:[]})),Za.set(this,void 0),Ga.set(this,void 0),Qa.set(this,void 0),el.set(this,{resize:o(this,Xa,"m",il).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(rl.content.cloneNode(!0)),i(this,Za,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Ga,o(this,Za,"f").querySelector(".content"),"f"),i(this,Qa,o(this,Za,"f").querySelector(".header"),"f")}updateData(e){o(this,Ya,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Ja(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(o(this,Za,"f"),o(this,Qa,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,el,"f").resize),(e=o(this,Za,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,Za,"f").onresize=o(this,Xa,"m",ol).bind(this),o(this,Ya,"f").subscribe(o(this,Xa,"m",tl).bind(this))}disconnectedCallback(){o(this,Ya,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,el,"f").resize)}}Ya=new WeakMap,Za=new WeakMap,Ga=new WeakMap,Qa=new WeakMap,el=new WeakMap,Xa=new WeakSet,tl=function(e){o(this,Xa,"m",nl).call(this,e),o(this,Xa,"m",ol).call(this)},nl=function(e){o(this,Ga,"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("")},ol=function(){o(this,Ga,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},il=function(){const[e,t]=Ja(o(this,Za,"f"),Number.parseInt(o(this,Za,"f").style.left,10),Number.parseInt(o(this,Za,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Za,"f").style.top=`${t}px`,o(this,Za,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",sl);var al=Object.freeze({__proto__:null});const ll=e=>e.me.data,cl=Ms(ll,(e=>e.picture)),dl=Ms(ll,(e=>e.email)),ul=Ms(ll,(e=>e.verifiedEmail)),hl=Ms(ll,(e=>e.name)),pl=Ms(ll,(e=>e.phone)),fl=Ms(ll,(e=>e.verifiedPhone)),gl=Ms(ll,(e=>e.webauthn));Ms(ll,(e=>e.password));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)}))}))},vl=da("users/me",((e,{extra:{api:t}})=>t.user.me())),bl=ml(vl)({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 wl={action:vl,reducer:bl},kl=da("users/logout",((e,{extra:{api:t}})=>t.user.logout())),Il={action:kl,reducer:ml(kl)({})},Sl={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})}))})),Cl=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return xl();const o=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)})))(o),o.json()}))}),El=l((e=>{var t,s,a,l;const c=r(Ca,ja,ya,Ea)(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 o(this,s,"f")||o(this,t,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,o)=>{const i=ro(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.0.55"}}));return{user:Object.assign(Object.assign({},Cl({httpClient:i.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):i.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},l})),Al=l((e=>{const t=r(Ka({name:"widget",initialState:Sl,reducers:{},extraReducers:e=>{wl.reducer(e),Il.reducer(e)},asyncActions:{getMe:wl.action,logout:Il.action}}),Sa,ya,El)(e);return class extends t{constructor(...e){super(...e),this.state=Sl,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ol=l((e=>{const t=r(Aa,xa({"widget-id":xa.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}))}}})),Ul=l((e=>{var t,i,a;return a=class extends(r(ya,Sa,La,Na,Ol,Al)(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}});var r;return n(this,void 0,void 0,(function*(){yield null===(r=e.init)||void 0===r?void 0:r.call(this),yield Promise.all([this.actions.getMe(),o(this,t,"m",i).call(this)]),this.onWidgetRootReady()}))}},t=new WeakSet,i=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})),Rl=(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 Ml(e){return new URLSearchParams(window.location.search).get(e)}const Tl=l((e=>{var t,s,l,c,d,u,h,p,f;return f=class extends(r(Al,ya,Ul,Fa,Ba)(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}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",u).call(this),o(this,t,"m",c).call(this),o(this,h,"f").call(this,cl(this.state)),o(this,p,"f").call(this,hl(this.state)),this.subscribe(o(this,h,"f").bind(this),cl),this.subscribe(o(this,p,"f").bind(this),hl)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(){i(this,s,this.createModal({"data-id":"update-pic"}),"f"),i(this,l,new vr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",d).bind(this),o(this,t,"m",d).call(this)},d=function(){o(this,s,"f").setContent(Rl({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new fr((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{o(this,s,"f").open()}))},f})),_l=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,v,b;return b=class extends(r(Al,ya,Ul,Fa)(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}))),v.set(this,a((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",p).call(this),o(this,m,"f").call(this,dl(this.state)),o(this,v,"f").call(this,ul(this.state)),this.subscribe(o(this,m,"f").bind(this),dl),this.subscribe(o(this,v,"f").bind(this),ul)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-email"}),"f"),i(this,l,new vr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Rl({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},p=function(){i(this,c,this.createModal({"data-id":"delete-email"}),"f"),i(this,d,new vr((()=>{var e;return null===(e=o(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,c,"f").afterClose=o(this,t,"m",f).bind(this),o(this,t,"m",f).call(this)},f=function(){o(this,c,"f").setContent(Rl({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new gr((()=>{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((()=>{o(this,s,"f").open()})),this.emailUserAttr.onDeleteClick((()=>{o(this,c,"f").open()}))},b})),Pl=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,v;return v=class extends(r(Al,ya,Ul,Fa)(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}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",p).call(this),o(this,m,"f").call(this,hl(this.state)),this.subscribe(o(this,m,"f").bind(this),hl)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-name"}),"f"),i(this,l,new vr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Rl({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},p=function(){i(this,c,this.createModal({"data-id":"delete-name"}),"f"),i(this,d,new vr((()=>{var e;return null===(e=o(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,c,"f").afterClose=o(this,t,"m",f).bind(this),o(this,t,"m",f).call(this)},f=function(){o(this,c,"f").setContent(Rl({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new gr((()=>{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((()=>{o(this,s,"f").open()})),this.nameUserAttr.onDeleteClick((()=>{o(this,c,"f").open()}))},v})),Wl=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,v,b;return b=class extends(r(Al,ya,Ul,Fa)(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}))),v.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",p).call(this),o(this,m,"f").call(this,pl(this.state)),o(this,v,"f").call(this,fl(this.state)),this.subscribe(o(this,m,"f").bind(this),pl),this.subscribe(o(this,v,"f").bind(this),fl)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-phone"}),"f"),i(this,l,new vr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Rl({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},p=function(){i(this,c,this.createModal({"data-id":"delete-phone"}),"f"),i(this,d,new vr((()=>{var e;return null===(e=o(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,c,"f").afterClose=o(this,t,"m",f).bind(this),o(this,t,"m",f).call(this)},f=function(){o(this,c,"f").setContent(Rl({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new gr((()=>{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((()=>{o(this,s,"f").open()})),this.phoneUserAttr.onDeleteClick((()=>{o(this,c,"f").open()}))},b})),Ll=l((e=>{var t,s,l,c,d,u,h,p;return p=class extends(r(Al,ya,Ul,Fa)(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}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",u).call(this),o(this,t,"m",c).call(this),o(this,h,"f").call(this,gl(this.state)),this.subscribe(o(this,h,"f").bind(this),gl)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,t=new WeakSet,c=function(){i(this,s,this.createModal({"data-id":"passkey"}),"f"),i(this,l,new vr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",d).bind(this),o(this,t,"m",d).call(this)},d=function(){o(this,s,"f").setContent(Rl({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,l,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new mr((()=>{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((()=>{o(this,s,"f").open()}))},p})),$l=l((e=>{var t,s,a,l,c,d,u;return u=class extends(r(Al,ya,Ul,Fa)(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}});var i;return n(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),o(this,t,"m",d).call(this),o(this,t,"m",l).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){i(this,s,this.createModal({"data-id":"password"}),"f"),i(this,a,new vr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",c).bind(this),o(this,t,"m",c).call(this)},c=function(){o(this,s,"f").setContent(Rl({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,a,"f").onSuccess((()=>{o(this,s,"f").close()}))},d=function(){this.passwordUserAuthMethod=new mr((()=>{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((()=>{o(this,s,"f").open()}))},u})),Dl=l((e=>{var t,i,s;return s=class extends(r(Al,ya,Ul,Fa)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var r;return n(this,void 0,void 0,(function*(){yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),o(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){this.logout=new dr((()=>{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})),Nl="widget-flow",ql=l((e=>{var t,i,s;return s=class extends(r(Sa,Fa,Al,ya)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});var r;return n(this,void 0,void 0,(function*(){yield null===(r=e.init)||void 0===r?void 0:r.call(this);const n=Ml(Nl);n&&(!function(e){if(window.history.replaceState&&Ml(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())}}(Nl),o(this,t,"m",i).call(this,n))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(Rl({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl}));const n=new vr((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger});n.onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),Fl=l((e=>class extends(r(Ua,Va,ql,_l,Tl,Pl,Wl,Ll,$l,Dl)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return n(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),zl=r((e=>class extends(Fl(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return n(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),lr.sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.0.55"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",zl);const Hl=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Vl,Kl,Bl,Jl,Xl,Yl,Zl,Gl,Ql,ec;const tc=document.createElement("template");tc.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 nc extends HTMLElement{constructor(){super(),Vl.add(this),Kl.set(this,new Go({messages:[]})),Bl.set(this,void 0),Jl.set(this,void 0),Xl.set(this,void 0),Yl.set(this,{resize:o(this,Vl,"m",ec).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(tc.content.cloneNode(!0)),i(this,Bl,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Jl,o(this,Bl,"f").querySelector(".content"),"f"),i(this,Xl,o(this,Bl,"f").querySelector(".header"),"f")}updateData(e){o(this,Kl,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Hl(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(o(this,Bl,"f"),o(this,Xl,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Yl,"f").resize),(e=o(this,Bl,"f")).onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight},o(this,Bl,"f").onresize=o(this,Vl,"m",Ql).bind(this),o(this,Kl,"f").subscribe(o(this,Vl,"m",Zl).bind(this))}disconnectedCallback(){o(this,Kl,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Yl,"f").resize)}}Kl=new WeakMap,Bl=new WeakMap,Jl=new WeakMap,Xl=new WeakMap,Yl=new WeakMap,Vl=new WeakSet,Zl=function(e){o(this,Vl,"m",Gl).call(this,e),o(this,Vl,"m",Ql).call(this)},Gl=function(e){o(this,Jl,"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("")},Ql=function(){o(this,Jl,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},ec=function(){const[e,t]=Hl(o(this,Bl,"f"),Number.parseInt(o(this,Bl,"f").style.left,10),Number.parseInt(o(this,Bl,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Bl,"f").style.top=`${t}px`,o(this,Bl,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",nc);var oc=Object.freeze({__proto__:null,default:nc});return zl}();
|
|
8
8
|
//# sourceMappingURL=index.js.map
|