@descope/web-component 3.24.1 → 3.24.2

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.
@@ -1 +1 @@
1
- import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-b8eab371.js";import"@descope/web-js-sdk";import"@descope/sdk-mixins";import"@descope/sdk-helpers";const s=(e,n,t,s={})=>{var o,i,l,r;return[Math.min(Math.max(n,("all"===s.left?e.offsetWidth:null!==(o=s.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(i=s.right)&&void 0!==i?i:0)),Math.min(Math.max(t,("all"===s.top?e.offsetHeight:null!==(l=s.top)&&void 0!==l?l:0)-e.offsetHeight),window.innerHeight-("all"===s.bottom?e.offsetHeight:null!==(r=s.bottom)&&void 0!==r?r:0))]};var o,i,l,r,a,d,c,p,h,g;const f=document.createElement("template");f.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 m extends HTMLElement{constructor(){super(),o.add(this),i.set(this,new t({messages:[]})),l.set(this,void 0),r.set(this,void 0),a.set(this,void 0),d.set(this,{resize:e(this,o,"m",g).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(f.content.cloneNode(!0)),n(this,l,this.shadowRoot.querySelector(".debugger"),"f"),n(this,r,e(this,l,"f").querySelector(".content"),"f"),n(this,a,e(this,l,"f").querySelector(".header"),"f")}updateData(n){e(this,i,"f").update((e=>({messages:e.messages.concat(n)})))}connectedCallback(){var n;((e,n,t)=>{let o=0,i=0,l=0,r=0;function a(n){n.preventDefault(),o=l-n.clientX,i=r-n.clientY,l=n.clientX,r=n.clientY;const[a,d]=s(e,e.offsetLeft-o,e.offsetTop-i,t);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),l=e.clientX,r=e.clientY,document.onmouseup=d,document.onmousemove=a}n?n.onmousedown=c:e.onmousedown=c})(e(this,l,"f"),e(this,a,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",e(this,d,"f").resize),(n=e(this,l,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},e(this,l,"f").onresize=e(this,o,"m",h).bind(this),e(this,i,"f").subscribe(e(this,o,"m",c).bind(this))}disconnectedCallback(){e(this,i,"f").unsubscribeAll(),window.removeEventListener("resize",e(this,d,"f").resize)}}i=new WeakMap,l=new WeakMap,r=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,c=function(n){e(this,o,"m",p).call(this,n),e(this,o,"m",h).call(this)},p=function(n){e(this,r,"f").innerHTML=n.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("")},h=function(){e(this,r,"f").querySelectorAll(".msg").forEach((e=>{const n=e.querySelector(".msg_desc"),t=n.scrollWidth>n.clientWidth,s=n.clientHeight>20;t||s?(e.classList.add("collapsible"),e.onclick=n=>{n.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},g=function(){const[n,t]=s(e(this,l,"f"),Number.parseInt(e(this,l,"f").style.left,10),Number.parseInt(e(this,l,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});e(this,l,"f").style.top=`${t}px`,e(this,l,"f").style.left=`${n}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",m);export{m as default};
1
+ import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-23637c29.js";import"@descope/web-js-sdk";import"@descope/sdk-mixins";import"@descope/sdk-helpers";const s=(e,n,t,s={})=>{var o,i,l,r;return[Math.min(Math.max(n,("all"===s.left?e.offsetWidth:null!==(o=s.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(i=s.right)&&void 0!==i?i:0)),Math.min(Math.max(t,("all"===s.top?e.offsetHeight:null!==(l=s.top)&&void 0!==l?l:0)-e.offsetHeight),window.innerHeight-("all"===s.bottom?e.offsetHeight:null!==(r=s.bottom)&&void 0!==r?r:0))]};var o,i,l,r,a,d,c,p,h,g;const f=document.createElement("template");f.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 m extends HTMLElement{constructor(){super(),o.add(this),i.set(this,new t({messages:[]})),l.set(this,void 0),r.set(this,void 0),a.set(this,void 0),d.set(this,{resize:e(this,o,"m",g).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(f.content.cloneNode(!0)),n(this,l,this.shadowRoot.querySelector(".debugger"),"f"),n(this,r,e(this,l,"f").querySelector(".content"),"f"),n(this,a,e(this,l,"f").querySelector(".header"),"f")}updateData(n){e(this,i,"f").update((e=>({messages:e.messages.concat(n)})))}connectedCallback(){var n;((e,n,t)=>{let o=0,i=0,l=0,r=0;function a(n){n.preventDefault(),o=l-n.clientX,i=r-n.clientY,l=n.clientX,r=n.clientY;const[a,d]=s(e,e.offsetLeft-o,e.offsetTop-i,t);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),l=e.clientX,r=e.clientY,document.onmouseup=d,document.onmousemove=a}n?n.onmousedown=c:e.onmousedown=c})(e(this,l,"f"),e(this,a,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",e(this,d,"f").resize),(n=e(this,l,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},e(this,l,"f").onresize=e(this,o,"m",h).bind(this),e(this,i,"f").subscribe(e(this,o,"m",c).bind(this))}disconnectedCallback(){e(this,i,"f").unsubscribeAll(),window.removeEventListener("resize",e(this,d,"f").resize)}}i=new WeakMap,l=new WeakMap,r=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,c=function(n){e(this,o,"m",p).call(this,n),e(this,o,"m",h).call(this)},p=function(n){e(this,r,"f").innerHTML=n.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("")},h=function(){e(this,r,"f").querySelectorAll(".msg").forEach((e=>{const n=e.querySelector(".msg_desc"),t=n.scrollWidth>n.clientWidth,s=n.clientHeight>20;t||s?(e.classList.add("collapsible"),e.onclick=n=>{n.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},g=function(){const[n,t]=s(e(this,l,"f"),Number.parseInt(e(this,l,"f").style.left,10),Number.parseInt(e(this,l,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});e(this,l,"f").style.top=`${t}px`,e(this,l,"f").style.left=`${n}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",m);export{m as default};
@@ -1 +1 @@
1
- import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i,__rest as o}from"tslib";import r,{ensureFingerprintIds as n,clearFingerprintData as s}from"@descope/web-js-sdk";import{themeMixin as a}from"@descope/sdk-mixins";import{createSingletonMixin as l,compose as d}from"@descope/sdk-helpers";const c="undefined"!=typeof localStorage,u="J151000",h=c&&localStorage.getItem("base.content.url")||"",p="config.json",f="base.ui.components.url";c&&localStorage.getItem(f),c&&localStorage.getItem(f);const g="descope-login-flow",v="code",m="ra-challenge",b="ra-callback",w="ra-backup-callback",y="ra-initiator",I="data-exclude-field",k="dls_last_auth",C="state_id",A="saml_idp_state_id",S="saml_idp_username",j="descope_idp_initiated",E="sso_app_id",x="oidc_login_hint",U="oidc_prompt",O="oidc_error_redirect_uri",L="data-type",R="redirect",T="poll",W="webauthnCreate",$="webauthnGet",M="loadForm",P="submit",N="polling",q=["descope-multi-select-combo-box","descope-text-area"];var _;function F(t){return new URLSearchParams(window.location.search).get(t)}function D(t){if(window.history.replaceState&&F(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}function V(e,i){return t(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw Error(`Error fetching URL ${e} [${t.status}]`);return{body:yield t[i||"text"](),headers:Object.fromEntries(t.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(_||(_={}));function K({projectId:t,filename:e,assetsFolder:i="v2-beta",baseUrl:o}){const r=new URL(h||o||"https://static.descope.com/pages");return r.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(r.pathname,t,i,e),r.toString()}function H(t,e){if(!e)return;const i=+t,o=+e;return Number.isNaN(i)||Number.isNaN(o)?void 0:i>o?_.forward:i<o?_.backward:void 0}const B=()=>{const[t="",e=""]=(F(g)||"").split("_");return{executionId:t,stepId:e}};function J(){D(g)}const G=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),z=()=>{const{executionId:t,stepId:e}=B();(t||e)&&J();const i=F("t")||void 0;i&&D("t");const o=F(v)||void 0;o&&D(v);const r=F("err")||void 0;r&&D("err");const{redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:F(m),redirectAuthCallbackUrl:F(b),redirectAuthBackupCallbackUri:F(w),redirectAuthInitiator:F(y)};(n||s||a||l)&&(D(m),D(b),D(w),D(y));const d=F(C);d&&D(C);const c=F(A);c&&D(A);const u=F(S);c&&D(S);const h=F(j);h&&D(j);const p=F(E);p&&D(E);const f=F(x);f&&D(x);const g=F(U);g&&D(U);const I=F(O);I&&D(O);return{executionId:t,stepId:e,token:i,code:o,exchangeError:r,redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:d,samlIdpStateId:c,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:f,oidcPrompt:g,oidcErrorRedirectUri:I}}},Q=t=>{let e,i;return(...o)=>{return e&&(n=o,(r=e).length===n.length&&r.every(((t,e)=>t===n[e])))||(e=o,i=t(...o)),i;var r,n}};const X=(t,{oidcIdpStateId:e,samlIdpStateId:i,samlIdpUsername:o,ssoAppId:r,oidcLoginHint:n,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||i||o||r||n||s||a),Y=t=>null==t?void 0:t.submit(),Z=(t,e)=>{const i=e.find((e=>t[e]));return i?t[i]:null},tt=(t,e=100)=>{let i;return function(...o){i||t.apply(this,o),clearTimeout(i),i=setTimeout((()=>{i=null}),e)}};function et(t){if(t)return{locale:t.toLowerCase(),fallback:t.toLowerCase()};const e=navigator.language;return e?e.includes("-")?{locale:e.toLowerCase(),fallback:e.split("-")[0].toLowerCase()}:{locale:e.toLowerCase(),fallback:e.toLowerCase()}:{locale:"",fallback:""}}var it,ot,rt,nt;function st(t,e){const i=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(i.length!==o.length)return!1;for(let o=0;o<i.length;o+=1){const r=i[o],n=t[r],s=e[r];if(null===n||null===s){if(n!==s)return!1}else if("object"==typeof n&&"object"==typeof s){if(!st(n,s))return!1}else if(n!==s)return!1}return!0}class at{constructor(t={},{updateOnlyOnChange:o=!0}={}){it.set(this,void 0),ot.set(this,{}),rt.set(this,0),nt.set(this,!1),this.update=t=>{const o="function"==typeof t?t(e(this,it,"f")):t,r=Object.assign(Object.assign({},e(this,it,"f")),o);if(!e(this,nt,"f")||!st(e(this,it,"f"),r)){const t=e(this,it,"f");i(this,it,r,"f"),Object.freeze(e(this,it,"f")),setTimeout((()=>{Object.values(e(this,ot,"f")).forEach((e=>e(r,t,((t,e)=>i=>t[i]!==e[i])(r,t))))}),0)}},i(this,it,t,"f"),i(this,nt,o,"f")}get current(){return Object.assign({},e(this,it,"f"))}subscribe(t){return i(this,rt,e(this,rt,"f")+1,"f"),e(this,ot,"f")[e(this,rt,"f")]=t,e(this,rt,"f").toString()}unsubscribe(t){const i=!!e(this,ot,"f")[t];return i&&delete e(this,ot,"f")[t],i}unsubscribeAll(){return i(this,ot,{},"f"),!0}}it=new WeakMap,ot=new WeakMap,rt=new WeakMap,nt=new WeakMap;const lt=["disabled"],dt=(t,e)=>{Object.entries(e||{}).forEach((([e,i])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${I}])`)).forEach((t=>{t.value=i}))}))},ct=(t,e)=>t.replace(/{{(.+?)}}/g,((t,i)=>{return o=e,i.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),ut=(t,e,i)=>{t.querySelectorAll(`[${L}="${e}"]`).forEach((t=>{t.setAttribute("href",i)}))},ht=(t,e,i)=>{var o,r;const n=null===(o=customElements.get(e))||void 0===o?void 0:o.cssVarList.url;i&&n&&(null===(r=null==t?void 0:t.style)||void 0===r||r.setProperty(n,`url(data:image/jpg;base64,${i})`))},pt=(t,e,i,o,r,n)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==r?void 0:r({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){n.error("Error transforming error message",t.message)}((t,e,i="")=>{t.querySelectorAll(`[${L}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",l),ut(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ut(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{t.textContent=ct(t.textContent,e);const i=t.getAttribute("href");i&&t.setAttribute("href",ct(i,e))}))})(t,e),((t,e,i)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const r=e[o];Object.keys(r).forEach((e=>{let o=r[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){i.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,i,n),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=ct(t.value,e)}))}))})(t,e),((t,e)=>{Object.entries(e).forEach((([e,i])=>{t.querySelectorAll(`[name="${e}"]`).forEach((t=>{Object.entries(i).forEach((([e,i])=>{lt.includes(e)&&t.setAttribute(e,i)}))}))}))})(t,o)},ft=Q((()=>t(void 0,void 0,void 0,(function*(){var t,e,i,o,r;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),s=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,i=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return i?i.version:0})()>=108;return yield(i=100,o=n,r=s,new Promise(((t,e)=>{let n=!1;const s=setTimeout((()=>{n=!0,void 0!==r?t(r):e(new Error(`Promise timed out after ${i} ms`))}),i);o.then((e=>{n||(clearTimeout(s),t(e))})).catch((t=>{n||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),gt={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function vt(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(k)))}catch(t){}return e}const mt="dls_ab_testing_id",bt=l((t=>{var i,o,r,n;return n=class extends t{constructor(){super(...arguments),i.add(this)}connectedCallback(){var t;e(this,i,"m",o).call(this)&&e(this,i,"m",r).call(this),null===(t=super.connectedCallback)||void 0===t||t.call(this)}},i=new WeakSet,o=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},r=function(){const t=this.shadowRoot.host,e=document.createElement("form");e.style.width="100%",e.style.height="100%",t.parentElement.appendChild(e),e.appendChild(t)},n})),wt=document.createElement("template");wt.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t";const yt=(t,e="")=>Object.keys(t).reduce(((i,o)=>{var r;if("object"==typeof t[o]&&null!==t[o]&&!(null===(r=t[o])||void 0===r?void 0:r.value))return Object.assign(Object.assign({},i),yt(t[o],`${e+o}.`));const n="object"==typeof t[o]?t[o]:{value:t[o]},s=Object.assign(Object.assign({},i),{[e+o]:n,[`form.${e}${o}`]:n});return"displayName"===o?Object.assign(Object.assign({},s),{[`${e}fullName`]:n,[`form.${e}fullName`]:n}):s}),[]);var It,kt,Ct,At,St,jt,Et,xt,Ut,Ot,Lt,Rt,Tt,Wt,$t,Mt,Pt,Nt,qt,_t,Ft,Dt;const Vt=d(a,bt)(HTMLElement);class Kt extends Vt{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(o){super(),It.add(this),Ct.set(this,!1),this.loggerWrapper={error:(t,i="")=>{this.logger.error(t,i,new Error),e(this,It,"m",Ft).call(this,t,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},At.set(this,new at),St.set(this,new at),jt.set(this,{}),this.getComponentsContext=()=>e(this,jt,"f"),this.nextRequestStatus=new at({isLoading:!1}),Et.set(this,void 0),xt.set(this,{popstate:e(this,It,"m",Rt).bind(this),componentsContext:e(this,It,"m",Nt).bind(this)}),Ut.set(this,void 0),Pt.set(this,Q((()=>t(this,void 0,void 0,(function*(){const t=K({projectId:this.projectId,filename:p,baseUrl:this.baseStaticUrl});try{const{body:e,headers:i}=yield V(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),i(this,Ut,o,"f"),e(this,It,"m",Ot).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(t=>{try{return yt(JSON.parse(t))}catch(t){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return t=this.formConfig,e="value",Object.fromEntries(Object.entries(t).map((([t,i])=>[t,i[e]])));var t,e}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield e(this,Pt,"f").call(this);return t}))}getProjectConfig(){return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,Pt,"f").call(this);return t}))}getFlowConfig(){return t(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),o=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(o.version=0),o}))}getTargetLocales(){return t(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}init(){const o=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;if(yield null===(t=o.init)||void 0===t?void 0:t.call(this),e(this,St,"f").subscribe(e(this,It,"m",_t).bind(this)),e(this,St,"f").update({isDebug:this.debug}),e(this,It,"m",Lt).call(this),yield e(this,It,"m",$t).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 e(this,Pt,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");e(this,It,"m",Dt).call(this);const{executionId:r,stepId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=z();window.addEventListener("popstate",e(this,xt,"f").popstate),window.addEventListener("components-context",e(this,xt,"f").componentsContext),e(this,At,"f").subscribe(e(this,It,"m",Wt).bind(this)),e(this,At,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:u,redirectAuthInitiator:h},p)),i(this,Ct,!0,"f")}))}disconnectedCallback(){e(this,At,"f").unsubscribeAll(),e(this,St,"f").unsubscribeAll(),e(this,It,"m",qt).call(this),window.removeEventListener("popstate",e(this,xt,"f").popstate),window.removeEventListener("components-context",e(this,xt,"f").componentsContext)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,Ct,"f")&&i!==o&&kt.observedAttributes.includes(t)){e(this,It,"m",Lt).call(this);const r=null===i;e(this,At,"f").update((({stepId:e,executionId:i})=>{let n=e,s=i;return r||(s=null,n=null,J()),{[G(t)]:o,stepId:n,executionId:s}})),e(this,St,"f").update({isDebug:this.debug})}}}function Ht(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Bt,Jt,Gt,zt,Qt,Xt,Yt,Zt,te,ee,ie,oe,re,ne,se,ae,le,de,ce,ue;kt=Kt,Ct=new WeakMap,At=new WeakMap,St=new WeakMap,jt=new WeakMap,Et=new WeakMap,xt=new WeakMap,Ut=new WeakMap,Pt=new WeakMap,It=new WeakSet,Ot=function(){this.shadowRoot.appendChild(wt.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},Lt=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];kt.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[G(e)])throw Error(`${e} cannot be empty`)}))},Rt=function(){const{stepId:t,executionId:i}=B();e(this,At,"f").update({stepId:t,executionId:i})},Tt=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},kt.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}catch(t){return{error:{errorCode:u,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Wt=function(i,o,r){return t(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:o}=i;if(r("projectId")||r("baseUrl")){if(!t)return;e(this,It,"m",Tt).call(this,t,o)}e(this,Ut,"f").call(this,i)}))},$t=function(){return t(this,void 0,void 0,(function*(){return(yield e(this,Pt,"f").call(this)).isMissingConfig&&(yield e(this,It,"m",Mt).call(this))}))},Mt=function(){return t(this,void 0,void 0,(function*(){const t=K({projectId:this.projectId,filename:p,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield V(t,"json"),!0}catch(t){return!1}}))},Nt=function(t){i(this,jt,Object.assign(Object.assign({},e(this,jt,"f")),t.detail),"f")},qt=function(){var t;null===(t=e(this,Et,"f"))||void 0===t||t.remove(),i(this,Et,null,"f")},_t=function(o){return t(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,Et,document.createElement("descope-debugger"),"f"),Object.assign(e(this,Et,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-64e73d17.js"),document.body.appendChild(e(this,Et,"f"))):e(this,It,"m",qt).call(this)}))},Ft=function(t,i){var o;t&&this.debug&&(null===(o=e(this,Et,"f"))||void 0===o||o.updateData({title:t,description:i}))},Dt=function(){this.rootElement.onkeydown=t=>{var e,i,o;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=q.includes(null!==(o=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==o?o:"");if("Enter"!==t.key||r||n)return;t.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((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(s).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},Kt.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.24.1"}};class he extends Kt{static set sdkConfigOverrides(t){Kt.sdkConfigOverrides=t}constructor(){const o=new at({deferredRedirect:!1});super(o.update.bind(o)),Bt.add(this),this.stepState=new at({},{updateOnlyOnChange:!1}),Jt.set(this,void 0),Gt.set(this,null),zt.set(this,{visibilitychange:e(this,Bt,"m",Qt).bind(this)}),Xt.set(this,((o,r,n,s,a)=>{n===T&&(this.logger.debug("polling - Scheduling polling request"),i(this,Jt,setTimeout((()=>t(this,void 0,void 0,(function*(){var t,i;this.logger.debug("polling - Calling next");const l=yield this.sdk.flow.next(o,r,N,s,a,{});if((null===(t=null==l?void 0:l.error)||void 0===t?void 0:t.errorCode)===u)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,Xt,"f").call(this,o,r,n,s,a);this.logger.debug("polling - Got a response"),(null==l?void 0:l.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(l.error,null,4)),e(this,Zt,"f").call(this,l);const{action:d}=null!==(i=null==l?void 0:l.data)&&void 0!==i?i:{};e(this,Xt,"f").call(this,o,r,d,s,a)}))),2e3),"f"))})),Yt.set(this,(()=>{clearTimeout(e(this,Jt,"f")),i(this,Jt,null,"f")})),Zt.set(this,(t=>{var i,o,r,n,s,a,l,d,u,h,p;if(!(null==t?void 0:t.ok)){const a=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,l=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.statusText}`;return e(this,Bt,"m",ue).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:l,errorMessage:a}),void this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||a,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||l)}null===(l=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===l||l.forEach((t=>{const{level:e,title:i,log:o}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](i,o):this.loggerWrapper.info(i,o)}));const f=null===(h=null===(u=null===(d=t.data)||void 0===d?void 0:d.screen)||void 0===u?void 0:u.state)||void 0===h?void 0:h.errorText;(null===(p=t.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${f?`${f} - `:""}${t.data.error.message}`):f&&this.loggerWrapper.error(f);const{status:g,authInfo:v,lastAuth:m}=t.data;if("completed"===g)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&c&&localStorage.setItem(k,JSON.stringify(t))}(m),void e(this,Bt,"m",ue).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:I,screen:C,redirect:A,openInNewTabUrl:S,webauthn:j,error:E,samlIdpResponse:x}=t.data;I!==T?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:C,status:g,stepId:w,stepName:y,action:I,error:E}),this.flowState.update({stepId:w,executionId:b,action:I,redirectTo:null==A?void 0:A.url,openInNewTabUrl:S,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==x?void 0:x.url,samlIdpResponseSamlResponse:null==x?void 0:x.samlResponse,samlIdpResponseRelayState:null==x?void 0:x.relayState})):this.flowState.update({action:I})})),te.set(this,Q((()=>t(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.warn("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.warn("Webauthn start failed",t.message)}}))))),ae.set(this,tt(((i,o)=>t(this,void 0,void 0,(function*(){if("true"===i.getAttribute("formnovalidate")||e(this,Bt,"m",oe).call(this)){const r=null==i?void 0:i.getAttribute("id");e(this,Bt,"m",ne).call(this,i);const n=yield e(this,Bt,"m",re).call(this),s=(t=i,Array.from((null==t?void 0:t.attributes)||[]).reduce(((t,e)=>{var i;const o=null===(i=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===i?void 0:i[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),n),{origin:window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),u=yield o(r,d.version,c.componentsVersion,l);e(this,Zt,"f").call(this,u),e(this,Bt,"m",se).call(this,n)}var t}))))),this.flowState=o}loadSdkScripts(){return t(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>t(this,void 0,void 0,(function*(){(yield function(e){return t(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield import("./forter-74d50b85.js"),t.default;case"fingerprint":return t=yield import("./fingerprint-84b451f2.js"),t.default;case"fingerprintDescope":return t=yield import("./fingerprintDescope-effc737b.js"),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Ht(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t,o,r;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)),window.addEventListener("visibilitychange",e(this,zt,"f").visibilitychange)),yield null===(r=i.init)||void 0===r?void 0:r.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=e(this,Gt,"f"))||void 0===t||t.abort(),i(this,Gt,null,"f"),window.removeEventListener("visibilitychange",e(this,zt,"f").visibilitychange)}getHtmlFilenameWithLocale(e,i){return t(this,void 0,void 0,(function*(){let t;const o=et(e),r=yield this.getTargetLocales();return r.includes(o.locale)?t=`${i}-${o.locale}.html`:r.includes(o.fallback)&&(t=`${i}-${o.fallback}.html`),t}))}getPageContent(e,i){return t(this,void 0,void 0,(function*(){if(i)try{const{body:t}=yield V(i,"text");return t}catch(t){this.loggerWrapper.error(`Failed to fetch flow page from ${i}. Fallback to url ${e}`,t)}try{const{body:t}=yield V(e,"text");return t}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(r,a,l){return t(this,void 0,void 0,(function*(){var t,d;const{projectId:c,flowId:u,tenant:h,stepId:p,executionId:f,action:g,screenId:v,screenState:m,redirectTo:b,openInNewTabUrl:w,redirectUrl:y,token:I,code:k,exchangeError:C,webauthnTransactionId:A,webauthnOptions:S,redirectAuthCodeChallenge:j,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:x,redirectAuthInitiator:U,locale:O,samlIdpResponseUrl:L,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:N}=r,q=o(r,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"]);let _,F;const D=(()=>{const t=localStorage.getItem(mt);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(mt,t.toString()),t}return Number(t)})(),V=this.sdk.getLastUserLoginId(),B=yield this.getFlowConfig(),J=yield this.getProjectConfig(),G=E&&j?{callbackUrl:E,codeChallenge:j,backupCallbackUri:x}:void 0;if(!f&&(this.loadSdkScripts(),B.fingerprintEnabled&&B.fingerprintKey?yield n(B.fingerprintKey,this.baseUrl):s(),B.conditions?({startScreenId:_,conditionInteractionId:F}=((t,e)=>{const i=null==e?void 0:e.find((({key:e,operator:i,predicate:o})=>{var r;if("ELSE"===e)return!0;const n=null===(r=gt[e])||void 0===r?void 0:r[i];return!!(null==n?void 0:n(t,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}})({loginId:V,code:k,token:I,abTestingKey:D},B.conditions)):B.condition?({startScreenId:_,conditionInteractionId:F}=((t,e)=>{var i;const o=null===(i=gt[null==t?void 0:t.key])||void 0===i?void 0:i[t.operator];if(!o)return{};const r=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})(B.condition,{loginId:V,code:k,token:I,abTestingKey:D})):_=B.startScreenId,!X(_,q))){const i=yield this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:G},q),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:vt(V),abTestingKey:D,locale:et(O).locale}),F,"",B.version,J.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),I?{token:I}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return e(this,Zt,"f").call(this,i),void("completed"!==(null===(t=null==i?void 0:i.data)||void 0===t?void 0:t.status)&&this.flowState.update({code:void 0,token:void 0}))}if(f&&(l("token")&&I||l("code")&&k||l("exchangeError")&&C)){const t=yield this.sdk.flow.next(f,p,P,B.version,J.componentsVersion,{token:I,exchangeCode:k,exchangeError:C});return e(this,Zt,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===M&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>l(t)))){if(!L||!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,i,o)=>{const r=document.createElement("form");r.method="POST",r.action=t,r.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${i}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(r),o(r)})(L,T,N||"",Y)}if(g===R&&(l("redirectTo")||l("deferredRedirect")))return b?"android"===U&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(b):void this.loggerWrapper.error("Did not get redirect url");if(g===W||g===$){if(!A||!S)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,o;null===(d=e(this,Gt,"f"))||void 0===d||d.abort(),i(this,Gt,null,"f");try{t=g===W?yield this.sdk.webauthn.helpers.create(S):yield this.sdk.webauthn.helpers.get(S)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),o=t.name}const r=yield this.sdk.flow.next(f,p,P,B.version,J.componentsVersion,{transactionId:A,response:t,failure:o});e(this,Zt,"f").call(this,r)}if(e(this,Xt,"f").call(this,f,p,g,B.version,J.componentsVersion),!v&&!_)return void this.loggerWrapper.warn("No screen was found to show");const z=_||v,Q=yield this.getHtmlFilenameWithLocale(O,z),{oidcLoginHint:Z,oidcPrompt:tt,oidcErrorRedirectUri:it,samlIdpUsername:ot}=q,rt={direction:H(p,a.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:V,name:this.sdk.getLastUserDisplayName()||V}}),htmlUrl:K({projectId:c,filename:`${z}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:Q&&K({projectId:c,filename:Q,baseUrl:this.baseStaticUrl}),samlIdpUsername:ot,oidcLoginHint:Z,oidcPrompt:tt,oidcErrorRedirectUri:it,openInNewTabUrl:w},nt=vt(V);X(_,q)?rt.next=(t,e,i,o)=>this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:G},q),{lastAuth:nt,preview:this.preview,abTestingKey:D,client:this.client}),y&&{redirectUrl:y}),{locale:et(O).locale}),F,t,e,i,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),I&&{token:I})):(l("projectId")||l("baseUrl")||l("executionId")||l("stepId"))&&(rt.next=(...t)=>this.sdk.flow.next(f,p,...t)),this.stepState.update(rt)}))}onStepChange(i,o){return t(this,void 0,void 0,(function*(){var r,n;const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:d,screenState:c,openInNewTabUrl:u}=i,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield e(this,Bt,"m",ie).call(this,p,d):p.querySelectorAll(`descope-button[${L}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!i.samlIdpUsername||(null===(r=c.form)||void 0===r?void 0:r.loginId)||(null===(n=c.form)||void 0===n?void 0:n.email)||(c.form||(c.form={}),c.form.loginId=i.samlIdpUsername,c.form.email=i.samlIdpUsername),pt(p,c,c.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,g);const v=()=>t(this,void 0,void 0,(function*(){var t,i;yield f;const r=this.shadowRoot.querySelector("div");var n,s;n=r,s=null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image,ht(n,"descope-totp-image",s),((t,e)=>{ht(t,"descope-notp-image",e)})(r,null===(i=null==c?void 0:c.notp)||void 0===i?void 0:i.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((t,e)=>{dt(t,null==e?void 0:e.inputs),dt(t,null==e?void 0:e.form)})(this.rootElement,c)}));const a=!o.htmlUrl;((t,e,i)=>{if(!0===e||"skipFirstScreen"===e&&!i){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const i=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=i}))}))}))})(this.rootElement),e(this,Bt,"m",de).call(this,d),a&&e(this,Bt,"m",ue).call(this,"ready",{}),e(this,Bt,"m",ue).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${L}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(N,t.version,i.componentsVersion,{});e(this,Zt,"f").call(this,o)}u&&!o.openInNewTabUrl&&window.open(u,"_blank")}));l?e(this,Bt,"m",ce).call(this,v,l):v()}))}}Jt=new WeakMap,Gt=new WeakMap,zt=new WeakMap,Xt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ae=new WeakMap,Bt=new WeakSet,Qt=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},ee=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const i=`user-${e}`;t.setAttribute("name",i),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:i)}))}},ie=function(o,r){return t(this,void 0,void 0,(function*(){var n;null===(n=e(this,Gt,"f"))||void 0===n||n.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield ft())){const{options:o,transactionId:n}=(yield e(this,te,"f").call(this))||{};if(o&&n){e(this,Bt,"m",ee).call(this,s),i(this,Gt,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,Gt,"f")).then((i=>t(this,void 0,void 0,(function*(){const t=yield r(s.id,a.version,l.componentsVersion,{transactionId:n,response:i});e(this,Zt,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},oe=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var i,o;"slot"!==e.localName&&(null===(i=e.reportValidity)||void 0===i||i.call(e),t&&(t=null===(o=e.checkValidity)||void 0===o?void 0:o.call(e)))})),t},re=function(){return t(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${I}])`));return(yield Promise.all(e.map((e=>t(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},ne=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},se=function(t={}){var e,i;const o=Z(t,["externalId","email","phone"]),r=Z(t,["newPassword","password"]);if(o&&r)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:o,password:r});null===(i=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===i||i.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},le=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&e(this,ae,"f").call(this,i,t)}))}))},de=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{e(this,ae,"f").call(this,i,t)}})),e(this,Bt,"m",le).call(this,t)},ce=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===_.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(i)})),this.rootElement.classList.add("fade-out")},ue=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",he);export{he as D,at as S};
1
+ import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i,__rest as o}from"tslib";import r,{ensureFingerprintIds as n,clearFingerprintData as s}from"@descope/web-js-sdk";import{themeMixin as a}from"@descope/sdk-mixins";import{createSingletonMixin as l,compose as d}from"@descope/sdk-helpers";const c="undefined"!=typeof localStorage,u="J151000",h=c&&localStorage.getItem("base.content.url")||"",p="config.json",f="base.ui.components.url";c&&localStorage.getItem(f),c&&localStorage.getItem(f);const g="descope-login-flow",v="code",m="ra-challenge",b="ra-callback",w="ra-backup-callback",y="ra-initiator",I="data-exclude-field",k="dls_last_auth",C="state_id",A="saml_idp_state_id",S="saml_idp_username",j="descope_idp_initiated",E="sso_app_id",x="oidc_login_hint",U="oidc_prompt",O="oidc_error_redirect_uri",L="data-type",R="redirect",T="poll",W="webauthnCreate",$="webauthnGet",M="loadForm",P="submit",N="polling",q=["descope-multi-select-combo-box","descope-text-area"];var _;function F(t){return new URLSearchParams(window.location.search).get(t)}function D(t){if(window.history.replaceState&&F(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}function V(e,i){return t(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw Error(`Error fetching URL ${e} [${t.status}]`);return{body:yield t[i||"text"](),headers:Object.fromEntries(t.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(_||(_={}));function K({projectId:t,filename:e,assetsFolder:i="v2-beta",baseUrl:o}){const r=new URL(h||o||"https://static.descope.com/pages");return r.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(r.pathname,t,i,e),r.toString()}function H(t,e){if(!e)return;const i=+t,o=+e;return Number.isNaN(i)||Number.isNaN(o)?void 0:i>o?_.forward:i<o?_.backward:void 0}const B=()=>{const[t="",e=""]=(F(g)||"").split("_");return{executionId:t,stepId:e}};function J(){D(g)}const G=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),z=()=>{const{executionId:t,stepId:e}=B();(t||e)&&J();const i=F("t")||void 0;i&&D("t");const o=F(v)||void 0;o&&D(v);const r=F("err")||void 0;r&&D("err");const{redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:F(m),redirectAuthCallbackUrl:F(b),redirectAuthBackupCallbackUri:F(w),redirectAuthInitiator:F(y)};(n||s||a||l)&&(D(m),D(b),D(w),D(y));const d=F(C);d&&D(C);const c=F(A);c&&D(A);const u=F(S);c&&D(S);const h=F(j);h&&D(j);const p=F(E);p&&D(E);const f=F(x);f&&D(x);const g=F(U);g&&D(U);const I=F(O);I&&D(O);return{executionId:t,stepId:e,token:i,code:o,exchangeError:r,redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:d,samlIdpStateId:c,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:f,oidcPrompt:g,oidcErrorRedirectUri:I}}},Q=t=>{let e,i;return(...o)=>{return e&&(n=o,(r=e).length===n.length&&r.every(((t,e)=>t===n[e])))||(e=o,i=t(...o)),i;var r,n}};const X=(t,{oidcIdpStateId:e,samlIdpStateId:i,samlIdpUsername:o,ssoAppId:r,oidcLoginHint:n,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||i||o||r||n||s||a),Y=t=>null==t?void 0:t.submit(),Z=(t,e)=>{const i=e.find((e=>t[e]));return i?t[i]:null},tt=(t,e=100)=>{let i;return function(...o){i||t.apply(this,o),clearTimeout(i),i=setTimeout((()=>{i=null}),e)}};function et(t){if(t)return{locale:t.toLowerCase(),fallback:t.toLowerCase()};const e=navigator.language;return e?e.includes("-")?{locale:e.toLowerCase(),fallback:e.split("-")[0].toLowerCase()}:{locale:e.toLowerCase(),fallback:e.toLowerCase()}:{locale:"",fallback:""}}var it,ot,rt,nt;function st(t,e){const i=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(i.length!==o.length)return!1;for(let o=0;o<i.length;o+=1){const r=i[o],n=t[r],s=e[r];if(null===n||null===s){if(n!==s)return!1}else if("object"==typeof n&&"object"==typeof s){if(!st(n,s))return!1}else if(n!==s)return!1}return!0}class at{constructor(t={},{updateOnlyOnChange:o=!0}={}){it.set(this,void 0),ot.set(this,{}),rt.set(this,0),nt.set(this,!1),this.update=t=>{const o="function"==typeof t?t(e(this,it,"f")):t,r=Object.assign(Object.assign({},e(this,it,"f")),o);if(!e(this,nt,"f")||!st(e(this,it,"f"),r)){const t=e(this,it,"f");i(this,it,r,"f"),Object.freeze(e(this,it,"f")),setTimeout((()=>{Object.values(e(this,ot,"f")).forEach((e=>e(r,t,((t,e)=>i=>t[i]!==e[i])(r,t))))}),0)}},i(this,it,t,"f"),i(this,nt,o,"f")}get current(){return Object.assign({},e(this,it,"f"))}subscribe(t){return i(this,rt,e(this,rt,"f")+1,"f"),e(this,ot,"f")[e(this,rt,"f")]=t,e(this,rt,"f").toString()}unsubscribe(t){const i=!!e(this,ot,"f")[t];return i&&delete e(this,ot,"f")[t],i}unsubscribeAll(){return i(this,ot,{},"f"),!0}}it=new WeakMap,ot=new WeakMap,rt=new WeakMap,nt=new WeakMap;const lt=["disabled"],dt=(t,e)=>{Object.entries(e||{}).forEach((([e,i])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${I}])`)).forEach((t=>{t.value=i}))}))},ct=(t,e)=>t.replace(/{{(.+?)}}/g,((t,i)=>{return o=e,i.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),ut=(t,e,i)=>{t.querySelectorAll(`[${L}="${e}"]`).forEach((t=>{t.setAttribute("href",i)}))},ht=(t,e,i)=>{var o,r;const n=null===(o=customElements.get(e))||void 0===o?void 0:o.cssVarList.url;i&&n&&(null===(r=null==t?void 0:t.style)||void 0===r||r.setProperty(n,`url(data:image/jpg;base64,${i})`))},pt=(t,e,i,o,r,n)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==r?void 0:r({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){n.error("Error transforming error message",t.message)}((t,e,i="")=>{t.querySelectorAll(`[${L}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",l),ut(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ut(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{t.textContent=ct(t.textContent,e);const i=t.getAttribute("href");i&&t.setAttribute("href",ct(i,e))}))})(t,e),((t,e,i)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const r=e[o];Object.keys(r).forEach((e=>{let o=r[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){i.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,i,n),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=ct(t.value,e)}))}))})(t,e),((t,e)=>{Object.entries(e).forEach((([e,i])=>{t.querySelectorAll(`[name="${e}"]`).forEach((t=>{Object.entries(i).forEach((([e,i])=>{lt.includes(e)&&t.setAttribute(e,i)}))}))}))})(t,o)},ft=Q((()=>t(void 0,void 0,void 0,(function*(){var t,e,i,o,r;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),s=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,i=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return i?i.version:0})()>=108;return yield(i=100,o=n,r=s,new Promise(((t,e)=>{let n=!1;const s=setTimeout((()=>{n=!0,void 0!==r?t(r):e(new Error(`Promise timed out after ${i} ms`))}),i);o.then((e=>{n||(clearTimeout(s),t(e))})).catch((t=>{n||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),gt={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function vt(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(k)))}catch(t){}return e}const mt="dls_ab_testing_id",bt=l((t=>{var i,o,r,n;return n=class extends t{constructor(){super(...arguments),i.add(this)}connectedCallback(){var t;e(this,i,"m",o).call(this)&&e(this,i,"m",r).call(this),null===(t=super.connectedCallback)||void 0===t||t.call(this)}},i=new WeakSet,o=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},r=function(){const t=this.shadowRoot.host,e=document.createElement("form");e.style.width="100%",e.style.height="100%",t.parentElement.appendChild(e),e.appendChild(t)},n})),wt=document.createElement("template");wt.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t";const yt=(t,e="")=>Object.keys(t).reduce(((i,o)=>{var r;if("object"==typeof t[o]&&null!==t[o]&&!(null===(r=t[o])||void 0===r?void 0:r.value))return Object.assign(Object.assign({},i),yt(t[o],`${e+o}.`));const n="object"==typeof t[o]?t[o]:{value:t[o]},s=Object.assign(Object.assign({},i),{[e+o]:n,[`form.${e}${o}`]:n});return"displayName"===o?Object.assign(Object.assign({},s),{[`${e}fullName`]:n,[`form.${e}fullName`]:n}):s}),[]);var It,kt,Ct,At,St,jt,Et,xt,Ut,Ot,Lt,Rt,Tt,Wt,$t,Mt,Pt,Nt,qt,_t,Ft,Dt;const Vt=d(a,bt)(HTMLElement);class Kt extends Vt{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(o){super(),It.add(this),Ct.set(this,!1),this.loggerWrapper={error:(t,i="")=>{this.logger.error(t,i,new Error),e(this,It,"m",Ft).call(this,t,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},At.set(this,new at),St.set(this,new at),jt.set(this,{}),this.getComponentsContext=()=>e(this,jt,"f"),this.nextRequestStatus=new at({isLoading:!1}),Et.set(this,void 0),xt.set(this,{popstate:e(this,It,"m",Rt).bind(this),componentsContext:e(this,It,"m",Nt).bind(this)}),Ut.set(this,void 0),Pt.set(this,Q((()=>t(this,void 0,void 0,(function*(){const t=K({projectId:this.projectId,filename:p,baseUrl:this.baseStaticUrl});try{const{body:e,headers:i}=yield V(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),i(this,Ut,o,"f"),e(this,It,"m",Ot).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(t=>{try{return yt(JSON.parse(t))}catch(t){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return t=this.formConfig,e="value",Object.fromEntries(Object.entries(t).map((([t,i])=>[t,i[e]])));var t,e}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield e(this,Pt,"f").call(this);return t}))}getProjectConfig(){return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,Pt,"f").call(this);return t}))}getFlowConfig(){return t(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),o=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(o.version=0),o}))}getTargetLocales(){return t(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}init(){const o=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;if(yield null===(t=o.init)||void 0===t?void 0:t.call(this),e(this,St,"f").subscribe(e(this,It,"m",_t).bind(this)),e(this,St,"f").update({isDebug:this.debug}),e(this,It,"m",Lt).call(this),yield e(this,It,"m",$t).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 e(this,Pt,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");e(this,It,"m",Dt).call(this);const{executionId:r,stepId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=z();window.addEventListener("popstate",e(this,xt,"f").popstate),window.addEventListener("components-context",e(this,xt,"f").componentsContext),e(this,At,"f").subscribe(e(this,It,"m",Wt).bind(this)),e(this,At,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:u,redirectAuthInitiator:h},p)),i(this,Ct,!0,"f")}))}disconnectedCallback(){e(this,At,"f").unsubscribeAll(),e(this,St,"f").unsubscribeAll(),e(this,It,"m",qt).call(this),window.removeEventListener("popstate",e(this,xt,"f").popstate),window.removeEventListener("components-context",e(this,xt,"f").componentsContext)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,Ct,"f")&&i!==o&&kt.observedAttributes.includes(t)){e(this,It,"m",Lt).call(this);const r=null===i;e(this,At,"f").update((({stepId:e,executionId:i})=>{let n=e,s=i;return r||(s=null,n=null,J()),{[G(t)]:o,stepId:n,executionId:s}})),e(this,St,"f").update({isDebug:this.debug})}}}function Ht(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Bt,Jt,Gt,zt,Qt,Xt,Yt,Zt,te,ee,ie,oe,re,ne,se,ae,le,de,ce,ue;kt=Kt,Ct=new WeakMap,At=new WeakMap,St=new WeakMap,jt=new WeakMap,Et=new WeakMap,xt=new WeakMap,Ut=new WeakMap,Pt=new WeakMap,It=new WeakSet,Ot=function(){this.shadowRoot.appendChild(wt.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},Lt=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];kt.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[G(e)])throw Error(`${e} cannot be empty`)}))},Rt=function(){const{stepId:t,executionId:i}=B();e(this,At,"f").update({stepId:t,executionId:i})},Tt=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},kt.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}catch(t){return{error:{errorCode:u,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Wt=function(i,o,r){return t(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:o}=i;if(r("projectId")||r("baseUrl")){if(!t)return;e(this,It,"m",Tt).call(this,t,o)}e(this,Ut,"f").call(this,i)}))},$t=function(){return t(this,void 0,void 0,(function*(){return(yield e(this,Pt,"f").call(this)).isMissingConfig&&(yield e(this,It,"m",Mt).call(this))}))},Mt=function(){return t(this,void 0,void 0,(function*(){const t=K({projectId:this.projectId,filename:p,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield V(t,"json"),!0}catch(t){return!1}}))},Nt=function(t){i(this,jt,Object.assign(Object.assign({},e(this,jt,"f")),t.detail),"f")},qt=function(){var t;null===(t=e(this,Et,"f"))||void 0===t||t.remove(),i(this,Et,null,"f")},_t=function(o){return t(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,Et,document.createElement("descope-debugger"),"f"),Object.assign(e(this,Et,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-a79e75d7.js"),document.body.appendChild(e(this,Et,"f"))):e(this,It,"m",qt).call(this)}))},Ft=function(t,i){var o;t&&this.debug&&(null===(o=e(this,Et,"f"))||void 0===o||o.updateData({title:t,description:i}))},Dt=function(){this.rootElement.onkeydown=t=>{var e,i,o;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=q.includes(null!==(o=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==o?o:"");if("Enter"!==t.key||r||n)return;t.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((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(s).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},Kt.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.24.2"}};class he extends Kt{static set sdkConfigOverrides(t){Kt.sdkConfigOverrides=t}constructor(){const o=new at({deferredRedirect:!1});super(o.update.bind(o)),Bt.add(this),this.stepState=new at({},{updateOnlyOnChange:!1}),Jt.set(this,void 0),Gt.set(this,null),zt.set(this,{visibilitychange:e(this,Bt,"m",Qt).bind(this)}),Xt.set(this,((o,r,n,s,a)=>{n===T&&(this.logger.debug("polling - Scheduling polling request"),i(this,Jt,setTimeout((()=>t(this,void 0,void 0,(function*(){var t,i;this.logger.debug("polling - Calling next");const l=yield this.sdk.flow.next(o,r,N,s,a,{});if((null===(t=null==l?void 0:l.error)||void 0===t?void 0:t.errorCode)===u)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,Xt,"f").call(this,o,r,n,s,a);this.logger.debug("polling - Got a response"),(null==l?void 0:l.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(l.error,null,4)),e(this,Zt,"f").call(this,l);const{action:d}=null!==(i=null==l?void 0:l.data)&&void 0!==i?i:{};e(this,Xt,"f").call(this,o,r,d,s,a)}))),2e3),"f"))})),Yt.set(this,(()=>{clearTimeout(e(this,Jt,"f")),i(this,Jt,null,"f")})),Zt.set(this,(t=>{var i,o,r,n,s,a,l,d,u,h,p;if(!(null==t?void 0:t.ok)){const a=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,l=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.statusText}`;return e(this,Bt,"m",ue).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:l,errorMessage:a}),void this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||a,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||l)}null===(l=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===l||l.forEach((t=>{const{level:e,title:i,log:o}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](i,o):this.loggerWrapper.info(i,o)}));const f=null===(h=null===(u=null===(d=t.data)||void 0===d?void 0:d.screen)||void 0===u?void 0:u.state)||void 0===h?void 0:h.errorText;(null===(p=t.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${f?`${f} - `:""}${t.data.error.message}`):f&&this.loggerWrapper.error(f);const{status:g,authInfo:v,lastAuth:m}=t.data;if("completed"===g)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&c&&localStorage.setItem(k,JSON.stringify(t))}(m),void e(this,Bt,"m",ue).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:I,screen:C,redirect:A,openInNewTabUrl:S,webauthn:j,error:E,samlIdpResponse:x}=t.data;I!==T?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:C,status:g,stepId:w,stepName:y,action:I,error:E}),this.flowState.update({stepId:w,executionId:b,action:I,redirectTo:null==A?void 0:A.url,openInNewTabUrl:S,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==x?void 0:x.url,samlIdpResponseSamlResponse:null==x?void 0:x.samlResponse,samlIdpResponseRelayState:null==x?void 0:x.relayState})):this.flowState.update({action:I})})),te.set(this,Q((()=>t(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.warn("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.warn("Webauthn start failed",t.message)}}))))),ae.set(this,tt(((i,o)=>t(this,void 0,void 0,(function*(){if("true"===i.getAttribute("formnovalidate")||e(this,Bt,"m",oe).call(this)){const r=null==i?void 0:i.getAttribute("id");e(this,Bt,"m",ne).call(this,i);const n=yield e(this,Bt,"m",re).call(this),s=(t=i,Array.from((null==t?void 0:t.attributes)||[]).reduce(((t,e)=>{var i;const o=null===(i=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===i?void 0:i[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),n),{origin:window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),u=yield o(r,d.version,c.componentsVersion,l);e(this,Zt,"f").call(this,u),e(this,Bt,"m",se).call(this,n)}var t}))))),this.flowState=o}loadSdkScripts(){return t(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>t(this,void 0,void 0,(function*(){(yield function(e){return t(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield import("./forter-74d50b85.js"),t.default;case"fingerprint":return t=yield import("./fingerprint-84b451f2.js"),t.default;case"fingerprintDescope":return t=yield import("./fingerprintDescope-effc737b.js"),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Ht(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t,o,r;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)),window.addEventListener("visibilitychange",e(this,zt,"f").visibilitychange)),yield null===(r=i.init)||void 0===r?void 0:r.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=e(this,Gt,"f"))||void 0===t||t.abort(),i(this,Gt,null,"f"),window.removeEventListener("visibilitychange",e(this,zt,"f").visibilitychange)}getHtmlFilenameWithLocale(e,i){return t(this,void 0,void 0,(function*(){let t;const o=et(e),r=yield this.getTargetLocales();return r.includes(o.locale)?t=`${i}-${o.locale}.html`:r.includes(o.fallback)&&(t=`${i}-${o.fallback}.html`),t}))}getPageContent(e,i){return t(this,void 0,void 0,(function*(){if(i)try{const{body:t}=yield V(i,"text");return t}catch(t){this.loggerWrapper.error(`Failed to fetch flow page from ${i}. Fallback to url ${e}`,t)}try{const{body:t}=yield V(e,"text");return t}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(r,a,l){return t(this,void 0,void 0,(function*(){var t,d;const{projectId:c,flowId:u,tenant:h,stepId:p,executionId:f,action:g,screenId:v,screenState:m,redirectTo:b,openInNewTabUrl:w,redirectUrl:y,token:I,code:k,exchangeError:C,webauthnTransactionId:A,webauthnOptions:S,redirectAuthCodeChallenge:j,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:x,redirectAuthInitiator:U,locale:O,samlIdpResponseUrl:L,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:N}=r,q=o(r,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"]);let _,F;const D=(()=>{const t=localStorage.getItem(mt);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(mt,t.toString()),t}return Number(t)})(),V=this.sdk.getLastUserLoginId(),B=yield this.getFlowConfig(),J=yield this.getProjectConfig(),G=E&&j?{callbackUrl:E,codeChallenge:j,backupCallbackUri:x}:void 0;if(!f&&(this.loadSdkScripts(),B.fingerprintEnabled&&B.fingerprintKey?yield n(B.fingerprintKey,this.baseUrl):s(),B.conditions?({startScreenId:_,conditionInteractionId:F}=((t,e)=>{const i=null==e?void 0:e.find((({key:e,operator:i,predicate:o})=>{var r;if("ELSE"===e)return!0;const n=null===(r=gt[e])||void 0===r?void 0:r[i];return!!(null==n?void 0:n(t,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}})({loginId:V,code:k,token:I,abTestingKey:D},B.conditions)):B.condition?({startScreenId:_,conditionInteractionId:F}=((t,e)=>{var i;const o=null===(i=gt[null==t?void 0:t.key])||void 0===i?void 0:i[t.operator];if(!o)return{};const r=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})(B.condition,{loginId:V,code:k,token:I,abTestingKey:D})):_=B.startScreenId,!X(_,q))){const i=yield this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:G},q),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:vt(V),abTestingKey:D,locale:et(O).locale}),F,"",B.version,J.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),I?{token:I}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return e(this,Zt,"f").call(this,i),void("completed"!==(null===(t=null==i?void 0:i.data)||void 0===t?void 0:t.status)&&this.flowState.update({code:void 0,token:void 0}))}if(f&&(l("token")&&I||l("code")&&k||l("exchangeError")&&C)){const t=yield this.sdk.flow.next(f,p,P,B.version,J.componentsVersion,{token:I,exchangeCode:k,exchangeError:C});return e(this,Zt,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===M&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>l(t)))){if(!L||!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,i,o)=>{const r=document.createElement("form");r.method="POST",r.action=t,r.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${i}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(r),o(r)})(L,T,N||"",Y)}if(g===R&&(l("redirectTo")||l("deferredRedirect")))return b?"android"===U&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(b):void this.loggerWrapper.error("Did not get redirect url");if(g===W||g===$){if(!A||!S)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,o;null===(d=e(this,Gt,"f"))||void 0===d||d.abort(),i(this,Gt,null,"f");try{t=g===W?yield this.sdk.webauthn.helpers.create(S):yield this.sdk.webauthn.helpers.get(S)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),o=t.name}const r=yield this.sdk.flow.next(f,p,P,B.version,J.componentsVersion,{transactionId:A,response:t,failure:o});e(this,Zt,"f").call(this,r)}if(e(this,Xt,"f").call(this,f,p,g,B.version,J.componentsVersion),!v&&!_)return void this.loggerWrapper.warn("No screen was found to show");const z=_||v,Q=yield this.getHtmlFilenameWithLocale(O,z),{oidcLoginHint:Z,oidcPrompt:tt,oidcErrorRedirectUri:it,samlIdpUsername:ot}=q,rt={direction:H(p,a.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:V,name:this.sdk.getLastUserDisplayName()||V}}),htmlUrl:K({projectId:c,filename:`${z}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:Q&&K({projectId:c,filename:Q,baseUrl:this.baseStaticUrl}),samlIdpUsername:ot,oidcLoginHint:Z,oidcPrompt:tt,oidcErrorRedirectUri:it,openInNewTabUrl:w},nt=vt(V);X(_,q)?rt.next=(t,e,i,o)=>this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:G},q),{lastAuth:nt,preview:this.preview,abTestingKey:D,client:this.client}),y&&{redirectUrl:y}),{locale:et(O).locale}),F,t,e,i,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),I&&{token:I})):(l("projectId")||l("baseUrl")||l("executionId")||l("stepId"))&&(rt.next=(...t)=>this.sdk.flow.next(f,p,...t)),this.stepState.update(rt)}))}onStepChange(i,o){return t(this,void 0,void 0,(function*(){var r,n;const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:d,screenState:c,openInNewTabUrl:u}=i,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield e(this,Bt,"m",ie).call(this,p,d):p.querySelectorAll(`descope-button[${L}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!i.samlIdpUsername||(null===(r=c.form)||void 0===r?void 0:r.loginId)||(null===(n=c.form)||void 0===n?void 0:n.email)||(c.form||(c.form={}),c.form.loginId=i.samlIdpUsername,c.form.email=i.samlIdpUsername),pt(p,c,c.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,g);const v=()=>t(this,void 0,void 0,(function*(){var t,i;yield f;const r=this.shadowRoot.querySelector("div");var n,s;n=r,s=null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image,ht(n,"descope-totp-image",s),((t,e)=>{ht(t,"descope-notp-image",e)})(r,null===(i=null==c?void 0:c.notp)||void 0===i?void 0:i.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((t,e)=>{dt(t,null==e?void 0:e.inputs),dt(t,null==e?void 0:e.form)})(this.rootElement,c)}));const a=!o.htmlUrl;((t,e,i)=>{if(!0===e||"skipFirstScreen"===e&&!i){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const i=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=i}))}))}))})(this.rootElement),e(this,Bt,"m",de).call(this,d),a&&e(this,Bt,"m",ue).call(this,"ready",{}),e(this,Bt,"m",ue).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${L}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(N,t.version,i.componentsVersion,{});e(this,Zt,"f").call(this,o)}u&&!o.openInNewTabUrl&&window.open(u,"_blank")}));l?e(this,Bt,"m",ce).call(this,v,l):v()}))}}Jt=new WeakMap,Gt=new WeakMap,zt=new WeakMap,Xt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ae=new WeakMap,Bt=new WeakSet,Qt=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},ee=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const i=`user-${e}`;t.setAttribute("name",i),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:i)}))}},ie=function(o,r){return t(this,void 0,void 0,(function*(){var n;null===(n=e(this,Gt,"f"))||void 0===n||n.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield ft())){const{options:o,transactionId:n}=(yield e(this,te,"f").call(this))||{};if(o&&n){e(this,Bt,"m",ee).call(this,s),i(this,Gt,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,Gt,"f")).then((i=>t(this,void 0,void 0,(function*(){const t=yield r(s.id,a.version,l.componentsVersion,{transactionId:n,response:i});e(this,Zt,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},oe=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var i,o;"slot"!==e.localName&&(null===(i=e.reportValidity)||void 0===i||i.call(e),t&&(t=null===(o=e.checkValidity)||void 0===o?void 0:o.call(e)))})),t},re=function(){return t(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${I}])`));return(yield Promise.all(e.map((e=>t(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},ne=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},se=function(t={}){var e,i;const o=Z(t,["externalId","email","phone"]),r=Z(t,["newPassword","password"]);if(o&&r)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:o,password:r});null===(i=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===i||i.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},le=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&e(this,ae,"f").call(this,i,t)}))}))},de=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{e(this,ae,"f").call(this,i,t)}})),e(this,Bt,"m",le).call(this,t)},ce=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===_.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(i)})),this.rootElement.classList.add("fade-out")},ue=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",he);export{he as D,at as S};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{D as default}from"./index-b8eab371.js";import"tslib";import"@descope/web-js-sdk";import"@descope/sdk-mixins";import"@descope/sdk-helpers";
1
+ export{D as default}from"./index-23637c29.js";import"tslib";import"@descope/web-js-sdk";import"@descope/sdk-mixins";import"@descope/sdk-helpers";
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- !function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function i(t,e,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 e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n}"function"==typeof SuppressedError&&SuppressedError;class r extends Error{}function s(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(t){return decodeURIComponent(atob(t).replace(/(.)/g,((t,e)=>{let n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return atob(e)}}function a(t,e){if("string"!=typeof t)throw new r("Invalid token specified: must be a string");e||(e={});const n=!0===e.header?0:1,o=t.split(".")[n];if("string"!=typeof o)throw new r(`Invalid token specified: missing part #${n+1}`);let i;try{i=s(o)}catch(t){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${t.message})`)}try{return JSON.parse(i)}catch(t){throw new r(`Invalid token specified: invalid json for part #${n+1} (${t.message})`)}}r.prototype.name="InvalidTokenError";var l="/v1/auth/accesskey/exchange",c="/v1/auth/otp/verify",d="/v1/auth/otp/signin",u="/v1/auth/otp/signup",h={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},p="/v1/auth/otp/signup-in",f="/v1/auth/magiclink/verify",g="/v1/auth/magiclink/signin",v="/v1/auth/magiclink/signup",m={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},b="/v1/auth/magiclink/signup-in",w="/v1/auth/enchantedlink/verify",y="/v1/auth/enchantedlink/signin",k="/v1/auth/enchantedlink/signup",I="/v1/auth/enchantedlink/pending-session",x={email:"/v1/auth/enchantedlink/update/email"},C="/v1/auth/enchantedlink/signup-in",j="/v1/auth/oauth/authorize",A="/v1/auth/oauth/exchange",S="v1/auth/oauth/native/start",O="v1/auth/oauth/native/finish",E="/v1/auth/saml/authorize",U="/v1/auth/saml/exchange",L="/v1/auth/totp/verify",T="/v1/auth/totp/signup",_="/v1/auth/totp/update",R="/v1/auth/notp/whatsapp/signin",M="/v1/auth/notp/whatsapp/signup",$="/v1/auth/notp/whatsapp/signup-in",P="/v1/auth/notp/pending-session",D={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},W={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},N={start:"/v1/auth/webauthn/signup-in/start"},F={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},q="/v1/auth/password/signup",B="/v1/auth/password/signin",H="/v1/auth/password/reset",V="/v1/auth/password/update",K="/v1/auth/password/replace",z="/v1/auth/password/policy",G="/v1/auth/refresh",J="/v1/auth/tenant/select",X="/v1/auth/logout",Z="/v1/auth/logoutall",Q="/v1/auth/me",Y="/v1/auth/me/history",tt="/v1/flow/start",et="/v1/flow/next";const nt="<region>",ot=`https://api.${nt}descope.com`,it=6e5,rt="dct",st=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};var at,lt;(lt=at||(at={})).get="GET",lt.delete="DELETE",lt.post="POST",lt.put="PUT",lt.patch="PATCH";const ct=({path:t,baseUrl:e,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);e=e.replace(nt,i?i+".":"");let r=t?`${e.replace(/\/$/,"")}/${null==t?void 0:t.replace(/^\//,"")}`:e;if(n){r=`${r}?`;const t=Object.keys(n);t.forEach(((e,o)=>{r=`${r}${e}=${n[e]}${o===t.length-1?"":"&"}`}))}return r},dt=(...t)=>new Headers(t.reduce(((t,e)=>{const n=(t=>Array.isArray(t)?t:t instanceof Headers?Array.from(t.entries()):t?Object.entries(t):[])(e);return n.reduce(((e,[n,o])=>(t[n]=o,t)),t),t}),{})),ut={"Content-Type":"application/json"},ht=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},pt=t=>{try{t=JSON.parse(t)}catch(t){return!1}return"object"==typeof t&&null!==t},ft=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=(t=>async(...e)=>{const n=await t(...e),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(e||fetch);return n||null==t||t.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"),t?async(...e)=>{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");t.log((t=>st().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const o=await n(...e);return t[o.ok?"log":"error"](await(async t=>{const e=await t.text();return st().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).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=(t=>void 0===t?void 0:JSON.stringify(t))(d),v={headers:dt(ht(e,f),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.24.4"},(null==n?void 0:n.baseHeaders)||{},pt(g)?ut:{},u),method:p,body:g};null!==r&&(v.credentials=r||"include");const m=await a(ct({path:c,baseUrl:t,queryParams:h,projectId:e}),v);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==m?void 0:m.clone()),null==i?void 0:i.transformResponse){const t=await m.json(),e=((null===(s=m.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((t,e)=>{const[n,o]=e.split("=");return Object.assign(Object.assign({},t),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(t),cookies:e});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:at.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:at.post,token:i}),patch:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:at.patch,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:at.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:at.delete,token:o}),hooks:i,buildUrl:(n,o)=>ct({projectId:e,baseUrl:t,path:n,queryParams:o})}};var gt=429;function vt(t,e,n){var o;let i=mt(t);if(e){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[rt])===e)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[e]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function mt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return a(t)}function bt(t){const{exp:e}=mt(t);return(new Date).getTime()/1e3>e}function wt(t){let e=mt(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function yt(t,e){return vt(t,e,"permissions")}function kt(t,e){return vt(t,e,"roles")}const It=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function xt(t,e){var n;const o=await t,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=e?e(r):r:(i.error=r,o.status===gt&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Ct=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),jt=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),At=t=>e=>t.test(e),St=At(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ot=At(/^\+[1-9]{1}[0-9]{3,14}$/),Et=Ct(St,'"{val}" is not a valid email'),Ut=Ct(Ot,'"{val}" is not a valid phone number'),Lt=Ct((t=>t.length>=1),"Minimum length is 1");const Tt=Ct((t=>"string"==typeof t),"Input is not a string"),_t=Ct((t=>void 0===t),"Input is defined"),Rt=(Mt=[Tt(),_t()],(t="Input is not a string or undefined")=>e=>{const n=Mt.filter((t=>t(e)));return!(n.length<Mt.length)&&(t?t.replace("{val}",e):n.join(" OR "))});var Mt;const $t=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>jt(...t).validate(n[e]))),e(...n)),Pt=t=>[Tt(`"${t}" must be a string`)],Dt=t=>[Tt(`"${t}" must be a string`),Lt(`"${t}" must not be empty`)],Wt=t=>[Tt(`"${t}" must be a string`),Et()],Nt=t=>[Tt(`"${t}" must be a string`),Ut()],Ft=$t(Dt("accessKey")),qt=t=>({exchange:Ft(((e,n)=>xt(t.post(l,{loginOptions:n},{token:e}))))}),Bt=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let i=o.shift(),r=t;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${e}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${e}" is not a function`);const s=r[i];r[i]=n(s)})),t),Ht=({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||it,it)});var Vt,Kt;!function(t){t.sms="sms",t.voice="voice",t.whatsapp="whatsapp"}(Vt||(Vt={})),function(t){t.email="email"}(Kt||(Kt={}));const zt=Object.assign(Object.assign({},Vt),Kt);var Gt;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(Gt||(Gt={}));const Jt=Dt("loginId"),Xt=$t(Dt("token")),Zt=$t(Jt),Qt=$t(Dt("pendingRef")),Yt=$t(Jt,Wt("email")),te=t=>({verify:Xt((e=>xt(t.post(w,{token:e})))),signIn:Zt(((e,n,o,i)=>xt(t.post(It(y,zt.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:Zt(((e,n,o)=>xt(t.post(It(C,zt.email),{loginId:e,URI:n,loginOptions:o})))),signUp:Zt(((e,n,o,i)=>xt(t.post(It(k,zt.email),{loginId:e,URI:n,user:o,loginOptions:i})))),waitForSession:Qt(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ht(n);let s;const a=setInterval((async()=>{const n=await t.post(I,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Yt(((e,n,o,i,r)=>xt(t.post(x.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),ee=$t(Dt("flowId")),ne=$t(Dt("executionId"),Dt("stepId"),Dt("interactionId")),oe=t=>({start:ee(((e,n,o,i,r,s,a)=>xt(t.post(tt,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:ne(((e,n,o,i,r,s)=>xt(t.post(et,{executionId:e,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),ie=Dt("loginId"),re=$t(Dt("token")),se=$t(ie),ae=$t(ie,Nt("phone")),le=$t(ie,Wt("email")),ce=Object.keys(zt).filter((t=>t!==Vt.voice)),de=t=>({verify:re((e=>xt(t.post(f,{token:e})))),signIn:ce.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,o,i,r)=>xt(t.post(It(g,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:ce.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,o,i,r)=>xt(t.post(It(v,n),{loginId:e,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:ce.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,o,i)=>xt(t.post(It(b,n),{loginId:e,URI:o,loginOptions:i}))))})),{}),update:{email:le(((e,n,o,i,r)=>xt(t.post(m.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(Vt).filter((t=>t!==Vt.voice)).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ae(((e,o,i,r,s)=>xt(t.post(It(m.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var ue;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple",t.discord="discord",t.linkedin="linkedin",t.slack="slack"}(ue||(ue={}));const he=$t(Dt("code")),pe=t=>({start:Object.assign(((e,n,o,i)=>xt(t.post(j,o||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:i}))),Object.keys(ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>xt(t.post(j,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{})),exchange:he((e=>xt(t.post(A,{code:e})))),startNative:(e,n,o)=>xt(t.post(S,{provider:e,loginOptions:n,implicit:o})),finishNative:(e,n,o,i,r)=>xt(t.post(O,{provider:e,stateId:n,user:o,code:i,idToken:r}))}),fe=Dt("loginId"),ge=$t(fe,Dt("code")),ve=$t(fe),me=$t(fe,Nt("phone")),be=$t(fe,Wt("email")),we=t=>({verify:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,o)=>xt(t.post(It(c,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ve(((e,o,i)=>xt(t.post(It(d,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ve(((e,o,i)=>xt(t.post(It(u,n),{loginId:e,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ve(((e,o)=>xt(t.post(It(p,n),{loginId:e,loginOptions:o}))))})),{}),update:{email:be(((e,n,o,i)=>xt(t.post(h.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(Vt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:me(((e,o,i,r)=>xt(t.post(It(h.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),ye=$t(Dt("tenant")),ke=$t(Dt("code")),Ie=t=>({start:ye(((e,n,o,i)=>xt(t.post(E,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:ke((e=>xt(t.post(U,{code:e}))))}),xe=Dt("loginId"),Ce=$t(xe,Dt("code")),je=$t(xe),Ae=$t(xe),Se=t=>({signUp:je(((e,n)=>xt(t.post(T,{loginId:e,user:n})))),verify:Ce(((e,n,o,i)=>xt(t.post(L,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Ae(((e,n)=>xt(t.post(_,{loginId:e},{token:n}))))}),Oe=Dt("loginId"),Ee=Dt("newPassword"),Ue=$t(Oe,Dt("password")),Le=$t(Oe),Te=$t(Oe,Ee),_e=$t(Oe,Dt("oldPassword"),Ee),Re=t=>({signUp:Ue(((e,n,o,i)=>xt(t.post(q,{loginId:e,password:n,user:o,loginOptions:i})))),signIn:Ue(((e,n,o)=>xt(t.post(B,{loginId:e,password:n,loginOptions:o})))),sendReset:Le(((e,n,o)=>xt(t.post(H,{loginId:e,redirectUrl:n,templateOptions:o})))),update:Te(((e,n,o)=>xt(t.post(V,{loginId:e,newPassword:n},{token:o})))),replace:_e(((e,n,o)=>xt(t.post(K,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>xt(t.get(z))}),Me=Pt("loginId"),$e=Dt("loginId"),Pe=Dt("origin"),De=$t($e,Pe,Dt("name")),We=$t($e,Pe),Ne=$t(Me,Pe),Fe=$t($e,Pe,Dt("token")),qe=$t(Dt("transactionId"),Dt("response")),Be=t=>({signUp:{start:De(((e,n,o)=>xt(t.post(D.start,{user:{loginId:e,name:o},origin:n})))),finish:qe(((e,n)=>xt(t.post(D.finish,{transactionId:e,response:n}))))},signIn:{start:Ne(((e,n,o,i)=>xt(t.post(W.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:qe(((e,n)=>xt(t.post(W.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:We(((e,n)=>xt(t.post(N.start,{loginId:e,origin:n}))))},update:{start:Fe(((e,n,o)=>xt(t.post(F.start,{loginId:e,origin:n},{token:o})))),finish:qe(((e,n)=>xt(t.post(F.finish,{transactionId:e,response:n}))))}}),He=Pt("loginId"),Ve=$t(He),Ke=$t(Dt("pendingRef")),ze=t=>({signUpOrIn:Ve(((e,n)=>xt(t.post($,{loginId:e,loginOptions:n})))),signUp:Ve(((e,n,o)=>xt(t.post(M,{loginId:e,user:n,loginOptions:o})))),signIn:Ve(((e,n,o)=>xt(t.post(R,{loginId:e,loginOptions:n},{token:o})))),waitForSession:Ke(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ht(n);let s;const a=setInterval((async()=>{const n=await t.post(P,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ge=$t(Dt("token")),Je=$t([Rt('"token" must be string or undefined')]);var Xe,Ze=$t([(Xe=Dt("projectId"),Ct(((t,e)=>n=>jt(...e).validate(((t,e)=>{const n=(Array.isArray(e)?e.join("."):String(e)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((t,e,n)=>"."+n)).split("."),o=n.length;let i=0,r=t===Object(t)?t:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,t)))("projectId",Xe))())])((t=>{var e;return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=ft({baseUrl:n||ot,projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:qt(a),otp:we(a),magicLink:de(a),enchantedLink:te(a),oauth:pe(a),saml:Ie(a),totp:Se(a),notp:ze(a),webauthn:Be(a),password:Re(a),flow:oe(a),refresh:Je(((t,e)=>xt(a.post(G,{},{token:t,queryParams:e})))),selectTenant:$t([Tt("tenantId")],[Rt('"token" must be string or undefined')])(((t,e)=>xt(a.post(J,{tenant:t},{token:e})))),logout:Je((t=>xt(a.post(X,{},{token:t})))),logoutAll:Je((t=>xt(a.post(Z,{},{token:t})))),me:Je((t=>xt(a.get(Q,{token:t})))),history:Je((t=>xt(a.get(Y,{token:t})))),isJwtExpired:Ge(bt),getTenants:Ge(wt),getJwtPermissions:Ge(yt),getJwtRoles:Ge(kt),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>{var n;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((t,e)=>e(t)),e)},afterRequest:async(e,n)=>{var o;const i=[].concat((null===(o=t.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))},transformResponse:null===(e=t.hooks)||void 0===e?void 0:e.transformResponse}}))})),Qe=Object.assign(Ze,{DeliveryMethods:zt});
1
+ !function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function i(t,e,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 e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n}"function"==typeof SuppressedError&&SuppressedError;class r extends Error{}function s(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(t){return decodeURIComponent(atob(t).replace(/(.)/g,((t,e)=>{let n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return atob(e)}}function a(t,e){if("string"!=typeof t)throw new r("Invalid token specified: must be a string");e||(e={});const n=!0===e.header?0:1,o=t.split(".")[n];if("string"!=typeof o)throw new r(`Invalid token specified: missing part #${n+1}`);let i;try{i=s(o)}catch(t){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${t.message})`)}try{return JSON.parse(i)}catch(t){throw new r(`Invalid token specified: invalid json for part #${n+1} (${t.message})`)}}r.prototype.name="InvalidTokenError";var l="/v1/auth/accesskey/exchange",c="/v1/auth/otp/verify",d="/v1/auth/otp/signin",u="/v1/auth/otp/signup",h={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},p="/v1/auth/otp/signup-in",f="/v1/auth/magiclink/verify",g="/v1/auth/magiclink/signin",v="/v1/auth/magiclink/signup",m={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},b="/v1/auth/magiclink/signup-in",w="/v1/auth/enchantedlink/verify",y="/v1/auth/enchantedlink/signin",k="/v1/auth/enchantedlink/signup",I="/v1/auth/enchantedlink/pending-session",x={email:"/v1/auth/enchantedlink/update/email"},C="/v1/auth/enchantedlink/signup-in",j="/v1/auth/oauth/authorize",A="/v1/auth/oauth/exchange",S="v1/auth/oauth/native/start",O="v1/auth/oauth/native/finish",E="/v1/auth/saml/authorize",U="/v1/auth/saml/exchange",L="/v1/auth/totp/verify",T="/v1/auth/totp/signup",_="/v1/auth/totp/update",R="/v1/auth/notp/whatsapp/signin",M="/v1/auth/notp/whatsapp/signup",$="/v1/auth/notp/whatsapp/signup-in",P="/v1/auth/notp/pending-session",D={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},W={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},N={start:"/v1/auth/webauthn/signup-in/start"},F={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},q="/v1/auth/password/signup",B="/v1/auth/password/signin",H="/v1/auth/password/reset",V="/v1/auth/password/update",K="/v1/auth/password/replace",z="/v1/auth/password/policy",G="/v1/auth/refresh",J="/v1/auth/tenant/select",X="/v1/auth/logout",Z="/v1/auth/logoutall",Q="/v1/auth/me",Y="/v1/auth/me/tenants",tt="/v1/auth/me/history",et="/v1/flow/start",nt="/v1/flow/next";const ot="<region>",it=`https://api.${ot}descope.com`,rt=6e5,st="dct",at=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};var lt,ct;(ct=lt||(lt={})).get="GET",ct.delete="DELETE",ct.post="POST",ct.put="PUT",ct.patch="PATCH";const dt=({path:t,baseUrl:e,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);e=e.replace(ot,i?i+".":"");let r=t?`${e.replace(/\/$/,"")}/${null==t?void 0:t.replace(/^\//,"")}`:e;if(n){r=`${r}?`;const t=Object.keys(n);t.forEach(((e,o)=>{r=`${r}${e}=${n[e]}${o===t.length-1?"":"&"}`}))}return r},ut=(...t)=>new Headers(t.reduce(((t,e)=>{const n=(t=>Array.isArray(t)?t:t instanceof Headers?Array.from(t.entries()):t?Object.entries(t):[])(e);return n.reduce(((e,[n,o])=>(t[n]=o,t)),t),t}),{})),ht={"Content-Type":"application/json"},pt=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},ft=t=>{try{t=JSON.parse(t)}catch(t){return!1}return"object"==typeof t&&null!==t},gt=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=(t=>async(...e)=>{const n=await t(...e),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(e||fetch);return n||null==t||t.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"),t?async(...e)=>{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");t.log((t=>at().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const o=await n(...e);return t[o.ok?"log":"error"](await(async t=>{const e=await t.text();return at().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).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=(t=>void 0===t?void 0:JSON.stringify(t))(d),v={headers:ut(pt(e,f),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.25.0"},(null==n?void 0:n.baseHeaders)||{},ft(g)?ht:{},u),method:p,body:g};null!==r&&(v.credentials=r||"include");const m=await a(dt({path:c,baseUrl:t,queryParams:h,projectId:e}),v);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==m?void 0:m.clone()),null==i?void 0:i.transformResponse){const t=await m.json(),e=((null===(s=m.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((t,e)=>{const[n,o]=e.split("=");return Object.assign(Object.assign({},t),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(t),cookies:e});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:lt.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:lt.post,token:i}),patch:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:lt.patch,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:lt.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:lt.delete,token:o}),hooks:i,buildUrl:(n,o)=>dt({projectId:e,baseUrl:t,path:n,queryParams:o})}};var vt=429;function mt(t,e,n){var o;let i=bt(t);if(e){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[st])===e)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[e]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function bt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return a(t)}function wt(t){const{exp:e}=bt(t);return(new Date).getTime()/1e3>e}function yt(t){let e=bt(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function kt(t,e){return mt(t,e,"permissions")}function It(t,e){return mt(t,e,"roles")}const xt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Ct(t,e){var n;const o=await t,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=e?e(r):r:(i.error=r,o.status===vt&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const jt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),At=(t,e)=>(n=e)=>e=>{const o=t.filter((t=>t(e)));return!(o.length<t.length)&&(n?n.replace("{val}",e):o.join(" OR "))},St=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ot=t=>e=>t.test(e),Et=Ot(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ut=Ot(/^\+[1-9]{1}[0-9]{3,14}$/),Lt=jt(Et,'"{val}" is not a valid email'),Tt=jt(Ut,'"{val}" is not a valid phone number'),_t=jt((t=>t.length>=1),"Minimum length is 1");const Rt=jt((t=>"string"==typeof t),"Input is not a string"),Mt=jt((t=>Array.isArray(t)),"Input is not an array"),$t=jt((t=>"boolean"==typeof t),"Input is not a boolean"),Pt=jt((t=>void 0===t),"Input is defined"),Dt=At([Rt(),Pt()],"Input is not a string or undefined"),Wt=At([Mt(),$t()],"Input is not an array or boolean"),Nt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>St(...t).validate(n[e]))),e(...n)),Ft=t=>[Rt(`"${t}" must be a string`)],qt=t=>[Rt(`"${t}" must be a string`),_t(`"${t}" must not be empty`)],Bt=t=>[Rt(`"${t}" must be a string`),Lt()],Ht=t=>[Rt(`"${t}" must be a string`),Tt()],Vt=Nt(qt("accessKey")),Kt=t=>({exchange:Vt(((e,n)=>Ct(t.post(l,{loginOptions:n},{token:e}))))}),zt=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let i=o.shift(),r=t;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${e}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${e}" is not a function`);const s=r[i];r[i]=n(s)})),t),Gt=({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||rt,rt)});var Jt,Xt;!function(t){t.sms="sms",t.voice="voice",t.whatsapp="whatsapp"}(Jt||(Jt={})),function(t){t.email="email"}(Xt||(Xt={}));const Zt=Object.assign(Object.assign({},Jt),Xt);var Qt;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(Qt||(Qt={}));const Yt=qt("loginId"),te=Nt(qt("token")),ee=Nt(Yt),ne=Nt(qt("pendingRef")),oe=Nt(Yt,Bt("email")),ie=t=>({verify:te((e=>Ct(t.post(w,{token:e})))),signIn:ee(((e,n,o,i)=>Ct(t.post(xt(y,Zt.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:ee(((e,n,o)=>Ct(t.post(xt(C,Zt.email),{loginId:e,URI:n,loginOptions:o})))),signUp:ee(((e,n,o,i)=>Ct(t.post(xt(k,Zt.email),{loginId:e,URI:n,user:o,loginOptions:i})))),waitForSession:ne(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Gt(n);let s;const a=setInterval((async()=>{const n=await t.post(I,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Ct(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:oe(((e,n,o,i,r)=>Ct(t.post(x.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),re=Nt(qt("flowId")),se=Nt(qt("executionId"),qt("stepId"),qt("interactionId")),ae=t=>({start:re(((e,n,o,i,r,s,a)=>Ct(t.post(et,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:se(((e,n,o,i,r,s)=>Ct(t.post(nt,{executionId:e,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),le=qt("loginId"),ce=Nt(qt("token")),de=Nt(le),ue=Nt(le,Ht("phone")),he=Nt(le,Bt("email")),pe=Object.keys(Zt).filter((t=>t!==Jt.voice)),fe=t=>({verify:ce((e=>Ct(t.post(f,{token:e})))),signIn:pe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:de(((e,o,i,r)=>Ct(t.post(xt(g,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:pe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:de(((e,o,i,r)=>Ct(t.post(xt(v,n),{loginId:e,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:pe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:de(((e,o,i)=>Ct(t.post(xt(b,n),{loginId:e,URI:o,loginOptions:i}))))})),{}),update:{email:he(((e,n,o,i,r)=>Ct(t.post(m.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(Jt).filter((t=>t!==Jt.voice)).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i,r,s)=>Ct(t.post(xt(m.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var ge;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple",t.discord="discord",t.linkedin="linkedin",t.slack="slack"}(ge||(ge={}));const ve=Nt(qt("code")),me=t=>({start:Object.assign(((e,n,o,i)=>Ct(t.post(j,o||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:i}))),Object.keys(ge).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>Ct(t.post(j,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{})),exchange:ve((e=>Ct(t.post(A,{code:e})))),startNative:(e,n,o)=>Ct(t.post(S,{provider:e,loginOptions:n,implicit:o})),finishNative:(e,n,o,i,r)=>Ct(t.post(O,{provider:e,stateId:n,user:o,code:i,idToken:r}))}),be=qt("loginId"),we=Nt(be,qt("code")),ye=Nt(be),ke=Nt(be,Ht("phone")),Ie=Nt(be,Bt("email")),xe=t=>({verify:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:we(((e,o)=>Ct(t.post(xt(c,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ye(((e,o,i)=>Ct(t.post(xt(d,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ye(((e,o,i)=>Ct(t.post(xt(u,n),{loginId:e,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ye(((e,o)=>Ct(t.post(xt(p,n),{loginId:e,loginOptions:o}))))})),{}),update:{email:Ie(((e,n,o,i)=>Ct(t.post(h.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(Jt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o,i,r)=>Ct(t.post(xt(h.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),Ce=Nt(qt("tenant")),je=Nt(qt("code")),Ae=t=>({start:Ce(((e,n,o,i)=>Ct(t.post(E,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:je((e=>Ct(t.post(U,{code:e}))))}),Se=qt("loginId"),Oe=Nt(Se,qt("code")),Ee=Nt(Se),Ue=Nt(Se),Le=t=>({signUp:Ee(((e,n)=>Ct(t.post(T,{loginId:e,user:n})))),verify:Oe(((e,n,o,i)=>Ct(t.post(L,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Ue(((e,n)=>Ct(t.post(_,{loginId:e},{token:n}))))}),Te=qt("loginId"),_e=qt("newPassword"),Re=Nt(Te,qt("password")),Me=Nt(Te),$e=Nt(Te,_e),Pe=Nt(Te,qt("oldPassword"),_e),De=t=>({signUp:Re(((e,n,o,i)=>Ct(t.post(q,{loginId:e,password:n,user:o,loginOptions:i})))),signIn:Re(((e,n,o)=>Ct(t.post(B,{loginId:e,password:n,loginOptions:o})))),sendReset:Me(((e,n,o)=>Ct(t.post(H,{loginId:e,redirectUrl:n,templateOptions:o})))),update:$e(((e,n,o)=>Ct(t.post(V,{loginId:e,newPassword:n},{token:o})))),replace:Pe(((e,n,o)=>Ct(t.post(K,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>Ct(t.get(z))}),We=Ft("loginId"),Ne=qt("loginId"),Fe=qt("origin"),qe=Nt(Ne,Fe,qt("name")),Be=Nt(Ne,Fe),He=Nt(We,Fe),Ve=Nt(Ne,Fe,qt("token")),Ke=Nt(qt("transactionId"),qt("response")),ze=t=>({signUp:{start:qe(((e,n,o)=>Ct(t.post(D.start,{user:{loginId:e,name:o},origin:n})))),finish:Ke(((e,n)=>Ct(t.post(D.finish,{transactionId:e,response:n}))))},signIn:{start:He(((e,n,o,i)=>Ct(t.post(W.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:Ke(((e,n)=>Ct(t.post(W.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Be(((e,n)=>Ct(t.post(N.start,{loginId:e,origin:n}))))},update:{start:Ve(((e,n,o)=>Ct(t.post(F.start,{loginId:e,origin:n},{token:o})))),finish:Ke(((e,n)=>Ct(t.post(F.finish,{transactionId:e,response:n}))))}}),Ge=Ft("loginId"),Je=Nt(Ge),Xe=Nt(qt("pendingRef")),Ze=t=>({signUpOrIn:Je(((e,n)=>Ct(t.post($,{loginId:e,loginOptions:n})))),signUp:Je(((e,n,o)=>Ct(t.post(M,{loginId:e,user:n,loginOptions:o})))),signIn:Je(((e,n,o)=>Ct(t.post(R,{loginId:e,loginOptions:n},{token:o})))),waitForSession:Xe(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Gt(n);let s;const a=setInterval((async()=>{const n=await t.post(P,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Ct(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Qe=Nt(qt("token")),Ye=Nt([Dt('"token" must be string or undefined')]);var tn,en=Nt([(tn=qt("projectId"),jt(((t,e)=>n=>St(...e).validate(((t,e)=>{const n=(Array.isArray(e)?e.join("."):String(e)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((t,e,n)=>"."+n)).split("."),o=n.length;let i=0,r=t===Object(t)?t:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,t)))("projectId",tn))())])((t=>{var e;return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=gt({baseUrl:n||it,projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Kt(a),otp:xe(a),magicLink:fe(a),enchantedLink:ie(a),oauth:me(a),saml:Ae(a),totp:Le(a),notp:Ze(a),webauthn:ze(a),password:De(a),flow:ae(a),refresh:Ye(((t,e)=>Ct(a.post(G,{},{token:t,queryParams:e})))),selectTenant:Nt([Rt("tenantId")],[Dt('"token" must be string or undefined')])(((t,e)=>Ct(a.post(J,{tenant:t},{token:e})))),logout:Ye((t=>Ct(a.post(X,{},{token:t})))),logoutAll:Ye((t=>Ct(a.post(Z,{},{token:t})))),me:Ye((t=>Ct(a.get(Q,{token:t})))),myTenants:Nt([Wt('"tenants" must a string array or a boolean')],[Dt('"token" must be string or undefined')])(((t,e)=>{const n={};return"boolean"==typeof t?n.dct=t:n.ids=t,Ct(a.post(Y,n,{token:e}))})),history:Ye((t=>Ct(a.get(tt,{token:t})))),isJwtExpired:Qe(wt),getTenants:Qe(yt),getJwtPermissions:Qe(kt),getJwtRoles:Qe(It),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>{var n;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((t,e)=>e(t)),e)},afterRequest:async(e,n)=>{var o;const i=[].concat((null===(o=t.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))},transformResponse:null===(e=t.hooks)||void 0===e?void 0:e.transformResponse}}))})),nn=Object.assign(en,{DeliveryMethods:Zt});
2
2
  /*! js-cookie v3.0.5 | MIT */
3
- function Ye(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}var tn=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=Ye({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).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=t+"="+e.write(o,t)+r}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){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]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",Ye({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Ye({},this.attributes,e))},withConverter:function(e){return t(Ye({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var en={default:"endpoint"},nn="Blocked by CSP",on="The endpoint parameter is not a valid URL",rn="Failed to load the JS script of the agent",sn="9319";function an(t,e){var n,o,i,r,s=[],a=(n=function(t){var e=function(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}([],t,!0);return{current:function(){return e[0]},postpone:function(){var t=e.shift();void 0!==t&&e.push(t)},exclude:function(){e.shift()}}}(t),r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(t,e){var r,s=e instanceof Error?e.message:"";if(s===nn||s===on)n.exclude(),r=0;else if(s===sn)n.exclude();else if(s===rn){var a=Date.now()-t.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:t.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(t){var n=new Date,o=function(e){return s.push({url:t,startedAt:n,finishedAt:new Date,error:e})},i=e(t);return i.then((function(){return o()}),o),i.catch((function(t){if(s.length>=5)throw t;var e=c(n,t);if(!e)throw t;var o,i=e[0],r=e[1];return(o=r,new Promise((function(t){return setTimeout(t,o)}))).then((function(){return d(i)}))}))};return d(l).then((function(t){return[t,s]}))}var ln="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",cn=ln;function dn(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:ln,c=function(){var t=[],e=function(){t.push({time:new Date,state:document.visibilityState})},n=function(t,e,n,o){return t.addEventListener(e,n,o),function(){return t.removeEventListener(e,n,o)}}(document,"visibilitychange",e);return e(),[t,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var t=function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.9.9"):t}))}(String(t),e)}))}(l,s);return an(t,un)})).catch((function(t){throw u(),function(t){return t instanceof Error&&t.message===sn?new Error(rn):t}(t)})).then((function(e){var n=e[0],o=e[1];return u(),n.load(t(t({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function un(t){return function(t,e,n,o){var i,r=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),o=e.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=e,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return null==o||o.then(l,l),Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){var e=new MessageChannel;e.port1.onmessage=function(){return t()},e.port2.postMessage(null)})).then((function(){if(l(),i)return n(i);throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(on);var o=document.createElement("script"),i=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),e()},o.onerror=function(){i(),n(new Error(rn))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)}),(function(){throw new Error(nn)})).then(hn)}function hn(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==o?void 0:o.configurable)?delete t[e]:o&&!o.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error(sn);return n}const pn=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=t.hooks)||void 0===i?void 0:i[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},fn=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},gn=async t=>{const e=await fn(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},vn="undefined"!=typeof localStorage,mn=(t,e)=>vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),bn=t=>vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),wn=t=>vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),yn=(...t)=>{console.debug(...t)},kn="undefined"!=typeof window,In=Math.pow(2,31)-1,xn="DS",Cn="DSR";function jn(t=""){return bn(`${t}${Cn}`)||""}function An(t=""){return tn.get(xn)||bn(`${t}${xn}`)||""}function Sn(t=""){wn(`${t}${Cn}`),wn(`${t}${xn}`),tn.remove(xn)}const On=kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",En="fp",Un=(t=!1)=>{const e=localStorage.getItem(En);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Ln=async(t,e=On)=>{try{if(Un())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(e);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(e);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=dn({apiKey:t,endpoint:[o.toString(),en],scriptUrlPattern:[r,cn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((t,e)=>({vsid:t,vrid:e}))(n,l);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(En,JSON.stringify(e))})(c)}catch(t){console.warn("Could not load fingerprint",t)}},Tn=t=>{const e=Un(!0);return e&&t.body&&(t.body.fpData=e),t},_n="dls_last_user_login_id",Rn="dls_last_user_display_name",Mn=()=>bn(_n),$n=()=>bn(Rn),Pn=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Mn(),r=$n();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)};function Dn(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}async function Wn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Vn(n.publicKey.challenge),n.publicKey.user.id=Vn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Vn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Kn(n.rawId),type:n.type,response:{attestationObject:Kn(n.response.attestationObject),clientDataJSON:Kn(n.response.clientDataJSON)}});var n}async function Nn(t){const e=Bn(t);return Hn(await navigator.credentials.get(e))}async function Fn(t,e){const n=Bn(t);return n.signal=e.signal,n.mediation="conditional",Hn(await navigator.credentials.get(n))}async function qn(t=!1){if(!kn)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Bn(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Vn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Vn(t.id)})),n}function Hn(t){return JSON.stringify({id:t.id,rawId:Kn(t.rawId),type:t.type,response:{authenticatorData:Kn(t.response.authenticatorData),clientDataJSON:Kn(t.response.clientDataJSON),signature:Kn(t.response.signature),userHandle:t.response.userHandle?Kn(t.response.userHandle):void 0}})}function Vn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Kn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var zn,Gn=(zn=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Wn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await Nn(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await Wn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Nn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Wn(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Wn,get:Nn,isSupported:qn,conditional:Fn}}),(...t)=>{const e=zn(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const Jn="/fedcm/config",Xn=(t,e)=>({async oneTap(e,n,o,i){const r=null!=e?e:"google",s=await t.oauth.startNative(r,o,!0);if(!s.ok)return s;const{clientId:a,stateId:l,nonce:c}=s.data,d=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(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?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{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=>{e(t.oauth.finishNative(r,l,"","",n.credential))},nonce:c})),d.prompt((t=>{(null==t?void 0:t.isSkippedMoment())&&(null==i||i())}))}))},async launch(n){var o;const i={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+Jn),clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return t.refresh(r.token)},isSupported:()=>kn&&"IdentityCredential"in window});var Zn=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await qn(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const Qn=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return kn?(o&&i&&Ln(o).catch((()=>null)),t(pn(r,{beforeRequest:Tn}))):t(r)}),(t=>n=>{var{autoRefresh:o}=n,i=e(n,["autoRefresh"]);if(!o)return t(i);const{clearAllTimers:r,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let l,c;kn&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>l&&(yn("Expiration time passed, refreshing session"),d.refresh(jn()||c))}));const d=t(pn(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await fn(e);if(401===(null==e?void 0:e.status))yn("Received 401, canceling all timers"),r();else if(o){if(l=(t=>{try{const e=a(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(o),!l)return void yn("Could not extract expiration time from session token");c=n;let t=((i=l)?i.getTime()-(new Date).getTime():0)-2e4;t>In&&(yn(`Timeout is too large (${t}ms), setting it to ${In}ms`),t=In),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});yn(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{yn("Refreshing session due to timer"),d.refresh(jn()||n)}),t)}var i}}));return Bt(d,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return yn("Clearing all timers"),r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.16.4"},e.baseHeaders)}))),(t=>e=>{const n=Dn(),o=Dn(),i=t(pn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await gn(e);t&&o.pub(t);const{sessionJwt:i}=await fn(e);i&&n.pub(i)}}})),r=Bt(i,["logout","logoutAll"],(t=>async(...e)=>{const i=await t(...e);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(t(r),{getLastUserLoginId:Mn,getLastUserDisplayName:$n});const s=t(pn(r,{afterRequest:async(t,e)=>{var n;const o=await gn(e),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((t=>{mn(_n,t)})(i),(t=>{mn(Rn,t)})(r))}}));let a=Bt(s,["flow.start"],Pn);return a=Bt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return t||(wn(_n),wn(Rn)),o})(i)),Object.assign(a,{getLastUserLoginId:Mn,getLastUserDisplayName:$n})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!kn)return t(s);const a=t(pn(s,{beforeRequest:(l=r,t=>Object.assign(t,{token:t.token||jn(l)})),afterRequest:async(t,n)=>{const o=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?o||Sn(r):((t={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&mn(`${o}${Cn}`,i),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);tn.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(xn,r,s):mn(`${o}${xn}`,r))})(await fn(n),i,r)}}));var l;const c=Bt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return Sn(t),o})(r));return Object.assign(c,{getRefreshToken:()=>jn(r),getSessionToken:()=>An(r)})}))(((...t)=>{const e=Qe(...t);return Object.assign(Object.assign({},e),{refresh:t=>{const n=An();return e.refresh(t,{dcs:n?"t":"f"})},flow:Zn(e),webauthn:Gn(e),fedcm:Xn(e,t[0].projectId)})})),Yn="undefined"!=typeof localStorage,to="J151000",eo=Yn&&localStorage.getItem("base.content.url")||"",no="config.json",oo="base.ui.components.url";Yn&&localStorage.getItem(oo),Yn&&localStorage.getItem(oo);const io="descope-login-flow",ro="code",so="ra-challenge",ao="ra-callback",lo="ra-backup-callback",co="ra-initiator",uo="data-exclude-field",ho="dls_last_auth",po="state_id",fo="saml_idp_state_id",go="saml_idp_username",vo="descope_idp_initiated",mo="sso_app_id",bo="oidc_login_hint",wo="oidc_prompt",yo="oidc_error_redirect_uri",ko="data-type",Io="redirect",xo="poll",Co="webauthnCreate",jo="webauthnGet",Ao="loadForm",So="submit",Oo="polling",Eo=["descope-multi-select-combo-box","descope-text-area"];var Uo;function Lo(t){return new URLSearchParams(window.location.search).get(t)}function To(t){if(window.history.replaceState&&Lo(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function _o(t,e){return n(this,void 0,void 0,(function*(){const n=yield fetch(t,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${t} [${n.status}]`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(Uo||(Uo={}));function Ro({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(eo||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.toString()}function Mo(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Uo.forward:n<o?Uo.backward:void 0}const $o=()=>{const[t="",e=""]=(Lo(io)||"").split("_");return{executionId:t,stepId:e}};function Po(){To(io)}const Do=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),Wo=()=>{const{executionId:t,stepId:e}=$o();(t||e)&&Po();const n=Lo("t")||void 0;n&&To("t");const o=Lo(ro)||void 0;o&&To(ro);const i=Lo("err")||void 0;i&&To("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:Lo(so),redirectAuthCallbackUrl:Lo(ao),redirectAuthBackupCallbackUri:Lo(lo),redirectAuthInitiator:Lo(co)};(r||s||a||l)&&(To(so),To(ao),To(lo),To(co));const c=Lo(po);c&&To(po);const d=Lo(fo);d&&To(fo);const u=Lo(go);d&&To(go);const h=Lo(vo);h&&To(vo);const p=Lo(mo);p&&To(mo);const f=Lo(bo);f&&To(bo);const g=Lo(wo);g&&To(wo);const v=Lo(yo);v&&To(yo);return{executionId:t,stepId:e,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:c,samlIdpStateId:d,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:f,oidcPrompt:g,oidcErrorRedirectUri:v}}},No=t=>{let e,n;return(...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}};const Fo=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||n||o||i||r||s||a),qo=t=>null==t?void 0:t.submit(),Bo=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Ho=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Vo(t){if(t)return{locale:t.toLowerCase(),fallback:t.toLowerCase()};const e=navigator.language;return e?e.includes("-")?{locale:e.toLowerCase(),fallback:e.split("-")[0].toLowerCase()}:{locale:e.toLowerCase(),fallback:e.toLowerCase()}:{locale:"",fallback:""}}var Ko,zo,Go,Jo;function Xo(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Xo(r,s))return!1}else if(r!==s)return!1}return!0}class Zo{constructor(t={},{updateOnlyOnChange:e=!0}={}){Ko.set(this,void 0),zo.set(this,{}),Go.set(this,0),Jo.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,Ko,"f")):t,n=Object.assign(Object.assign({},o(this,Ko,"f")),e);if(!o(this,Jo,"f")||!Xo(o(this,Ko,"f"),n)){const t=o(this,Ko,"f");i(this,Ko,n,"f"),Object.freeze(o(this,Ko,"f")),setTimeout((()=>{Object.values(o(this,zo,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,Ko,t,"f"),i(this,Jo,e,"f")}get current(){return Object.assign({},o(this,Ko,"f"))}subscribe(t){return i(this,Go,o(this,Go,"f")+1,"f"),o(this,zo,"f")[o(this,Go,"f")]=t,o(this,Go,"f").toString()}unsubscribe(t){const e=!!o(this,zo,"f")[t];return e&&delete o(this,zo,"f")[t],e}unsubscribeAll(){return i(this,zo,{},"f"),!0}}Ko=new WeakMap,zo=new WeakMap,Go=new WeakMap,Jo=new WeakMap;const Qo=["disabled"],Yo=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${uo}])`)).forEach((t=>{t.value=n}))}))},ti=(t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),ei=(t,e,n)=>{t.querySelectorAll(`[${ko}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},ni=(t,e,n)=>{var o,i;const r=null===(o=customElements.get(e))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==t?void 0:t.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},oi=(t,e,n,o,i,r)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==i?void 0:i({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){r.error("Error transforming error message",t.message)}((t,e,n="")=>{t.querySelectorAll(`[${ko}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),ei(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ei(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{t.textContent=ti(t.textContent,e);const n=t.getAttribute("href");n&&t.setAttribute("href",ti(n,e))}))})(t,e),((t,e,n)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const i=e[o];Object.keys(i).forEach((e=>{let o=i[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){n.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,n,r),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=ti(t.value,e)}))}))})(t,e),((t,e)=>{Object.entries(e).forEach((([e,n])=>{t.querySelectorAll(`[name="${e}"]`).forEach((t=>{Object.entries(n).forEach((([e,n])=>{Qo.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,o)},ii=No((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o,i;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),s=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0})()>=108;return yield(n=100,o=r,i=s,new Promise(((t,e)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==i?t(i):e(new Error(`Promise timed out after ${n} ms`))}),n);o.then((e=>{r||(clearTimeout(s),t(e))})).catch((t=>{r||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),ri=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},si={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function ai(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(ho)))}catch(t){}return e}const li="dls_ab_testing_id";function ci(...t){return e=>t.reduce(((t,e)=>e(t)),e)}const di=t=>{const e=Symbol((t=>{const e=t.toString();let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n&=n;return n.toString(16)})(t));return n=>{if(n[e])return n;const o=t(n);return o[e]=!0,o}};var ui,hi,pi,fi,gi,vi;function mi(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!mi(r,s))return!1}else if(r!==s)return!1}return!0}class bi{constructor(t={},{updateOnlyOnChange:e=!0}={}){ui.set(this,void 0),hi.set(this,{}),pi.set(this,0),fi.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,ui,"f")):t,n=Object.assign(Object.assign({},o(this,ui,"f")),e);if(!o(this,fi,"f")||!mi(o(this,ui,"f"),n)){const t=o(this,ui,"f");i(this,ui,n,"f"),Object.freeze(o(this,ui,"f")),setTimeout((()=>{Object.values(o(this,hi,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,ui,t,"f"),i(this,fi,e,"f")}get current(){return Object.assign({},o(this,ui,"f"))}subscribe(t){return i(this,pi,o(this,pi,"f")+1,"f"),o(this,hi,"f")[o(this,pi,"f")]=t,o(this,pi,"f").toString()}unsubscribe(t){const e=!!o(this,hi,"f")[t];return e&&delete o(this,hi,"f")[t],e}unsubscribeAll(){return i(this,hi,{},"f"),!0}}ui=new WeakMap,hi=new WeakMap,pi=new WeakMap,fi=new WeakMap;class wi{constructor(t,e){gi.set(this,void 0),this.nodeName="",i(this,gi,t,"f"),this.logger=e.logger}get asyncEle(){return(async t=>new Promise((e=>{const n=setInterval((()=>{const o="function"==typeof t?t():t;o&&(clearInterval(n),e(o))}),100);setTimeout((()=>{clearInterval(n),e(null)}),1e3)})))(o(this,gi,"f"))}get ele(){var t,e;const n="function"==typeof o(this,gi,"f")?o(this,gi,"f").call(this):o(this,gi,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(e=this.logger)||void 0===e||e.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(t=this.logger)||void 0===t||t.debug("no element for driver ",this.constructor.name,new Error),null)}}gi=new WeakMap;class yi extends wi{constructor(){super(...arguments),vi.set(this,void 0),this.nodeName="descope-modal"}close(){var t,e;null===(t=this.ele)||void 0===t||t.removeAttribute("opened"),null===(e=this.afterClose)||void 0===e||e.call(this)}async open(){var t,e;await(null===(t=this.beforeOpen)||void 0===t?void 0:t.call(this)),null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}reset(){var t;this.ele&&(this.ele.innerHTML=""),o(this,vi,"f")&&(null===(t=this.ele)||void 0===t||t.append(o(this,vi,"f").content.cloneNode(!0)))}setContent(t){i(this,vi,t,"f"),this.reset()}remove(){var t;null===(t=this.ele)||void 0===t||t.remove()}}vi=new WeakMap;class ki extends wi{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var t;null===(t=this.ele)||void 0===t||t.removeAttribute("opened")}show(){var t;null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}setContent(t){this.ele.innerHTML="",this.ele.appendChild(t.content.cloneNode(!0))}remove(){var t;null===(t=this.ele)||void 0===t||t.remove()}}const Ii=["error","warn","info","debug"],xi=di((t=>{var e,n,r,s;return s=class extends t{constructor(){super(...arguments),e.add(this),n.set(this,o(this,e,"m",r).call(this,console))}set logger(t){i(this,n,o(this,e,"m",r).call(this,t),"f")}get logger(){return o(this,n,"f")}onLogEvent(t,e){}},n=new WeakMap,e=new WeakSet,r=function(t){return Ii.reduce(((e,n)=>(e[n]=(...e)=>{var o;this.onLogEvent(n,e),null===(o=t[n])||void 0===o||o.call(t,...e)},e)),{})},s})),Ci="undefined"!=typeof localStorage,ji=Ci&&localStorage.getItem("base.content.url")||"",Ai=(t,e)=>!e&&`${t} cannot be empty, please make sure to set this attribute`,Si=di((t=>{var e,n;return n=class extends t{constructor(){super(...arguments),e.set(this,!0)}connectedCallback(){var t,n;null===(t=super.connectedCallback)||void 0===t||t.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,e,"f")&&(i(this,e,!1,"f"),this.init())}async init(){}},e=new WeakMap,n})),Oi=di((t=>{var e,n;const i=ci(xi,Si)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,{})}async init(){var t,n,i;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),n=this,i=t=>{var n;null===(n=o(this,e,"f")[t])||void 0===n||n.forEach((e=>{e(t,this.getAttribute(t))}))},Array.from(n.attributes).forEach((t=>i(t.name))),new MutationObserver((t=>{t.forEach((t=>{"attributes"===t.type&&i(t.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(t,n){o(this,e,"f")[t]||(o(this,e,"f")[t]=[]);const i=o(this,e,"f")[t].push(n);return()=>o(this,e,"f")[t].splice(i,1)}observeAttributes(t,e){const n=t.reduce(((t,n)=>(t.push(this.observeAttribute(n,e)),t)),[]);return()=>n.forEach((t=>t()))}},e=new WeakMap,n})),Ei=t=>e=>{var n,i,r;const s=ci(xi,Si,Oi)(e),a=Object.keys(t);return r=class extends s{constructor(...t){super(...t),n.add(this),this.observeAttributes(a,o(this,n,"m",i).bind(this))}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),a.forEach((t=>o(this,n,"m",i).call(this,t,this.getAttribute(t))))}},n=new WeakSet,i=function(e,n){const o=t[e],i="function"==typeof o?o(e,n):o;i&&this.logger.error(i)},r};Ei.missingAttrValidator=Ai;const Ui=di((t=>{const e=ci(Ei({"project-id":Ai}))(t);return class extends e{get projectId(){return this.getAttribute("project-id")}}})),Li=di((t=>class extends t{get baseUrl(){return this.getAttribute("base-url")||""}}));const Ti=di((t=>{const e=ci(xi,Ui,Li)(t);return class extends e{async fetchStaticResource(t,e){const n=function({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(ji||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.toString()}({projectId:this.projectId,filename:t,baseUrl:this.baseStaticUrl}),o=await fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:await o[e](),headers:Object.fromEntries(o.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),_i=di((t=>{var e,n,r;const s=ci(Ti)(t);return r=class extends s{constructor(){super(...arguments),e.set(this,void 0),n.set(this,(async()=>{try{const{body:t,headers:e}=await this.fetchStaticResource("config.json","json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}get config(){return o(this,e,"f")||i(this,e,o(this,n,"f").call(this),"f"),o(this,e,"f")}},e=new WeakMap,n=new WeakMap,r}));di((t=>{var e,n,r,s,a,l,c;return c=class extends(ci(Si,xi)(t)){constructor(){super(...arguments),e.add(this),n.set(this,void 0),this.attributeChangedCallback=(t,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,t,n,i),"debug"===t&&o(this,e,"m",a).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(t,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,t,n),"error"===t&&o(this,e,"m",l).call(this,n[0]||"Error",n[1])}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),o(this,e,"m",a).call(this)}},n=new WeakMap,e=new WeakSet,r=function(){var t;null===(t=o(this,n,"f"))||void 0===t||t.remove(),i(this,n,null,"f")},s=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 ar})),document.body.appendChild(o(this,n,"f"))},a=function(){this.debug?o(this,e,"m",s).call(this):o(this,e,"m",r).call(this)},l=function(t,e){var i;t&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:t,description:e}))},c}));const Ri="load-descope-ui",Mi="base.ui.components.url",$i=Ci&&localStorage.getItem(Mi)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Pi=Ci&&localStorage.getItem(Mi)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Di=t=>{const e=document.createElement("script");return e.id=t,e},Wi=(t,e)=>t.replace("<version>",e),Ni=di((t=>{var e,n,r,s,a,l,c,d,u,h,p,f;const g=ci(xi,_i)(t);return f=class extends g{constructor(){super(...arguments),e.add(this),n.set(this,Symbol("errorCbs")),r.set(this,Symbol("loadCbs")),u.set(this,void 0)}get descopeUi(){return o(this,u,"f")||i(this,u,o(this,e,"m",p).call(this),"f"),o(this,u,"f")}async loadDescopeUiComponents(t){const n=Array.isArray(t)?t:(t=>[...Array.from(t.content.querySelectorAll("*")).reduce(((t,e)=>e.localName.startsWith("descope-")?t.add(e.localName):t),new Set)])(t);return Promise.all(n.map((t=>o(this,e,"m",h).call(this,t))))}},n=new WeakMap,r=new WeakMap,u=new WeakMap,e=new WeakSet,s=async function(){var t;const e=await this.config,n=null===(t=null==e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},a=function(t){const e=o(this,n,"f"),i=o(this,r,"f");t[e]=[],t[i]=[],Object.defineProperty(t,"onerror",{set(n){t[e].push(n)}}),Object.defineProperty(t,"onload",{set(e){t[i].push(e)}})},l=async function(t,n){this.logger.debug("Trying to load DescopeUI from a fallback URL");const i=Di("load-descope-ui-fallback-script");document.body.append(i),i.addEventListener("error",(()=>{t.forEach((t=>t(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${i.src}"`)))})),i.addEventListener("load",(()=>{n.forEach((t=>t()))})),i.src=Wi(Pi,await o(this,e,"m",s).call(this))},c=function(t){t.addEventListener("error",(()=>{t[o(this,n,"f")].forEach((e=>e(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${t.src}"`))),o(this,e,"m",l).call(this,t[o(this,n,"f")],t[o(this,r,"f")])})),t.addEventListener("load",(()=>{t[o(this,r,"f")].forEach((t=>t()))}))},d=async function(){if(document.querySelector(`script#${Ri}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const t=Di(Ri);document.body.append(t),o(this,e,"m",a).call(this,t),o(this,e,"m",c).call(this,t),t.src=Wi($i,await o(this,e,"m",s).call(this))}return document.getElementById(Ri)},h=async function(t){if(!!customElements.get(t))return void this.logger.debug(`Loading component "${t}" is skipped as it is already defined`);const e=await this.descopeUi;if(e[t])try{return await e[t]()}catch(e){if("NotSupportedError"!==e.name)throw e;console.debug(`Encountered an error while attempting to define the "${t}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${t}"`,`Descope UI does not have a component named "${t}", available components are: "${Object.keys(e).join(", ")}"`)},p=function(){return new Promise((t=>{globalThis.DescopeUI&&t(globalThis.DescopeUI),o(this,e,"m",d).call(this).then((e=>{e.onerror=this.logger.error,e.onload=()=>{this.logger.debug("DescopeUI was loaded"),t(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&t(globalThis.DescopeUI)}))}))}))},f})),Fi="content-root",qi="root",Bi=di((t=>class extends t{constructor(...t){var e,n;super(...t),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${qi}, #${Fi} {\n height: 100%;\n }\n #${qi} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${qi}">\n <div id="${Fi}"></div>\n </div>\n `,this.contentRootElement=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(Fi),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(qi)}})),Hi="descope-modal";di((t=>{var e,n;const i=ci(Si,Bi,Ni)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,(()=>{const t=this.loadDescopeUiComponents.bind(this);return class extends yi{setContent(e){t(e),super.setContent(e)}}})())}createModal(t){const n=((t={})=>{const e=document.createElement(Hi);return Object.keys(t).forEach((n=>{e.setAttribute(n,t[n])})),e})(Object.assign(Object.assign({},{}),t));return this.rootElement.append(n),new(o(this,e,"f"))(n,{logger:this.logger})}async init(){var t;this.loadDescopeUiComponents([Hi]),await(null===(t=super.init)||void 0===t?void 0:t.call(this))}},e=new WeakMap,n}));const Vi="descope-notification";di((t=>{var e,n;const i=ci(Si,Bi,Ni)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,(()=>{const t=this.loadDescopeUiComponents.bind(this);return class extends ki{setContent(e){const n="string"==typeof e?(t=>{const e=document.createElement("template");return e.innerHTML=t,e})(e):e;t(n),super.setContent(n)}}})())}createNotification(t){const n=((t={})=>{const e=document.createElement(Vi);return Object.keys(t).forEach((n=>{e.setAttribute(n,t[n])})),e})(Object.assign(Object.assign({},{}),t));return this.rootElement.append(n),new(o(this,e,"f"))(n,{logger:this.logger})}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),this.loadDescopeUiComponents([Vi])}},e=new WeakMap,n}));const Ki=(t,e)=>!!e&&"light"!==e&&"dark"!==e&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',zi=di((t=>{var e,n,r,s,a,l,c,d,u,h,p;const f=ci(Ei({theme:Ki}),Ti,Si,Ni,_i,Bi,Oi)(t);return p=class extends f{constructor(){super(...arguments),e.add(this),n.set(this,void 0),r.set(this,void 0)}get theme(){var t,e;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),o(this,e,"m",l).call(this),o(this,e,"m",c).call(this),o(this,e,"m",u).call(this),o(this,e,"m",h).call(this),this.observeAttributes(["theme"],(()=>{o(this,e,"m",u).call(this),o(this,e,"m",h).call(this)})),this.observeAttributes(["style-id"],(()=>{i(this,r,null,"f"),o(this,e,"m",u).call(this),o(this,e,"m",l).call(this),o(this,e,"m",c).call(this)}))}},n=new WeakMap,r=new WeakMap,e=new WeakSet,s=async function(){try{const{body:t}=await this.fetchStaticResource(`${this.styleId}.json`,"json");return t}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},a=function(){return o(this,r,"f")||(i(this,r,o(this,e,"m",s).call(this),"f"),o(this,r,"f").then((t=>this.logger.debug("Fetched theme",t)))),o(this,r,"f")},l=async function(){var t,r;const s=await o(this,e,"a",a);s&&(o(this,n,"f")||(i(this,n,document.createElement("style"),"f"),o(this,n,"f").id="global-style",this.shadowRoot.appendChild(o(this,n,"f"))),o(this,n,"f").innerText=((null===(t=null==s?void 0:s.light)||void 0===t?void 0:t.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||""))},c=async function(){var t,n;const i=Object.assign({},await o(this,e,"a",a));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(t=null==i?void 0:i.light)||void 0===t?void 0:t.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=async function(){var t,e;const{projectConfig:n}=await this.config||{},o=null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(e=null==r?void 0:r[this.theme])||void 0===e?void 0:e.fonts},u=async function(){const t=await o(this,e,"m",d).call(this);t?Object.values(t).forEach((t=>{t.url&&(this.logger.debug(`Loading font from URL "${t.url}"`),(t=>{const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url))})):this.logger.debug("No fonts to load")},h=async function(){this.rootElement.setAttribute("data-theme",this.theme);const t=await this.descopeUi;(null==t?void 0:t.componentsThemeManager)&&(t.componentsThemeManager.currentThemeName=this.theme)},p}));di((t=>class extends(xi(t)){validateForm(t){return this.getFormInputs(t).every((t=>{var e,n;return null===(e=t.reportValidity)||void 0===e||e.call(t),null===(n=t.checkValidity)||void 0===n?void 0:n.call(t)}))}getFormInputs(t){return t?Array.from(t.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(t){return this.getFormInputs(t).reduce(((t,e)=>Object.assign(t,{[e.getAttribute("name")]:e.value})),{})}setFormData(t,e){this.getFormInputs(t).forEach((t=>{e.hasOwnProperty(t.getAttribute("name"))&&(t.value=e[t.getAttribute("name")])}))}resetFormData(t){this.getFormInputs(t).forEach((t=>{t.value="",t.checked=!1}))}getFormFieldNames(t){return this.getFormInputs(t).map((t=>t.name))}disableFormField(t,e){var n;null===(n=this.getFormInputs(t).find((t=>t.name===e)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(t,e){var n;null===(n=this.getFormInputs(t).find((t=>t.name===e)))||void 0===n||n.remove()}})),di((t=>class extends t{get baseStaticUrl(){return this.getAttribute("base-static-url")||""}}));const Gi=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Ji,Xi,Zi,Qi,Yi,tr,er,nr,or,ir;const rr=document.createElement("template");rr.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`;let sr=class extends HTMLElement{constructor(){var t;super(),Ji.add(this),Xi.set(this,new bi({messages:[]})),Zi.set(this,void 0),Qi.set(this,void 0),Yi.set(this,void 0),tr.set(this,{resize:o(this,Ji,"m",ir).bind(this)}),this.attachShadow({mode:"open"}),null===(t=this.shadowRoot)||void 0===t||t.appendChild(rr.content.cloneNode(!0)),i(this,Zi,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Qi,o(this,Zi,"f").querySelector(".content"),"f"),i(this,Yi,o(this,Zi,"f").querySelector(".header"),"f")}updateData(t){o(this,Xi,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=Gi(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(o(this,Zi,"f"),o(this,Yi,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,tr,"f").resize),(t=o(this,Zi,"f")).onmousemove=e=>{var n;const o=e.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=t.onresize)||void 0===n||n.call(t,e)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,Zi,"f").onresize=o(this,Ji,"m",or).bind(this),o(this,Xi,"f").subscribe(o(this,Ji,"m",er).bind(this))}disconnectedCallback(){o(this,Xi,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,tr,"f").resize)}};Xi=new WeakMap,Zi=new WeakMap,Qi=new WeakMap,Yi=new WeakMap,tr=new WeakMap,Ji=new WeakSet,er=function(t){o(this,Ji,"m",nr).call(this,t),o(this,Ji,"m",or).call(this)},nr=function(t){o(this,Qi,"f").innerHTML=t.messages.map((t=>`\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 ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},or=function(){o(this,Qi,"f").querySelectorAll(".msg").forEach((t=>{const e=t,n=e.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},ir=function(){const[t,e]=Gi(o(this,Zi,"f"),Number.parseInt(o(this,Zi,"f").style.left,10),Number.parseInt(o(this,Zi,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Zi,"f").style.top=`${e}px`,o(this,Zi,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",sr);var ar=Object.freeze({__proto__:null});const lr=di((t=>{var e,n,i,r;return r=class extends t{constructor(){super(...arguments),e.add(this)}connectedCallback(){var t;o(this,e,"m",n).call(this)&&o(this,e,"m",i).call(this),null===(t=super.connectedCallback)||void 0===t||t.call(this)}},e=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},i=function(){const t=this.shadowRoot.host,e=document.createElement("form");e.style.width="100%",e.style.height="100%",t.parentElement.appendChild(e),e.appendChild(t)},r})),cr=document.createElement("template");cr.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t";const dr=(t,e="")=>Object.keys(t).reduce(((n,o)=>{var i;if("object"==typeof t[o]&&null!==t[o]&&!(null===(i=t[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),dr(t[o],`${e+o}.`));const r="object"==typeof t[o]?t[o]:{value:t[o]},s=Object.assign(Object.assign({},n),{[e+o]:r,[`form.${e}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${e}fullName`]:r,[`form.${e}fullName`]:r}):s}),[]);var ur,hr,pr,fr,gr,vr,mr,br,wr,yr,kr,Ir,xr,Cr,jr,Ar,Sr,Or,Er,Ur,Lr,Tr;const _r=ci(zi,lr)(HTMLElement);class Rr extends _r{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(t){super(),ur.add(this),pr.set(this,!1),this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),o(this,ur,"m",Lr).call(this,t,e)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",n={})=>{this.logger.info(t,e,n)},debug:(t,e="")=>{this.logger.debug(t,e)}},fr.set(this,new Zo),gr.set(this,new Zo),vr.set(this,{}),this.getComponentsContext=()=>o(this,vr,"f"),this.nextRequestStatus=new Zo({isLoading:!1}),mr.set(this,void 0),br.set(this,{popstate:o(this,ur,"m",Ir).bind(this),componentsContext:o(this,ur,"m",Or).bind(this)}),wr.set(this,void 0),Sr.set(this,No((()=>n(this,void 0,void 0,(function*(){const t=Ro({projectId:this.projectId,filename:no,baseUrl:this.baseStaticUrl});try{const{body:e,headers:n}=yield _o(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),i(this,wr,t,"f"),o(this,ur,"m",yr).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(t=>{try{return dr(JSON.parse(t))}catch(t){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return t=this.formConfig,e="value",Object.fromEntries(Object.entries(t).map((([t,n])=>[t,n[e]])));var t,e}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,Sr,"f").call(this);return t}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:t}=yield o(this,Sr,"f").call(this);return t}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var t,e;const n=yield this.getProjectConfig(),o=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e;if(yield null===(e=t.init)||void 0===e?void 0:e.call(this),o(this,gr,"f").subscribe(o(this,ur,"m",Ur).bind(this)),o(this,gr,"f").update({isDebug:this.debug}),o(this,ur,"m",kr).call(this),yield o(this,ur,"m",jr).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,Sr,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,ur,"m",Tr).call(this);const{executionId:n,stepId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=Wo();window.addEventListener("popstate",o(this,br,"f").popstate),window.addEventListener("components-context",o(this,br,"f").componentsContext),o(this,fr,"f").subscribe(o(this,ur,"m",Cr).bind(this)),o(this,fr,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:r,executionId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h},p)),i(this,pr,!0,"f")}))}disconnectedCallback(){o(this,fr,"f").unsubscribeAll(),o(this,gr,"f").unsubscribeAll(),o(this,ur,"m",Er).call(this),window.removeEventListener("popstate",o(this,br,"f").popstate),window.removeEventListener("components-context",o(this,br,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,pr,"f")&&e!==n&&hr.observedAttributes.includes(t)){o(this,ur,"m",kr).call(this);const i=null===e;o(this,fr,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Po()),{[Do(t)]:n,stepId:r,executionId:s}})),o(this,gr,"f").update({isDebug:this.debug})}}}function Mr(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var $r,Pr,Dr,Wr,Nr,Fr,qr,Br,Hr,Vr,Kr,zr,Gr,Jr,Xr,Zr,Qr,Yr,ts,es,ns,os,is,rs,ss,as,ls,cs,ds,us;hr=Rr,pr=new WeakMap,fr=new WeakMap,gr=new WeakMap,vr=new WeakMap,mr=new WeakMap,br=new WeakMap,wr=new WeakMap,Sr=new WeakMap,ur=new WeakSet,yr=function(){this.shadowRoot.appendChild(cr.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},kr=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];hr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[Do(e)])throw Error(`${e} cannot be empty`)}))},Ir=function(){const{stepId:t,executionId:e}=$o();o(this,fr,"f").update({stepId:t,executionId:e})},xr=function(t,e){this.sdk=Qn(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},hr.sdkConfigOverrides),{projectId:t,baseUrl:e})),["start","next"].forEach((t=>{const e=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield e(...t)}catch(t){return{error:{errorCode:to,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Cr=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n}=t;if(i("projectId")||i("baseUrl")){if(!e)return;o(this,ur,"m",xr).call(this,e,n)}o(this,wr,"f").call(this,t)}))},jr=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,Sr,"f").call(this)).isMissingConfig&&(yield o(this,ur,"m",Ar).call(this))}))},Ar=function(){return n(this,void 0,void 0,(function*(){const t=Ro({projectId:this.projectId,filename:no,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield _o(t,"json"),!0}catch(t){return!1}}))},Or=function(t){i(this,vr,Object.assign(Object.assign({},o(this,vr,"f")),t.detail),"f")},Er=function(){var t;null===(t=o(this,mr,"f"))||void 0===t||t.remove(),i(this,mr,null,"f")},Ur=function(t){return n(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,mr,document.createElement("descope-debugger"),"f"),Object.assign(o(this,mr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return gs})),document.body.appendChild(o(this,mr,"f"))):o(this,ur,"m",Er).call(this)}))},Lr=function(t,e){var n;t&&this.debug&&(null===(n=o(this,mr,"f"))||void 0===n||n.updateData({title:t,description:e}))},Tr=function(){this.rootElement.onkeydown=t=>{var e,n,o;const i=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),r=Eo.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==t.key||i||r)return;t.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((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(s).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},Rr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.24.1"}};class hs extends Rr{static set sdkConfigOverrides(t){Rr.sdkConfigOverrides=t}constructor(){const t=new Zo({deferredRedirect:!1});super(t.update.bind(t)),$r.add(this),this.stepState=new Zo({},{updateOnlyOnChange:!1}),Pr.set(this,void 0),Dr.set(this,null),Wr.set(this,{visibilitychange:o(this,$r,"m",Nr).bind(this)}),Fr.set(this,((t,e,r,s,a)=>{r===xo&&(this.logger.debug("polling - Scheduling polling request"),i(this,Pr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,i;this.logger.debug("polling - Calling next");const l=yield this.sdk.flow.next(t,e,Oo,s,a,{});if((null===(n=null==l?void 0:l.error)||void 0===n?void 0:n.errorCode)===to)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,Fr,"f").call(this,t,e,r,s,a);this.logger.debug("polling - Got a response"),(null==l?void 0:l.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(l.error,null,4)),o(this,Br,"f").call(this,l);const{action:c}=null!==(i=null==l?void 0:l.data)&&void 0!==i?i:{};o(this,Fr,"f").call(this,t,e,c,s,a)}))),2e3),"f"))})),qr.set(this,(()=>{clearTimeout(o(this,Pr,"f")),i(this,Pr,null,"f")})),Br.set(this,(t=>{var e,n,i,r,s,a,l,c,d,u,h;if(!(null==t?void 0:t.ok)){const a=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;return o(this,$r,"m",es).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:l,errorMessage:a}),void this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||l)}null===(l=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===l||l.forEach((t=>{const{level:e,title:n,log:o}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](n,o):this.loggerWrapper.info(n,o)}));const p=null===(u=null===(d=null===(c=t.data)||void 0===c?void 0:c.screen)||void 0===d?void 0:d.state)||void 0===u?void 0:u.errorText;(null===(h=t.data)||void 0===h?void 0:h.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${p?`${p} - `:""}${t.data.error.message}`):p&&this.loggerWrapper.error(p);const{status:f,authInfo:g,lastAuth:v}=t.data;if("completed"===f)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&Yn&&localStorage.setItem(ho,JSON.stringify(t))}(v),void o(this,$r,"m",es).call(this,"success",g);const{executionId:m,stepId:b,stepName:w,action:y,screen:k,redirect:I,openInNewTabUrl:x,webauthn:C,error:j,samlIdpResponse:A}=t.data;y!==xo?(this.loggerWrapper.info(`Step "${w||`#${b}`}" is ${f}`,"",{screen:k,status:f,stepId:b,stepName:w,action:y,error:j}),this.flowState.update({stepId:b,executionId:m,action:y,redirectTo:null==I?void 0:I.url,openInNewTabUrl:x,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==C?void 0:C.transactionId,webauthnOptions:null==C?void 0:C.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState})):this.flowState.update({action:y})})),Hr.set(this,No((()=>n(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.warn("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.warn("Webauthn start failed",t.message)}}))))),Zr.set(this,Ho(((t,e)=>n(this,void 0,void 0,(function*(){if("true"===t.getAttribute("formnovalidate")||o(this,$r,"m",zr).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,$r,"m",Jr).call(this,t);const r=yield o(this,$r,"m",Gr).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),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 e(i,c.version,d.componentsVersion,l);o(this,Br,"f").call(this,u),o(this,$r,"m",Xr).call(this,r)}var n}))))),this.flowState=t}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const t=(yield this.getFlowConfig()).sdkScripts;null==t||t.forEach((t=>n(this,void 0,void 0,(function*(){(yield function(t){return n(this,void 0,void 0,(function*(){let e;switch(t){case"forter":return e=yield Promise.resolve().then((function(){return ms})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return ws})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return ks})),e.default;default:throw new Error(`Unknown script id: ${t}`)}}))}(t.id))(t.initArgs,{baseUrl:this.baseUrl},(e=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Mr(t.id,t.resultKey)]:e},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e,n,i;this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",o(this,Wr,"f").visibilitychange)),yield null===(i=t.init)||void 0===i?void 0:i.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=o(this,Dr,"f"))||void 0===t||t.abort(),i(this,Dr,null,"f"),window.removeEventListener("visibilitychange",o(this,Wr,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const o=Vo(t),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${e}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${e}-${o.fallback}.html`),n}))}getPageContent(t,e){return n(this,void 0,void 0,(function*(){if(e)try{const{body:t}=yield _o(e,"text");return t}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${e}. Fallback to url ${t}`,n)}try{const{body:e}=yield _o(t,"text");return e}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(t,r,s){return n(this,void 0,void 0,(function*(){var n,a;const{projectId:l,flowId:c,tenant:d,stepId:u,executionId:h,action:p,screenId:f,screenState:g,redirectTo:v,openInNewTabUrl:m,redirectUrl:b,token:w,code:y,exchangeError:k,webauthnTransactionId:I,webauthnOptions:x,redirectAuthCodeChallenge:C,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:A,redirectAuthInitiator:S,locale:O,samlIdpResponseUrl:E,samlIdpResponseSamlResponse:U,samlIdpResponseRelayState:L}=t,T=e(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"]);let _,R;const M=(()=>{const t=localStorage.getItem(li);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(li,t.toString()),t}return Number(t)})(),$=this.sdk.getLastUserLoginId(),P=yield this.getFlowConfig(),D=yield this.getProjectConfig(),W=j&&C?{callbackUrl:j,codeChallenge:C,backupCallbackUri:A}:void 0;if(!h&&(this.loadSdkScripts(),P.fingerprintEnabled&&P.fingerprintKey?yield Ln(P.fingerprintKey,this.baseUrl):localStorage.removeItem(En),P.conditions?({startScreenId:_,conditionInteractionId:R}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n,predicate:o})=>{var i;if("ELSE"===e)return!0;const r=null===(i=si[e])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(t,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:$,code:y,token:w,abTestingKey:M},P.conditions)):P.condition?({startScreenId:_,conditionInteractionId:R}=((t,e)=>{var n;const o=null===(n=si[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(P.condition,{loginId:$,code:y,token:w,abTestingKey:M})):_=P.startScreenId,!Fo(_,T))){const t=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:W},T),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:ai($),abTestingKey:M,locale:Vo(O).locale}),R,"",P.version,D.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),y?{exchangeCode:y,idpInitiated:!0}:{}),T.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),T.oidcLoginHint?{externalId:T.oidcLoginHint}:{}));return o(this,Br,"f").call(this,t),void("completed"!==(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}if(h&&(s("token")&&w||s("code")&&y||s("exchangeError")&&k)){const t=yield this.sdk.flow.next(h,u,So,P.version,D.componentsVersion,{token:w,exchangeCode:y,exchangeError:k});return o(this,Br,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===Ao&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!E||!U)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=t,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})(E,U,L||"",qo)}if(p===Io&&(s("redirectTo")||s("deferredRedirect")))return v?"android"===S&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(v):void this.loggerWrapper.error("Did not get redirect url");if(p===Co||p===jo){if(!I||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,Dr,"f"))||void 0===a||a.abort(),i(this,Dr,null,"f");try{t=p===Co?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),e=t.name}const n=yield this.sdk.flow.next(h,u,So,P.version,D.componentsVersion,{transactionId:I,response:t,failure:e});o(this,Br,"f").call(this,n)}if(o(this,Fr,"f").call(this,h,u,p,P.version,D.componentsVersion),!f&&!_)return void this.loggerWrapper.warn("No screen was found to show");const N=_||f,F=yield this.getHtmlFilenameWithLocale(O,N),{oidcLoginHint:q,oidcPrompt:B,oidcErrorRedirectUri:H,samlIdpUsername:V}=T,K={direction:Mo(u,r.stepId),screenState:Object.assign(Object.assign({},g),{form:Object.assign(Object.assign({},this.formConfigValues),null==g?void 0:g.form),lastAuth:{loginId:$,name:this.sdk.getLastUserDisplayName()||$}}),htmlUrl:Ro({projectId:l,filename:`${N}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:F&&Ro({projectId:l,filename:F,baseUrl:this.baseStaticUrl}),samlIdpUsername:V,oidcLoginHint:q,oidcPrompt:B,oidcErrorRedirectUri:H,openInNewTabUrl:m},z=ai($);Fo(_,T)?K.next=(t,e,n,o)=>this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:W},T),{lastAuth:z,preview:this.preview,abTestingKey:M,client:this.client}),b&&{redirectUrl:b}),{locale:Vo(O).locale}),R,t,e,n,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),y&&{exchangeCode:y,idpInitiated:!0}),T.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(K.next=(...t)=>this.sdk.flow.next(h,u,...t)),this.stepState.update(K)}))}onStepChange(t,e){return n(this,void 0,void 0,(function*(){var i,r;const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=t,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield o(this,$r,"m",Kr).call(this,p,c):p.querySelectorAll(`descope-button[${ko}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!t.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=t.samlIdpUsername,d.form.email=t.samlIdpUsername),oi(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,g);const v=()=>n(this,void 0,void 0,(function*(){var t,n;yield f;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(t=null==d?void 0:d.totp)||void 0===t?void 0:t.image,ni(r,"descope-totp-image",s),((t,e)=>{ni(t,"descope-notp-image",e)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((t,e)=>{Yo(t,null==e?void 0:e.inputs),Yo(t,null==e?void 0:e.form)})(this.rootElement,d)}));const a=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))}))}))})(this.rootElement),o(this,$r,"m",Yr).call(this,c),a&&o(this,$r,"m",es).call(this,"ready",{}),o(this,$r,"m",es).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${ko}="polling"]`)){const t=yield this.getFlowConfig(),e=yield this.getProjectConfig(),n=yield c(Oo,t.version,e.componentsVersion,{});o(this,Br,"f").call(this,n)}u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,$r,"m",ts).call(this,v,l):v()}))}}Pr=new WeakMap,Dr=new WeakMap,Wr=new WeakMap,Fr=new WeakMap,qr=new WeakMap,Br=new WeakMap,Hr=new WeakMap,Zr=new WeakMap,$r=new WeakSet,Nr=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Vr=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const n=`user-${e}`;t.setAttribute("name",n),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:n)}))}},Kr=function(t,e){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,Dr,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield ii())){const{options:t,transactionId:r}=(yield o(this,Hr,"f").call(this))||{};if(t&&r){o(this,$r,"m",Vr).call(this,s),i(this,Dr,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,o(this,Dr,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,a.version,l.componentsVersion,{transactionId:r,response:t});o(this,Br,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},zr=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var n,o;"slot"!==e.localName&&(null===(n=e.reportValidity)||void 0===n||n.call(e),t&&(t=null===(o=e.checkValidity)||void 0===o?void 0:o.call(e)))})),t},Gr=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${uo}])`));return(yield Promise.all(t.map((t=>n(this,void 0,void 0,(function*(){return{name:t.getAttribute("name"),value:t.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},Jr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},Xr=function(t={}){var e,n;const o=Bo(t,["externalId","email","phone"]),i=Bo(t,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===n||n.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},Qr=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.addEventListener("input",(()=>{var n;(null===(n=e.checkValidity)||void 0===n?void 0:n.call(e))&&o(this,Zr,"f").call(this,e,t)}))}))},Yr=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{o(this,Zr,"f").call(this,e,t)}})),o(this,$r,"m",Qr).call(this,t)},ts=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===Uo.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.rootElement.classList.add("fade-out")},es=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",hs);const ps=document.createElement("template");ps.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 fs extends HTMLElement{constructor(){super(),ns.add(this),os.set(this,new Zo({messages:[]})),is.set(this,void 0),rs.set(this,void 0),ss.set(this,void 0),as.set(this,{resize:o(this,ns,"m",us).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ps.content.cloneNode(!0)),i(this,is,this.shadowRoot.querySelector(".debugger"),"f"),i(this,rs,o(this,is,"f").querySelector(".content"),"f"),i(this,ss,o(this,is,"f").querySelector(".header"),"f")}updateData(t){o(this,os,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=ri(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(o(this,is,"f"),o(this,ss,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,as,"f").resize),(t=o(this,is,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},o(this,is,"f").onresize=o(this,ns,"m",ds).bind(this),o(this,os,"f").subscribe(o(this,ns,"m",ls).bind(this))}disconnectedCallback(){o(this,os,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,as,"f").resize)}}os=new WeakMap,is=new WeakMap,rs=new WeakMap,ss=new WeakMap,as=new WeakMap,ns=new WeakSet,ls=function(t){o(this,ns,"m",cs).call(this,t),o(this,ns,"m",ds).call(this)},cs=function(t){o(this,rs,"f").innerHTML=t.messages.map((t=>`\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 ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},ds=function(){o(this,rs,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,o=e.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},us=function(){const[t,e]=ri(o(this,is,"f"),Number.parseInt(o(this,is,"f").style.left,10),Number.parseInt(o(this,is,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,is,"f").style.top=`${e}px`,o(this,is,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",fs);var gs=Object.freeze({__proto__:null,default:fs});const vs='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n';var ms=Object.freeze({__proto__:null,default:(t,e,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=vs.replace(/{{SITE_ID}}/g,e),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",e),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(t=>{o(t.detail)}))}))});const bs=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:n,cloudflareScriptUrl:i,cloudflareEndpointUrl:r}=t;let s=[];s=n&&r?[r,en]:[en];let a=[];if(n&&i){const t=new URL(i);a=[`${t.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,cn]}else a=[cn];const l=dn({apiKey:e,endpoint:s,scriptUrlPattern:a}),c=yield l,{requestId:d}=yield c.get();o(d)}catch(t){console.warn("Could not load fingerprint",t)}}));var ws=Object.freeze({__proto__:null,default:bs,loadFingerprint:bs});const ys=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,cloudflareEndpointPath:r,cloudflareScriptPath:s}=t,{baseUrl:a}=e;let l;l=n?`https://${n}`:a||"https://api.descope.com";const c=new URL(l);c.pathname=r;const d=new URL(l);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=dn({apiKey:i,endpoint:[c.toString(),en],scriptUrlPattern:[u,cn]}),p=yield h,{requestId:f}=yield p.get();o(f)}catch(t){console.warn("Could not load descope fingerprint",t)}}));var ks=Object.freeze({__proto__:null,default:ys,loadFingerprint:ys})}();
3
+ function on(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}var rn=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=on({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).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=t+"="+e.write(o,t)+r}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){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]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",on({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,on({},this.attributes,e))},withConverter:function(e){return t(on({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var sn={default:"endpoint"},an="Blocked by CSP",ln="The endpoint parameter is not a valid URL",cn="Failed to load the JS script of the agent",dn="9319";function un(t,e){var n,o,i,r,s=[],a=(n=function(t){var e=function(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}([],t,!0);return{current:function(){return e[0]},postpone:function(){var t=e.shift();void 0!==t&&e.push(t)},exclude:function(){e.shift()}}}(t),r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(t,e){var r,s=e instanceof Error?e.message:"";if(s===an||s===ln)n.exclude(),r=0;else if(s===dn)n.exclude();else if(s===cn){var a=Date.now()-t.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:t.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(t){var n=new Date,o=function(e){return s.push({url:t,startedAt:n,finishedAt:new Date,error:e})},i=e(t);return i.then((function(){return o()}),o),i.catch((function(t){if(s.length>=5)throw t;var e=c(n,t);if(!e)throw t;var o,i=e[0],r=e[1];return(o=r,new Promise((function(t){return setTimeout(t,o)}))).then((function(){return d(i)}))}))};return d(l).then((function(t){return[t,s]}))}var hn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",pn=hn;function fn(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:hn,c=function(){var t=[],e=function(){t.push({time:new Date,state:document.visibilityState})},n=function(t,e,n,o){return t.addEventListener(e,n,o),function(){return t.removeEventListener(e,n,o)}}(document,"visibilitychange",e);return e(),[t,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var t=function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.9.9"):t}))}(String(t),e)}))}(l,s);return un(t,gn)})).catch((function(t){throw u(),function(t){return t instanceof Error&&t.message===dn?new Error(cn):t}(t)})).then((function(e){var n=e[0],o=e[1];return u(),n.load(t(t({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function gn(t){return function(t,e,n,o){var i,r=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),o=e.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=e,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return null==o||o.then(l,l),Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){var e=new MessageChannel;e.port1.onmessage=function(){return t()},e.port2.postMessage(null)})).then((function(){if(l(),i)return n(i);throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(ln);var o=document.createElement("script"),i=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),e()},o.onerror=function(){i(),n(new Error(cn))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)}),(function(){throw new Error(an)})).then(vn)}function vn(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==o?void 0:o.configurable)?delete t[e]:o&&!o.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error(dn);return n}const mn=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=t.hooks)||void 0===i?void 0:i[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},bn=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},wn=async t=>{const e=await bn(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},yn="undefined"!=typeof localStorage,kn=(t,e)=>yn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),In=t=>yn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),xn=t=>yn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Cn=(...t)=>{console.debug(...t)},jn="undefined"!=typeof window,An=Math.pow(2,31)-1,Sn="DS",On="DSR";function En(t=""){return In(`${t}${On}`)||""}function Un(t=""){return rn.get(Sn)||In(`${t}${Sn}`)||""}function Ln(t=""){xn(`${t}${On}`),xn(`${t}${Sn}`),rn.remove(Sn)}const Tn=jn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",_n="fp",Rn=(t=!1)=>{const e=localStorage.getItem(_n);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Mn=async(t,e=Tn)=>{try{if(Rn())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(e);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(e);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=fn({apiKey:t,endpoint:[o.toString(),sn],scriptUrlPattern:[r,pn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((t,e)=>({vsid:t,vrid:e}))(n,l);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(_n,JSON.stringify(e))})(c)}catch(t){console.warn("Could not load fingerprint",t)}},$n=t=>{const e=Rn(!0);return e&&t.body&&(t.body.fpData=e),t},Pn="dls_last_user_login_id",Dn="dls_last_user_display_name",Wn=()=>In(Pn),Nn=()=>In(Dn),Fn=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Wn(),r=Nn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)};function qn(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}async function Bn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Jn(n.publicKey.challenge),n.publicKey.user.id=Jn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Jn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Xn(n.rawId),type:n.type,response:{attestationObject:Xn(n.response.attestationObject),clientDataJSON:Xn(n.response.clientDataJSON)}});var n}async function Hn(t){const e=zn(t);return Gn(await navigator.credentials.get(e))}async function Vn(t,e){const n=zn(t);return n.signal=e.signal,n.mediation="conditional",Gn(await navigator.credentials.get(n))}async function Kn(t=!1){if(!jn)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function zn(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Jn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Jn(t.id)})),n}function Gn(t){return JSON.stringify({id:t.id,rawId:Xn(t.rawId),type:t.type,response:{authenticatorData:Xn(t.response.authenticatorData),clientDataJSON:Xn(t.response.clientDataJSON),signature:Xn(t.response.signature),userHandle:t.response.userHandle?Xn(t.response.userHandle):void 0}})}function Jn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Xn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Zn,Qn=(Zn=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Bn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await Hn(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await Bn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Hn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Bn(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Bn,get:Hn,isSupported:Kn,conditional:Vn}}),(...t)=>{const e=Zn(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const Yn="/fedcm/config",to=(t,e)=>({async oneTap(e,n,o,i){const r=null!=e?e:"google",s=await t.oauth.startNative(r,o,!0);if(!s.ok)return s;const{clientId:a,stateId:l,nonce:c}=s.data,d=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(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?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{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=>{e(t.oauth.finishNative(r,l,"","",n.credential))},nonce:c})),d.prompt((t=>{(null==t?void 0:t.isSkippedMoment())&&(null==i||i())}))}))},async launch(n){var o;const i={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+Yn),clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return t.refresh(r.token)},isSupported:()=>jn&&"IdentityCredential"in window});var eo=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await Kn(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const no=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return jn?(o&&i&&Mn(o).catch((()=>null)),t(mn(r,{beforeRequest:$n}))):t(r)}),(t=>n=>{var{autoRefresh:o}=n,i=e(n,["autoRefresh"]);if(!o)return t(i);const{clearAllTimers:r,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let l,c;jn&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>l&&(Cn("Expiration time passed, refreshing session"),d.refresh(En()||c))}));const d=t(mn(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await bn(e);if(401===(null==e?void 0:e.status))Cn("Received 401, canceling all timers"),r();else if(o){if(l=(t=>{try{const e=a(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(o),!l)return void Cn("Could not extract expiration time from session token");c=n;let t=((i=l)?i.getTime()-(new Date).getTime():0)-2e4;t>An&&(Cn(`Timeout is too large (${t}ms), setting it to ${An}ms`),t=An),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});Cn(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{Cn("Refreshing session due to timer"),d.refresh(En()||n)}),t)}var i}}));return zt(d,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return Cn("Clearing all timers"),r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.16.5"},e.baseHeaders)}))),(t=>e=>{const n=qn(),o=qn(),i=t(mn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await wn(e);t&&o.pub(t);const{sessionJwt:i}=await bn(e);i&&n.pub(i)}}})),r=zt(i,["logout","logoutAll"],(t=>async(...e)=>{const i=await t(...e);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(t(r),{getLastUserLoginId:Wn,getLastUserDisplayName:Nn});const s=t(mn(r,{afterRequest:async(t,e)=>{var n;const o=await wn(e),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((t=>{kn(Pn,t)})(i),(t=>{kn(Dn,t)})(r))}}));let a=zt(s,["flow.start"],Fn);return a=zt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return t||(xn(Pn),xn(Dn)),o})(i)),Object.assign(a,{getLastUserLoginId:Wn,getLastUserDisplayName:Nn})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!jn)return t(s);const a=t(mn(s,{beforeRequest:(l=r,t=>Object.assign(t,{token:t.token||En(l)})),afterRequest:async(t,n)=>{const o=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?o||Ln(r):((t={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&kn(`${o}${On}`,i),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);rn.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(Sn,r,s):kn(`${o}${Sn}`,r))})(await bn(n),i,r)}}));var l;const c=zt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return Ln(t),o})(r));return Object.assign(c,{getRefreshToken:()=>En(r),getSessionToken:()=>Un(r)})}))(((...t)=>{const e=nn(...t);return Object.assign(Object.assign({},e),{refresh:t=>{const n=Un();return e.refresh(t,{dcs:n?"t":"f"})},flow:eo(e),webauthn:Qn(e),fedcm:to(e,t[0].projectId)})})),oo="undefined"!=typeof localStorage,io="J151000",ro=oo&&localStorage.getItem("base.content.url")||"",so="config.json",ao="base.ui.components.url";oo&&localStorage.getItem(ao),oo&&localStorage.getItem(ao);const lo="descope-login-flow",co="code",uo="ra-challenge",ho="ra-callback",po="ra-backup-callback",fo="ra-initiator",go="data-exclude-field",vo="dls_last_auth",mo="state_id",bo="saml_idp_state_id",wo="saml_idp_username",yo="descope_idp_initiated",ko="sso_app_id",Io="oidc_login_hint",xo="oidc_prompt",Co="oidc_error_redirect_uri",jo="data-type",Ao="redirect",So="poll",Oo="webauthnCreate",Eo="webauthnGet",Uo="loadForm",Lo="submit",To="polling",_o=["descope-multi-select-combo-box","descope-text-area"];var Ro;function Mo(t){return new URLSearchParams(window.location.search).get(t)}function $o(t){if(window.history.replaceState&&Mo(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function Po(t,e){return n(this,void 0,void 0,(function*(){const n=yield fetch(t,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${t} [${n.status}]`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(Ro||(Ro={}));function Do({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(ro||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.toString()}function Wo(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Ro.forward:n<o?Ro.backward:void 0}const No=()=>{const[t="",e=""]=(Mo(lo)||"").split("_");return{executionId:t,stepId:e}};function Fo(){$o(lo)}const qo=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),Bo=()=>{const{executionId:t,stepId:e}=No();(t||e)&&Fo();const n=Mo("t")||void 0;n&&$o("t");const o=Mo(co)||void 0;o&&$o(co);const i=Mo("err")||void 0;i&&$o("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:Mo(uo),redirectAuthCallbackUrl:Mo(ho),redirectAuthBackupCallbackUri:Mo(po),redirectAuthInitiator:Mo(fo)};(r||s||a||l)&&($o(uo),$o(ho),$o(po),$o(fo));const c=Mo(mo);c&&$o(mo);const d=Mo(bo);d&&$o(bo);const u=Mo(wo);d&&$o(wo);const h=Mo(yo);h&&$o(yo);const p=Mo(ko);p&&$o(ko);const f=Mo(Io);f&&$o(Io);const g=Mo(xo);g&&$o(xo);const v=Mo(Co);v&&$o(Co);return{executionId:t,stepId:e,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:c,samlIdpStateId:d,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:f,oidcPrompt:g,oidcErrorRedirectUri:v}}},Ho=t=>{let e,n;return(...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}};const Vo=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||n||o||i||r||s||a),Ko=t=>null==t?void 0:t.submit(),zo=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Go=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Jo(t){if(t)return{locale:t.toLowerCase(),fallback:t.toLowerCase()};const e=navigator.language;return e?e.includes("-")?{locale:e.toLowerCase(),fallback:e.split("-")[0].toLowerCase()}:{locale:e.toLowerCase(),fallback:e.toLowerCase()}:{locale:"",fallback:""}}var Xo,Zo,Qo,Yo;function ti(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!ti(r,s))return!1}else if(r!==s)return!1}return!0}class ei{constructor(t={},{updateOnlyOnChange:e=!0}={}){Xo.set(this,void 0),Zo.set(this,{}),Qo.set(this,0),Yo.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,Xo,"f")):t,n=Object.assign(Object.assign({},o(this,Xo,"f")),e);if(!o(this,Yo,"f")||!ti(o(this,Xo,"f"),n)){const t=o(this,Xo,"f");i(this,Xo,n,"f"),Object.freeze(o(this,Xo,"f")),setTimeout((()=>{Object.values(o(this,Zo,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,Xo,t,"f"),i(this,Yo,e,"f")}get current(){return Object.assign({},o(this,Xo,"f"))}subscribe(t){return i(this,Qo,o(this,Qo,"f")+1,"f"),o(this,Zo,"f")[o(this,Qo,"f")]=t,o(this,Qo,"f").toString()}unsubscribe(t){const e=!!o(this,Zo,"f")[t];return e&&delete o(this,Zo,"f")[t],e}unsubscribeAll(){return i(this,Zo,{},"f"),!0}}Xo=new WeakMap,Zo=new WeakMap,Qo=new WeakMap,Yo=new WeakMap;const ni=["disabled"],oi=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${go}])`)).forEach((t=>{t.value=n}))}))},ii=(t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),ri=(t,e,n)=>{t.querySelectorAll(`[${jo}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},si=(t,e,n)=>{var o,i;const r=null===(o=customElements.get(e))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==t?void 0:t.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},ai=(t,e,n,o,i,r)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==i?void 0:i({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){r.error("Error transforming error message",t.message)}((t,e,n="")=>{t.querySelectorAll(`[${jo}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),ri(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ri(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{t.textContent=ii(t.textContent,e);const n=t.getAttribute("href");n&&t.setAttribute("href",ii(n,e))}))})(t,e),((t,e,n)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const i=e[o];Object.keys(i).forEach((e=>{let o=i[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){n.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,n,r),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=ii(t.value,e)}))}))})(t,e),((t,e)=>{Object.entries(e).forEach((([e,n])=>{t.querySelectorAll(`[name="${e}"]`).forEach((t=>{Object.entries(n).forEach((([e,n])=>{ni.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,o)},li=Ho((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o,i;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),s=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0})()>=108;return yield(n=100,o=r,i=s,new Promise(((t,e)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==i?t(i):e(new Error(`Promise timed out after ${n} ms`))}),n);o.then((e=>{r||(clearTimeout(s),t(e))})).catch((t=>{r||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),ci=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},di={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function ui(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(vo)))}catch(t){}return e}const hi="dls_ab_testing_id";function pi(...t){return e=>t.reduce(((t,e)=>e(t)),e)}const fi=t=>{const e=Symbol((t=>{const e=t.toString();let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n&=n;return n.toString(16)})(t));return n=>{if(n[e])return n;const o=t(n);return o[e]=!0,o}};var gi,vi,mi,bi,wi,yi;function ki(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!ki(r,s))return!1}else if(r!==s)return!1}return!0}class Ii{constructor(t={},{updateOnlyOnChange:e=!0}={}){gi.set(this,void 0),vi.set(this,{}),mi.set(this,0),bi.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,gi,"f")):t,n=Object.assign(Object.assign({},o(this,gi,"f")),e);if(!o(this,bi,"f")||!ki(o(this,gi,"f"),n)){const t=o(this,gi,"f");i(this,gi,n,"f"),Object.freeze(o(this,gi,"f")),setTimeout((()=>{Object.values(o(this,vi,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,gi,t,"f"),i(this,bi,e,"f")}get current(){return Object.assign({},o(this,gi,"f"))}subscribe(t){return i(this,mi,o(this,mi,"f")+1,"f"),o(this,vi,"f")[o(this,mi,"f")]=t,o(this,mi,"f").toString()}unsubscribe(t){const e=!!o(this,vi,"f")[t];return e&&delete o(this,vi,"f")[t],e}unsubscribeAll(){return i(this,vi,{},"f"),!0}}gi=new WeakMap,vi=new WeakMap,mi=new WeakMap,bi=new WeakMap;class xi{constructor(t,e){wi.set(this,void 0),this.nodeName="",i(this,wi,t,"f"),this.logger=e.logger}get asyncEle(){return(async t=>new Promise((e=>{const n=setInterval((()=>{const o="function"==typeof t?t():t;o&&(clearInterval(n),e(o))}),100);setTimeout((()=>{clearInterval(n),e(null)}),1e3)})))(o(this,wi,"f"))}get ele(){var t,e;const n="function"==typeof o(this,wi,"f")?o(this,wi,"f").call(this):o(this,wi,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(e=this.logger)||void 0===e||e.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(t=this.logger)||void 0===t||t.debug("no element for driver ",this.constructor.name,new Error),null)}}wi=new WeakMap;class Ci extends xi{constructor(){super(...arguments),yi.set(this,void 0),this.nodeName="descope-modal"}close(){var t,e;null===(t=this.ele)||void 0===t||t.removeAttribute("opened"),null===(e=this.afterClose)||void 0===e||e.call(this)}async open(){var t,e;await(null===(t=this.beforeOpen)||void 0===t?void 0:t.call(this)),null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}reset(){var t;this.ele&&(this.ele.innerHTML=""),o(this,yi,"f")&&(null===(t=this.ele)||void 0===t||t.append(o(this,yi,"f").content.cloneNode(!0)))}setContent(t){i(this,yi,t,"f"),this.reset()}remove(){var t;null===(t=this.ele)||void 0===t||t.remove()}}yi=new WeakMap;class ji extends xi{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var t;null===(t=this.ele)||void 0===t||t.removeAttribute("opened")}show(){var t;null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}setContent(t){this.ele.innerHTML="",this.ele.appendChild(t.content.cloneNode(!0))}remove(){var t;null===(t=this.ele)||void 0===t||t.remove()}}const Ai=["error","warn","info","debug"],Si=fi((t=>{var e,n,r,s;return s=class extends t{constructor(){super(...arguments),e.add(this),n.set(this,o(this,e,"m",r).call(this,console))}set logger(t){i(this,n,o(this,e,"m",r).call(this,t),"f")}get logger(){return o(this,n,"f")}onLogEvent(t,e){}},n=new WeakMap,e=new WeakSet,r=function(t){return Ai.reduce(((e,n)=>(e[n]=(...e)=>{var o;this.onLogEvent(n,e),null===(o=t[n])||void 0===o||o.call(t,...e)},e)),{})},s})),Oi="undefined"!=typeof localStorage,Ei=Oi&&localStorage.getItem("base.content.url")||"",Ui=(t,e)=>!e&&`${t} cannot be empty, please make sure to set this attribute`,Li=fi((t=>{var e,n;return n=class extends t{constructor(){super(...arguments),e.set(this,!0)}connectedCallback(){var t,n;null===(t=super.connectedCallback)||void 0===t||t.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,e,"f")&&(i(this,e,!1,"f"),this.init())}async init(){}},e=new WeakMap,n})),Ti=fi((t=>{var e,n;const i=pi(Si,Li)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,{})}async init(){var t,n,i;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),n=this,i=t=>{var n;null===(n=o(this,e,"f")[t])||void 0===n||n.forEach((e=>{e(t,this.getAttribute(t))}))},Array.from(n.attributes).forEach((t=>i(t.name))),new MutationObserver((t=>{t.forEach((t=>{"attributes"===t.type&&i(t.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(t,n){o(this,e,"f")[t]||(o(this,e,"f")[t]=[]);const i=o(this,e,"f")[t].push(n);return()=>o(this,e,"f")[t].splice(i,1)}observeAttributes(t,e){const n=t.reduce(((t,n)=>(t.push(this.observeAttribute(n,e)),t)),[]);return()=>n.forEach((t=>t()))}},e=new WeakMap,n})),_i=t=>e=>{var n,i,r;const s=pi(Si,Li,Ti)(e),a=Object.keys(t);return r=class extends s{constructor(...t){super(...t),n.add(this),this.observeAttributes(a,o(this,n,"m",i).bind(this))}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),a.forEach((t=>o(this,n,"m",i).call(this,t,this.getAttribute(t))))}},n=new WeakSet,i=function(e,n){const o=t[e],i="function"==typeof o?o(e,n):o;i&&this.logger.error(i)},r};_i.missingAttrValidator=Ui;const Ri=fi((t=>{const e=pi(_i({"project-id":Ui}))(t);return class extends e{get projectId(){return this.getAttribute("project-id")}}})),Mi=fi((t=>class extends t{get baseUrl(){return this.getAttribute("base-url")||""}}));const $i=fi((t=>{const e=pi(Si,Ri,Mi)(t);return class extends e{async fetchStaticResource(t,e){const n=function({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(Ei||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.toString()}({projectId:this.projectId,filename:t,baseUrl:this.baseStaticUrl}),o=await fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:await o[e](),headers:Object.fromEntries(o.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),Pi=fi((t=>{var e,n,r;const s=pi($i)(t);return r=class extends s{constructor(){super(...arguments),e.set(this,void 0),n.set(this,(async()=>{try{const{body:t,headers:e}=await this.fetchStaticResource("config.json","json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}get config(){return o(this,e,"f")||i(this,e,o(this,n,"f").call(this),"f"),o(this,e,"f")}},e=new WeakMap,n=new WeakMap,r}));fi((t=>{var e,n,r,s,a,l,c;return c=class extends(pi(Li,Si)(t)){constructor(){super(...arguments),e.add(this),n.set(this,void 0),this.attributeChangedCallback=(t,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,t,n,i),"debug"===t&&o(this,e,"m",a).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(t,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,t,n),"error"===t&&o(this,e,"m",l).call(this,n[0]||"Error",n[1])}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),o(this,e,"m",a).call(this)}},n=new WeakMap,e=new WeakSet,r=function(){var t;null===(t=o(this,n,"f"))||void 0===t||t.remove(),i(this,n,null,"f")},s=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 ur})),document.body.appendChild(o(this,n,"f"))},a=function(){this.debug?o(this,e,"m",s).call(this):o(this,e,"m",r).call(this)},l=function(t,e){var i;t&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:t,description:e}))},c}));const Di="load-descope-ui",Wi="base.ui.components.url",Ni=Oi&&localStorage.getItem(Wi)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Fi=Oi&&localStorage.getItem(Wi)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",qi=t=>{const e=document.createElement("script");return e.id=t,e},Bi=(t,e)=>t.replace("<version>",e),Hi=fi((t=>{var e,n,r,s,a,l,c,d,u,h,p,f;const g=pi(Si,Pi)(t);return f=class extends g{constructor(){super(...arguments),e.add(this),n.set(this,Symbol("errorCbs")),r.set(this,Symbol("loadCbs")),u.set(this,void 0)}get descopeUi(){return o(this,u,"f")||i(this,u,o(this,e,"m",p).call(this),"f"),o(this,u,"f")}async loadDescopeUiComponents(t){const n=Array.isArray(t)?t:(t=>[...Array.from(t.content.querySelectorAll("*")).reduce(((t,e)=>e.localName.startsWith("descope-")?t.add(e.localName):t),new Set)])(t);return Promise.all(n.map((t=>o(this,e,"m",h).call(this,t))))}},n=new WeakMap,r=new WeakMap,u=new WeakMap,e=new WeakSet,s=async function(){var t;const e=await this.config,n=null===(t=null==e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},a=function(t){const e=o(this,n,"f"),i=o(this,r,"f");t[e]=[],t[i]=[],Object.defineProperty(t,"onerror",{set(n){t[e].push(n)}}),Object.defineProperty(t,"onload",{set(e){t[i].push(e)}})},l=async function(t,n){this.logger.debug("Trying to load DescopeUI from a fallback URL");const i=qi("load-descope-ui-fallback-script");document.body.append(i),i.addEventListener("error",(()=>{t.forEach((t=>t(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${i.src}"`)))})),i.addEventListener("load",(()=>{n.forEach((t=>t()))})),i.src=Bi(Fi,await o(this,e,"m",s).call(this))},c=function(t){t.addEventListener("error",(()=>{t[o(this,n,"f")].forEach((e=>e(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${t.src}"`))),o(this,e,"m",l).call(this,t[o(this,n,"f")],t[o(this,r,"f")])})),t.addEventListener("load",(()=>{t[o(this,r,"f")].forEach((t=>t()))}))},d=async function(){if(document.querySelector(`script#${Di}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const t=qi(Di);document.body.append(t),o(this,e,"m",a).call(this,t),o(this,e,"m",c).call(this,t),t.src=Bi(Ni,await o(this,e,"m",s).call(this))}return document.getElementById(Di)},h=async function(t){if(!!customElements.get(t))return void this.logger.debug(`Loading component "${t}" is skipped as it is already defined`);const e=await this.descopeUi;if(e[t])try{return await e[t]()}catch(e){if("NotSupportedError"!==e.name)throw e;console.debug(`Encountered an error while attempting to define the "${t}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${t}"`,`Descope UI does not have a component named "${t}", available components are: "${Object.keys(e).join(", ")}"`)},p=function(){return new Promise((t=>{globalThis.DescopeUI&&t(globalThis.DescopeUI),o(this,e,"m",d).call(this).then((e=>{e.onerror=this.logger.error,e.onload=()=>{this.logger.debug("DescopeUI was loaded"),t(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&t(globalThis.DescopeUI)}))}))}))},f})),Vi="content-root",Ki="root",zi=fi((t=>class extends t{constructor(...t){var e,n;super(...t),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Ki}, #${Vi} {\n height: 100%;\n }\n #${Ki} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Ki}">\n <div id="${Vi}"></div>\n </div>\n `,this.contentRootElement=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(Vi),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Ki)}})),Gi="descope-modal";fi((t=>{var e,n;const i=pi(Li,zi,Hi)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,(()=>{const t=this.loadDescopeUiComponents.bind(this);return class extends Ci{setContent(e){t(e),super.setContent(e)}}})())}createModal(t){const n=((t={})=>{const e=document.createElement(Gi);return Object.keys(t).forEach((n=>{e.setAttribute(n,t[n])})),e})(Object.assign(Object.assign({},{}),t));return this.rootElement.append(n),new(o(this,e,"f"))(n,{logger:this.logger})}async init(){var t;this.loadDescopeUiComponents([Gi]),await(null===(t=super.init)||void 0===t?void 0:t.call(this))}},e=new WeakMap,n}));const Ji="descope-notification";fi((t=>{var e,n;const i=pi(Li,zi,Hi)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,(()=>{const t=this.loadDescopeUiComponents.bind(this);return class extends ji{setContent(e){const n="string"==typeof e?(t=>{const e=document.createElement("template");return e.innerHTML=t,e})(e):e;t(n),super.setContent(n)}}})())}createNotification(t){const n=((t={})=>{const e=document.createElement(Ji);return Object.keys(t).forEach((n=>{e.setAttribute(n,t[n])})),e})(Object.assign(Object.assign({},{}),t));return this.rootElement.append(n),new(o(this,e,"f"))(n,{logger:this.logger})}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),this.loadDescopeUiComponents([Ji])}},e=new WeakMap,n}));const Xi=(t,e)=>!!e&&"light"!==e&&"dark"!==e&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Zi=fi((t=>{var e,n,r,s,a,l,c,d,u,h,p;const f=pi(_i({theme:Xi}),$i,Li,Hi,Pi,zi,Ti)(t);return p=class extends f{constructor(){super(...arguments),e.add(this),n.set(this,void 0),r.set(this,void 0)}get theme(){var t,e;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),o(this,e,"m",l).call(this),o(this,e,"m",c).call(this),o(this,e,"m",u).call(this),o(this,e,"m",h).call(this),this.observeAttributes(["theme"],(()=>{o(this,e,"m",u).call(this),o(this,e,"m",h).call(this)})),this.observeAttributes(["style-id"],(()=>{i(this,r,null,"f"),o(this,e,"m",u).call(this),o(this,e,"m",l).call(this),o(this,e,"m",c).call(this)}))}},n=new WeakMap,r=new WeakMap,e=new WeakSet,s=async function(){try{const{body:t}=await this.fetchStaticResource(`${this.styleId}.json`,"json");return t}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},a=function(){return o(this,r,"f")||(i(this,r,o(this,e,"m",s).call(this),"f"),o(this,r,"f").then((t=>this.logger.debug("Fetched theme",t)))),o(this,r,"f")},l=async function(){var t,r;const s=await o(this,e,"a",a);s&&(o(this,n,"f")||(i(this,n,document.createElement("style"),"f"),o(this,n,"f").id="global-style",this.shadowRoot.appendChild(o(this,n,"f"))),o(this,n,"f").innerText=((null===(t=null==s?void 0:s.light)||void 0===t?void 0:t.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||""))},c=async function(){var t,n;const i=Object.assign({},await o(this,e,"a",a));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(t=null==i?void 0:i.light)||void 0===t?void 0:t.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=async function(){var t,e;const{projectConfig:n}=await this.config||{},o=null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(e=null==r?void 0:r[this.theme])||void 0===e?void 0:e.fonts},u=async function(){const t=await o(this,e,"m",d).call(this);t?Object.values(t).forEach((t=>{t.url&&(this.logger.debug(`Loading font from URL "${t.url}"`),(t=>{const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url))})):this.logger.debug("No fonts to load")},h=async function(){this.rootElement.setAttribute("data-theme",this.theme);const t=await this.descopeUi;(null==t?void 0:t.componentsThemeManager)&&(t.componentsThemeManager.currentThemeName=this.theme)},p}));fi((t=>class extends(Si(t)){validateForm(t){return this.getFormInputs(t).every((t=>{var e,n;return null===(e=t.reportValidity)||void 0===e||e.call(t),null===(n=t.checkValidity)||void 0===n?void 0:n.call(t)}))}getFormInputs(t){return t?Array.from(t.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(t){return this.getFormInputs(t).reduce(((t,e)=>Object.assign(t,{[e.getAttribute("name")]:e.value})),{})}setFormData(t,e){this.getFormInputs(t).forEach((t=>{e.hasOwnProperty(t.getAttribute("name"))&&(t.value=e[t.getAttribute("name")])}))}resetFormData(t){this.getFormInputs(t).forEach((t=>{t.value="",t.checked=!1}))}getFormFieldNames(t){return this.getFormInputs(t).map((t=>t.name))}disableFormField(t,e){var n;null===(n=this.getFormInputs(t).find((t=>t.name===e)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(t,e){var n;null===(n=this.getFormInputs(t).find((t=>t.name===e)))||void 0===n||n.remove()}})),fi((t=>class extends t{get baseStaticUrl(){return this.getAttribute("base-static-url")||""}}));const Qi=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Yi,tr,er,nr,or,ir,rr,sr,ar,lr;const cr=document.createElement("template");cr.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`;let dr=class extends HTMLElement{constructor(){var t;super(),Yi.add(this),tr.set(this,new Ii({messages:[]})),er.set(this,void 0),nr.set(this,void 0),or.set(this,void 0),ir.set(this,{resize:o(this,Yi,"m",lr).bind(this)}),this.attachShadow({mode:"open"}),null===(t=this.shadowRoot)||void 0===t||t.appendChild(cr.content.cloneNode(!0)),i(this,er,this.shadowRoot.querySelector(".debugger"),"f"),i(this,nr,o(this,er,"f").querySelector(".content"),"f"),i(this,or,o(this,er,"f").querySelector(".header"),"f")}updateData(t){o(this,tr,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=Qi(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(o(this,er,"f"),o(this,or,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ir,"f").resize),(t=o(this,er,"f")).onmousemove=e=>{var n;const o=e.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=t.onresize)||void 0===n||n.call(t,e)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,er,"f").onresize=o(this,Yi,"m",ar).bind(this),o(this,tr,"f").subscribe(o(this,Yi,"m",rr).bind(this))}disconnectedCallback(){o(this,tr,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ir,"f").resize)}};tr=new WeakMap,er=new WeakMap,nr=new WeakMap,or=new WeakMap,ir=new WeakMap,Yi=new WeakSet,rr=function(t){o(this,Yi,"m",sr).call(this,t),o(this,Yi,"m",ar).call(this)},sr=function(t){o(this,nr,"f").innerHTML=t.messages.map((t=>`\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 ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},ar=function(){o(this,nr,"f").querySelectorAll(".msg").forEach((t=>{const e=t,n=e.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},lr=function(){const[t,e]=Qi(o(this,er,"f"),Number.parseInt(o(this,er,"f").style.left,10),Number.parseInt(o(this,er,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,er,"f").style.top=`${e}px`,o(this,er,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",dr);var ur=Object.freeze({__proto__:null});const hr=fi((t=>{var e,n,i,r;return r=class extends t{constructor(){super(...arguments),e.add(this)}connectedCallback(){var t;o(this,e,"m",n).call(this)&&o(this,e,"m",i).call(this),null===(t=super.connectedCallback)||void 0===t||t.call(this)}},e=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},i=function(){const t=this.shadowRoot.host,e=document.createElement("form");e.style.width="100%",e.style.height="100%",t.parentElement.appendChild(e),e.appendChild(t)},r})),pr=document.createElement("template");pr.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t";const fr=(t,e="")=>Object.keys(t).reduce(((n,o)=>{var i;if("object"==typeof t[o]&&null!==t[o]&&!(null===(i=t[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),fr(t[o],`${e+o}.`));const r="object"==typeof t[o]?t[o]:{value:t[o]},s=Object.assign(Object.assign({},n),{[e+o]:r,[`form.${e}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${e}fullName`]:r,[`form.${e}fullName`]:r}):s}),[]);var gr,vr,mr,br,wr,yr,kr,Ir,xr,Cr,jr,Ar,Sr,Or,Er,Ur,Lr,Tr,_r,Rr,Mr,$r;const Pr=pi(Zi,hr)(HTMLElement);class Dr extends Pr{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(t){super(),gr.add(this),mr.set(this,!1),this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),o(this,gr,"m",Mr).call(this,t,e)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",n={})=>{this.logger.info(t,e,n)},debug:(t,e="")=>{this.logger.debug(t,e)}},br.set(this,new ei),wr.set(this,new ei),yr.set(this,{}),this.getComponentsContext=()=>o(this,yr,"f"),this.nextRequestStatus=new ei({isLoading:!1}),kr.set(this,void 0),Ir.set(this,{popstate:o(this,gr,"m",Ar).bind(this),componentsContext:o(this,gr,"m",Tr).bind(this)}),xr.set(this,void 0),Lr.set(this,Ho((()=>n(this,void 0,void 0,(function*(){const t=Do({projectId:this.projectId,filename:so,baseUrl:this.baseStaticUrl});try{const{body:e,headers:n}=yield Po(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),i(this,xr,t,"f"),o(this,gr,"m",Cr).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(t=>{try{return fr(JSON.parse(t))}catch(t){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return t=this.formConfig,e="value",Object.fromEntries(Object.entries(t).map((([t,n])=>[t,n[e]])));var t,e}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,Lr,"f").call(this);return t}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:t}=yield o(this,Lr,"f").call(this);return t}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var t,e;const n=yield this.getProjectConfig(),o=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e;if(yield null===(e=t.init)||void 0===e?void 0:e.call(this),o(this,wr,"f").subscribe(o(this,gr,"m",Rr).bind(this)),o(this,wr,"f").update({isDebug:this.debug}),o(this,gr,"m",jr).call(this),yield o(this,gr,"m",Er).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,Lr,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,gr,"m",$r).call(this);const{executionId:n,stepId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=Bo();window.addEventListener("popstate",o(this,Ir,"f").popstate),window.addEventListener("components-context",o(this,Ir,"f").componentsContext),o(this,br,"f").subscribe(o(this,gr,"m",Or).bind(this)),o(this,br,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:r,executionId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h},p)),i(this,mr,!0,"f")}))}disconnectedCallback(){o(this,br,"f").unsubscribeAll(),o(this,wr,"f").unsubscribeAll(),o(this,gr,"m",_r).call(this),window.removeEventListener("popstate",o(this,Ir,"f").popstate),window.removeEventListener("components-context",o(this,Ir,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,mr,"f")&&e!==n&&vr.observedAttributes.includes(t)){o(this,gr,"m",jr).call(this);const i=null===e;o(this,br,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Fo()),{[qo(t)]:n,stepId:r,executionId:s}})),o(this,wr,"f").update({isDebug:this.debug})}}}function Wr(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Nr,Fr,qr,Br,Hr,Vr,Kr,zr,Gr,Jr,Xr,Zr,Qr,Yr,ts,es,ns,os,is,rs,ss,as,ls,cs,ds,us,hs,ps,fs,gs;vr=Dr,mr=new WeakMap,br=new WeakMap,wr=new WeakMap,yr=new WeakMap,kr=new WeakMap,Ir=new WeakMap,xr=new WeakMap,Lr=new WeakMap,gr=new WeakSet,Cr=function(){this.shadowRoot.appendChild(pr.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},jr=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];vr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[qo(e)])throw Error(`${e} cannot be empty`)}))},Ar=function(){const{stepId:t,executionId:e}=No();o(this,br,"f").update({stepId:t,executionId:e})},Sr=function(t,e){this.sdk=no(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},vr.sdkConfigOverrides),{projectId:t,baseUrl:e})),["start","next"].forEach((t=>{const e=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield e(...t)}catch(t){return{error:{errorCode:io,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Or=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n}=t;if(i("projectId")||i("baseUrl")){if(!e)return;o(this,gr,"m",Sr).call(this,e,n)}o(this,xr,"f").call(this,t)}))},Er=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,Lr,"f").call(this)).isMissingConfig&&(yield o(this,gr,"m",Ur).call(this))}))},Ur=function(){return n(this,void 0,void 0,(function*(){const t=Do({projectId:this.projectId,filename:so,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield Po(t,"json"),!0}catch(t){return!1}}))},Tr=function(t){i(this,yr,Object.assign(Object.assign({},o(this,yr,"f")),t.detail),"f")},_r=function(){var t;null===(t=o(this,kr,"f"))||void 0===t||t.remove(),i(this,kr,null,"f")},Rr=function(t){return n(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,kr,document.createElement("descope-debugger"),"f"),Object.assign(o(this,kr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return ws})),document.body.appendChild(o(this,kr,"f"))):o(this,gr,"m",_r).call(this)}))},Mr=function(t,e){var n;t&&this.debug&&(null===(n=o(this,kr,"f"))||void 0===n||n.updateData({title:t,description:e}))},$r=function(){this.rootElement.onkeydown=t=>{var e,n,o;const i=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),r=_o.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==t.key||i||r)return;t.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((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(s).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},Dr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.24.2"}};class vs extends Dr{static set sdkConfigOverrides(t){Dr.sdkConfigOverrides=t}constructor(){const t=new ei({deferredRedirect:!1});super(t.update.bind(t)),Nr.add(this),this.stepState=new ei({},{updateOnlyOnChange:!1}),Fr.set(this,void 0),qr.set(this,null),Br.set(this,{visibilitychange:o(this,Nr,"m",Hr).bind(this)}),Vr.set(this,((t,e,r,s,a)=>{r===So&&(this.logger.debug("polling - Scheduling polling request"),i(this,Fr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,i;this.logger.debug("polling - Calling next");const l=yield this.sdk.flow.next(t,e,To,s,a,{});if((null===(n=null==l?void 0:l.error)||void 0===n?void 0:n.errorCode)===io)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,Vr,"f").call(this,t,e,r,s,a);this.logger.debug("polling - Got a response"),(null==l?void 0:l.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(l.error,null,4)),o(this,zr,"f").call(this,l);const{action:c}=null!==(i=null==l?void 0:l.data)&&void 0!==i?i:{};o(this,Vr,"f").call(this,t,e,c,s,a)}))),2e3),"f"))})),Kr.set(this,(()=>{clearTimeout(o(this,Fr,"f")),i(this,Fr,null,"f")})),zr.set(this,(t=>{var e,n,i,r,s,a,l,c,d,u,h;if(!(null==t?void 0:t.ok)){const a=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;return o(this,Nr,"m",rs).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:l,errorMessage:a}),void this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||l)}null===(l=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===l||l.forEach((t=>{const{level:e,title:n,log:o}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](n,o):this.loggerWrapper.info(n,o)}));const p=null===(u=null===(d=null===(c=t.data)||void 0===c?void 0:c.screen)||void 0===d?void 0:d.state)||void 0===u?void 0:u.errorText;(null===(h=t.data)||void 0===h?void 0:h.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${p?`${p} - `:""}${t.data.error.message}`):p&&this.loggerWrapper.error(p);const{status:f,authInfo:g,lastAuth:v}=t.data;if("completed"===f)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&oo&&localStorage.setItem(vo,JSON.stringify(t))}(v),void o(this,Nr,"m",rs).call(this,"success",g);const{executionId:m,stepId:b,stepName:w,action:y,screen:k,redirect:I,openInNewTabUrl:x,webauthn:C,error:j,samlIdpResponse:A}=t.data;y!==So?(this.loggerWrapper.info(`Step "${w||`#${b}`}" is ${f}`,"",{screen:k,status:f,stepId:b,stepName:w,action:y,error:j}),this.flowState.update({stepId:b,executionId:m,action:y,redirectTo:null==I?void 0:I.url,openInNewTabUrl:x,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==C?void 0:C.transactionId,webauthnOptions:null==C?void 0:C.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState})):this.flowState.update({action:y})})),Gr.set(this,Ho((()=>n(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.warn("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.warn("Webauthn start failed",t.message)}}))))),es.set(this,Go(((t,e)=>n(this,void 0,void 0,(function*(){if("true"===t.getAttribute("formnovalidate")||o(this,Nr,"m",Zr).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,Nr,"m",Yr).call(this,t);const r=yield o(this,Nr,"m",Qr).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),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 e(i,c.version,d.componentsVersion,l);o(this,zr,"f").call(this,u),o(this,Nr,"m",ts).call(this,r)}var n}))))),this.flowState=t}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const t=(yield this.getFlowConfig()).sdkScripts;null==t||t.forEach((t=>n(this,void 0,void 0,(function*(){(yield function(t){return n(this,void 0,void 0,(function*(){let e;switch(t){case"forter":return e=yield Promise.resolve().then((function(){return ks})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return xs})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return js})),e.default;default:throw new Error(`Unknown script id: ${t}`)}}))}(t.id))(t.initArgs,{baseUrl:this.baseUrl},(e=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Wr(t.id,t.resultKey)]:e},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e,n,i;this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",o(this,Br,"f").visibilitychange)),yield null===(i=t.init)||void 0===i?void 0:i.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=o(this,qr,"f"))||void 0===t||t.abort(),i(this,qr,null,"f"),window.removeEventListener("visibilitychange",o(this,Br,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const o=Jo(t),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${e}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${e}-${o.fallback}.html`),n}))}getPageContent(t,e){return n(this,void 0,void 0,(function*(){if(e)try{const{body:t}=yield Po(e,"text");return t}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${e}. Fallback to url ${t}`,n)}try{const{body:e}=yield Po(t,"text");return e}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(t,r,s){return n(this,void 0,void 0,(function*(){var n,a;const{projectId:l,flowId:c,tenant:d,stepId:u,executionId:h,action:p,screenId:f,screenState:g,redirectTo:v,openInNewTabUrl:m,redirectUrl:b,token:w,code:y,exchangeError:k,webauthnTransactionId:I,webauthnOptions:x,redirectAuthCodeChallenge:C,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:A,redirectAuthInitiator:S,locale:O,samlIdpResponseUrl:E,samlIdpResponseSamlResponse:U,samlIdpResponseRelayState:L}=t,T=e(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"]);let _,R;const M=(()=>{const t=localStorage.getItem(hi);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(hi,t.toString()),t}return Number(t)})(),$=this.sdk.getLastUserLoginId(),P=yield this.getFlowConfig(),D=yield this.getProjectConfig(),W=j&&C?{callbackUrl:j,codeChallenge:C,backupCallbackUri:A}:void 0;if(!h&&(this.loadSdkScripts(),P.fingerprintEnabled&&P.fingerprintKey?yield Mn(P.fingerprintKey,this.baseUrl):localStorage.removeItem(_n),P.conditions?({startScreenId:_,conditionInteractionId:R}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n,predicate:o})=>{var i;if("ELSE"===e)return!0;const r=null===(i=di[e])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(t,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:$,code:y,token:w,abTestingKey:M},P.conditions)):P.condition?({startScreenId:_,conditionInteractionId:R}=((t,e)=>{var n;const o=null===(n=di[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(P.condition,{loginId:$,code:y,token:w,abTestingKey:M})):_=P.startScreenId,!Vo(_,T))){const t=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:W},T),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:ui($),abTestingKey:M,locale:Jo(O).locale}),R,"",P.version,D.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),y?{exchangeCode:y,idpInitiated:!0}:{}),T.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),T.oidcLoginHint?{externalId:T.oidcLoginHint}:{}));return o(this,zr,"f").call(this,t),void("completed"!==(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}if(h&&(s("token")&&w||s("code")&&y||s("exchangeError")&&k)){const t=yield this.sdk.flow.next(h,u,Lo,P.version,D.componentsVersion,{token:w,exchangeCode:y,exchangeError:k});return o(this,zr,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===Uo&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!E||!U)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=t,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})(E,U,L||"",Ko)}if(p===Ao&&(s("redirectTo")||s("deferredRedirect")))return v?"android"===S&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(v):void this.loggerWrapper.error("Did not get redirect url");if(p===Oo||p===Eo){if(!I||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,qr,"f"))||void 0===a||a.abort(),i(this,qr,null,"f");try{t=p===Oo?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),e=t.name}const n=yield this.sdk.flow.next(h,u,Lo,P.version,D.componentsVersion,{transactionId:I,response:t,failure:e});o(this,zr,"f").call(this,n)}if(o(this,Vr,"f").call(this,h,u,p,P.version,D.componentsVersion),!f&&!_)return void this.loggerWrapper.warn("No screen was found to show");const N=_||f,F=yield this.getHtmlFilenameWithLocale(O,N),{oidcLoginHint:q,oidcPrompt:B,oidcErrorRedirectUri:H,samlIdpUsername:V}=T,K={direction:Wo(u,r.stepId),screenState:Object.assign(Object.assign({},g),{form:Object.assign(Object.assign({},this.formConfigValues),null==g?void 0:g.form),lastAuth:{loginId:$,name:this.sdk.getLastUserDisplayName()||$}}),htmlUrl:Do({projectId:l,filename:`${N}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:F&&Do({projectId:l,filename:F,baseUrl:this.baseStaticUrl}),samlIdpUsername:V,oidcLoginHint:q,oidcPrompt:B,oidcErrorRedirectUri:H,openInNewTabUrl:m},z=ui($);Vo(_,T)?K.next=(t,e,n,o)=>this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:W},T),{lastAuth:z,preview:this.preview,abTestingKey:M,client:this.client}),b&&{redirectUrl:b}),{locale:Jo(O).locale}),R,t,e,n,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),y&&{exchangeCode:y,idpInitiated:!0}),T.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(K.next=(...t)=>this.sdk.flow.next(h,u,...t)),this.stepState.update(K)}))}onStepChange(t,e){return n(this,void 0,void 0,(function*(){var i,r;const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=t,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield o(this,Nr,"m",Xr).call(this,p,c):p.querySelectorAll(`descope-button[${jo}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!t.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=t.samlIdpUsername,d.form.email=t.samlIdpUsername),ai(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,g);const v=()=>n(this,void 0,void 0,(function*(){var t,n;yield f;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(t=null==d?void 0:d.totp)||void 0===t?void 0:t.image,si(r,"descope-totp-image",s),((t,e)=>{si(t,"descope-notp-image",e)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((t,e)=>{oi(t,null==e?void 0:e.inputs),oi(t,null==e?void 0:e.form)})(this.rootElement,d)}));const a=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))}))}))})(this.rootElement),o(this,Nr,"m",os).call(this,c),a&&o(this,Nr,"m",rs).call(this,"ready",{}),o(this,Nr,"m",rs).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${jo}="polling"]`)){const t=yield this.getFlowConfig(),e=yield this.getProjectConfig(),n=yield c(To,t.version,e.componentsVersion,{});o(this,zr,"f").call(this,n)}u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,Nr,"m",is).call(this,v,l):v()}))}}Fr=new WeakMap,qr=new WeakMap,Br=new WeakMap,Vr=new WeakMap,Kr=new WeakMap,zr=new WeakMap,Gr=new WeakMap,es=new WeakMap,Nr=new WeakSet,Hr=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Jr=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const n=`user-${e}`;t.setAttribute("name",n),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:n)}))}},Xr=function(t,e){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,qr,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield li())){const{options:t,transactionId:r}=(yield o(this,Gr,"f").call(this))||{};if(t&&r){o(this,Nr,"m",Jr).call(this,s),i(this,qr,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,o(this,qr,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,a.version,l.componentsVersion,{transactionId:r,response:t});o(this,zr,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},Zr=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var n,o;"slot"!==e.localName&&(null===(n=e.reportValidity)||void 0===n||n.call(e),t&&(t=null===(o=e.checkValidity)||void 0===o?void 0:o.call(e)))})),t},Qr=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${go}])`));return(yield Promise.all(t.map((t=>n(this,void 0,void 0,(function*(){return{name:t.getAttribute("name"),value:t.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},Yr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},ts=function(t={}){var e,n;const o=zo(t,["externalId","email","phone"]),i=zo(t,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===n||n.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},ns=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.addEventListener("input",(()=>{var n;(null===(n=e.checkValidity)||void 0===n?void 0:n.call(e))&&o(this,es,"f").call(this,e,t)}))}))},os=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{o(this,es,"f").call(this,e,t)}})),o(this,Nr,"m",ns).call(this,t)},is=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===Ro.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.rootElement.classList.add("fade-out")},rs=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",vs);const ms=document.createElement("template");ms.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 bs extends HTMLElement{constructor(){super(),ss.add(this),as.set(this,new ei({messages:[]})),ls.set(this,void 0),cs.set(this,void 0),ds.set(this,void 0),us.set(this,{resize:o(this,ss,"m",gs).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ms.content.cloneNode(!0)),i(this,ls,this.shadowRoot.querySelector(".debugger"),"f"),i(this,cs,o(this,ls,"f").querySelector(".content"),"f"),i(this,ds,o(this,ls,"f").querySelector(".header"),"f")}updateData(t){o(this,as,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=ci(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(o(this,ls,"f"),o(this,ds,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,us,"f").resize),(t=o(this,ls,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},o(this,ls,"f").onresize=o(this,ss,"m",fs).bind(this),o(this,as,"f").subscribe(o(this,ss,"m",hs).bind(this))}disconnectedCallback(){o(this,as,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,us,"f").resize)}}as=new WeakMap,ls=new WeakMap,cs=new WeakMap,ds=new WeakMap,us=new WeakMap,ss=new WeakSet,hs=function(t){o(this,ss,"m",ps).call(this,t),o(this,ss,"m",fs).call(this)},ps=function(t){o(this,cs,"f").innerHTML=t.messages.map((t=>`\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 ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},fs=function(){o(this,cs,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,o=e.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},gs=function(){const[t,e]=ci(o(this,ls,"f"),Number.parseInt(o(this,ls,"f").style.left,10),Number.parseInt(o(this,ls,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,ls,"f").style.top=`${e}px`,o(this,ls,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",bs);var ws=Object.freeze({__proto__:null,default:bs});const ys='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n';var ks=Object.freeze({__proto__:null,default:(t,e,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=ys.replace(/{{SITE_ID}}/g,e),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",e),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(t=>{o(t.detail)}))}))});const Is=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:n,cloudflareScriptUrl:i,cloudflareEndpointUrl:r}=t;let s=[];s=n&&r?[r,sn]:[sn];let a=[];if(n&&i){const t=new URL(i);a=[`${t.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,pn]}else a=[pn];const l=fn({apiKey:e,endpoint:s,scriptUrlPattern:a}),c=yield l,{requestId:d}=yield c.get();o(d)}catch(t){console.warn("Could not load fingerprint",t)}}));var xs=Object.freeze({__proto__:null,default:Is,loadFingerprint:Is});const Cs=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,cloudflareEndpointPath:r,cloudflareScriptPath:s}=t,{baseUrl:a}=e;let l;l=n?`https://${n}`:a||"https://api.descope.com";const c=new URL(l);c.pathname=r;const d=new URL(l);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=fn({apiKey:i,endpoint:[c.toString(),sn],scriptUrlPattern:[u,pn]}),p=yield h,{requestId:f}=yield p.get();o(f)}catch(t){console.warn("Could not load descope fingerprint",t)}}));var js=Object.freeze({__proto__:null,default:Cs,loadFingerprint:Cs})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-component",
3
- "version": "3.24.1",
3
+ "version": "3.24.2",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/descope-js",
6
6
  "bugs": {
@@ -68,7 +68,7 @@
68
68
  "tslib": "2.6.3",
69
69
  "@fingerprintjs/fingerprintjs-pro": "3.9.9",
70
70
  "@descope/sdk-helpers": "0.1.60",
71
- "@descope/web-js-sdk": "1.16.4",
71
+ "@descope/web-js-sdk": "1.16.5",
72
72
  "@descope/sdk-mixins": "0.3.1"
73
73
  },
74
74
  "overrides": {