@descope/web-component 3.27.3 → 3.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-96862809.js";import"@descope/escape-markdown";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 m=document.createElement("template");m.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 f 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(m.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",f);export{f as default};
1
+ import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-213a4ec6.js";import"@descope/escape-markdown";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 m=document.createElement("template");m.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 f 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(m.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",f);export{f as default};
@@ -0,0 +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{escapeMarkdown as a}from"@descope/escape-markdown";import{themeMixin as l}from"@descope/sdk-mixins";import{createSingletonMixin as d,compose as c}from"@descope/sdk-helpers";const u="undefined"!=typeof localStorage,h="J151000",p=u&&localStorage.getItem("base.content.url")||"",g="config.json",f="base.ui.components.url";u&&localStorage.getItem(f),u&&localStorage.getItem(f);const v="descope-login-flow",m="code",b="data-exclude-field",y="dls_last_auth",w="state_id",I="saml_idp_state_id",C="saml_idp_username",k="descope_idp_initiated",A="sso_app_id",S="oidc_login_hint",E="oidc_prompt",x="oidc_error_redirect_uri",j="data-type",O="redirect",U="poll",R="webauthnCreate",L="webauthnGet",T="nativeBridge",W="loadForm",$="submit",P="polling",M=["descope-multi-select-combo-box","descope-text-area"];var N;!function(t){t.backward="backward",t.forward="forward"}(N||(N={}));const q=["descope-enriched-text"];function _(t){return new URLSearchParams(window.location.search).get(t)}function V(t){if(window.history.replaceState&&_(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 D(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 F({projectId:t,filename:e,assetsFolder:i="v2-beta",baseUrl:o}){const r=new URL(p||o||"https://static.descope.com/pages");return r.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(r.pathname,t,i,e),r.toString()}function K(t,e){if(!e)return;const i=+t,o=+e;return Number.isNaN(i)||Number.isNaN(o)?void 0:i>o?N.forward:i<o?N.backward:void 0}const H=()=>{const[t="",e=""]=(_(v)||"").split("_");return{executionId:t,stepId:e}};function B(){V(v)}const J=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),G=()=>{const{executionId:t,stepId:e}=H();(t||e)&&B();const i=_("t")||void 0;i&&V("t");const o=_(m)||void 0;o&&V(m);const r=_("err")||void 0;r&&V("err");const{redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:_("ra-challenge"),redirectAuthCallbackUrl:_("ra-callback"),redirectAuthBackupCallbackUri:_("ra-backup-callback"),redirectAuthInitiator:_("ra-initiator")},d=_(w);d&&V(w);const c=_(I);c&&V(I);const u=_(C);c&&V(C);const h=_(k);h&&V(k);const p=_(A);p&&V(A);const g=_(S);g&&V(S);const f=_(E);f&&V(E);const v=_(x);v&&V(x);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:g,oidcPrompt:f,oidcErrorRedirectUri:v}}},z=t=>{let e,i;return Object.assign(((...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}),{reset:()=>{e=void 0,i=void 0}})};function Q(t,e,i){return new Promise(((o,r)=>{let n=!1;const s=setTimeout((()=>{n=!0,void 0!==i?o(i):r(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{n||(clearTimeout(s),o(t))})).catch((t=>{n||(clearTimeout(s),r(t))}))}))}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([${b}])`)).forEach((t=>{t.value=i}))}))},ct=(t,e)=>e.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),t),ut=(t,e,i)=>t.replace(/{{(.+?)}}/g,((t,o)=>i?a(ct(e,o)):ct(e,o))),ht=(t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{const i=(o=t.localName,q.includes(o));var o;t.textContent=ut(t.textContent,e,i);const r=t.getAttribute("href");r&&t.setAttribute("href",ut(r,e))}))},pt=(t,e,i)=>{t.querySelectorAll(`[${j}="${e}"]`).forEach((t=>{t.setAttribute("href",i)}))},gt=(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})`))},ft=(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(`[${j}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",l),pt(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),pt(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),ht(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=ut(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)},vt=z((()=>t(void 0,void 0,void 0,(function*(){var t,e;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=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)))),o=(()=>{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 Q(100,i,o)}catch(t){return console.error("Conditional login check failed",t),!1}})))),mt={"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 bt(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(y)))}catch(t){}return e}const yt="dls_ab_testing_id",wt=d((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})),It=document.createElement("template");It.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 Ct=(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),Ct(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 kt,At,St,Et,xt,jt,Ot,Ut,Rt,Lt,Tt,Wt,$t,Pt,Mt,Nt,qt,_t,Vt,Dt,Ft;const Kt=c(l,wt)(HTMLElement);class Ht extends Kt{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(),kt.add(this),St.set(this,!1),this.loggerWrapper={error:(t,i="")=>{this.logger.error(t,i,new Error),e(this,kt,"m",Dt).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)}},Et.set(this,new at),xt.set(this,new at),jt.set(this,{}),this.getComponentsContext=()=>e(this,jt,"f"),this.nextRequestStatus=new at({isLoading:!1}),Ot.set(this,void 0),Ut.set(this,{popstate:e(this,kt,"m",Wt).bind(this),componentsContext:e(this,kt,"m",qt).bind(this)}),Rt.set(this,void 0),this.getConfig=z((()=>t(this,void 0,void 0,(function*(){const t=F({projectId:this.projectId,filename:g,baseUrl:this.baseStaticUrl});try{const{body:e,headers:i}=yield D(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,Rt,o,"f"),e(this,kt,"m",Lt).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 Ct(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}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();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()))}))}getComponentsVersion(){return t(this,void 0,void 0,(function*(){var t,e;const i=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}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,xt,"f").subscribe(e(this,kt,"m",Vt).bind(this)),e(this,xt,"f").update({isDebug:this.debug}),e(this,kt,"m",Tt).call(this),yield e(this,kt,"m",Mt).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");e(this,kt,"m",Ft).call(this);const{executionId:r,stepId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=G();window.addEventListener("popstate",e(this,Ut,"f").popstate),window.addEventListener("components-context",e(this,Ut,"f").componentsContext),e(this,Et,"f").subscribe(e(this,kt,"m",Pt).bind(this)),e(this,Et,"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,St,!0,"f")}))}disconnectedCallback(){e(this,Et,"f").unsubscribeAll(),e(this,xt,"f").unsubscribeAll(),e(this,kt,"m",_t).call(this),window.removeEventListener("popstate",e(this,Ut,"f").popstate),window.removeEventListener("components-context",e(this,Ut,"f").componentsContext)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,St,"f")&&i!==o&&At.observedAttributes.includes(t)){e(this,kt,"m",Tt).call(this);const r=null===i;e(this,Et,"f").update((({stepId:e,executionId:i})=>{let n=e,s=i;return r||(s=null,n=null,B()),{[J(t)]:o,stepId:n,executionId:s}})),e(this,xt,"f").update({isDebug:this.debug})}}}function Bt(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Jt,Gt,zt,Qt,Xt,Yt,Zt,te,ee,ie,oe,re,ne,se,ae,le,de,ce,ue,he,pe,ge,fe;At=Ht,St=new WeakMap,Et=new WeakMap,xt=new WeakMap,jt=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Rt=new WeakMap,kt=new WeakSet,Lt=function(){this.shadowRoot.appendChild(It.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},Tt=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"];At.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[J(e)])throw Error(`${e} cannot be empty`)}))},Wt=function(){const{stepId:t,executionId:i}=H();e(this,Et,"f").update({stepId:t,executionId:i})},$t=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},At.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:h,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Pt=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,kt,"m",$t).call(this,t,o)}e(this,Rt,"f").call(this,i)}))},Mt=function(){return t(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield e(this,kt,"m",Nt).call(this))}))},Nt=function(){return t(this,void 0,void 0,(function*(){const t=F({projectId:this.projectId,filename:g,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield D(t,"json"),!0}catch(t){return!1}}))},qt=function(t){i(this,jt,Object.assign(Object.assign({},e(this,jt,"f")),t.detail),"f")},_t=function(){var t;null===(t=e(this,Ot,"f"))||void 0===t||t.remove(),i(this,Ot,null,"f")},Vt=function(o){return t(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,Ot,document.createElement("descope-debugger"),"f"),Object.assign(e(this,Ot,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-5816689e.js"),document.body.appendChild(e(this,Ot,"f"))):e(this,kt,"m",_t).call(this)}))},Dt=function(t,i){var o;t&&this.debug&&(null===(o=e(this,Ot,"f"))||void 0===o||o.updateData({title:t,description:i}))},Ft=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=M.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()}}},Ht.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.29.0"}};class ve extends Ht{static set sdkConfigOverrides(t){Ht.sdkConfigOverrides=t}constructor(){const o=new at({deferredRedirect:!1});super(o.update.bind(o)),Jt.add(this),this.stepState=new at({},{updateOnlyOnChange:!1}),Gt.set(this,void 0),zt.set(this,null),Qt.set(this,{visibilitychange:e(this,Jt,"m",Xt).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,i)=>{var o;const r=JSON.parse(i);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:t}=r;if(!t){t=null===(o=new URL(r.url).searchParams)||void 0===o?void 0:o.get(m)}this.nativeComplete({exchangeCode:t,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(r.url),i=t.searchParams.get("t"),o=t.searchParams.get(v).split("_").pop();e(this,te,"f").call(this),this.flowState.update({token:i,stepId:o,action:void 0})}else this.nativeComplete(r)},Zt.set(this,((o,r,n,s,a=!1)=>{if(this.flowState.current.action===U){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),d=a?500:2e3;i(this,Gt,setTimeout((()=>t(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(o,r,P,n,s,{}),c=document.hidden&&!a&&Date.now()-l>d+500;let u;c&&this.logger.debug("polling - The polling seems to be throttled");try{const t=c?1e3:6e3;u=yield Q(t,i)}catch(t){return this.logger.warn(`polling - The ${c?"throttled fetch":"fetch"} call timed out or was aborted`),void e(this,Zt,"f").call(this,o,r,n,s,c)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===h)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,Zt,"f").call(this,o,r,n,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),e(this,ee,"f").call(this,u),e(this,Zt,"f").call(this,o,r,n,s)}))),d),"f")}})),te.set(this,(()=>{clearTimeout(e(this,Gt,"f")),i(this,Gt,null,"f")})),ee.set(this,(t=>{var i,o,r,n,s,a,l,d,c,h,p,g;if(!(null==t?void 0:t.ok)){const l=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${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}`;e(this,Jt,"m",fe).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:d,errorMessage:l}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||l,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||d);const c=null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorCode;return void("E102004"!==c&&"E103205"!==c||!this.isRestartOnError||e(this,Jt,"m",Yt).call(this))}null===(d=null===(l=t.data)||void 0===l?void 0:l.runnerLogs)||void 0===d||d.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===(p=null===(h=null===(c=t.data)||void 0===c?void 0:c.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.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:v,authInfo:m,lastAuth:b}=t.data;if("completed"===v)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&u&&localStorage.setItem(y,JSON.stringify(t))}(b),void e(this,Jt,"m",fe).call(this,"success",m);const{executionId:w,stepId:I,stepName:C,action:k,screen:A,redirect:S,openInNewTabUrl:E,webauthn:x,error:j,samlIdpResponse:O,nativeResponse:R}=t.data;k!==U?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${v}`,"",{screen:A,status:v,stepId:I,stepName:C,action:k,error:j}),this.flowState.update({stepId:I,executionId:w,action:k,redirectTo:null==S?void 0:S.url,openInNewTabUrl:E,screenId:null==A?void 0:A.id,screenState:null==A?void 0:A.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options,samlIdpResponseUrl:null==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState,nativeResponseType:null==R?void 0:R.type,nativePayload:null==R?void 0:R.payload})):this.flowState.update({action:k})})),ie.set(this,z((()=>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)}}))))),ue.set(this,tt(((i,o)=>t(this,void 0,void 0,(function*(){var t,r;if("true"===i.getAttribute("formnovalidate")||e(this,Jt,"m",ne).call(this)){const n=null==i?void 0:i.getAttribute("id");e(this,Jt,"m",ae).call(this,i);const s=yield e(this,Jt,"m",se).call(this),a=(r=i,Array.from((null==r?void 0:r.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}),{})),l=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},l),a),s),{origin:(null===(t=this.nativeOptions)||void 0===t?void 0:t.origin)||window.location.origin}),c=yield this.getFlowConfig(),u=yield this.getProjectConfig(),h=yield o(n,c.version,u.componentsVersion,d);e(this,ee,"f").call(this,h),e(this,Jt,"m",le).call(this,s)}}))))),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:{[Bt(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,Qt,"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,zt,"f"))||void 0===t||t.abort(),i(this,zt,null,"f"),window.removeEventListener("visibilitychange",e(this,Qt,"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 D(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 D(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 d,c;const{projectId:u,flowId:h,tenant:p,stepId:g,executionId:f,action:v,screenId:m,screenState:b,redirectTo:y,openInNewTabUrl:w,redirectUrl:I,token:C,code:k,exchangeError:A,webauthnTransactionId:S,webauthnOptions:E,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:U,redirectAuthInitiator:P,locale:M,samlIdpResponseUrl:N,samlIdpResponseSamlResponse:q,samlIdpResponseRelayState:_,nativeResponseType:V,nativePayload:D}=r,H=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","nativeResponseType","nativePayload"]);let B,J;const G=(()=>{const t=localStorage.getItem(yt);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(yt,t.toString()),t}return Number(t)})(),z=this.sdk.getLastUserLoginId(),Q=yield this.getFlowConfig(),Z=yield this.getProjectConfig(),tt=Object.entries(Z.flows||{}).reduce(((t,[e,i])=>(t[e]=i.version,t)),{}),it=j&&x?{callbackUrl:j,codeChallenge:x,backupCallbackUri:U}:void 0,ot=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!f&&(this.loadSdkScripts(),Q.fingerprintEnabled&&Q.fingerprintKey?yield n(Q.fingerprintKey,this.baseUrl):s(),Q.conditions?({startScreenId:B,conditionInteractionId:J}=((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=mt[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:z,code:k,token:C,abTestingKey:G},Q.conditions)):Q.condition?({startScreenId:B,conditionInteractionId:J}=((t,e)=>{var i;const o=null===(i=mt[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}})(Q.condition,{loginId:z,code:k,token:C,abTestingKey:G})):B=Q.startScreenId,!X(B,H))){const t=yield this.sdk.flow.start(h,Object.assign(Object.assign(Object.assign(Object.assign({tenant:p,redirectAuth:it},H),{client:this.client}),I&&{redirectUrl:I}),{lastAuth:bt(z),abTestingKey:G,locale:et(M).locale,nativeOptions:ot}),J,"",Z.componentsVersion,tt,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),H.descopeIdpInitiated&&{idpInitiated:!0}),C?{token:C}:{}),H.oidcLoginHint?{externalId:H.oidcLoginHint}:{}));return e(this,ee,"f").call(this,t),void("completed"!==(null===(d=null==t?void 0:t.data)||void 0===d?void 0:d.status)&&this.flowState.update({code:void 0,token:void 0}))}if(f&&(l("token")&&C||l("code")&&k||l("exchangeError")&&A)){const t=yield this.sdk.flow.next(f,g,$,Q.version,Z.componentsVersion,{token:C,exchangeCode:k,exchangeError:A});return e(this,ee,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(v===W&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>l(t)))){if(!N||!q)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)})(N,q,_||"",Y)}if(v===O&&(l("redirectTo")||l("deferredRedirect")))return y?"android"===P&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(y):void this.loggerWrapper.error("Did not get redirect url");if(v===R||v===L){if(!S||!E)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,o;null===(c=e(this,zt,"f"))||void 0===c||c.abort(),i(this,zt,null,"f");try{t=v===R?yield this.sdk.webauthn.helpers.create(E):yield this.sdk.webauthn.helpers.get(E)}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,g,$,Q.version,Z.componentsVersion,{transactionId:S,response:t,failure:o});e(this,ee,"f").call(this,r)}if(v===T)return this.nativeComplete=i=>t(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(f,g,$,Q.version,Z.componentsVersion,i);e(this,ee,"f").call(this,t)})),void e(this,Jt,"m",fe).call(this,"bridge",{type:V,payload:D});if(e(this,Zt,"f").call(this,f,g,Q.version,Z.componentsVersion),!m&&!B)return void this.loggerWrapper.warn("No screen was found to show");const rt=B||m,nt=yield this.getHtmlFilenameWithLocale(M,rt),{oidcLoginHint:st,oidcPrompt:at,oidcErrorRedirectUri:lt,samlIdpUsername:dt}=H,ct={direction:K(g,a.stepId),screenState:Object.assign(Object.assign({},b),{form:Object.assign(Object.assign({},this.formConfigValues),null==b?void 0:b.form),lastAuth:{loginId:z,name:this.sdk.getLastUserDisplayName()||z}}),htmlUrl:F({projectId:u,filename:`${rt}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:nt&&F({projectId:u,filename:nt,baseUrl:this.baseStaticUrl}),samlIdpUsername:dt,oidcLoginHint:st,oidcPrompt:at,oidcErrorRedirectUri:lt,openInNewTabUrl:w},ut=bt(z);X(B,H)?ct.next=(t,e,i,o)=>this.sdk.flow.start(h,Object.assign(Object.assign(Object.assign(Object.assign({tenant:p,redirectAuth:it},H),{lastAuth:ut,preview:this.preview,abTestingKey:G,client:this.client}),I&&{redirectUrl:I}),{locale:et(M).locale,nativeOptions:ot}),J,t,i,tt,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),H.descopeIdpInitiated&&{idpInitiated:!0}),C&&{token:C})):(l("projectId")||l("baseUrl")||l("executionId")||l("stepId"))&&(ct.next=(...t)=>this.sdk.flow.next(f,g,...t)),this.stepState.update(ct)}))}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),g=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield e(this,Jt,"m",re).call(this,p,d):p.querySelectorAll(`descope-button[${j}="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),ft(p,c,c.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,f);const v=()=>t(this,void 0,void 0,(function*(){var t,i;yield g;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,gt(n,"descope-totp-image",s),((t,e)=>{gt(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);const a=!o.htmlUrl;setTimeout((()=>{e(this,Jt,"m",de).call(this),((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),((t,e)=>{dt(t,null==e?void 0:e.inputs),dt(t,null==e?void 0:e.form)})(this.rootElement,c)})),e(this,Jt,"m",pe).call(this,d),a&&e(this,Jt,"m",fe).call(this,"ready",{}),e(this,Jt,"m",fe).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${j}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(P,t.version,i.componentsVersion,{});e(this,ee,"f").call(this,o)}u&&!o.openInNewTabUrl&&window.open(u,"_blank")}));l?e(this,Jt,"m",ge).call(this,v,l):v()}))}}Gt=new WeakMap,zt=new WeakMap,Qt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,ie=new WeakMap,ue=new WeakMap,Jt=new WeakSet,Xt=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Yt=function(){return t(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const t=yield this.getComponentsVersion();this.getConfig.reset();t===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},oe=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)}))}},re=function(o,r){return t(this,void 0,void 0,(function*(){var n;null===(n=e(this,zt,"f"))||void 0===n||n.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield vt())){const{options:o,transactionId:n}=(yield e(this,ie,"f").call(this))||{};if(o&&n){e(this,Jt,"m",oe).call(this,s),i(this,zt,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,zt,"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,ee,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},ne=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},se=function(){return t(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${b}])`));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})),{})}))},ae=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},le=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)}},de=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()));this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>e(this,Jt,"m",ce).call(this,t)))},ce=function(t){if(!t)return;t.querySelectorAll("input").forEach((e=>{const i=e.getAttribute("slot"),o=`input-${t.id}-${i}`,r=document.createElement("slot");r.setAttribute("name",o),r.setAttribute("slot",i),t.appendChild(r),e.setAttribute("slot",o),this.appendChild(e)}))},he=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,ue,"f").call(this,i,t)}))}))},pe=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{e(this,ue,"f").call(this,i,t)}})),e(this,Jt,"m",he).call(this,t)},ge=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===N.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")},fe=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",ve);export{ve as D,at as S};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{D as default}from"./index-96862809.js";import"tslib";import"@descope/web-js-sdk";import"@descope/escape-markdown";import"@descope/sdk-mixins";import"@descope/sdk-helpers";
1
+ export{D as default}from"./index-213a4ec6.js";import"tslib";import"@descope/web-js-sdk";import"@descope/escape-markdown";import"@descope/sdk-mixins";import"@descope/sdk-helpers";
package/dist/index.d.ts CHANGED
@@ -488,24 +488,24 @@ declare const BaseClass: {
488
488
  focus(options?: FocusOptions): void;
489
489
  };
490
490
  } & (new (...params: any[]) => {
491
- "__#12337@#globalStyleTag": HTMLStyleElement;
491
+ "__#12343@#globalStyleTag": HTMLStyleElement;
492
492
  readonly theme: _descope_sdk_mixins.ThemeOptions;
493
493
  readonly styleId: string;
494
- "__#12337@#_themeResource": Promise<void | Record<string, any>>;
495
- "__#12337@#fetchTheme"(): Promise<Record<string, any>>;
496
- readonly "__#12337@#themeResource": Promise<void | Record<string, any>>;
497
- "__#12337@#loadGlobalStyle"(): Promise<void>;
498
- "__#12337@#loadComponentsStyle"(): Promise<void>;
499
- "__#12337@#getFontsConfig"(): Promise<Record<string, {
494
+ "__#12343@#_themeResource": Promise<void | Record<string, any>>;
495
+ "__#12343@#fetchTheme"(): Promise<Record<string, any>>;
496
+ readonly "__#12343@#themeResource": Promise<void | Record<string, any>>;
497
+ "__#12343@#loadGlobalStyle"(): Promise<void>;
498
+ "__#12343@#loadComponentsStyle"(): Promise<void>;
499
+ "__#12343@#getFontsConfig"(): Promise<Record<string, {
500
500
  url?: string;
501
501
  }>>;
502
- "__#12337@#loadFonts"(): Promise<void>;
503
- "__#12337@#applyTheme"(): Promise<void>;
502
+ "__#12343@#loadFonts"(): Promise<void>;
503
+ "__#12343@#applyTheme"(): Promise<void>;
504
504
  init(): Promise<void>;
505
- "__#12326@#observeMappings": {};
505
+ "__#12332@#observeMappings": {};
506
506
  observeAttribute: ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any);
507
507
  observeAttributes: ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void);
508
- "__#12325@#isInit": boolean;
508
+ "__#12331@#isInit": boolean;
509
509
  connectedCallback: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
510
510
  accessKey: string;
511
511
  readonly accessKeyLabel: string;
@@ -832,13 +832,13 @@ declare const BaseClass: {
832
832
  tabIndex: number;
833
833
  blur(): void;
834
834
  focus(options?: FocusOptions): void;
835
- "__#12324@#logger": {
835
+ "__#12330@#logger": {
836
836
  error(...data: any[]): void;
837
837
  warn(...data: any[]): void;
838
838
  info(...data: any[]): void;
839
839
  debug(...data: any[]): void;
840
840
  };
841
- "__#12324@#wrapLogger": ((logger: Partial<{
841
+ "__#12330@#wrapLogger": ((logger: Partial<{
842
842
  error(...data: any[]): void;
843
843
  warn(...data: any[]): void;
844
844
  info(...data: any[]): void;
@@ -985,8 +985,8 @@ declare const BaseClass: {
985
985
  contentRootElement: HTMLElement;
986
986
  rootElement: HTMLElement;
987
987
  readonly config: any;
988
- "__#12328@#_configResource": any;
989
- "__#12328@#fetchConfig": (() => Promise<{
988
+ "__#12334@#_configResource": any;
989
+ "__#12334@#fetchConfig": (() => Promise<{
990
990
  projectConfig: _descope_sdk_mixins.ProjectConfiguration;
991
991
  executionContext: {
992
992
  geo: string;
@@ -1010,19 +1010,19 @@ declare const BaseClass: {
1010
1010
  readonly baseStaticUrl: string;
1011
1011
  readonly baseUrl: string;
1012
1012
  readonly projectId: string;
1013
- "__#12327@#handleError": ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void);
1014
- "__#12331@#errorCbsSym": symbol;
1015
- "__#12331@#loadCbsSym": symbol;
1016
- "__#12331@#getComponentsVersion"(): Promise<any>;
1017
- "__#12331@#exposeAlternateEvents"(scriptEle: HTMLScriptElement): void;
1018
- "__#12331@#handleFallbackScript"(errorCbs: ((error: string) => void)[], loadCbs: (() => void)[]): Promise<void>;
1019
- "__#12331@#registerEvents"(scriptEle: HTMLScriptElement): void;
1020
- "__#12331@#getDescopeUiLoadingScript"(): Promise<HTMLElement>;
1021
- "__#12331@#descopeUi": Promise<any>;
1013
+ "__#12333@#handleError": ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void);
1014
+ "__#12337@#errorCbsSym": symbol;
1015
+ "__#12337@#loadCbsSym": symbol;
1016
+ "__#12337@#getComponentsVersion"(): Promise<any>;
1017
+ "__#12337@#exposeAlternateEvents"(scriptEle: HTMLScriptElement): void;
1018
+ "__#12337@#handleFallbackScript"(errorCbs: ((error: string) => void)[], loadCbs: (() => void)[], elemId: string, scriptUrl: string): Promise<void>;
1019
+ "__#12337@#registerEvents"(scriptEle: HTMLScriptElement): void;
1020
+ "__#12337@#getDescopeUiLoadingScript"(): Promise<HTMLElement>;
1021
+ "__#12337@#descopeUi": Promise<any>;
1022
1022
  readonly descopeUi: Promise<any>;
1023
- "__#12331@#loadDescopeUiComponent"(componentName: string): Promise<any>;
1023
+ "__#12337@#loadDescopeUiComponent"(componentName: string): Promise<any>;
1024
1024
  loadDescopeUiComponents(templateOrComponentNames: string[] | HTMLTemplateElement): Promise<any[]>;
1025
- "__#12331@#getDescopeUi"(): Promise<unknown>;
1025
+ "__#12337@#getDescopeUi"(): Promise<unknown>;
1026
1026
  }) & {
1027
1027
  new (): HTMLElement;
1028
1028
  prototype: HTMLElement;
@@ -1100,11 +1100,14 @@ declare class DescopeWc extends BaseDescopeWc {
1100
1100
  stepState: State<StepState>;
1101
1101
  constructor();
1102
1102
  bridgeVersion: number;
1103
- nativeComplete: (bridgeResponse: string) => Promise<void>;
1103
+ nativeComplete: (input: Record<string, any>) => Promise<void>;
1104
+ nativeResume: (type: string, payload: string) => void;
1104
1105
  nativeOptions: {
1105
1106
  platform: 'ios' | 'android';
1106
1107
  oauthProvider?: string;
1107
1108
  oauthRedirect?: string;
1109
+ magicLinkRedirect?: string;
1110
+ ssoRedirect?: string;
1108
1111
  origin?: string;
1109
1112
  } | undefined;
1110
1113
  loadSdkScripts(): Promise<void>;
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",S="/v1/auth/oauth/authorize",O="/v1/auth/oauth/exchange",j="v1/auth/oauth/native/start",A="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",R="/v1/auth/totp/update",_="/v1/auth/notp/whatsapp/signin",$="/v1/auth/notp/whatsapp/signup",M="/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"},q={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},F="/v1/auth/password/signup",B="/v1/auth/password/signin",V="/v1/auth/password/reset",H="/v1/auth/password/update",K="/v1/auth/password/replace",z="/v1/auth/password/policy",J="/v1/auth/refresh",G="/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")}};let lt;const ct=()=>{if(lt)return lt;const t=new Date,e=`${t.getUTCFullYear().toString()}-${(t.getUTCMonth()+1).toString().padStart(2,"0")}-${t.getUTCDate().toString().padStart(2,"0")}-${t.getUTCHours().toString().padStart(2,"0")}:${t.getUTCMinutes().toString().padStart(2,"0")}:${t.getUTCSeconds().toString().padStart(2,"0")}:${t.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return lt=`${e}-${n}`,lt};var dt;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT",t.patch="PATCH"}(dt||(dt={}));const ut=({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){const t=Object.keys(n);t.forEach(((e,o)=>{r=`${r}${0===o?"?":""}${e}=${encodeURIComponent(n[e])}${o===t.length-1?"":"&"}`}))}return r},ht=(...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}),{})),pt={"Content-Type":"application/json"},ft=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},gt=t=>{try{t=JSON.parse(t)}catch(t){return!1}return"object"==typeof t&&null!==t},vt=({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:ht(ft(e,f),{"x-descope-sdk-session-id":ct(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.29.1"},(null==n?void 0:n.baseHeaders)||{},gt(g)?pt:{},u),method:p,body:g};null!==r&&(v.credentials=r||"include");const m=await a(ut({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:dt.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.post,token:i}),patch:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.patch,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:dt.delete,token:o}),hooks:i,buildUrl:(n,o)=>ut({projectId:e,baseUrl:t,path:n,queryParams:o})}};var mt=429;function bt(t,e,n){var o;let i=wt(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 wt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return a(t)}function yt(t){const{exp:e}=wt(t);return(new Date).getTime()/1e3>e}function kt(t){let e=wt(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function It(t,e){return bt(t,e,"permissions")}function xt(t,e){return bt(t,e,"roles")}const Ct=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function St(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===mt&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Ot=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),jt=(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 "))},At=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Et=t=>e=>t.test(e),Ut=Et(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Lt=Et(/^\+[1-9]{1}[0-9]{3,14}$/),Tt=Ot(Ut,'"{val}" is not a valid email'),Rt=Ot(Lt,'"{val}" is not a valid phone number'),_t=Ot((t=>t.length>=1),"Minimum length is 1");const $t=Ot((t=>"string"==typeof t),"Input is not a string"),Mt=Ot((t=>Array.isArray(t)),"Input is not an array"),Pt=Ot((t=>"boolean"==typeof t),"Input is not a boolean"),Dt=Ot((t=>void 0===t),"Input is defined"),Wt=jt([$t(),Dt()],"Input is not a string or undefined"),Nt=jt([Mt(),Pt()],"Input is not an array or boolean"),qt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>At(...t).validate(n[e]))),e(...n)),Ft=t=>[$t(`"${t}" must be a string`)],Bt=t=>[$t(`"${t}" must be a string`),_t(`"${t}" must not be empty`)],Vt=t=>[$t(`"${t}" must be a string`),Tt()],Ht=t=>[$t(`"${t}" must be a string`),Rt()],Kt=qt(Bt("accessKey")),zt=t=>({exchange:Kt(((e,n)=>St(t.post(l,{loginOptions:n},{token:e}))))}),Jt=(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 Xt,Zt;!function(t){t.sms="sms",t.voice="voice",t.whatsapp="whatsapp"}(Xt||(Xt={})),function(t){t.email="email"}(Zt||(Zt={}));const Qt=Object.assign(Object.assign({},Xt),Zt);var Yt;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(Yt||(Yt={}));const te=Bt("loginId"),ee=qt(Bt("token")),ne=qt(te),oe=qt(Bt("pendingRef")),ie=qt(te,Vt("email")),re=t=>({verify:ee((e=>St(t.post(w,{token:e})))),signIn:ne(((e,n,o,i)=>St(t.post(Ct(y,Qt.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:ne(((e,n,o)=>St(t.post(Ct(C,Qt.email),{loginId:e,URI:n,loginOptions:o})))),signUp:ne(((e,n,o,i)=>St(t.post(Ct(k,Qt.email),{loginId:e,URI:n,user:o,loginOptions:i})))),waitForSession:oe(((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(St(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:ie(((e,n,o,i,r)=>St(t.post(x.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),se=qt(Bt("flowId")),ae=qt(Bt("executionId"),Bt("stepId"),Bt("interactionId")),le=t=>({start:se(((e,n,o,i,r,s,a)=>St(t.post(et,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a})))),next:ae(((e,n,o,i,r,s)=>St(t.post(nt,{executionId:e,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),ce=Bt("loginId"),de=qt(Bt("token")),ue=qt(ce),he=qt(ce,Ht("phone")),pe=qt(ce,Vt("email")),fe=Object.keys(Qt).filter((t=>t!==Xt.voice)),ge=t=>({verify:de((e=>St(t.post(f,{token:e})))),signIn:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i,r)=>St(t.post(Ct(g,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i,r)=>St(t.post(Ct(v,n),{loginId:e,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i)=>St(t.post(Ct(b,n),{loginId:e,URI:o,loginOptions:i}))))})),{}),update:{email:pe(((e,n,o,i,r)=>St(t.post(m.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(Xt).filter((t=>t!==Xt.voice)).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:he(((e,o,i,r,s)=>St(t.post(Ct(m.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var ve;!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"}(ve||(ve={}));const me=qt(Bt("code")),be=t=>({start:Object.assign(((e,n,o,i)=>St(t.post(S,o||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:i}))),Object.keys(ve).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>St(t.post(S,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{})),exchange:me((e=>St(t.post(O,{code:e})))),startNative:(e,n,o)=>St(t.post(j,{provider:e,loginOptions:n,implicit:o})),finishNative:(e,n,o,i,r)=>St(t.post(A,{provider:e,stateId:n,user:o,code:i,idToken:r}))}),we=Bt("loginId"),ye=qt(we,Bt("code")),ke=qt(we),Ie=qt(we,Ht("phone")),xe=qt(we,Vt("email")),Ce=t=>({verify:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ye(((e,o)=>St(t.post(Ct(c,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o,i)=>St(t.post(Ct(d,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o,i)=>St(t.post(Ct(u,n),{loginId:e,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o)=>St(t.post(Ct(p,n),{loginId:e,loginOptions:o}))))})),{}),update:{email:xe(((e,n,o,i)=>St(t.post(h.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(Xt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ie(((e,o,i,r)=>St(t.post(Ct(h.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),Se=qt(Bt("tenant")),Oe=qt(Bt("code")),je=t=>({start:Se(((e,n,o,i)=>St(t.post(E,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:Oe((e=>St(t.post(U,{code:e}))))}),Ae=Bt("loginId"),Ee=qt(Ae,Bt("code")),Ue=qt(Ae),Le=qt(Ae),Te=t=>({signUp:Ue(((e,n)=>St(t.post(T,{loginId:e,user:n})))),verify:Ee(((e,n,o,i)=>St(t.post(L,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Le(((e,n)=>St(t.post(R,{loginId:e},{token:n}))))}),Re=Bt("loginId"),_e=Bt("newPassword"),$e=qt(Re,Bt("password")),Me=qt(Re),Pe=qt(Re,_e),De=qt(Re,Bt("oldPassword"),_e),We=t=>({signUp:$e(((e,n,o,i)=>St(t.post(F,{loginId:e,password:n,user:o,loginOptions:i})))),signIn:$e(((e,n,o)=>St(t.post(B,{loginId:e,password:n,loginOptions:o})))),sendReset:Me(((e,n,o)=>St(t.post(V,{loginId:e,redirectUrl:n,templateOptions:o})))),update:Pe(((e,n,o)=>St(t.post(H,{loginId:e,newPassword:n},{token:o})))),replace:De(((e,n,o)=>St(t.post(K,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>St(t.get(z))}),Ne=Ft("loginId"),qe=Bt("loginId"),Fe=Bt("origin"),Be=qt(qe,Fe,Bt("name")),Ve=qt(qe,Fe),He=qt(Ne,Fe),Ke=qt(qe,Fe,Bt("token")),ze=qt(Bt("transactionId"),Bt("response")),Je=t=>({signUp:{start:Be(((e,n,o,i)=>St(t.post(D.start,{user:{loginId:e,name:o},origin:n,passkeyOptions:i})))),finish:ze(((e,n)=>St(t.post(D.finish,{transactionId:e,response:n}))))},signIn:{start:He(((e,n,o,i,r)=>St(t.post(W.start,{loginId:e,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:ze(((e,n)=>St(t.post(W.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Ve(((e,n,o)=>St(t.post(N.start,{loginId:e,origin:n,passkeyOptions:o}))))},update:{start:Ke(((e,n,o,i)=>St(t.post(q.start,{loginId:e,origin:n,passkeyOptions:i},{token:o})))),finish:ze(((e,n)=>St(t.post(q.finish,{transactionId:e,response:n}))))}}),Ge=Ft("loginId"),Xe=qt(Ge),Ze=qt(Bt("pendingRef")),Qe=t=>({signUpOrIn:Xe(((e,n)=>St(t.post(M,{loginId:e,loginOptions:n})))),signUp:Xe(((e,n,o)=>St(t.post($,{loginId:e,user:n,loginOptions:o})))),signIn:Xe(((e,n,o)=>St(t.post(_,{loginId:e,loginOptions:n},{token:o})))),waitForSession:Ze(((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(St(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ye=qt(Bt("token")),tn=qt([Wt('"token" must be string or undefined')]);var en,nn=qt([(en=Bt("projectId"),Ot(((t,e)=>n=>At(...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",en))())])((t=>{var e;return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=vt({baseUrl:n||it,projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:zt(a),otp:Ce(a),magicLink:ge(a),enchantedLink:re(a),oauth:be(a),saml:je(a),totp:Te(a),notp:Qe(a),webauthn:Je(a),password:We(a),flow:le(a),refresh:tn(((t,e)=>St(a.post(J,{},{token:t,queryParams:e})))),selectTenant:qt([$t("tenantId")],[Wt('"token" must be string or undefined')])(((t,e)=>St(a.post(G,{tenant:t},{token:e})))),logout:tn((t=>St(a.post(X,{},{token:t})))),logoutAll:tn((t=>St(a.post(Z,{},{token:t})))),me:tn((t=>St(a.get(Q,{token:t})))),myTenants:qt([Nt('"tenants" must a string array or a boolean')],[Wt('"token" must be string or undefined')])(((t,e)=>{const n={};return"boolean"==typeof t?n.dct=t:n.ids=t,St(a.post(Y,n,{token:e}))})),history:tn((t=>St(a.get(tt,{token:t})))),isJwtExpired:Ye(yt),getTenants:Ye(kt),getJwtPermissions:Ye(It),getJwtRoles:Ye(xt),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}}))})),on=Object.assign(nn,{DeliveryMethods:Qt});
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",S="/v1/auth/oauth/authorize",O="/v1/auth/oauth/exchange",j="v1/auth/oauth/native/start",A="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",R="/v1/auth/totp/update",_="/v1/auth/notp/whatsapp/signin",$="/v1/auth/notp/whatsapp/signup",P="/v1/auth/notp/whatsapp/signup-in",M="/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"},q={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},F="/v1/auth/password/signup",B="/v1/auth/password/signin",V="/v1/auth/password/reset",H="/v1/auth/password/update",K="/v1/auth/password/replace",z="/v1/auth/password/policy",J="/v1/auth/refresh",G="/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")}};let lt;const ct=()=>{if(lt)return lt;const t=new Date,e=`${t.getUTCFullYear().toString()}-${(t.getUTCMonth()+1).toString().padStart(2,"0")}-${t.getUTCDate().toString().padStart(2,"0")}-${t.getUTCHours().toString().padStart(2,"0")}:${t.getUTCMinutes().toString().padStart(2,"0")}:${t.getUTCSeconds().toString().padStart(2,"0")}:${t.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return lt=`${e}-${n}`,lt};var dt;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT",t.patch="PATCH"}(dt||(dt={}));const ut=({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){const t=Object.keys(n);t.forEach(((e,o)=>{r=`${r}${0===o?"?":""}${e}=${encodeURIComponent(n[e])}${o===t.length-1?"":"&"}`}))}return r},ht=(...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}),{})),pt={"Content-Type":"application/json"},ft=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},gt=t=>{try{t=JSON.parse(t)}catch(t){return!1}return"object"==typeof t&&null!==t},vt=({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:ht(ft(e,f),{"x-descope-sdk-session-id":ct(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.29.1"},(null==n?void 0:n.baseHeaders)||{},gt(g)?pt:{},u),method:p,body:g};null!==r&&(v.credentials=r||"include");const m=await a(ut({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:dt.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.post,token:i}),patch:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.patch,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:dt.delete,token:o}),hooks:i,buildUrl:(n,o)=>ut({projectId:e,baseUrl:t,path:n,queryParams:o})}};var mt=429;function bt(t,e,n){var o;let i=wt(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 wt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return a(t)}function yt(t){const{exp:e}=wt(t);return(new Date).getTime()/1e3>e}function kt(t){let e=wt(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function It(t,e){return bt(t,e,"permissions")}function xt(t,e){return bt(t,e,"roles")}const Ct=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function St(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===mt&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Ot=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),jt=(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 "))},At=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Et=t=>e=>t.test(e),Ut=Et(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Lt=Et(/^\+[1-9]{1}[0-9]{3,14}$/),Tt=Ot(Ut,'"{val}" is not a valid email'),Rt=Ot(Lt,'"{val}" is not a valid phone number'),_t=Ot((t=>t.length>=1),"Minimum length is 1");const $t=Ot((t=>"string"==typeof t),"Input is not a string"),Pt=Ot((t=>Array.isArray(t)),"Input is not an array"),Mt=Ot((t=>"boolean"==typeof t),"Input is not a boolean"),Dt=Ot((t=>void 0===t),"Input is defined"),Wt=jt([$t(),Dt()],"Input is not a string or undefined"),Nt=jt([Pt(),Mt()],"Input is not an array or boolean"),qt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>At(...t).validate(n[e]))),e(...n)),Ft=t=>[$t(`"${t}" must be a string`)],Bt=t=>[$t(`"${t}" must be a string`),_t(`"${t}" must not be empty`)],Vt=t=>[$t(`"${t}" must be a string`),Tt()],Ht=t=>[$t(`"${t}" must be a string`),Rt()],Kt=qt(Bt("accessKey")),zt=t=>({exchange:Kt(((e,n)=>St(t.post(l,{loginOptions:n},{token:e}))))}),Jt=(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 Xt,Zt;!function(t){t.sms="sms",t.voice="voice",t.whatsapp="whatsapp"}(Xt||(Xt={})),function(t){t.email="email"}(Zt||(Zt={}));const Qt=Object.assign(Object.assign({},Xt),Zt);var Yt;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(Yt||(Yt={}));const te=Bt("loginId"),ee=qt(Bt("token")),ne=qt(te),oe=qt(Bt("pendingRef")),ie=qt(te,Vt("email")),re=t=>({verify:ee((e=>St(t.post(w,{token:e})))),signIn:ne(((e,n,o,i)=>St(t.post(Ct(y,Qt.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:ne(((e,n,o)=>St(t.post(Ct(C,Qt.email),{loginId:e,URI:n,loginOptions:o})))),signUp:ne(((e,n,o,i)=>St(t.post(Ct(k,Qt.email),{loginId:e,URI:n,user:o,loginOptions:i})))),waitForSession:oe(((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(St(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:ie(((e,n,o,i,r)=>St(t.post(x.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),se=qt(Bt("flowId")),ae=qt(Bt("executionId"),Bt("stepId"),Bt("interactionId")),le=t=>({start:se(((e,n,o,i,r,s,a)=>St(t.post(et,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a})))),next:ae(((e,n,o,i,r,s)=>St(t.post(nt,{executionId:e,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),ce=Bt("loginId"),de=qt(Bt("token")),ue=qt(ce),he=qt(ce,Ht("phone")),pe=qt(ce,Vt("email")),fe=Object.keys(Qt).filter((t=>t!==Xt.voice)),ge=t=>({verify:de((e=>St(t.post(f,{token:e})))),signIn:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i,r)=>St(t.post(Ct(g,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i,r)=>St(t.post(Ct(v,n),{loginId:e,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i)=>St(t.post(Ct(b,n),{loginId:e,URI:o,loginOptions:i}))))})),{}),update:{email:pe(((e,n,o,i,r)=>St(t.post(m.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(Xt).filter((t=>t!==Xt.voice)).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:he(((e,o,i,r,s)=>St(t.post(Ct(m.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var ve;!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"}(ve||(ve={}));const me=qt(Bt("code")),be=t=>({start:Object.assign(((e,n,o,i)=>St(t.post(S,o||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:i}))),Object.keys(ve).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>St(t.post(S,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{})),exchange:me((e=>St(t.post(O,{code:e})))),startNative:(e,n,o)=>St(t.post(j,{provider:e,loginOptions:n,implicit:o})),finishNative:(e,n,o,i,r)=>St(t.post(A,{provider:e,stateId:n,user:o,code:i,idToken:r}))}),we=Bt("loginId"),ye=qt(we,Bt("code")),ke=qt(we),Ie=qt(we,Ht("phone")),xe=qt(we,Vt("email")),Ce=t=>({verify:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ye(((e,o)=>St(t.post(Ct(c,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o,i)=>St(t.post(Ct(d,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o,i)=>St(t.post(Ct(u,n),{loginId:e,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Qt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o)=>St(t.post(Ct(p,n),{loginId:e,loginOptions:o}))))})),{}),update:{email:xe(((e,n,o,i)=>St(t.post(h.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(Xt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ie(((e,o,i,r)=>St(t.post(Ct(h.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),Se=qt(Bt("tenant")),Oe=qt(Bt("code")),je=t=>({start:Se(((e,n,o,i)=>St(t.post(E,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:Oe((e=>St(t.post(U,{code:e}))))}),Ae=Bt("loginId"),Ee=qt(Ae,Bt("code")),Ue=qt(Ae),Le=qt(Ae),Te=t=>({signUp:Ue(((e,n)=>St(t.post(T,{loginId:e,user:n})))),verify:Ee(((e,n,o,i)=>St(t.post(L,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Le(((e,n)=>St(t.post(R,{loginId:e},{token:n}))))}),Re=Bt("loginId"),_e=Bt("newPassword"),$e=qt(Re,Bt("password")),Pe=qt(Re),Me=qt(Re,_e),De=qt(Re,Bt("oldPassword"),_e),We=t=>({signUp:$e(((e,n,o,i)=>St(t.post(F,{loginId:e,password:n,user:o,loginOptions:i})))),signIn:$e(((e,n,o)=>St(t.post(B,{loginId:e,password:n,loginOptions:o})))),sendReset:Pe(((e,n,o)=>St(t.post(V,{loginId:e,redirectUrl:n,templateOptions:o})))),update:Me(((e,n,o)=>St(t.post(H,{loginId:e,newPassword:n},{token:o})))),replace:De(((e,n,o)=>St(t.post(K,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>St(t.get(z))}),Ne=Ft("loginId"),qe=Bt("loginId"),Fe=Bt("origin"),Be=qt(qe,Fe,Bt("name")),Ve=qt(qe,Fe),He=qt(Ne,Fe),Ke=qt(qe,Fe,Bt("token")),ze=qt(Bt("transactionId"),Bt("response")),Je=t=>({signUp:{start:Be(((e,n,o,i)=>St(t.post(D.start,{user:{loginId:e,name:o},origin:n,passkeyOptions:i})))),finish:ze(((e,n)=>St(t.post(D.finish,{transactionId:e,response:n}))))},signIn:{start:He(((e,n,o,i,r)=>St(t.post(W.start,{loginId:e,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:ze(((e,n)=>St(t.post(W.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Ve(((e,n,o)=>St(t.post(N.start,{loginId:e,origin:n,passkeyOptions:o}))))},update:{start:Ke(((e,n,o,i)=>St(t.post(q.start,{loginId:e,origin:n,passkeyOptions:i},{token:o})))),finish:ze(((e,n)=>St(t.post(q.finish,{transactionId:e,response:n}))))}}),Ge=Ft("loginId"),Xe=qt(Ge),Ze=qt(Bt("pendingRef")),Qe=t=>({signUpOrIn:Xe(((e,n)=>St(t.post(P,{loginId:e,loginOptions:n})))),signUp:Xe(((e,n,o)=>St(t.post($,{loginId:e,user:n,loginOptions:o})))),signIn:Xe(((e,n,o)=>St(t.post(_,{loginId:e,loginOptions:n},{token:o})))),waitForSession:Ze(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Gt(n);let s;const a=setInterval((async()=>{const n=await t.post(M,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(St(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ye=qt(Bt("token")),tn=qt([Wt('"token" must be string or undefined')]);var en,nn=qt([(en=Bt("projectId"),Ot(((t,e)=>n=>At(...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",en))())])((t=>{var e;return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=vt({baseUrl:n||it,projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:zt(a),otp:Ce(a),magicLink:ge(a),enchantedLink:re(a),oauth:be(a),saml:je(a),totp:Te(a),notp:Qe(a),webauthn:Je(a),password:We(a),flow:le(a),refresh:tn(((t,e)=>St(a.post(J,{},{token:t,queryParams:e})))),selectTenant:qt([$t("tenantId")],[Wt('"token" must be string or undefined')])(((t,e)=>St(a.post(G,{tenant:t},{token:e})))),logout:tn((t=>St(a.post(X,{},{token:t})))),logoutAll:tn((t=>St(a.post(Z,{},{token:t})))),me:tn((t=>St(a.get(Q,{token:t})))),myTenants:qt([Nt('"tenants" must a string array or a boolean')],[Wt('"token" must be string or undefined')])(((t,e)=>{const n={};return"boolean"==typeof t?n.dct=t:n.ids=t,St(a.post(Y,n,{token:e}))})),history:tn((t=>St(a.get(tt,{token:t})))),isJwtExpired:Ye(yt),getTenants:Ye(kt),getJwtPermissions:Ye(It),getJwtRoles:Ye(xt),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}}))})),on=Object.assign(nn,{DeliveryMethods:Qt});
2
2
  /*! js-cookie v3.0.5 | MIT */
3
- function rn(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 sn=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=rn({},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,"",rn({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,rn({},this.attributes,e))},withConverter:function(e){return t(rn({},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 an={default:"endpoint"},ln="Blocked by CSP",cn="The endpoint parameter is not a valid URL",dn="Failed to load the JS script of the agent",un="9319";function hn(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===ln||s===cn)n.exclude(),r=0;else if(s===un)n.exclude();else if(s===dn){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 pn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",fn=pn;function gn(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:pn,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 hn(t,vn)})).catch((function(t){throw u(),function(t){return t instanceof Error&&t.message===un?new Error(dn):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 vn(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(cn);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(dn))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)}),(function(){throw new Error(ln)})).then(mn)}function mn(){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(un);return n}const bn=(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},wn=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||{}},yn=async t=>{const e=await wn(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},kn="undefined"!=typeof localStorage,In=(t,e)=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),xn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Cn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Sn=(...t)=>{console.debug(...t)},On="undefined"!=typeof window,jn=Math.pow(2,31)-1,An="DS",En="DSR";function Un(t=""){return xn(`${t}${En}`)||""}function Ln(t=""){return sn.get(An)||xn(`${t}${An}`)||""}function Tn(t=""){Cn(`${t}${En}`),Cn(`${t}${An}`),sn.remove(An)}const Rn=On&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",_n="vsid",$n="vrid",Mn="fp",Pn=(t=!1)=>{const e=localStorage.getItem(Mn);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Dn=async(t,e=Rn)=>{try{if(Pn())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=gn({apiKey:t,endpoint:[o.toString(),an],scriptUrlPattern:[r,fn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((t,e)=>({[_n]:t,[$n]:e}))(n,l);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(Mn,JSON.stringify(e))})(c)}catch(t){console.warn("Could not load fingerprint",t)}},Wn=t=>{const e=Pn(!0);return e&&t.body&&(t.body.fpData=e),t},Nn="dls_last_user_login_id",qn="dls_last_user_display_name",Fn=()=>xn(Nn),Bn=()=>xn(qn),Vn=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Fn(),r=Bn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)};function Hn(){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 Kn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Qn(n.publicKey.challenge),n.publicKey.user.id=Qn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Qn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Yn(n.rawId),type:n.type,response:{attestationObject:Yn(n.response.attestationObject),clientDataJSON:Yn(n.response.clientDataJSON)}});var n}async function zn(t){const e=Xn(t);return Zn(await navigator.credentials.get(e))}async function Jn(t,e){const n=Xn(t);return n.signal=e.signal,n.mediation="conditional",Zn(await navigator.credentials.get(n))}async function Gn(t=!1){if(!On)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 Xn(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Qn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Qn(t.id)})),n}function Zn(t){return JSON.stringify({id:t.id,rawId:Yn(t.rawId),type:t.type,response:{authenticatorData:Yn(t.response.authenticatorData),clientDataJSON:Yn(t.response.clientDataJSON),signature:Yn(t.response.signature),userHandle:t.response.userHandle?Yn(t.response.userHandle):void 0}})}function Qn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Yn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var to,eo=(to=t=>({async signUp(e,n,o){const i=await t.webauthn.signUp.start(e,window.location.origin,n,o);if(!i.ok)return i;const r=await Kn(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(e,n){const o=await t.webauthn.signIn.start(e,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await zn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(e,n){var o;const i=await t.webauthn.signUpOrIn.start(e,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const e=await Kn(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,e)}{const e=await zn(i.data.options);return await t.webauthn.signIn.finish(i.data.transactionId,e)}},async update(e,n,o){const i=await t.webauthn.update.start(e,window.location.origin,n,o);if(!i.ok)return i;const r=await Kn(i.data.options);return await t.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Kn,get:zn,isSupported:Gn,conditional:Jn}}),(...t)=>{const e=to(...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 no="/fedcm/config",oo=(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+no),clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return t.refresh(r.token)},isSupported:()=>On&&"IdentityCredential"in window});var io=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await Gn(),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 ro=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 On?(o&&i&&Dn(o).catch((()=>null)),t(bn(r,{beforeRequest:Wn}))):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;On&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>l&&(Sn("Expiration time passed, refreshing session"),d.refresh(Un()||c))}));const d=t(bn(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await wn(e);if(401===(null==e?void 0:e.status))Sn("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 Sn("Could not extract expiration time from session token");c=n;let t=((i=l)?i.getTime()-(new Date).getTime():0)-2e4;t>jn&&(Sn(`Timeout is too large (${t}ms), setting it to ${jn}ms`),t=jn),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});Sn(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{Sn("Refreshing session due to timer"),d.refresh(Un()||n)}),t)}var i}}));return Jt(d,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return Sn("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.19.2"},e.baseHeaders)}))),(t=>e=>{const n=Hn(),o=Hn(),i=t(bn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await yn(e);t&&o.pub(t);const{sessionJwt:i}=await wn(e);i&&n.pub(i)}}})),r=Jt(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:Fn,getLastUserDisplayName:Bn});const s=t(bn(r,{afterRequest:async(t,e)=>{var n;const o=await yn(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=>{In(Nn,t)})(i),(t=>{In(qn,t)})(r))}}));let a=Jt(s,["flow.start"],Vn);return a=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return t||(Cn(Nn),Cn(qn)),o})(i)),Object.assign(a,{getLastUserLoginId:Fn,getLastUserDisplayName:Bn})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!On)return t(s);const a=t(bn(s,{beforeRequest:(l=r,t=>Object.assign(t,{token:t.token||Un(l)})),afterRequest:async(t,n)=>{const o=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?o||Tn(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&&In(`${o}${En}`,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);sn.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(An,r,s):In(`${o}${An}`,r))})(await wn(n),i,r)}}));var l;const c=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return Tn(t),o})(r));return Object.assign(c,{getRefreshToken:()=>Un(r),getSessionToken:()=>Ln(r)})}))(((...t)=>{const e=on(...t);return Object.assign(Object.assign({},e),{refresh:t=>{const n=Ln();return e.refresh(t,{dcs:n?"t":"f"})},flow:io(e),webauthn:eo(e),fedcm:oo(e,t[0].projectId)})})),so="undefined"!=typeof localStorage,ao="J151000",lo=so&&localStorage.getItem("base.content.url")||"",co="config.json",uo="base.ui.components.url";so&&localStorage.getItem(uo),so&&localStorage.getItem(uo);const ho="descope-login-flow",po="code",fo="data-exclude-field",go="dls_last_auth",vo="state_id",mo="saml_idp_state_id",bo="saml_idp_username",wo="descope_idp_initiated",yo="sso_app_id",ko="oidc_login_hint",Io="oidc_prompt",xo="oidc_error_redirect_uri",Co="data-type",So="redirect",Oo="poll",jo="webauthnCreate",Ao="webauthnGet",Eo="nativeBridge",Uo="loadForm",Lo="submit",To="polling",Ro=["descope-multi-select-combo-box","descope-text-area"];var _o;!function(t){t.backward="backward",t.forward="forward"}(_o||(_o={}));const $o=["descope-enriched-text"];function Mo(t){return new URLSearchParams(window.location.search).get(t)}function Po(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 Do(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 Wo({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(lo||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.toString()}function No(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?_o.forward:n<o?_o.backward:void 0}const qo=()=>{const[t="",e=""]=(Mo(ho)||"").split("_");return{executionId:t,stepId:e}};function Fo(){Po(ho)}const Bo=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),Vo=()=>{const{executionId:t,stepId:e}=qo();(t||e)&&Fo();const n=Mo("t")||void 0;n&&Po("t");const o=Mo(po)||void 0;o&&Po(po);const i=Mo("err")||void 0;i&&Po("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:Mo("ra-challenge"),redirectAuthCallbackUrl:Mo("ra-callback"),redirectAuthBackupCallbackUri:Mo("ra-backup-callback"),redirectAuthInitiator:Mo("ra-initiator")},c=Mo(vo);c&&Po(vo);const d=Mo(mo);d&&Po(mo);const u=Mo(bo);d&&Po(bo);const h=Mo(wo);h&&Po(wo);const p=Mo(yo);p&&Po(yo);const f=Mo(ko);f&&Po(ko);const g=Mo(Io);g&&Po(Io);const v=Mo(xo);v&&Po(xo);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 Object.assign(((...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}),{reset:()=>{e=void 0,n=void 0}})};function Ko(t,e,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{r||(clearTimeout(s),o(t))})).catch((t=>{r||(clearTimeout(s),i(t))}))}))}const zo=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||n||o||i||r||s||a),Jo=t=>null==t?void 0:t.submit(),Go=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Xo=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Zo(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 Qo,Yo,ti,ei;function ni(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(!ni(r,s))return!1}else if(r!==s)return!1}return!0}class oi{constructor(t={},{updateOnlyOnChange:e=!0}={}){Qo.set(this,void 0),Yo.set(this,{}),ti.set(this,0),ei.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,Qo,"f")):t,n=Object.assign(Object.assign({},o(this,Qo,"f")),e);if(!o(this,ei,"f")||!ni(o(this,Qo,"f"),n)){const t=o(this,Qo,"f");i(this,Qo,n,"f"),Object.freeze(o(this,Qo,"f")),setTimeout((()=>{Object.values(o(this,Yo,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,Qo,t,"f"),i(this,ei,e,"f")}get current(){return Object.assign({},o(this,Qo,"f"))}subscribe(t){return i(this,ti,o(this,ti,"f")+1,"f"),o(this,Yo,"f")[o(this,ti,"f")]=t,o(this,ti,"f").toString()}unsubscribe(t){const e=!!o(this,Yo,"f")[t];return e&&delete o(this,Yo,"f")[t],e}unsubscribeAll(){return i(this,Yo,{},"f"),!0}}Qo=new WeakMap,Yo=new WeakMap,ti=new WeakMap,ei=new WeakMap;const ii=["*","#","/","(",")","[","]","_","<",">","`"],ri=t=>{const e=ii.map((e=>`${t}${e}`)).join("|");return new RegExp(`(${e})`,"g")},si=["disabled"],ai=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${fo}])`)).forEach((t=>{t.value=n}))}))},li=(t,e)=>e.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),t),ci=(t,e,n)=>t.replace(/{{(.+?)}}/g,((t,o)=>n?(t=>"string"!=typeof t?t:t.replace(ri("\\"),"\\$1"))(li(e,o)):li(e,o))),di=(t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{const n=(o=t.localName,$o.includes(o));var o;t.textContent=ci(t.textContent,e,n);const i=t.getAttribute("href");i&&t.setAttribute("href",ci(i,e))}))},ui=(t,e,n)=>{t.querySelectorAll(`[${Co}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},hi=(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})`))},pi=(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(`[${Co}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),ui(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ui(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),di(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=ci(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])=>{si.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,o)},fi=Ho((()=>n(void 0,void 0,void 0,(function*(){var t,e;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)))),o=(()=>{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 Ko(100,n,o)}catch(t){return console.error("Conditional login check failed",t),!1}})))),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))]},vi={"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 mi(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(go)))}catch(t){}return e}const bi="dls_ab_testing_id";function wi(...t){return e=>t.reduce(((t,e)=>e(t)),e)}const yi=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 ki,Ii,xi,Ci,Si,Oi;function ji(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(!ji(r,s))return!1}else if(r!==s)return!1}return!0}class Ai{constructor(t={},{updateOnlyOnChange:e=!0}={}){ki.set(this,void 0),Ii.set(this,{}),xi.set(this,0),Ci.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,ki,"f")):t,n=Object.assign(Object.assign({},o(this,ki,"f")),e);if(!o(this,Ci,"f")||!ji(o(this,ki,"f"),n)){const t=o(this,ki,"f");i(this,ki,n,"f"),Object.freeze(o(this,ki,"f")),setTimeout((()=>{Object.values(o(this,Ii,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,ki,t,"f"),i(this,Ci,e,"f")}get current(){return Object.assign({},o(this,ki,"f"))}subscribe(t){return i(this,xi,o(this,xi,"f")+1,"f"),o(this,Ii,"f")[o(this,xi,"f")]=t,o(this,xi,"f").toString()}unsubscribe(t){const e=!!o(this,Ii,"f")[t];return e&&delete o(this,Ii,"f")[t],e}unsubscribeAll(){return i(this,Ii,{},"f"),!0}}ki=new WeakMap,Ii=new WeakMap,xi=new WeakMap,Ci=new WeakMap;class Ei{constructor(t,e){Si.set(this,void 0),this.nodeName="",i(this,Si,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,Si,"f"))}get ele(){var t,e;const n="function"==typeof o(this,Si,"f")?o(this,Si,"f").call(this):o(this,Si,"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(`Driver element is not available for ${this.nodeName}`,new Error),null)}}Si=new WeakMap;class Ui extends Ei{constructor(){super(...arguments),Oi.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,Oi,"f")&&(null===(t=this.ele)||void 0===t||t.append(o(this,Oi,"f").content.cloneNode(!0)))}setContent(t){i(this,Oi,t,"f"),this.reset()}remove(){var t;null===(t=this.ele)||void 0===t||t.remove()}}Oi=new WeakMap;class Li extends Ei{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 Ti=["error","warn","info","debug"],Ri=yi((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 Ti.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})),_i="undefined"!=typeof localStorage,$i=_i&&localStorage.getItem("base.content.url")||"",Mi=(t,e)=>!e&&`${t} cannot be empty, please make sure to set this attribute`,Pi=yi((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})),Di=yi((t=>{var e,n;const i=wi(Ri,Pi)(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})),Wi=t=>e=>{var n,i,r;const s=wi(Ri,Pi,Di)(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};Wi.missingAttrValidator=Mi;const Ni=yi((t=>{const e=wi(Wi({"project-id":Mi}))(t);return class extends e{get projectId(){return this.getAttribute("project-id")}}})),qi=yi((t=>class extends t{get baseUrl(){return this.getAttribute("base-url")||""}}));const Fi=yi((t=>{const e=wi(Ri,Ni,qi)(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($i||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")}}})),Bi=yi((t=>{var e,n,r;const s=wi(Fi)(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}));yi((t=>{var e,n,r,s,a,l,c;return c=class extends(wi(Pi,Ri)(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 mr})),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 Vi="load-descope-ui",Hi="base.ui.components.url",Ki=_i&&localStorage.getItem(Hi)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",zi=_i&&localStorage.getItem(Hi)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Ji=t=>{const e=document.createElement("script");return e.id=t,e},Gi=(t,e)=>t.replace("<version>",e),Xi=yi((t=>{var e,n,r,s,a,l,c,d,u,h,p,f;const g=wi(Ri,Bi)(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=Ji("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=Gi(zi,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#${Vi}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const t=Ji(Vi);document.body.append(t),o(this,e,"m",a).call(this,t),o(this,e,"m",c).call(this,t),t.src=Gi(Ki,await o(this,e,"m",s).call(this))}return document.getElementById(Vi)},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})),Zi="content-root",Qi="root",Yi=yi((t=>class extends t{constructor(...t){var e,n;super(...t),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Qi}, #${Zi} {\n height: 100%;\n }\n #${Qi} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Qi}">\n <div id="${Zi}"></div>\n </div>\n `,this.contentRootElement=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(Zi),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Qi)}})),tr="descope-modal";yi((t=>{var e,n;const i=wi(Pi,Yi,Xi)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,(()=>{const t=this.loadDescopeUiComponents.bind(this);return class extends Ui{setContent(e){t(e),super.setContent(e)}}})())}createModal(t){const n=((t={})=>{const e=document.createElement(tr);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([tr]),await(null===(t=super.init)||void 0===t?void 0:t.call(this))}},e=new WeakMap,n}));const er="descope-notification";yi((t=>{var e,n;const i=wi(Pi,Yi,Xi)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,(()=>{const t=this.loadDescopeUiComponents.bind(this);return class extends Li{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(er);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([er])}},e=new WeakMap,n}));const nr=(t,e)=>!!e&&"light"!==e&&"dark"!==e&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',or=yi((t=>{var e,n,r,s,a,l,c,d,u,h,p;const f=wi(Wi({theme:nr}),Fi,Pi,Xi,Bi,Yi,Di)(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}));yi((t=>class extends(Ri(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()}})),yi((t=>class extends t{get baseStaticUrl(){return this.getAttribute("base-static-url")||""}}));const ir=(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 rr,sr,ar,lr,cr,dr,ur,hr,pr,fr;const gr=document.createElement("template");gr.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 vr=class extends HTMLElement{constructor(){var t;super(),rr.add(this),sr.set(this,new Ai({messages:[]})),ar.set(this,void 0),lr.set(this,void 0),cr.set(this,void 0),dr.set(this,{resize:o(this,rr,"m",fr).bind(this)}),this.attachShadow({mode:"open"}),null===(t=this.shadowRoot)||void 0===t||t.appendChild(gr.content.cloneNode(!0)),i(this,ar,this.shadowRoot.querySelector(".debugger"),"f"),i(this,lr,o(this,ar,"f").querySelector(".content"),"f"),i(this,cr,o(this,ar,"f").querySelector(".header"),"f")}updateData(t){o(this,sr,"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]=ir(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,ar,"f"),o(this,cr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,dr,"f").resize),(t=o(this,ar,"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,ar,"f").onresize=o(this,rr,"m",pr).bind(this),o(this,sr,"f").subscribe(o(this,rr,"m",ur).bind(this))}disconnectedCallback(){o(this,sr,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,dr,"f").resize)}};sr=new WeakMap,ar=new WeakMap,lr=new WeakMap,cr=new WeakMap,dr=new WeakMap,rr=new WeakSet,ur=function(t){o(this,rr,"m",hr).call(this,t),o(this,rr,"m",pr).call(this)},hr=function(t){o(this,lr,"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("")},pr=function(){o(this,lr,"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)}))},fr=function(){const[t,e]=ir(o(this,ar,"f"),Number.parseInt(o(this,ar,"f").style.left,10),Number.parseInt(o(this,ar,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,ar,"f").style.top=`${e}px`,o(this,ar,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",vr);var mr=Object.freeze({__proto__:null});const br=yi((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})),wr=document.createElement("template");wr.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 yr=(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),yr(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 kr,Ir,xr,Cr,Sr,Or,jr,Ar,Er,Ur,Lr,Tr,Rr,_r,$r,Mr,Pr,Dr,Wr,Nr,qr;const Fr=wi(or,br)(HTMLElement);class Br extends Fr{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(),kr.add(this),xr.set(this,!1),this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),o(this,kr,"m",Nr).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)}},Cr.set(this,new oi),Sr.set(this,new oi),Or.set(this,{}),this.getComponentsContext=()=>o(this,Or,"f"),this.nextRequestStatus=new oi({isLoading:!1}),jr.set(this,void 0),Ar.set(this,{popstate:o(this,kr,"m",Tr).bind(this),componentsContext:o(this,kr,"m",Pr).bind(this)}),Er.set(this,void 0),this.getConfig=Ho((()=>n(this,void 0,void 0,(function*(){const t=Wo({projectId:this.projectId,filename:co,baseUrl:this.baseStaticUrl});try{const{body:e,headers:n}=yield Do(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,Er,t,"f"),o(this,kr,"m",Ur).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 yr(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}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();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()))}))}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var t,e;const n=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const 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,Sr,"f").subscribe(o(this,kr,"m",Wr).bind(this)),o(this,Sr,"f").update({isDebug:this.debug}),o(this,kr,"m",Lr).call(this),yield o(this,kr,"m",$r).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,kr,"m",qr).call(this);const{executionId:n,stepId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=Vo();window.addEventListener("popstate",o(this,Ar,"f").popstate),window.addEventListener("components-context",o(this,Ar,"f").componentsContext),o(this,Cr,"f").subscribe(o(this,kr,"m",_r).bind(this)),o(this,Cr,"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,xr,!0,"f")}))}disconnectedCallback(){o(this,Cr,"f").unsubscribeAll(),o(this,Sr,"f").unsubscribeAll(),o(this,kr,"m",Dr).call(this),window.removeEventListener("popstate",o(this,Ar,"f").popstate),window.removeEventListener("components-context",o(this,Ar,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,xr,"f")&&e!==n&&Ir.observedAttributes.includes(t)){o(this,kr,"m",Lr).call(this);const i=null===e;o(this,Cr,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Fo()),{[Bo(t)]:n,stepId:r,executionId:s}})),o(this,Sr,"f").update({isDebug:this.debug})}}}function Vr(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Hr,Kr,zr,Jr,Gr,Xr,Zr,Qr,Yr,ts,es,ns,os,is,rs,ss,as,ls,cs,ds,us,hs,ps,fs,gs,vs,ms,bs,ws,ys,ks,Is,xs;Ir=Br,xr=new WeakMap,Cr=new WeakMap,Sr=new WeakMap,Or=new WeakMap,jr=new WeakMap,Ar=new WeakMap,Er=new WeakMap,kr=new WeakSet,Ur=function(){this.shadowRoot.appendChild(wr.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},Lr=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"];Ir.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[Bo(e)])throw Error(`${e} cannot be empty`)}))},Tr=function(){const{stepId:t,executionId:e}=qo();o(this,Cr,"f").update({stepId:t,executionId:e})},Rr=function(t,e){this.sdk=ro(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},Ir.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:ao,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},_r=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,kr,"m",Rr).call(this,e,n)}o(this,Er,"f").call(this,t)}))},$r=function(){return n(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield o(this,kr,"m",Mr).call(this))}))},Mr=function(){return n(this,void 0,void 0,(function*(){const t=Wo({projectId:this.projectId,filename:co,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield Do(t,"json"),!0}catch(t){return!1}}))},Pr=function(t){i(this,Or,Object.assign(Object.assign({},o(this,Or,"f")),t.detail),"f")},Dr=function(){var t;null===(t=o(this,jr,"f"))||void 0===t||t.remove(),i(this,jr,null,"f")},Wr=function(t){return n(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,jr,document.createElement("descope-debugger"),"f"),Object.assign(o(this,jr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return js})),document.body.appendChild(o(this,jr,"f"))):o(this,kr,"m",Dr).call(this)}))},Nr=function(t,e){var n;t&&this.debug&&(null===(n=o(this,jr,"f"))||void 0===n||n.updateData({title:t,description:e}))},qr=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=Ro.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()}}},Br.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.27.3"}};class Cs extends Br{static set sdkConfigOverrides(t){Br.sdkConfigOverrides=t}constructor(){const t=new oi({deferredRedirect:!1});super(t.update.bind(t)),Hr.add(this),this.stepState=new oi({},{updateOnlyOnChange:!1}),Kr.set(this,void 0),zr.set(this,null),Jr.set(this,{visibilitychange:o(this,Hr,"m",Gr).bind(this)}),this.bridgeVersion=1,Zr.set(this,((t,e,r,s,a,l=!1)=>{if(r===Oo){this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=l?500:2e3;i(this,Kr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,i;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(t,e,To,s,a,{}),h=document.hidden&&!l&&Date.now()-c>d+500;let p;h&&this.logger.debug("polling - The polling seems to be throttled");try{const t=h?1e3:6e3;p=yield Ko(t,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,Zr,"f").call(this,t,e,r,s,a,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===ao)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,Zr,"f").call(this,t,e,r,s,a);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),o(this,Yr,"f").call(this,p);const{action:f}=null!==(i=null==p?void 0:p.data)&&void 0!==i?i:{};o(this,Zr,"f").call(this,t,e,f,s,a)}))),d),"f")}})),Qr.set(this,(()=>{clearTimeout(o(this,Kr,"f")),i(this,Kr,null,"f")})),Yr.set(this,(t=>{var e,n,i,r,s,a,l,c,d,u,h,p;if(!(null==t?void 0:t.ok)){const l=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,c=`${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}`;o(this,Hr,"m",ps).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:c,errorMessage:l}),this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||l,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||c);const d=null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||o(this,Hr,"m",Xr).call(this))}null===(c=null===(l=t.data)||void 0===l?void 0:l.runnerLogs)||void 0===c||c.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 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)&&so&&localStorage.setItem(go,JSON.stringify(t))}(m),void o(this,Hr,"m",ps).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:k,screen:I,redirect:x,openInNewTabUrl:C,webauthn:S,error:O,samlIdpResponse:j,nativeResponse:A}=t.data;k!==Oo?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:I,status:g,stepId:w,stepName:y,action:k,error:O}),this.flowState.update({stepId:w,executionId:b,action:k,redirectTo:null==x?void 0:x.url,openInNewTabUrl:C,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==S?void 0:S.transactionId,webauthnOptions:null==S?void 0:S.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:k})})),ts.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)}}))))),cs.set(this,Xo(((t,e)=>n(this,void 0,void 0,(function*(){var n,i;if("true"===t.getAttribute("formnovalidate")||o(this,Hr,"m",os).call(this)){const r=null==t?void 0:t.getAttribute("id");o(this,Hr,"m",rs).call(this,t);const s=yield o(this,Hr,"m",is).call(this),a=(i=t,Array.from((null==i?void 0:i.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}),{})),l=this.getComponentsContext(),c=Object.assign(Object.assign(Object.assign(Object.assign({},l),a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin}),d=yield this.getFlowConfig(),u=yield this.getProjectConfig(),h=yield e(r,d.version,u.componentsVersion,c);o(this,Yr,"f").call(this,h),o(this,Hr,"m",ss).call(this,s)}}))))),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 Es})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return Ls})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return Rs})),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:{[Vr(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,Jr,"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,zr,"f"))||void 0===t||t.abort(),i(this,zr,null,"f"),window.removeEventListener("visibilitychange",o(this,Jr,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const o=Zo(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 Do(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 Do(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 a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,openInNewTabUrl:b,redirectUrl:w,token:y,code:k,exchangeError:I,webauthnTransactionId:x,webauthnOptions:C,redirectAuthCodeChallenge:S,redirectAuthCallbackUrl:O,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:A,locale:E,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:L,samlIdpResponseRelayState:T,nativeResponseType:R,nativePayload:_}=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","nativeResponseType","nativePayload"]);let M,P;const D=(()=>{const t=localStorage.getItem(bi);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(bi,t.toString()),t}return Number(t)})(),W=this.sdk.getLastUserLoginId(),N=yield this.getFlowConfig(),q=yield this.getProjectConfig(),F=Object.entries(q.flows||{}).reduce(((t,[e,n])=>(t[e]=n.version,t)),{}),B=O&&S?{callbackUrl:O,codeChallenge:S,backupCallbackUri:j}:void 0,V=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect}:void 0;if(!p&&(this.loadSdkScripts(),N.fingerprintEnabled&&N.fingerprintKey?yield Dn(N.fingerprintKey,this.baseUrl):localStorage.removeItem(Mn),N.conditions?({startScreenId:M,conditionInteractionId:P}=((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=vi[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:W,code:k,token:y,abTestingKey:D},N.conditions)):N.condition?({startScreenId:M,conditionInteractionId:P}=((t,e)=>{var n;const o=null===(n=vi[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}})(N.condition,{loginId:W,code:k,token:y,abTestingKey:D})):M=N.startScreenId,!zo(M,$))){const t=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},$),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:mi(W),abTestingKey:D,locale:Zo(E).locale,nativeOptions:V}),P,"",q.componentsVersion,F,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return o(this,Yr,"f").call(this,t),void("completed"!==(null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const t=yield this.sdk.flow.next(p,h,Lo,N.version,q.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return o(this,Yr,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Uo&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!U||!L)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)})(U,L,T||"",Jo)}if(f===So&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===A&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(f===jo||f===Ao){if(!x||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(l=o(this,zr,"f"))||void 0===l||l.abort(),i(this,zr,null,"f");try{t=f===jo?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}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(p,h,Lo,N.version,q.componentsVersion,{transactionId:x,response:t,failure:e});o(this,Yr,"f").call(this,n)}if(f===Eo)return this.nativeComplete=t=>n(this,void 0,void 0,(function*(){const e=JSON.parse(t),n=yield this.sdk.flow.next(p,h,Lo,N.version,q.componentsVersion,e);o(this,Yr,"f").call(this,n)})),void o(this,Hr,"m",ps).call(this,"bridge",{type:R,payload:_});if(o(this,Zr,"f").call(this,p,h,f,N.version,q.componentsVersion),!g&&!M)return void this.loggerWrapper.warn("No screen was found to show");const H=M||g,K=yield this.getHtmlFilenameWithLocale(E,H),{oidcLoginHint:z,oidcPrompt:J,oidcErrorRedirectUri:G,samlIdpUsername:X}=$,Z={direction:No(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:W,name:this.sdk.getLastUserDisplayName()||W}}),htmlUrl:Wo({projectId:c,filename:`${H}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:K&&Wo({projectId:c,filename:K,baseUrl:this.baseStaticUrl}),samlIdpUsername:X,oidcLoginHint:z,oidcPrompt:J,oidcErrorRedirectUri:G,openInNewTabUrl:b},Q=mi(W);zo(M,$)?Z.next=(t,e,n,o)=>this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},$),{lastAuth:Q,preview:this.preview,abTestingKey:D,client:this.client}),w&&{redirectUrl:w}),{locale:Zo(E).locale,nativeOptions:V}),P,t,n,F,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Z.next=(...t)=>this.sdk.flow.next(p,h,...t)),this.stepState.update(Z)}))}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,Hr,"m",ns).call(this,p,c):p.querySelectorAll(`descope-button[${Co}="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),pi(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,hi(r,"descope-totp-image",s),((t,e)=>{hi(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);const a=!e.htmlUrl;setTimeout((()=>{o(this,Hr,"m",as).call(this),((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),((t,e)=>{ai(t,null==e?void 0:e.inputs),ai(t,null==e?void 0:e.form)})(this.rootElement,d)})),o(this,Hr,"m",us).call(this,c),a&&o(this,Hr,"m",ps).call(this,"ready",{}),o(this,Hr,"m",ps).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${Co}="polling"]`)){const t=yield this.getFlowConfig(),e=yield this.getProjectConfig(),n=yield c(To,t.version,e.componentsVersion,{});o(this,Yr,"f").call(this,n)}u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,Hr,"m",hs).call(this,v,l):v()}))}}Kr=new WeakMap,zr=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,Qr=new WeakMap,Yr=new WeakMap,ts=new WeakMap,cs=new WeakMap,Hr=new WeakSet,Gr=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Xr=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const t=yield this.getComponentsVersion();this.getConfig.reset();t===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},es=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)}))}},ns=function(t,e){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,zr,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield fi())){const{options:t,transactionId:r}=(yield o(this,ts,"f").call(this))||{};if(t&&r){o(this,Hr,"m",es).call(this,s),i(this,zr,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,o(this,zr,"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,Yr,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},os=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},is=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${fo}])`));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})),{})}))},rs=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},ss=function(t={}){var e,n;const o=Go(t,["externalId","email","phone"]),i=Go(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)}},as=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()));this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>o(this,Hr,"m",ls).call(this,t)))},ls=function(t){if(!t)return;t.querySelectorAll("input").forEach((e=>{const n=e.getAttribute("slot"),o=`input-${t.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),t.appendChild(i),e.setAttribute("slot",o),this.appendChild(e)}))},ds=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,cs,"f").call(this,e,t)}))}))},us=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{o(this,cs,"f").call(this,e,t)}})),o(this,Hr,"m",ds).call(this,t)},hs=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===_o.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")},ps=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",Cs);const Ss=document.createElement("template");Ss.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 Os extends HTMLElement{constructor(){super(),fs.add(this),gs.set(this,new oi({messages:[]})),vs.set(this,void 0),ms.set(this,void 0),bs.set(this,void 0),ws.set(this,{resize:o(this,fs,"m",xs).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ss.content.cloneNode(!0)),i(this,vs,this.shadowRoot.querySelector(".debugger"),"f"),i(this,ms,o(this,vs,"f").querySelector(".content"),"f"),i(this,bs,o(this,vs,"f").querySelector(".header"),"f")}updateData(t){o(this,gs,"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,vs,"f"),o(this,bs,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ws,"f").resize),(t=o(this,vs,"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,vs,"f").onresize=o(this,fs,"m",Is).bind(this),o(this,gs,"f").subscribe(o(this,fs,"m",ys).bind(this))}disconnectedCallback(){o(this,gs,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ws,"f").resize)}}gs=new WeakMap,vs=new WeakMap,ms=new WeakMap,bs=new WeakMap,ws=new WeakMap,fs=new WeakSet,ys=function(t){o(this,fs,"m",ks).call(this,t),o(this,fs,"m",Is).call(this)},ks=function(t){o(this,ms,"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("")},Is=function(){o(this,ms,"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)}))},xs=function(){const[t,e]=gi(o(this,vs,"f"),Number.parseInt(o(this,vs,"f").style.left,10),Number.parseInt(o(this,vs,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,vs,"f").style.top=`${e}px`,o(this,vs,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Os);var js=Object.freeze({__proto__:null,default:Os});const As='\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 Es=Object.freeze({__proto__:null,default:(t,e,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=As.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 Us=(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,an]:[an];let a=[];if(n&&i){const t=new URL(i);a=[`${t.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,fn]}else a=[fn];const l=gn({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 Ls=Object.freeze({__proto__:null,default:Us,loadFingerprint:Us});const Ts=(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=gn({apiKey:i,endpoint:[c.toString(),an],scriptUrlPattern:[u,fn]}),p=yield h,{requestId:f}=yield p.get();o(f)}catch(t){console.warn("Could not load descope fingerprint",t)}}));var Rs=Object.freeze({__proto__:null,default:Ts,loadFingerprint:Ts})}();
3
+ function rn(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 sn=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=rn({},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,"",rn({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,rn({},this.attributes,e))},withConverter:function(e){return t(rn({},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 an={default:"endpoint"},ln="Blocked by CSP",cn="The endpoint parameter is not a valid URL",dn="Failed to load the JS script of the agent",un="9319";function hn(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===ln||s===cn)n.exclude(),r=0;else if(s===un)n.exclude();else if(s===dn){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 pn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",fn=pn;function gn(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:pn,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 hn(t,vn)})).catch((function(t){throw u(),function(t){return t instanceof Error&&t.message===un?new Error(dn):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 vn(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(cn);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(dn))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)}),(function(){throw new Error(ln)})).then(mn)}function mn(){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(un);return n}const bn=(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},wn=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||{}},yn=async t=>{const e=await wn(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},kn="undefined"!=typeof localStorage,In=(t,e)=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),xn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Cn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Sn=(...t)=>{console.debug(...t)},On="undefined"!=typeof window,jn=Math.pow(2,31)-1,An="DS",En="DSR";function Un(t=""){return xn(`${t}${En}`)||""}function Ln(t=""){return sn.get(An)||xn(`${t}${An}`)||""}function Tn(t=""){Cn(`${t}${En}`),Cn(`${t}${An}`),sn.remove(An)}const Rn=On&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",_n="vsid",$n="vrid",Pn="fp",Mn=(t=!1)=>{const e=localStorage.getItem(Pn);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Dn=async(t,e=Rn)=>{try{if(Mn())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=gn({apiKey:t,endpoint:[o.toString(),an],scriptUrlPattern:[r,fn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((t,e)=>({[_n]:t,[$n]:e}))(n,l);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(Pn,JSON.stringify(e))})(c)}catch(t){console.warn("Could not load fingerprint",t)}},Wn=t=>{const e=Mn(!0);return e&&t.body&&(t.body.fpData=e),t},Nn="dls_last_user_login_id",qn="dls_last_user_display_name",Fn=()=>xn(Nn),Bn=()=>xn(qn),Vn=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Fn(),r=Bn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)};function Hn(){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 Kn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Qn(n.publicKey.challenge),n.publicKey.user.id=Qn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Qn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Yn(n.rawId),type:n.type,response:{attestationObject:Yn(n.response.attestationObject),clientDataJSON:Yn(n.response.clientDataJSON)}});var n}async function zn(t){const e=Xn(t);return Zn(await navigator.credentials.get(e))}async function Jn(t,e){const n=Xn(t);return n.signal=e.signal,n.mediation="conditional",Zn(await navigator.credentials.get(n))}async function Gn(t=!1){if(!On)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 Xn(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Qn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Qn(t.id)})),n}function Zn(t){return JSON.stringify({id:t.id,rawId:Yn(t.rawId),type:t.type,response:{authenticatorData:Yn(t.response.authenticatorData),clientDataJSON:Yn(t.response.clientDataJSON),signature:Yn(t.response.signature),userHandle:t.response.userHandle?Yn(t.response.userHandle):void 0}})}function Qn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Yn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var to,eo=(to=t=>({async signUp(e,n,o){const i=await t.webauthn.signUp.start(e,window.location.origin,n,o);if(!i.ok)return i;const r=await Kn(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(e,n){const o=await t.webauthn.signIn.start(e,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await zn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(e,n){var o;const i=await t.webauthn.signUpOrIn.start(e,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const e=await Kn(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,e)}{const e=await zn(i.data.options);return await t.webauthn.signIn.finish(i.data.transactionId,e)}},async update(e,n,o){const i=await t.webauthn.update.start(e,window.location.origin,n,o);if(!i.ok)return i;const r=await Kn(i.data.options);return await t.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Kn,get:zn,isSupported:Gn,conditional:Jn}}),(...t)=>{const e=to(...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 no="/fedcm/config",oo=(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+no),clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return t.refresh(r.token)},isSupported:()=>On&&"IdentityCredential"in window});var io=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await Gn(),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 ro=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 On?(o&&i&&Dn(o).catch((()=>null)),t(bn(r,{beforeRequest:Wn}))):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;On&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>l&&(Sn("Expiration time passed, refreshing session"),d.refresh(Un()||c))}));const d=t(bn(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await wn(e);if(401===(null==e?void 0:e.status))Sn("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 Sn("Could not extract expiration time from session token");c=n;let t=((i=l)?i.getTime()-(new Date).getTime():0)-2e4;t>jn&&(Sn(`Timeout is too large (${t}ms), setting it to ${jn}ms`),t=jn),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});Sn(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{Sn("Refreshing session due to timer"),d.refresh(Un()||n)}),t)}var i}}));return Jt(d,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return Sn("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.19.2"},e.baseHeaders)}))),(t=>e=>{const n=Hn(),o=Hn(),i=t(bn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await yn(e);t&&o.pub(t);const{sessionJwt:i}=await wn(e);i&&n.pub(i)}}})),r=Jt(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:Fn,getLastUserDisplayName:Bn});const s=t(bn(r,{afterRequest:async(t,e)=>{var n;const o=await yn(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=>{In(Nn,t)})(i),(t=>{In(qn,t)})(r))}}));let a=Jt(s,["flow.start"],Vn);return a=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return t||(Cn(Nn),Cn(qn)),o})(i)),Object.assign(a,{getLastUserLoginId:Fn,getLastUserDisplayName:Bn})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!On)return t(s);const a=t(bn(s,{beforeRequest:(l=r,t=>Object.assign(t,{token:t.token||Un(l)})),afterRequest:async(t,n)=>{const o=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?o||Tn(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&&In(`${o}${En}`,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);sn.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(An,r,s):In(`${o}${An}`,r))})(await wn(n),i,r)}}));var l;const c=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return Tn(t),o})(r));return Object.assign(c,{getRefreshToken:()=>Un(r),getSessionToken:()=>Ln(r)})}))(((...t)=>{const e=on(...t);return Object.assign(Object.assign({},e),{refresh:t=>{const n=Ln();return e.refresh(t,{dcs:n?"t":"f"})},flow:io(e),webauthn:eo(e),fedcm:oo(e,t[0].projectId)})})),so="undefined"!=typeof localStorage,ao="J151000",lo=so&&localStorage.getItem("base.content.url")||"",co="config.json",uo="base.ui.components.url";so&&localStorage.getItem(uo),so&&localStorage.getItem(uo);const ho="descope-login-flow",po="code",fo="data-exclude-field",go="dls_last_auth",vo="state_id",mo="saml_idp_state_id",bo="saml_idp_username",wo="descope_idp_initiated",yo="sso_app_id",ko="oidc_login_hint",Io="oidc_prompt",xo="oidc_error_redirect_uri",Co="data-type",So="redirect",Oo="poll",jo="webauthnCreate",Ao="webauthnGet",Eo="nativeBridge",Uo="loadForm",Lo="submit",To="polling",Ro=["descope-multi-select-combo-box","descope-text-area"];var _o;!function(t){t.backward="backward",t.forward="forward"}(_o||(_o={}));const $o=["descope-enriched-text"];function Po(t){return new URLSearchParams(window.location.search).get(t)}function Mo(t){if(window.history.replaceState&&Po(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 Do(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 Wo({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(lo||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.toString()}function No(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?_o.forward:n<o?_o.backward:void 0}const qo=()=>{const[t="",e=""]=(Po(ho)||"").split("_");return{executionId:t,stepId:e}};function Fo(){Mo(ho)}const Bo=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),Vo=()=>{const{executionId:t,stepId:e}=qo();(t||e)&&Fo();const n=Po("t")||void 0;n&&Mo("t");const o=Po(po)||void 0;o&&Mo(po);const i=Po("err")||void 0;i&&Mo("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:Po("ra-challenge"),redirectAuthCallbackUrl:Po("ra-callback"),redirectAuthBackupCallbackUri:Po("ra-backup-callback"),redirectAuthInitiator:Po("ra-initiator")},c=Po(vo);c&&Mo(vo);const d=Po(mo);d&&Mo(mo);const u=Po(bo);d&&Mo(bo);const h=Po(wo);h&&Mo(wo);const p=Po(yo);p&&Mo(yo);const f=Po(ko);f&&Mo(ko);const g=Po(Io);g&&Mo(Io);const v=Po(xo);v&&Mo(xo);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 Object.assign(((...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}),{reset:()=>{e=void 0,n=void 0}})};function Ko(t,e,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{r||(clearTimeout(s),o(t))})).catch((t=>{r||(clearTimeout(s),i(t))}))}))}const zo=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||n||o||i||r||s||a),Jo=t=>null==t?void 0:t.submit(),Go=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Xo=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Zo(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 Qo,Yo,ti,ei;function ni(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(!ni(r,s))return!1}else if(r!==s)return!1}return!0}class oi{constructor(t={},{updateOnlyOnChange:e=!0}={}){Qo.set(this,void 0),Yo.set(this,{}),ti.set(this,0),ei.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,Qo,"f")):t,n=Object.assign(Object.assign({},o(this,Qo,"f")),e);if(!o(this,ei,"f")||!ni(o(this,Qo,"f"),n)){const t=o(this,Qo,"f");i(this,Qo,n,"f"),Object.freeze(o(this,Qo,"f")),setTimeout((()=>{Object.values(o(this,Yo,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,Qo,t,"f"),i(this,ei,e,"f")}get current(){return Object.assign({},o(this,Qo,"f"))}subscribe(t){return i(this,ti,o(this,ti,"f")+1,"f"),o(this,Yo,"f")[o(this,ti,"f")]=t,o(this,ti,"f").toString()}unsubscribe(t){const e=!!o(this,Yo,"f")[t];return e&&delete o(this,Yo,"f")[t],e}unsubscribeAll(){return i(this,Yo,{},"f"),!0}}Qo=new WeakMap,Yo=new WeakMap,ti=new WeakMap,ei=new WeakMap;const ii=["*","#","/","(",")","[","]","_","<",">","`"],ri=t=>{const e=ii.map((e=>`${t}${e}`)).join("|");return new RegExp(`(${e})`,"g")},si=["disabled"],ai=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${fo}])`)).forEach((t=>{t.value=n}))}))},li=(t,e)=>e.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),t),ci=(t,e,n)=>t.replace(/{{(.+?)}}/g,((t,o)=>n?(t=>"string"!=typeof t?t:t.replace(ri("\\"),"\\$1"))(li(e,o)):li(e,o))),di=(t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{const n=(o=t.localName,$o.includes(o));var o;t.textContent=ci(t.textContent,e,n);const i=t.getAttribute("href");i&&t.setAttribute("href",ci(i,e))}))},ui=(t,e,n)=>{t.querySelectorAll(`[${Co}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},hi=(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})`))},pi=(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(`[${Co}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),ui(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ui(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),di(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=ci(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])=>{si.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,o)},fi=Ho((()=>n(void 0,void 0,void 0,(function*(){var t,e;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)))),o=(()=>{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 Ko(100,n,o)}catch(t){return console.error("Conditional login check failed",t),!1}})))),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))]},vi={"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 mi(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(go)))}catch(t){}return e}const bi="dls_ab_testing_id";function wi(...t){return e=>t.reduce(((t,e)=>e(t)),e)}const yi=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 ki,Ii,xi,Ci,Si,Oi;function ji(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(!ji(r,s))return!1}else if(r!==s)return!1}return!0}class Ai{constructor(t={},{updateOnlyOnChange:e=!0}={}){ki.set(this,void 0),Ii.set(this,{}),xi.set(this,0),Ci.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,ki,"f")):t,n=Object.assign(Object.assign({},o(this,ki,"f")),e);if(!o(this,Ci,"f")||!ji(o(this,ki,"f"),n)){const t=o(this,ki,"f");i(this,ki,n,"f"),Object.freeze(o(this,ki,"f")),setTimeout((()=>{Object.values(o(this,Ii,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,ki,t,"f"),i(this,Ci,e,"f")}get current(){return Object.assign({},o(this,ki,"f"))}subscribe(t){return i(this,xi,o(this,xi,"f")+1,"f"),o(this,Ii,"f")[o(this,xi,"f")]=t,o(this,xi,"f").toString()}unsubscribe(t){const e=!!o(this,Ii,"f")[t];return e&&delete o(this,Ii,"f")[t],e}unsubscribeAll(){return i(this,Ii,{},"f"),!0}}ki=new WeakMap,Ii=new WeakMap,xi=new WeakMap,Ci=new WeakMap;class Ei{constructor(t,e){Si.set(this,void 0),this.nodeName="",i(this,Si,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,Si,"f"))}get ele(){var t,e;const n="function"==typeof o(this,Si,"f")?o(this,Si,"f").call(this):o(this,Si,"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(`Driver element is not available for ${this.nodeName}`,new Error),null)}}Si=new WeakMap;class Ui extends Ei{constructor(){super(...arguments),Oi.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,Oi,"f")&&(null===(t=this.ele)||void 0===t||t.append(o(this,Oi,"f").content.cloneNode(!0)))}setContent(t){i(this,Oi,t,"f"),this.reset()}remove(){var t;null===(t=this.ele)||void 0===t||t.remove()}}Oi=new WeakMap;class Li extends Ei{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 Ti=["error","warn","info","debug"],Ri=yi((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 Ti.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})),_i="undefined"!=typeof localStorage,$i=_i&&localStorage.getItem("base.content.url")||"",Pi=(t,e)=>!e&&`${t} cannot be empty, please make sure to set this attribute`,Mi=yi((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})),Di=yi((t=>{var e,n;const i=wi(Ri,Mi)(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})),Wi=t=>e=>{var n,i,r;const s=wi(Ri,Mi,Di)(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};Wi.missingAttrValidator=Pi;const Ni=yi((t=>{const e=wi(Wi({"project-id":Pi}))(t);return class extends e{get projectId(){return this.getAttribute("project-id")}}})),qi=yi((t=>class extends t{get baseUrl(){return this.getAttribute("base-url")||""}}));const Fi=yi((t=>{const e=wi(Ri,Ni,qi)(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($i||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")}}})),Bi=yi((t=>{var e,n,r;const s=wi(Fi)(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}));yi((t=>{var e,n,r,s,a,l,c;return c=class extends(wi(Mi,Ri)(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 br})),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 Vi="load-descope-ui",Hi="base.ui.components.url",Ki=_i&&localStorage.getItem(Hi)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",zi=_i&&localStorage.getItem(Hi)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Ji=_i&&localStorage.getItem(Hi)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Gi=t=>{const e=document.createElement("script");return e.id=t,e},Xi=(t,e)=>t.replace("<version>",e),Zi=yi((t=>{var e,n,r,s,a,l,c,d,u,h,p,f;const g=wi(Ri,Bi)(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,i,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const a=Gi(i);document.body.append(a),a.addEventListener("error",(()=>{t.forEach((t=>t(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${a.src}"`)))})),a.addEventListener("load",(()=>{n.forEach((t=>t()))})),a.src=Xi(r,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,[o(this,e,"m",l).bind(this,t[o(this,n,"f")],t[o(this,r,"f")],"load-descope-ui-fallback-script-2",Ji),...t[o(this,n,"f")]],t[o(this,r,"f")],"load-descope-ui-fallback-script",zi)})),t.addEventListener("load",(()=>{t[o(this,r,"f")].forEach((t=>t()))}))},d=async function(){if(document.querySelector(`script#${Vi}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const t=Gi(Vi);document.body.append(t),o(this,e,"m",a).call(this,t),o(this,e,"m",c).call(this,t),t.src=Xi(Ki,await o(this,e,"m",s).call(this))}return document.getElementById(Vi)},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})),Qi="content-root",Yi="root",tr=yi((t=>class extends t{constructor(...t){var e,n;super(...t),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Yi}, #${Qi} {\n height: 100%;\n }\n #${Yi} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Yi}">\n <div id="${Qi}"></div>\n </div>\n `,this.contentRootElement=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(Qi),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Yi)}})),er="descope-modal";yi((t=>{var e,n;const i=wi(Mi,tr,Zi)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,(()=>{const t=this.loadDescopeUiComponents.bind(this);return class extends Ui{setContent(e){t(e),super.setContent(e)}}})())}createModal(t){const n=((t={})=>{const e=document.createElement(er);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([er]),await(null===(t=super.init)||void 0===t?void 0:t.call(this))}},e=new WeakMap,n}));const nr="descope-notification";yi((t=>{var e,n;const i=wi(Mi,tr,Zi)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,(()=>{const t=this.loadDescopeUiComponents.bind(this);return class extends Li{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(nr);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([nr])}},e=new WeakMap,n}));const or=(t,e)=>!!e&&"light"!==e&&"dark"!==e&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ir=yi((t=>{var e,n,r,s,a,l,c,d,u,h,p;const f=wi(Wi({theme:or}),Fi,Mi,Zi,Bi,tr,Di)(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}));yi((t=>class extends(Ri(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()}})),yi((t=>class extends t{get baseStaticUrl(){return this.getAttribute("base-static-url")||""}}));const rr=(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 sr,ar,lr,cr,dr,ur,hr,pr,fr,gr;const vr=document.createElement("template");vr.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 mr=class extends HTMLElement{constructor(){var t;super(),sr.add(this),ar.set(this,new Ai({messages:[]})),lr.set(this,void 0),cr.set(this,void 0),dr.set(this,void 0),ur.set(this,{resize:o(this,sr,"m",gr).bind(this)}),this.attachShadow({mode:"open"}),null===(t=this.shadowRoot)||void 0===t||t.appendChild(vr.content.cloneNode(!0)),i(this,lr,this.shadowRoot.querySelector(".debugger"),"f"),i(this,cr,o(this,lr,"f").querySelector(".content"),"f"),i(this,dr,o(this,lr,"f").querySelector(".header"),"f")}updateData(t){o(this,ar,"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]=rr(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,lr,"f"),o(this,dr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ur,"f").resize),(t=o(this,lr,"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,lr,"f").onresize=o(this,sr,"m",fr).bind(this),o(this,ar,"f").subscribe(o(this,sr,"m",hr).bind(this))}disconnectedCallback(){o(this,ar,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ur,"f").resize)}};ar=new WeakMap,lr=new WeakMap,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,sr=new WeakSet,hr=function(t){o(this,sr,"m",pr).call(this,t),o(this,sr,"m",fr).call(this)},pr=function(t){o(this,cr,"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("")},fr=function(){o(this,cr,"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)}))},gr=function(){const[t,e]=rr(o(this,lr,"f"),Number.parseInt(o(this,lr,"f").style.left,10),Number.parseInt(o(this,lr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,lr,"f").style.top=`${e}px`,o(this,lr,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",mr);var br=Object.freeze({__proto__:null});const wr=yi((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})),yr=document.createElement("template");yr.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 kr=(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),kr(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 Ir,xr,Cr,Sr,Or,jr,Ar,Er,Ur,Lr,Tr,Rr,_r,$r,Pr,Mr,Dr,Wr,Nr,qr,Fr;const Br=wi(ir,wr)(HTMLElement);class Vr extends Br{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(),Ir.add(this),Cr.set(this,!1),this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),o(this,Ir,"m",qr).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)}},Sr.set(this,new oi),Or.set(this,new oi),jr.set(this,{}),this.getComponentsContext=()=>o(this,jr,"f"),this.nextRequestStatus=new oi({isLoading:!1}),Ar.set(this,void 0),Er.set(this,{popstate:o(this,Ir,"m",Rr).bind(this),componentsContext:o(this,Ir,"m",Dr).bind(this)}),Ur.set(this,void 0),this.getConfig=Ho((()=>n(this,void 0,void 0,(function*(){const t=Wo({projectId:this.projectId,filename:co,baseUrl:this.baseStaticUrl});try{const{body:e,headers:n}=yield Do(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,Ur,t,"f"),o(this,Ir,"m",Lr).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 kr(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}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();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()))}))}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var t,e;const n=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const 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,Or,"f").subscribe(o(this,Ir,"m",Nr).bind(this)),o(this,Or,"f").update({isDebug:this.debug}),o(this,Ir,"m",Tr).call(this),yield o(this,Ir,"m",Pr).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,Ir,"m",Fr).call(this);const{executionId:n,stepId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=Vo();window.addEventListener("popstate",o(this,Er,"f").popstate),window.addEventListener("components-context",o(this,Er,"f").componentsContext),o(this,Sr,"f").subscribe(o(this,Ir,"m",$r).bind(this)),o(this,Sr,"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,Cr,!0,"f")}))}disconnectedCallback(){o(this,Sr,"f").unsubscribeAll(),o(this,Or,"f").unsubscribeAll(),o(this,Ir,"m",Wr).call(this),window.removeEventListener("popstate",o(this,Er,"f").popstate),window.removeEventListener("components-context",o(this,Er,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,Cr,"f")&&e!==n&&xr.observedAttributes.includes(t)){o(this,Ir,"m",Tr).call(this);const i=null===e;o(this,Sr,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Fo()),{[Bo(t)]:n,stepId:r,executionId:s}})),o(this,Or,"f").update({isDebug:this.debug})}}}function Hr(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Kr,zr,Jr,Gr,Xr,Zr,Qr,Yr,ts,es,ns,os,is,rs,ss,as,ls,cs,ds,us,hs,ps,fs,gs,vs,ms,bs,ws,ys,ks,Is,xs,Cs;xr=Vr,Cr=new WeakMap,Sr=new WeakMap,Or=new WeakMap,jr=new WeakMap,Ar=new WeakMap,Er=new WeakMap,Ur=new WeakMap,Ir=new WeakSet,Lr=function(){this.shadowRoot.appendChild(yr.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},Tr=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"];xr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[Bo(e)])throw Error(`${e} cannot be empty`)}))},Rr=function(){const{stepId:t,executionId:e}=qo();o(this,Sr,"f").update({stepId:t,executionId:e})},_r=function(t,e){this.sdk=ro(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},xr.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:ao,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},$r=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,Ir,"m",_r).call(this,e,n)}o(this,Ur,"f").call(this,t)}))},Pr=function(){return n(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield o(this,Ir,"m",Mr).call(this))}))},Mr=function(){return n(this,void 0,void 0,(function*(){const t=Wo({projectId:this.projectId,filename:co,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield Do(t,"json"),!0}catch(t){return!1}}))},Dr=function(t){i(this,jr,Object.assign(Object.assign({},o(this,jr,"f")),t.detail),"f")},Wr=function(){var t;null===(t=o(this,Ar,"f"))||void 0===t||t.remove(),i(this,Ar,null,"f")},Nr=function(t){return n(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,Ar,document.createElement("descope-debugger"),"f"),Object.assign(o(this,Ar,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return As})),document.body.appendChild(o(this,Ar,"f"))):o(this,Ir,"m",Wr).call(this)}))},qr=function(t,e){var n;t&&this.debug&&(null===(n=o(this,Ar,"f"))||void 0===n||n.updateData({title:t,description:e}))},Fr=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=Ro.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()}}},Vr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.29.0"}};class Ss extends Vr{static set sdkConfigOverrides(t){Vr.sdkConfigOverrides=t}constructor(){const t=new oi({deferredRedirect:!1});super(t.update.bind(t)),Kr.add(this),this.stepState=new oi({},{updateOnlyOnChange:!1}),zr.set(this,void 0),Jr.set(this,null),Gr.set(this,{visibilitychange:o(this,Kr,"m",Xr).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,e)=>{var n;const i=JSON.parse(e);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:t}=i;if(!t){t=null===(n=new URL(i.url).searchParams)||void 0===n?void 0:n.get(po)}this.nativeComplete({exchangeCode:t,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(i.url),e=t.searchParams.get("t"),n=t.searchParams.get(ho).split("_").pop();o(this,Yr,"f").call(this),this.flowState.update({token:e,stepId:n,action:void 0})}else this.nativeComplete(i)},Qr.set(this,((t,e,r,s,a=!1)=>{if(this.flowState.current.action===Oo){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;i(this,zr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(t,e,To,r,s,{}),d=document.hidden&&!a&&Date.now()-l>c+500;let u;d&&this.logger.debug("polling - The polling seems to be throttled");try{const t=d?1e3:6e3;u=yield Ko(t,i)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,Qr,"f").call(this,t,e,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===ao)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,Qr,"f").call(this,t,e,r,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),o(this,ts,"f").call(this,u),o(this,Qr,"f").call(this,t,e,r,s)}))),c),"f")}})),Yr.set(this,(()=>{clearTimeout(o(this,zr,"f")),i(this,zr,null,"f")})),ts.set(this,(t=>{var e,n,i,r,s,a,l,c,d,u,h,p;if(!(null==t?void 0:t.ok)){const l=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,c=`${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}`;o(this,Kr,"m",fs).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:c,errorMessage:l}),this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||l,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||c);const d=null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||o(this,Kr,"m",Zr).call(this))}null===(c=null===(l=t.data)||void 0===l?void 0:l.runnerLogs)||void 0===c||c.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 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)&&so&&localStorage.setItem(go,JSON.stringify(t))}(m),void o(this,Kr,"m",fs).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:k,screen:I,redirect:x,openInNewTabUrl:C,webauthn:S,error:O,samlIdpResponse:j,nativeResponse:A}=t.data;k!==Oo?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:I,status:g,stepId:w,stepName:y,action:k,error:O}),this.flowState.update({stepId:w,executionId:b,action:k,redirectTo:null==x?void 0:x.url,openInNewTabUrl:C,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==S?void 0:S.transactionId,webauthnOptions:null==S?void 0:S.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:k})})),es.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)}}))))),ds.set(this,Xo(((t,e)=>n(this,void 0,void 0,(function*(){var n,i;if("true"===t.getAttribute("formnovalidate")||o(this,Kr,"m",is).call(this)){const r=null==t?void 0:t.getAttribute("id");o(this,Kr,"m",ss).call(this,t);const s=yield o(this,Kr,"m",rs).call(this),a=(i=t,Array.from((null==i?void 0:i.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}),{})),l=this.getComponentsContext(),c=Object.assign(Object.assign(Object.assign(Object.assign({},l),a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin}),d=yield this.getFlowConfig(),u=yield this.getProjectConfig(),h=yield e(r,d.version,u.componentsVersion,c);o(this,ts,"f").call(this,h),o(this,Kr,"m",as).call(this,s)}}))))),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 Us})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return Ts})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return _s})),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:{[Hr(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,Gr,"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,Jr,"f"))||void 0===t||t.abort(),i(this,Jr,null,"f"),window.removeEventListener("visibilitychange",o(this,Gr,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const o=Zo(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 Do(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 Do(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 a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,openInNewTabUrl:b,redirectUrl:w,token:y,code:k,exchangeError:I,webauthnTransactionId:x,webauthnOptions:C,redirectAuthCodeChallenge:S,redirectAuthCallbackUrl:O,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:A,locale:E,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:L,samlIdpResponseRelayState:T,nativeResponseType:R,nativePayload:_}=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","nativeResponseType","nativePayload"]);let P,M;const D=(()=>{const t=localStorage.getItem(bi);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(bi,t.toString()),t}return Number(t)})(),W=this.sdk.getLastUserLoginId(),N=yield this.getFlowConfig(),q=yield this.getProjectConfig(),F=Object.entries(q.flows||{}).reduce(((t,[e,n])=>(t[e]=n.version,t)),{}),B=O&&S?{callbackUrl:O,codeChallenge:S,backupCallbackUri:j}:void 0,V=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!p&&(this.loadSdkScripts(),N.fingerprintEnabled&&N.fingerprintKey?yield Dn(N.fingerprintKey,this.baseUrl):localStorage.removeItem(Pn),N.conditions?({startScreenId:P,conditionInteractionId:M}=((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=vi[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:W,code:k,token:y,abTestingKey:D},N.conditions)):N.condition?({startScreenId:P,conditionInteractionId:M}=((t,e)=>{var n;const o=null===(n=vi[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}})(N.condition,{loginId:W,code:k,token:y,abTestingKey:D})):P=N.startScreenId,!zo(P,$))){const t=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},$),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:mi(W),abTestingKey:D,locale:Zo(E).locale,nativeOptions:V}),M,"",q.componentsVersion,F,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return o(this,ts,"f").call(this,t),void("completed"!==(null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const t=yield this.sdk.flow.next(p,h,Lo,N.version,q.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return o(this,ts,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Uo&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!U||!L)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)})(U,L,T||"",Jo)}if(f===So&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===A&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(f===jo||f===Ao){if(!x||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(l=o(this,Jr,"f"))||void 0===l||l.abort(),i(this,Jr,null,"f");try{t=f===jo?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}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(p,h,Lo,N.version,q.componentsVersion,{transactionId:x,response:t,failure:e});o(this,ts,"f").call(this,n)}if(f===Eo)return this.nativeComplete=t=>n(this,void 0,void 0,(function*(){const e=yield this.sdk.flow.next(p,h,Lo,N.version,q.componentsVersion,t);o(this,ts,"f").call(this,e)})),void o(this,Kr,"m",fs).call(this,"bridge",{type:R,payload:_});if(o(this,Qr,"f").call(this,p,h,N.version,q.componentsVersion),!g&&!P)return void this.loggerWrapper.warn("No screen was found to show");const H=P||g,K=yield this.getHtmlFilenameWithLocale(E,H),{oidcLoginHint:z,oidcPrompt:J,oidcErrorRedirectUri:G,samlIdpUsername:X}=$,Z={direction:No(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:W,name:this.sdk.getLastUserDisplayName()||W}}),htmlUrl:Wo({projectId:c,filename:`${H}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:K&&Wo({projectId:c,filename:K,baseUrl:this.baseStaticUrl}),samlIdpUsername:X,oidcLoginHint:z,oidcPrompt:J,oidcErrorRedirectUri:G,openInNewTabUrl:b},Q=mi(W);zo(P,$)?Z.next=(t,e,n,o)=>this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},$),{lastAuth:Q,preview:this.preview,abTestingKey:D,client:this.client}),w&&{redirectUrl:w}),{locale:Zo(E).locale,nativeOptions:V}),M,t,n,F,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Z.next=(...t)=>this.sdk.flow.next(p,h,...t)),this.stepState.update(Z)}))}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,Kr,"m",os).call(this,p,c):p.querySelectorAll(`descope-button[${Co}="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),pi(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,hi(r,"descope-totp-image",s),((t,e)=>{hi(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);const a=!e.htmlUrl;setTimeout((()=>{o(this,Kr,"m",ls).call(this),((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),((t,e)=>{ai(t,null==e?void 0:e.inputs),ai(t,null==e?void 0:e.form)})(this.rootElement,d)})),o(this,Kr,"m",hs).call(this,c),a&&o(this,Kr,"m",fs).call(this,"ready",{}),o(this,Kr,"m",fs).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${Co}="polling"]`)){const t=yield this.getFlowConfig(),e=yield this.getProjectConfig(),n=yield c(To,t.version,e.componentsVersion,{});o(this,ts,"f").call(this,n)}u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,Kr,"m",ps).call(this,v,l):v()}))}}zr=new WeakMap,Jr=new WeakMap,Gr=new WeakMap,Qr=new WeakMap,Yr=new WeakMap,ts=new WeakMap,es=new WeakMap,ds=new WeakMap,Kr=new WeakSet,Xr=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Zr=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const t=yield this.getComponentsVersion();this.getConfig.reset();t===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},ns=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)}))}},os=function(t,e){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,Jr,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield fi())){const{options:t,transactionId:r}=(yield o(this,es,"f").call(this))||{};if(t&&r){o(this,Kr,"m",ns).call(this,s),i(this,Jr,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,o(this,Jr,"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,ts,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},is=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},rs=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${fo}])`));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})),{})}))},ss=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},as=function(t={}){var e,n;const o=Go(t,["externalId","email","phone"]),i=Go(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)}},ls=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()));this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>o(this,Kr,"m",cs).call(this,t)))},cs=function(t){if(!t)return;t.querySelectorAll("input").forEach((e=>{const n=e.getAttribute("slot"),o=`input-${t.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),t.appendChild(i),e.setAttribute("slot",o),this.appendChild(e)}))},us=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,ds,"f").call(this,e,t)}))}))},hs=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{o(this,ds,"f").call(this,e,t)}})),o(this,Kr,"m",us).call(this,t)},ps=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===_o.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")},fs=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",Ss);const Os=document.createElement("template");Os.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 js extends HTMLElement{constructor(){super(),gs.add(this),vs.set(this,new oi({messages:[]})),ms.set(this,void 0),bs.set(this,void 0),ws.set(this,void 0),ys.set(this,{resize:o(this,gs,"m",Cs).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Os.content.cloneNode(!0)),i(this,ms,this.shadowRoot.querySelector(".debugger"),"f"),i(this,bs,o(this,ms,"f").querySelector(".content"),"f"),i(this,ws,o(this,ms,"f").querySelector(".header"),"f")}updateData(t){o(this,vs,"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,ms,"f"),o(this,ws,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ys,"f").resize),(t=o(this,ms,"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,ms,"f").onresize=o(this,gs,"m",xs).bind(this),o(this,vs,"f").subscribe(o(this,gs,"m",ks).bind(this))}disconnectedCallback(){o(this,vs,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ys,"f").resize)}}vs=new WeakMap,ms=new WeakMap,bs=new WeakMap,ws=new WeakMap,ys=new WeakMap,gs=new WeakSet,ks=function(t){o(this,gs,"m",Is).call(this,t),o(this,gs,"m",xs).call(this)},Is=function(t){o(this,bs,"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("")},xs=function(){o(this,bs,"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)}))},Cs=function(){const[t,e]=gi(o(this,ms,"f"),Number.parseInt(o(this,ms,"f").style.left,10),Number.parseInt(o(this,ms,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,ms,"f").style.top=`${e}px`,o(this,ms,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",js);var As=Object.freeze({__proto__:null,default:js});const Es='\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 Us=Object.freeze({__proto__:null,default:(t,e,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=Es.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 Ls=(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,an]:[an];let a=[];if(n&&i){const t=new URL(i);a=[`${t.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,fn]}else a=[fn];const l=gn({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 Ts=Object.freeze({__proto__:null,default:Ls,loadFingerprint:Ls});const Rs=(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=gn({apiKey:i,endpoint:[c.toString(),an],scriptUrlPattern:[u,fn]}),p=yield h,{requestId:f}=yield p.get();o(f)}catch(t){console.warn("Could not load descope fingerprint",t)}}));var _s=Object.freeze({__proto__:null,default:Rs,loadFingerprint:Rs})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-component",
3
- "version": "3.27.3",
3
+ "version": "3.29.0",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/descope-js",
6
6
  "bugs": {
@@ -67,10 +67,10 @@
67
67
  "dependencies": {
68
68
  "tslib": "2.6.3",
69
69
  "@fingerprintjs/fingerprintjs-pro": "3.9.9",
70
- "@descope/sdk-mixins": "0.3.2",
71
70
  "@descope/sdk-helpers": "0.1.60",
72
- "@descope/web-js-sdk": "1.19.2",
73
- "@descope/escape-markdown": "0.0.1"
71
+ "@descope/sdk-mixins": "0.4.0",
72
+ "@descope/escape-markdown": "0.0.2",
73
+ "@descope/web-js-sdk": "1.19.2"
74
74
  },
75
75
  "overrides": {
76
76
  "terser": "5.31.1"
@@ -1 +0,0 @@
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{escapeMarkdown as a}from"@descope/escape-markdown";import{themeMixin as l}from"@descope/sdk-mixins";import{createSingletonMixin as d,compose as c}from"@descope/sdk-helpers";const u="undefined"!=typeof localStorage,h="J151000",p=u&&localStorage.getItem("base.content.url")||"",g="config.json",f="base.ui.components.url";u&&localStorage.getItem(f),u&&localStorage.getItem(f);const v="descope-login-flow",m="code",b="data-exclude-field",y="dls_last_auth",w="state_id",I="saml_idp_state_id",C="saml_idp_username",k="descope_idp_initiated",A="sso_app_id",S="oidc_login_hint",E="oidc_prompt",j="oidc_error_redirect_uri",x="data-type",O="redirect",U="poll",L="webauthnCreate",R="webauthnGet",T="nativeBridge",W="loadForm",$="submit",P="polling",M=["descope-multi-select-combo-box","descope-text-area"];var N;!function(t){t.backward="backward",t.forward="forward"}(N||(N={}));const q=["descope-enriched-text"];function V(t){return new URLSearchParams(window.location.search).get(t)}function _(t){if(window.history.replaceState&&V(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 D(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 F({projectId:t,filename:e,assetsFolder:i="v2-beta",baseUrl:o}){const r=new URL(p||o||"https://static.descope.com/pages");return r.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(r.pathname,t,i,e),r.toString()}function K(t,e){if(!e)return;const i=+t,o=+e;return Number.isNaN(i)||Number.isNaN(o)?void 0:i>o?N.forward:i<o?N.backward:void 0}const H=()=>{const[t="",e=""]=(V(v)||"").split("_");return{executionId:t,stepId:e}};function B(){_(v)}const J=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),G=()=>{const{executionId:t,stepId:e}=H();(t||e)&&B();const i=V("t")||void 0;i&&_("t");const o=V(m)||void 0;o&&_(m);const r=V("err")||void 0;r&&_("err");const{redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:V("ra-challenge"),redirectAuthCallbackUrl:V("ra-callback"),redirectAuthBackupCallbackUri:V("ra-backup-callback"),redirectAuthInitiator:V("ra-initiator")},d=V(w);d&&_(w);const c=V(I);c&&_(I);const u=V(C);c&&_(C);const h=V(k);h&&_(k);const p=V(A);p&&_(A);const g=V(S);g&&_(S);const f=V(E);f&&_(E);const v=V(j);v&&_(j);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:g,oidcPrompt:f,oidcErrorRedirectUri:v}}},z=t=>{let e,i;return Object.assign(((...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}),{reset:()=>{e=void 0,i=void 0}})};function Q(t,e,i){return new Promise(((o,r)=>{let n=!1;const s=setTimeout((()=>{n=!0,void 0!==i?o(i):r(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{n||(clearTimeout(s),o(t))})).catch((t=>{n||(clearTimeout(s),r(t))}))}))}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([${b}])`)).forEach((t=>{t.value=i}))}))},ct=(t,e)=>e.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),t),ut=(t,e,i)=>t.replace(/{{(.+?)}}/g,((t,o)=>i?a(ct(e,o)):ct(e,o))),ht=(t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{const i=(o=t.localName,q.includes(o));var o;t.textContent=ut(t.textContent,e,i);const r=t.getAttribute("href");r&&t.setAttribute("href",ut(r,e))}))},pt=(t,e,i)=>{t.querySelectorAll(`[${x}="${e}"]`).forEach((t=>{t.setAttribute("href",i)}))},gt=(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})`))},ft=(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(`[${x}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",l),pt(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),pt(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),ht(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=ut(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)},vt=z((()=>t(void 0,void 0,void 0,(function*(){var t,e;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=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)))),o=(()=>{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 Q(100,i,o)}catch(t){return console.error("Conditional login check failed",t),!1}})))),mt={"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 bt(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(y)))}catch(t){}return e}const yt="dls_ab_testing_id",wt=d((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})),It=document.createElement("template");It.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 Ct=(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),Ct(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 kt,At,St,Et,jt,xt,Ot,Ut,Lt,Rt,Tt,Wt,$t,Pt,Mt,Nt,qt,Vt,_t,Dt,Ft;const Kt=c(l,wt)(HTMLElement);class Ht extends Kt{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(),kt.add(this),St.set(this,!1),this.loggerWrapper={error:(t,i="")=>{this.logger.error(t,i,new Error),e(this,kt,"m",Dt).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)}},Et.set(this,new at),jt.set(this,new at),xt.set(this,{}),this.getComponentsContext=()=>e(this,xt,"f"),this.nextRequestStatus=new at({isLoading:!1}),Ot.set(this,void 0),Ut.set(this,{popstate:e(this,kt,"m",Wt).bind(this),componentsContext:e(this,kt,"m",qt).bind(this)}),Lt.set(this,void 0),this.getConfig=z((()=>t(this,void 0,void 0,(function*(){const t=F({projectId:this.projectId,filename:g,baseUrl:this.baseStaticUrl});try{const{body:e,headers:i}=yield D(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,Lt,o,"f"),e(this,kt,"m",Rt).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 Ct(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}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();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()))}))}getComponentsVersion(){return t(this,void 0,void 0,(function*(){var t,e;const i=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}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,jt,"f").subscribe(e(this,kt,"m",_t).bind(this)),e(this,jt,"f").update({isDebug:this.debug}),e(this,kt,"m",Tt).call(this),yield e(this,kt,"m",Mt).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");e(this,kt,"m",Ft).call(this);const{executionId:r,stepId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=G();window.addEventListener("popstate",e(this,Ut,"f").popstate),window.addEventListener("components-context",e(this,Ut,"f").componentsContext),e(this,Et,"f").subscribe(e(this,kt,"m",Pt).bind(this)),e(this,Et,"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,St,!0,"f")}))}disconnectedCallback(){e(this,Et,"f").unsubscribeAll(),e(this,jt,"f").unsubscribeAll(),e(this,kt,"m",Vt).call(this),window.removeEventListener("popstate",e(this,Ut,"f").popstate),window.removeEventListener("components-context",e(this,Ut,"f").componentsContext)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,St,"f")&&i!==o&&At.observedAttributes.includes(t)){e(this,kt,"m",Tt).call(this);const r=null===i;e(this,Et,"f").update((({stepId:e,executionId:i})=>{let n=e,s=i;return r||(s=null,n=null,B()),{[J(t)]:o,stepId:n,executionId:s}})),e(this,jt,"f").update({isDebug:this.debug})}}}function Bt(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Jt,Gt,zt,Qt,Xt,Yt,Zt,te,ee,ie,oe,re,ne,se,ae,le,de,ce,ue,he,pe,ge,fe;At=Ht,St=new WeakMap,Et=new WeakMap,jt=new WeakMap,xt=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Lt=new WeakMap,kt=new WeakSet,Rt=function(){this.shadowRoot.appendChild(It.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},Tt=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"];At.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[J(e)])throw Error(`${e} cannot be empty`)}))},Wt=function(){const{stepId:t,executionId:i}=H();e(this,Et,"f").update({stepId:t,executionId:i})},$t=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},At.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:h,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Pt=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,kt,"m",$t).call(this,t,o)}e(this,Lt,"f").call(this,i)}))},Mt=function(){return t(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield e(this,kt,"m",Nt).call(this))}))},Nt=function(){return t(this,void 0,void 0,(function*(){const t=F({projectId:this.projectId,filename:g,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield D(t,"json"),!0}catch(t){return!1}}))},qt=function(t){i(this,xt,Object.assign(Object.assign({},e(this,xt,"f")),t.detail),"f")},Vt=function(){var t;null===(t=e(this,Ot,"f"))||void 0===t||t.remove(),i(this,Ot,null,"f")},_t=function(o){return t(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,Ot,document.createElement("descope-debugger"),"f"),Object.assign(e(this,Ot,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-1bccb5d6.js"),document.body.appendChild(e(this,Ot,"f"))):e(this,kt,"m",Vt).call(this)}))},Dt=function(t,i){var o;t&&this.debug&&(null===(o=e(this,Ot,"f"))||void 0===o||o.updateData({title:t,description:i}))},Ft=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=M.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()}}},Ht.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.27.3"}};class ve extends Ht{static set sdkConfigOverrides(t){Ht.sdkConfigOverrides=t}constructor(){const o=new at({deferredRedirect:!1});super(o.update.bind(o)),Jt.add(this),this.stepState=new at({},{updateOnlyOnChange:!1}),Gt.set(this,void 0),zt.set(this,null),Qt.set(this,{visibilitychange:e(this,Jt,"m",Xt).bind(this)}),this.bridgeVersion=1,Zt.set(this,((o,r,n,s,a,l=!1)=>{if(n===U){this.logger.debug("polling - Scheduling polling request");const d=Date.now(),c=l?500:2e3;i(this,Gt,setTimeout((()=>t(this,void 0,void 0,(function*(){var t,i;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(o,r,P,s,a,{}),p=document.hidden&&!l&&Date.now()-d>c+500;let g;p&&this.logger.debug("polling - The polling seems to be throttled");try{const t=p?1e3:6e3;g=yield Q(t,u)}catch(t){return this.logger.warn(`polling - The ${p?"throttled fetch":"fetch"} call timed out or was aborted`),void e(this,Zt,"f").call(this,o,r,n,s,a,p)}if((null===(t=null==g?void 0:g.error)||void 0===t?void 0:t.errorCode)===h)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,Zt,"f").call(this,o,r,n,s,a);this.logger.debug("polling - Got a response"),(null==g?void 0:g.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(g.error,null,4)),e(this,ee,"f").call(this,g);const{action:f}=null!==(i=null==g?void 0:g.data)&&void 0!==i?i:{};e(this,Zt,"f").call(this,o,r,f,s,a)}))),c),"f")}})),te.set(this,(()=>{clearTimeout(e(this,Gt,"f")),i(this,Gt,null,"f")})),ee.set(this,(t=>{var i,o,r,n,s,a,l,d,c,h,p,g;if(!(null==t?void 0:t.ok)){const l=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${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}`;e(this,Jt,"m",fe).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:d,errorMessage:l}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||l,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||d);const c=null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorCode;return void("E102004"!==c&&"E103205"!==c||!this.isRestartOnError||e(this,Jt,"m",Yt).call(this))}null===(d=null===(l=t.data)||void 0===l?void 0:l.runnerLogs)||void 0===d||d.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===(p=null===(h=null===(c=t.data)||void 0===c?void 0:c.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.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:v,authInfo:m,lastAuth:b}=t.data;if("completed"===v)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&u&&localStorage.setItem(y,JSON.stringify(t))}(b),void e(this,Jt,"m",fe).call(this,"success",m);const{executionId:w,stepId:I,stepName:C,action:k,screen:A,redirect:S,openInNewTabUrl:E,webauthn:j,error:x,samlIdpResponse:O,nativeResponse:L}=t.data;k!==U?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${v}`,"",{screen:A,status:v,stepId:I,stepName:C,action:k,error:x}),this.flowState.update({stepId:I,executionId:w,action:k,redirectTo:null==S?void 0:S.url,openInNewTabUrl:E,screenId:null==A?void 0:A.id,screenState:null==A?void 0:A.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState,nativeResponseType:null==L?void 0:L.type,nativePayload:null==L?void 0:L.payload})):this.flowState.update({action:k})})),ie.set(this,z((()=>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)}}))))),ue.set(this,tt(((i,o)=>t(this,void 0,void 0,(function*(){var t,r;if("true"===i.getAttribute("formnovalidate")||e(this,Jt,"m",ne).call(this)){const n=null==i?void 0:i.getAttribute("id");e(this,Jt,"m",ae).call(this,i);const s=yield e(this,Jt,"m",se).call(this),a=(r=i,Array.from((null==r?void 0:r.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}),{})),l=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},l),a),s),{origin:(null===(t=this.nativeOptions)||void 0===t?void 0:t.origin)||window.location.origin}),c=yield this.getFlowConfig(),u=yield this.getProjectConfig(),h=yield o(n,c.version,u.componentsVersion,d);e(this,ee,"f").call(this,h),e(this,Jt,"m",le).call(this,s)}}))))),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:{[Bt(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,Qt,"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,zt,"f"))||void 0===t||t.abort(),i(this,zt,null,"f"),window.removeEventListener("visibilitychange",e(this,Qt,"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 D(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 D(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 d,c;const{projectId:u,flowId:h,tenant:p,stepId:g,executionId:f,action:v,screenId:m,screenState:b,redirectTo:y,openInNewTabUrl:w,redirectUrl:I,token:C,code:k,exchangeError:A,webauthnTransactionId:S,webauthnOptions:E,redirectAuthCodeChallenge:j,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:U,redirectAuthInitiator:P,locale:M,samlIdpResponseUrl:N,samlIdpResponseSamlResponse:q,samlIdpResponseRelayState:V,nativeResponseType:_,nativePayload:D}=r,H=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","nativeResponseType","nativePayload"]);let B,J;const G=(()=>{const t=localStorage.getItem(yt);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(yt,t.toString()),t}return Number(t)})(),z=this.sdk.getLastUserLoginId(),Q=yield this.getFlowConfig(),Z=yield this.getProjectConfig(),tt=Object.entries(Z.flows||{}).reduce(((t,[e,i])=>(t[e]=i.version,t)),{}),it=x&&j?{callbackUrl:x,codeChallenge:j,backupCallbackUri:U}:void 0,ot=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect}:void 0;if(!f&&(this.loadSdkScripts(),Q.fingerprintEnabled&&Q.fingerprintKey?yield n(Q.fingerprintKey,this.baseUrl):s(),Q.conditions?({startScreenId:B,conditionInteractionId:J}=((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=mt[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:z,code:k,token:C,abTestingKey:G},Q.conditions)):Q.condition?({startScreenId:B,conditionInteractionId:J}=((t,e)=>{var i;const o=null===(i=mt[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}})(Q.condition,{loginId:z,code:k,token:C,abTestingKey:G})):B=Q.startScreenId,!X(B,H))){const t=yield this.sdk.flow.start(h,Object.assign(Object.assign(Object.assign(Object.assign({tenant:p,redirectAuth:it},H),{client:this.client}),I&&{redirectUrl:I}),{lastAuth:bt(z),abTestingKey:G,locale:et(M).locale,nativeOptions:ot}),J,"",Z.componentsVersion,tt,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),H.descopeIdpInitiated&&{idpInitiated:!0}),C?{token:C}:{}),H.oidcLoginHint?{externalId:H.oidcLoginHint}:{}));return e(this,ee,"f").call(this,t),void("completed"!==(null===(d=null==t?void 0:t.data)||void 0===d?void 0:d.status)&&this.flowState.update({code:void 0,token:void 0}))}if(f&&(l("token")&&C||l("code")&&k||l("exchangeError")&&A)){const t=yield this.sdk.flow.next(f,g,$,Q.version,Z.componentsVersion,{token:C,exchangeCode:k,exchangeError:A});return e(this,ee,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(v===W&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>l(t)))){if(!N||!q)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)})(N,q,V||"",Y)}if(v===O&&(l("redirectTo")||l("deferredRedirect")))return y?"android"===P&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(y):void this.loggerWrapper.error("Did not get redirect url");if(v===L||v===R){if(!S||!E)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,o;null===(c=e(this,zt,"f"))||void 0===c||c.abort(),i(this,zt,null,"f");try{t=v===L?yield this.sdk.webauthn.helpers.create(E):yield this.sdk.webauthn.helpers.get(E)}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,g,$,Q.version,Z.componentsVersion,{transactionId:S,response:t,failure:o});e(this,ee,"f").call(this,r)}if(v===T)return this.nativeComplete=i=>t(this,void 0,void 0,(function*(){const t=JSON.parse(i),o=yield this.sdk.flow.next(f,g,$,Q.version,Z.componentsVersion,t);e(this,ee,"f").call(this,o)})),void e(this,Jt,"m",fe).call(this,"bridge",{type:_,payload:D});if(e(this,Zt,"f").call(this,f,g,v,Q.version,Z.componentsVersion),!m&&!B)return void this.loggerWrapper.warn("No screen was found to show");const rt=B||m,nt=yield this.getHtmlFilenameWithLocale(M,rt),{oidcLoginHint:st,oidcPrompt:at,oidcErrorRedirectUri:lt,samlIdpUsername:dt}=H,ct={direction:K(g,a.stepId),screenState:Object.assign(Object.assign({},b),{form:Object.assign(Object.assign({},this.formConfigValues),null==b?void 0:b.form),lastAuth:{loginId:z,name:this.sdk.getLastUserDisplayName()||z}}),htmlUrl:F({projectId:u,filename:`${rt}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:nt&&F({projectId:u,filename:nt,baseUrl:this.baseStaticUrl}),samlIdpUsername:dt,oidcLoginHint:st,oidcPrompt:at,oidcErrorRedirectUri:lt,openInNewTabUrl:w},ut=bt(z);X(B,H)?ct.next=(t,e,i,o)=>this.sdk.flow.start(h,Object.assign(Object.assign(Object.assign(Object.assign({tenant:p,redirectAuth:it},H),{lastAuth:ut,preview:this.preview,abTestingKey:G,client:this.client}),I&&{redirectUrl:I}),{locale:et(M).locale,nativeOptions:ot}),J,t,i,tt,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),H.descopeIdpInitiated&&{idpInitiated:!0}),C&&{token:C})):(l("projectId")||l("baseUrl")||l("executionId")||l("stepId"))&&(ct.next=(...t)=>this.sdk.flow.next(f,g,...t)),this.stepState.update(ct)}))}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),g=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield e(this,Jt,"m",re).call(this,p,d):p.querySelectorAll(`descope-button[${x}="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),ft(p,c,c.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,f);const v=()=>t(this,void 0,void 0,(function*(){var t,i;yield g;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,gt(n,"descope-totp-image",s),((t,e)=>{gt(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);const a=!o.htmlUrl;setTimeout((()=>{e(this,Jt,"m",de).call(this),((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),((t,e)=>{dt(t,null==e?void 0:e.inputs),dt(t,null==e?void 0:e.form)})(this.rootElement,c)})),e(this,Jt,"m",pe).call(this,d),a&&e(this,Jt,"m",fe).call(this,"ready",{}),e(this,Jt,"m",fe).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${x}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(P,t.version,i.componentsVersion,{});e(this,ee,"f").call(this,o)}u&&!o.openInNewTabUrl&&window.open(u,"_blank")}));l?e(this,Jt,"m",ge).call(this,v,l):v()}))}}Gt=new WeakMap,zt=new WeakMap,Qt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,ie=new WeakMap,ue=new WeakMap,Jt=new WeakSet,Xt=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Yt=function(){return t(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const t=yield this.getComponentsVersion();this.getConfig.reset();t===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},oe=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)}))}},re=function(o,r){return t(this,void 0,void 0,(function*(){var n;null===(n=e(this,zt,"f"))||void 0===n||n.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield vt())){const{options:o,transactionId:n}=(yield e(this,ie,"f").call(this))||{};if(o&&n){e(this,Jt,"m",oe).call(this,s),i(this,zt,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,zt,"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,ee,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},ne=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},se=function(){return t(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${b}])`));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})),{})}))},ae=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},le=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)}},de=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()));this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>e(this,Jt,"m",ce).call(this,t)))},ce=function(t){if(!t)return;t.querySelectorAll("input").forEach((e=>{const i=e.getAttribute("slot"),o=`input-${t.id}-${i}`,r=document.createElement("slot");r.setAttribute("name",o),r.setAttribute("slot",i),t.appendChild(r),e.setAttribute("slot",o),this.appendChild(e)}))},he=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,ue,"f").call(this,i,t)}))}))},pe=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{e(this,ue,"f").call(this,i,t)}})),e(this,Jt,"m",he).call(this,t)},ge=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===N.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")},fe=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",ve);export{ve as D,at as S};