@descope/web-component 2.0.23 → 2.0.25

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{S as e,_ as n,a as t}from"./index-d3fa479e.js";const s=(e,n,t,s={})=>{var i,o,l,a;return[Math.min(Math.max(n,("all"===s.left?e.offsetWidth:null!==(i=s.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(o=s.right)&&void 0!==o?o: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!==(a=s.bottom)&&void 0!==a?a:0))]};var i,o,l,a,r,d,c,h,p,g;const f=document.createElement("template");f.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey; \n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n \n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n } \n\n .msg_desc {\n color: #646464;\n cursor: initial;\n } \n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class m extends HTMLElement{constructor(){super(),i.add(this),o.set(this,new e({messages:[]})),l.set(this,void 0),a.set(this,void 0),r.set(this,void 0),d.set(this,{resize:n(this,i,"m",g).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(f.content.cloneNode(!0)),t(this,l,this.shadowRoot.querySelector(".debugger"),"f"),t(this,a,n(this,l,"f").querySelector(".content"),"f"),t(this,r,n(this,l,"f").querySelector(".header"),"f")}updateData(e){n(this,o,"f").update((n=>({messages:n.messages.concat(e)})))}connectedCallback(){var e;((e,n,t)=>{let i=0,o=0,l=0,a=0;function r(n){n.preventDefault(),i=l-n.clientX,o=a-n.clientY,l=n.clientX,a=n.clientY;const[r,d]=s(e,e.offsetLeft-i,e.offsetTop-o,t);e.style.top=`${d}px`,e.style.left=`${r}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),l=e.clientX,a=e.clientY,document.onmouseup=d,document.onmousemove=r}n?n.onmousedown=c:e.onmousedown=c})(n(this,l,"f"),n(this,r,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",n(this,d,"f").resize),(e=n(this,l,"f")).onmousemove=n=>{(n.target.w&&n.target.w!==n.target.offsetWidth||n.target.h&&n.target.h!==n.target.offsetHeight)&&e.onresize(n),n.target.w=n.target.offsetWidth,n.target.h=n.target.offsetHeight},n(this,l,"f").onresize=n(this,i,"m",p).bind(this),n(this,o,"f").subscribe(n(this,i,"m",c).bind(this))}disconnectedCallback(){n(this,o,"f").unsubscribeAll(),window.removeEventListener("resize",n(this,d,"f").resize)}}o=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,d=new WeakMap,i=new WeakSet,c=function(e){n(this,i,"m",h).call(this,e),n(this,i,"m",p).call(this)},h=function(e){n(this,a,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},p=function(){n(this,a,"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[e,t]=s(n(this,l,"f"),Number.parseInt(n(this,l,"f").style.left,10),Number.parseInt(n(this,l,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});n(this,l,"f").style.top=`${t}px`,n(this,l,"f").style.left=`${e}px`},customElements.define("descope-debugger",m);export{m as default};
1
+ import{S as e,_ as n,a as t}from"./index-48dfd25f.js";const s=(e,n,t,s={})=>{var i,o,l,a;return[Math.min(Math.max(n,("all"===s.left?e.offsetWidth:null!==(i=s.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(o=s.right)&&void 0!==o?o: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!==(a=s.bottom)&&void 0!==a?a:0))]};var i,o,l,a,r,d,c,h,p,g;const f=document.createElement("template");f.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey; \n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n \n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n } \n\n .msg_desc {\n color: #646464;\n cursor: initial;\n } \n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class m extends HTMLElement{constructor(){super(),i.add(this),o.set(this,new e({messages:[]})),l.set(this,void 0),a.set(this,void 0),r.set(this,void 0),d.set(this,{resize:n(this,i,"m",g).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(f.content.cloneNode(!0)),t(this,l,this.shadowRoot.querySelector(".debugger"),"f"),t(this,a,n(this,l,"f").querySelector(".content"),"f"),t(this,r,n(this,l,"f").querySelector(".header"),"f")}updateData(e){n(this,o,"f").update((n=>({messages:n.messages.concat(e)})))}connectedCallback(){var e;((e,n,t)=>{let i=0,o=0,l=0,a=0;function r(n){n.preventDefault(),i=l-n.clientX,o=a-n.clientY,l=n.clientX,a=n.clientY;const[r,d]=s(e,e.offsetLeft-i,e.offsetTop-o,t);e.style.top=`${d}px`,e.style.left=`${r}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),l=e.clientX,a=e.clientY,document.onmouseup=d,document.onmousemove=r}n?n.onmousedown=c:e.onmousedown=c})(n(this,l,"f"),n(this,r,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",n(this,d,"f").resize),(e=n(this,l,"f")).onmousemove=n=>{(n.target.w&&n.target.w!==n.target.offsetWidth||n.target.h&&n.target.h!==n.target.offsetHeight)&&e.onresize(n),n.target.w=n.target.offsetWidth,n.target.h=n.target.offsetHeight},n(this,l,"f").onresize=n(this,i,"m",p).bind(this),n(this,o,"f").subscribe(n(this,i,"m",c).bind(this))}disconnectedCallback(){n(this,o,"f").unsubscribeAll(),window.removeEventListener("resize",n(this,d,"f").resize)}}o=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,d=new WeakMap,i=new WeakSet,c=function(e){n(this,i,"m",h).call(this,e),n(this,i,"m",p).call(this)},h=function(e){n(this,a,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},p=function(){n(this,a,"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[e,t]=s(n(this,l,"f"),Number.parseInt(n(this,l,"f").style.left,10),Number.parseInt(n(this,l,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});n(this,l,"f").style.top=`${t}px`,n(this,l,"f").style.left=`${e}px`},customElements.define("descope-debugger",m);export{m as default};
@@ -1,2 +1,2 @@
1
- var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(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 r(t,e,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(t,n):r?r.value=n:e.set(t,n),n}const i="undefined"!=typeof localStorage,s=i&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",a="descope-login-flow",l="t",c="code",u="err",d="data-exclude-field",h="dls_last_auth",p="data-type",f="redirect",g="poll",v="webauthnCreate",b="webauthnGet",w="v2-alpha",m="submit",y="polling";var k,I,O;function j(t){return new URLSearchParams(window.location.search).get(t)}function S(t){if(window.history.replaceState&&j(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 E(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}`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(k||(k={}));const x=(...t)=>t.join("/").replace(/\/+/g,"/");function C(t,e){const n=new URL(s);return n.pathname=x(n.pathname,t,w,e),n.toString()}function A(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?k.forward:t<e?k.backward:void 0}const U=()=>{const[t="",e=""]=(j(a)||"").split("_");return{executionId:t,stepId:e}};function _(){S(a)}const P=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),R=()=>{const{executionId:t,stepId:e}=U();(t||e)&&_();const n=j(l)||void 0;n&&S(l);const o=j(c)||void 0;o&&S(c);const r=j(u)||void 0;return r&&S(u),{executionId:t,stepId:e,token:n,code:o,exchangeError:r}},T=t=>{let e,n;return(...o)=>{return e&&(i=o,(r=e).length===i.length&&r.every(((t,e)=>t===i[e])))||(e=o,n=t(...o)),n;var r,i}},q=null===(O=null===(I=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===I?void 0:I.brands)||void 0===O?void 0:O.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));var M,$,L,D;function N(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 r=n[o],i=t[r],s=e[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!N(i,s))return!1}else if(i!==s)return!1}return!0}class K{constructor(t={},{updateOnlyOnChange:e=!0}={}){M.set(this,void 0),$.set(this,{}),L.set(this,0),D.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,M,"f")):t,n=Object.assign(Object.assign({},o(this,M,"f")),e);if(!o(this,D,"f")||!N(o(this,M,"f"),n)){const t=o(this,M,"f");r(this,M,n,"f"),Object.freeze(o(this,M,"f")),setTimeout((()=>{Object.values(o(this,$,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},r(this,M,t,"f"),r(this,D,e,"f")}get current(){return Object.assign({},o(this,M,"f"))}subscribe(t){return r(this,L,o(this,L,"f")+1,"f"),o(this,$,"f")[o(this,L,"f")]=t,o(this,L,"f").toString()}unsubscribe(t){const e=!!o(this,$,"f")[t];return e&&delete o(this,$,"f")[t],e}unsubscribeAll(){return r(this,$,{},"f"),!0}}M=new WeakMap,$=new WeakMap,L=new WeakMap,D=new WeakMap;const J=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[${p}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${d}])`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(`[${p}="totp-link"]`).forEach((t=>{t.href=e}))})(t,null===(n=null==e?void 0:e.totp)||void 0===n?void 0:n.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},F=T((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return console.warn("webauthn","Conditional UI is not supported"),!1;try{const r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),i=108;return yield Promise.race([r,(n=100,new Promise(((t,e)=>{const r=setTimeout((()=>{e(new Error(`Promise timed out after ${n} ms`))}),n);null==o||o((e=>{clearTimeout(r),t(e)}),(t=>{clearTimeout(r),e(t)}))}))).catch((()=>q()>=i))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),W={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function H(t){this.message=t}H.prototype=new Error,H.prototype.name="InvalidCharacterError";var B="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new H("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,r=0,i=0,s="";o=e.charAt(i++);~o&&(n=r%4?64*n+o:o,r++%4)?s+=String.fromCharCode(255&n>>(-2*r&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function V(t){this.message=t}function z(t,e){if("string"!=typeof t)throw new V("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(B(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return B(e)}}(t.split(".")[n]))}catch(t){throw new V("Invalid token specified: "+t.message)}}V.prototype=new Error,V.prototype.name="InvalidTokenError";var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Z="Expected a function",Q="__lodash_hash_undefined__",Y=1/0,X="[object Function]",tt="[object GeneratorFunction]",et="[object Symbol]",nt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ot=/^\w*$/,rt=/^\./,it=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,st=/\\(\\)?/g,at=/^\[object .+?Constructor\]$/,lt="object"==typeof G&&G&&G.Object===Object&&G,ct="object"==typeof self&&self&&self.Object===Object&&self,ut=lt||ct||Function("return this")();var dt,ht=Array.prototype,pt=Function.prototype,ft=Object.prototype,gt=ut["__core-js_shared__"],vt=(dt=/[^.]+$/.exec(gt&&gt.keys&&gt.keys.IE_PROTO||""))?"Symbol(src)_1."+dt:"",bt=pt.toString,wt=ft.hasOwnProperty,mt=ft.toString,yt=RegExp("^"+bt.call(wt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),kt=ut.Symbol,It=ht.splice,Ot=Tt(ut,"Map"),jt=Tt(Object,"create"),St=kt?kt.prototype:void 0,Et=St?St.toString:void 0;function xt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Ct(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function At(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Ut(t,e){for(var n,o,r=t.length;r--;)if((n=t[r][0])===(o=e)||n!=n&&o!=o)return r;return-1}function _t(t,e){var n;e=function(t,e){if(Lt(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Nt(t))return!0;return ot.test(t)||!nt.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Lt(n=e)?n:qt(n);for(var o=0,r=e.length;null!=t&&o<r;)t=t[Mt(e[o++])];return o&&o==r?t:void 0}function Pt(t){if(!Dt(t)||(e=t,vt&&vt in e))return!1;var e,n=function(t){var e=Dt(t)?mt.call(t):"";return e==X||e==tt}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?yt:at;return n.test(function(t){if(null!=t){try{return bt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Rt(t,e){var n,o,r=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof e?"string":"hash"]:r.map}function Tt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Pt(n)?n:void 0}xt.prototype.clear=function(){this.__data__=jt?jt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(jt){var n=e[t];return n===Q?void 0:n}return wt.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return jt?void 0!==e[t]:wt.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=jt&&void 0===e?Q:e,this},Ct.prototype.clear=function(){this.__data__=[]},Ct.prototype.delete=function(t){var e=this.__data__,n=Ut(e,t);return!(n<0)&&(n==e.length-1?e.pop():It.call(e,n,1),!0)},Ct.prototype.get=function(t){var e=this.__data__,n=Ut(e,t);return n<0?void 0:e[n][1]},Ct.prototype.has=function(t){return Ut(this.__data__,t)>-1},Ct.prototype.set=function(t,e){var n=this.__data__,o=Ut(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},At.prototype.clear=function(){this.__data__={hash:new xt,map:new(Ot||Ct),string:new xt}},At.prototype.delete=function(t){return Rt(this,t).delete(t)},At.prototype.get=function(t){return Rt(this,t).get(t)},At.prototype.has=function(t){return Rt(this,t).has(t)},At.prototype.set=function(t,e){return Rt(this,t).set(t,e),this};var qt=$t((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Nt(t))return Et?Et.call(t):"";var e=t+"";return"0"==e&&1/t==-Y?"-0":e}(e);var n=[];return rt.test(t)&&n.push(""),t.replace(it,(function(t,e,o,r){n.push(o?r.replace(st,"$1"):e||t)})),n}));function Mt(t){if("string"==typeof t||Nt(t))return t;var e=t+"";return"0"==e&&1/t==-Y?"-0":e}function $t(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(Z);var n=function(){var o=arguments,r=e?e.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var s=t.apply(this,o);return n.cache=i.set(r,s),s};return n.cache=new($t.Cache||At),n}$t.Cache=At;var Lt=Array.isArray;function Dt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Nt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&mt.call(t)==et}var Kt=function(t,e,n){var o=null==t?void 0:_t(t,e);return void 0===o?n:o},Jt="/v1/auth/accesskey/exchange",Ft="/v1/auth/otp/verify",Wt="/v1/auth/otp/signin",Ht="/v1/auth/otp/signup",Bt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Vt="/v1/auth/otp/signup-in",zt="/v1/auth/magiclink/verify",Gt="/v1/auth/magiclink/signin",Zt="/v1/auth/magiclink/signup",Qt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},Yt="/v1/auth/magiclink/signup-in",Xt="/v1/auth/enchantedlink/verify",te="/v1/auth/enchantedlink/signin",ee="/v1/auth/enchantedlink/signup",ne="/v1/auth/enchantedlink/pending-session",oe={email:"/v1/auth/enchantedlink/update/email"},re="/v1/auth/enchantedlink/signup-in",ie="/v1/auth/oauth/authorize",se="/v1/auth/oauth/exchange",ae="/v1/auth/saml/authorize",le="/v1/auth/saml/exchange",ce="/v1/auth/totp/verify",ue="/v1/auth/totp/signup",de="/v1/auth/totp/update",he={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},pe={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},fe={start:"/v1/auth/webauthn/signup-in/start"},ge={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},ve="/v1/auth/password/signup",be="/v1/auth/password/signin",we="/v1/auth/password/reset",me="/v1/auth/password/update",ye="/v1/auth/password/replace",ke="/v1/auth/password/policy",Ie="/v1/auth/refresh",Oe="/v1/auth/logout",je="/v1/auth/logoutall",Se="/v1/auth/me",Ee="/v1/flow/start",xe="/v1/flow/next";const Ce=6e5,Ae=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};var Ue;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Ue||(Ue={}));const _e=(...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}),{})),Pe=t=>void 0===t?void 0:JSON.stringify(t),Re=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Te=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,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=>Ae().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 Ae().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=>{const s=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:l,body:c,headers:u,queryParams:d,method:h,token:p}=s,f=await a((({path:t,baseUrl:e,queryParams:n})=>{const o=new URL(t,e);return n&&(o.search=new URLSearchParams(n).toString()),o})({path:l,baseUrl:t,queryParams:d}),{headers:_e(Re(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.0.15"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:Pe(c),credentials:i||"include"});return(null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Ue.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.post,token:r}),put:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.put,token:r}),delete:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.delete,token:r}),hooks:r}};var qe={TOO_MANY_REQUESTS:429};function Me(t,e,n){var o;let r=$e(t);e&&(r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[e]);const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function $e(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return z(t)}function Le(t){const{exp:e}=$e(t);return(new Date).getTime()/1e3>e}function De(t,e){return Me(t,e,"permissions")}function Ne(t,e){return Me(t,e,"roles")}const Ke=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Je(t,e){var n;const o=await t,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=e?e(i):i:(r.error=i,o.status===qe.TOO_MANY_REQUESTS&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const Fe=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),We=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),He=t=>e=>t.test(e),Be=He(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ve=He(/^\+[1-9]{1}[0-9]{3,14}$/),ze=Fe(Be,'"{val}" is not a valid email'),Ge=Fe(Ve,'"{val}" is not a valid phone number'),Ze=Fe((1,t=>t.length>=1),"Minimum length is 1");const Qe=Fe((t=>"string"==typeof t),"Input is not a string"),Ye=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>We(...t).validate(n[e]))),e(...n)),Xe=t=>[Qe(`"${t}" must be a string`),Ze(`"${t}" must not be empty`)],tn=t=>[Qe(`"${t}" must be a string`),ze()],en=t=>[Qe(`"${t}" must be a string`),Ge()],nn=Ye(Xe("accessKey")),on=t=>({exchange:nn((e=>Je(t.post(Jt,{},{token:e}))))});var rn,sn;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(rn||(rn={})),(sn||(sn={})).email="email";const an=Object.assign(Object.assign({},rn),sn);var ln;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(ln||(ln={}));const cn=Xe("loginId"),un=Ye(Xe("token")),dn=Ye(cn),hn=Ye(Xe("pendingRef")),pn=Ye(cn,tn("email")),fn=t=>({verify:un((e=>Je(t.post(Xt,{token:e})))),signIn:dn(((e,n,o,r)=>Je(t.post(Ke(te,an.email),{loginId:e,URI:n,loginOptions:o},{token:r})))),signUpOrIn:dn(((e,n)=>Je(t.post(Ke(re,an.email),{loginId:e,URI:n})))),signUp:dn(((e,n,o)=>Je(t.post(Ke(ee,an.email),{loginId:e,URI:n,user:o})))),waitForSession:hn(((e,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||Ce,Ce)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(ne,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Je(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:pn(((e,n,o,r)=>Je(t.post(oe.email,{loginId:e,email:n,URI:o},{token:r}))))}}),gn=Ye(Xe("flowId")),vn=Ye(Xe("executionId"),Xe("stepId"),Xe("interactionId")),bn=t=>({start:gn(((e,n,o,r,i)=>Je(t.post(Ee,{flowId:e,options:n,conditionInteractionId:o,interactionId:r,input:i})))),next:vn(((e,n,o,r)=>Je(t.post(xe,{executionId:e,stepId:n,interactionId:o,input:r}))))}),wn=Xe("loginId"),mn=Ye(Xe("token")),yn=Ye(wn),kn=Ye(wn,en("phone")),In=Ye(wn,tn("email")),On=t=>({verify:mn((e=>Je(t.post(zt,{token:e})))),signIn:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:yn(((e,o,r,i)=>Je(t.post(Ke(Gt,n),{loginId:e,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:yn(((e,o,r)=>Je(t.post(Ke(Zt,n),{loginId:e,URI:o,user:r}))))})),{}),signUpOrIn:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:yn(((e,o)=>Je(t.post(Ke(Yt,n),{loginId:e,URI:o}))))})),{}),update:{email:In(((e,n,o,r)=>Je(t.post(Qt.email,{loginId:e,email:n,URI:o},{token:r})))),phone:Object.keys(rn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:kn(((e,o,r,i)=>Je(t.post(Ke(Qt.phone,n),{loginId:e,phone:o,URI:r},{token:i}))))})),{})}});var jn;!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"}(jn||(jn={}));const Sn=Ye(Xe("code")),En=t=>({start:Object.keys(jn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:o=!1}={},r,i)=>{const s=await t.post(ie,r||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i});if(!o||!s.ok)return Je(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:Sn((e=>Je(t.post(se,{code:e}))))}),xn=Xe("loginId"),Cn=Ye(xn,Xe("code")),An=Ye(xn),Un=Ye(xn,en("phone")),_n=Ye(xn,tn("email")),Pn=t=>({verify:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Cn(((e,o)=>Je(t.post(Ke(Ft,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An(((e,o,r)=>Je(t.post(Ke(Wt,n),{loginId:e,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An(((e,o)=>Je(t.post(Ke(Ht,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An((e=>Je(t.post(Ke(Vt,n),{loginId:e}))))})),{}),update:{email:_n(((e,n,o)=>Je(t.post(Bt.email,{loginId:e,email:n},{token:o})))),phone:Object.keys(rn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Un(((e,o,r)=>Je(t.post(Ke(Bt.phone,n),{loginId:e,phone:o},{token:r}))))})),{})}}),Rn=Ye(Xe("tenant")),Tn=Ye(Xe("code")),qn=t=>({start:Rn((async(e,n,{redirect:o=!1}={},r,i)=>{const s=await t.post(ae,r||{},{queryParams:{tenant:e,redirectURL:n},token:i});if(!o||!s.ok)return Je(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a})),exchange:Tn((e=>Je(t.post(le,{code:e}))))}),Mn=Xe("loginId"),$n=Ye(Mn,Xe("code")),Ln=Ye(Mn),Dn=Ye(Mn),Nn=t=>({signUp:Ln(((e,n)=>Je(t.post(ue,{loginId:e,user:n})))),verify:$n(((e,n,o,r)=>Je(t.post(ce,{loginId:e,code:n,loginOptions:o},{token:r})))),update:Dn(((e,n)=>Je(t.post(de,{loginId:e},{token:n}))))}),Kn=Xe("loginId"),Jn=Xe("newPassword"),Fn=Ye(Kn,Xe("password")),Wn=Ye(Kn),Hn=Ye(Kn,Jn),Bn=Ye(Kn,Xe("oldPassword"),Jn),Vn=t=>({signUp:Fn(((e,n,o)=>Je(t.post(ve,{loginId:e,password:n,user:o})))),signIn:Fn(((e,n)=>Je(t.post(be,{loginId:e,password:n})))),sendReset:Wn(((e,n)=>Je(t.post(we,{loginId:e,redirectUrl:n})))),update:Hn(((e,n,o)=>Je(t.post(me,{loginId:e,newPassword:n},{token:o})))),replace:Bn(((e,n,o)=>Je(t.post(ye,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>Je(t.get(ke))}),zn=[Qe('"loginId" must be a string')],Gn=Xe("loginId"),Zn=Xe("origin"),Qn=Ye(Gn,Zn,Xe("name")),Yn=Ye(Gn,Zn),Xn=Ye(zn,Zn),to=Ye(Gn,Zn,Xe("token")),eo=Ye(Xe("transactionId"),Xe("response")),no=t=>({signUp:{start:Qn(((e,n,o)=>Je(t.post(he.start,{user:{loginId:e,name:o},origin:n})))),finish:eo(((e,n)=>Je(t.post(he.finish,{transactionId:e,response:n}))))},signIn:{start:Xn(((e,n,o,r)=>Je(t.post(pe.start,{loginId:e,origin:n,loginOptions:o},{token:r})))),finish:eo(((e,n)=>Je(t.post(pe.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Yn(((e,n)=>Je(t.post(fe.start,{loginId:e,origin:n}))))},update:{start:to(((e,n,o)=>Je(t.post(ge.start,{loginId:e,origin:n},{token:o})))),finish:eo(((e,n)=>Je(t.post(ge.finish,{transactionId:e,response:n}))))}}),oo=Ye(Xe("token"));var ro,io=Ye([("projectId",ro=Xe("projectId"),Fe(((t,e)=>n=>We(...e).validate(Kt(n,t)))("projectId",ro))())])((t=>{var e,n;const o=[].concat((null===(e=t.hooks)||void 0===e?void 0:e.beforeRequest)||[]),r=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:s})=>{return a=Te({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:on(a),otp:Pn(a),magicLink:On(a),enchantedLink:fn(a),oauth:En(a),saml:qn(a),totp:Nn(a),webauthn:no(a),password:Vn(a),flow:bn(a),refresh:t=>Je(a.post(Ie,{},{token:t})),logout:t=>Je(a.post(Oe,{},{token:t})),logoutAll:t=>Je(a.post(je,{},{token:t})),me:t=>Je(a.get(Se,{token:t})),isJwtExpired:oo(Le),getJwtPermissions:oo(De),getJwtRoles:oo(Ne),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:t=>null==o?void 0:o.reduce(((t,e)=>e(t)),t),afterRequest:async(e,n)=>{(await Promise.allSettled(null==r?void 0:r.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))}))}}}))}));const so=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let r=o.shift(),i=t;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${e}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${e}" is not a function`);const s=i[r];i[r]=n(s)})),t);var ao=Object.assign(io,{DeliveryMethods:an});var lo="Blocked by CSP",co="API key required",uo="3.8.2",ho="9319";function po(t,e){var n=[];return function(t,e){var n,o,r=(o=function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}([],t,!0),{current:function(){return o[0]},postpone:function(){var t=o.shift();void 0!==t&&o.push(t)},exclude:function(){o.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=r.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return e===lo||e===ho}(t)?r.postpone():r.exclude();var e,o=r.current();if(void 0===o)throw t;return(e=i(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(t,(function(t){var o=new Date,r=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},i=e(t);return i.then(r,r),i})).then((function(t){return[t,{attempts:n}]}))}var fo="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",go="Failed to load the JS script of the agent";function vo(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,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:fo;return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error(co);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(uo):t}))}(String(t),e)}))}(l,s);return po(t,bo).catch(mo)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function bo(t){return function(t,e,n,o){var r,i=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||(r=e,l())};i.addEventListener(s,a);var l=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(l(),r)return function(){throw new Error(lo)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){var o=document.createElement("script"),r=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),e()},o.onerror=function(){r(),n(new Error(go))},o.async=!0,o.src=t,i.appendChild(o)}))}(t)})).then(wo)}function wo(){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(ho);return n}function mo(t){throw t instanceof Error&&t.message===ho?new Error(go):t}
2
- /*! js-cookie v3.0.1 | MIT */function yo(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 ko=function t(e,n){function o(t,o,r){if("undefined"!=typeof document){"number"==typeof(r=yo({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=t+"="+e.write(o,t)+i}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",yo({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,yo({},this.attributes,e))},withConverter:function(e){return t(yo({},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:"/"});const Io=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=t.hooks)||void 0===r?void 0:r[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},Oo=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||{}},jo=async t=>{const e=await Oo(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},So="undefined"!=typeof localStorage,Eo=(t,e)=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),xo=t=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Co=t=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Ao="undefined"!=typeof window,Uo=Ao&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",_o=(t="",e="")=>({vsid:t,vrid:e}),Po=(t=!1)=>{const e=localStorage.getItem("fp");if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Ro=t=>(t.body&&(t.body.fpData=Po(!0)||_o()),t),To="dls_last_user_login_id",qo="dls_last_user_display_name",Mo=()=>xo(To),$o=()=>xo(qo),Lo=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,r=Mo(),i=$o();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await t(...e)},Do=t=>async(...e)=>{const n=await t(...e);return Co(To),Co(qo),n};function No(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Ko="DS",Jo="DSR",Fo=(t={},n)=>{var{refreshJwt:o,sessionJwt:r}=t,i=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&Eo(Jo,o),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(e){const i=new Date(1e3*r);ko.set(t,e,{path:n,domain:o,expires:i,sameSite:"Strict",secure:!0})}}(Ko,r,i):Eo(Ko,r))};function Wo(){return xo(Jo)||""}function Ho(){return ko.get(Ko)||xo(Ko)||""}function Bo(){Co(Jo),Co(Ko),ko.remove(Ko)}const Vo=t=>Object.assign(t,{token:t.token||Wo()}),zo=t=>async(...e)=>{const n=await t(...e);return Bo(),n};async function Go(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=er(n.publicKey.challenge),n.publicKey.user.id=er(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=er(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:nr(n.rawId),type:n.type,response:{attestationObject:nr(n.response.attestationObject),clientDataJSON:nr(n.response.clientDataJSON)}});var n}async function Zo(t){const e=Xo(t);return tr(await navigator.credentials.get(e))}async function Qo(t,e){const n=Xo(t);return n.signal=e.signal,n.mediation="conditional",tr(await navigator.credentials.get(n))}async function Yo(t=!1){if(!Ao)return Promise.resolve(!1);const e=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Xo(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=er(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=er(t.id)})),n}function tr(t){return JSON.stringify({id:t.id,rawId:nr(t.rawId),type:t.type,response:{authenticatorData:nr(t.response.authenticatorData),clientDataJSON:nr(t.response.clientDataJSON),signature:nr(t.response.signature),userHandle:t.response.userHandle?nr(t.response.userHandle):void 0}})}function er(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function nr(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var or,rr=(or=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const r=await Go(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await Zo(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await Go(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Zo(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const r=await Go(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Go,get:Zo,isSupported:Yo,conditional:Qo}}),(...t)=>{const e=or(...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}),ir=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await Yo(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const sr=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:r}=n,i=e(n,["fpKey","fpLoad"]);return o?(Ao?r&&(async t=>{try{if(Po())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=vo({apiKey:t,endpoint:Uo}),o=await n,{requestId:r}=await o.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(_o(e,r))}catch(t){global.FB_DEBUG&&console.error(t)}})(o).catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(Io(i,{beforeRequest:Ro}))):t(Object.assign({},i))}),(t=>n=>{var{autoRefresh:o}=n,r=e(n,["autoRefresh"]);if(!o)return t(r);const{clearAllTimers:i,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})(),a=t(Io(r,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await Oo(e);if(401===(null==e?void 0:e.status))i();else if(o){const t=((r=(t=>{const e=t.split(".");try{if(3===e.length){const t=JSON.parse(window.atob(e[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(t){}return null})(o))?r.getTime()-(new Date).getTime():0)-2e4;i(),s((()=>a.refresh(n)),t)}var r}}));return so(a,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return i(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.0.16"},e.baseHeaders)}))),(t=>e=>{const n=No(),o=No(),r=t(Io(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await jo(e);t&&o.pub(t);const{sessionJwt:r}=await Oo(e);r&&n.pub(r)}}})),i=so(r,["logout","logoutAll"],(t=>async(...e)=>{const r=await t(...e);return n.pub(null),o.pub(null),r}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>e=>{const n=t(Io(e,{afterRequest:async(t,e)=>{var n;const o=await jo(e),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((t=>{Eo(To,t)})(r),(t=>{Eo(qo,t)})(i))}}));let o=so(n,["flow.start"],Lo);return o=so(o,["logout","logoutAll"],Do),Object.assign(o,{getLastUserLoginId:Mo,getLastUserDisplayName:$o})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:r}=n,i=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!Ao)return o&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),t(i);const s=t(Io(i,{beforeRequest:Vo,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?Bo():Fo(await Oo(e),r)}})),a=so(s,["logout","logoutAll"],zo);return Object.assign(a,{getRefreshToken:Wo,getSessionToken:Ho})}))(((...t)=>{const e=ao(...t);return Object.assign(Object.assign({},e),{flow:ir(e),webauthn:rr(e)})})),ar=document.createElement("template");var lr,cr,ur,dr,hr,pr,fr,gr,vr,br,wr,mr,yr,kr,Ir,Or,jr,Sr,Er,xr,Cr,Ar,Ur,_r,Pr,Rr,Tr,qr,Mr,$r,Lr,Dr,Nr,Kr,Jr,Fr,Wr,Hr;ar.innerHTML='\n\t<style>\n\t\t:host {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<div id="wc-root"></div>\n\t';class Br extends HTMLElement{constructor(t){super(),lr.add(this),cr.set(this,!1),ur.set(this,new K),dr.set(this,new K),this.nextRequestStatus=new K({isLoading:!1}),hr.set(this,void 0),pr.set(this,{popstate:o(this,lr,"m",mr).bind(this)}),fr.set(this,void 0),Ir.set(this,T((()=>n(this,void 0,void 0,(function*(){const t=C(this.projectId,"config.json");try{const{body:e,headers:n}=yield E(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){this.logger.error("Cannot get config file","make sure that your projectId & flowId are correct")}return{}}))))),this.logger={error:(t,e="")=>{console.error(t,e,new Error),o(this,lr,"m",Ar).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},r(this,fr,t,"f"),o(this,lr,"m",gr).call(this)}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"]}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get baseUrl(){return this.getAttribute("base-url")||void 0}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 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 telemetryKey(){return this.getAttribute("telemetryKey")||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}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,Ir,"f").call(this);return t}))}getFlowConfig(){var t;return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,Ir,"f").call(this);return(null===(t=null==e?void 0:e.flows)||void 0===t?void 0:t[this.flowId])||{}}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,lr,"m",vr).call(this))return void o(this,lr,"m",br).call(this);o(this,lr,"m",wr).call(this),o(this,lr,"m",jr).call(this),o(this,lr,"m",Or).call(this),o(this,lr,"m",Ur).call(this);const{executionId:t,stepId:e,token:n,code:i,exchangeError:s}=R();window.addEventListener("popstate",o(this,pr,"f").popstate),o(this,ur,"f").subscribe(o(this,lr,"m",kr).bind(this)),o(this,dr,"f").subscribe(o(this,lr,"m",Cr).bind(this)),o(this,ur,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:e,executionId:t,token:n,code:i,exchangeError:s,telemetryKey:this.telemetryKey}),o(this,dr,"f").update({isDebug:this.debug}),r(this,cr,!0,"f")}}))}disconnectedCallback(){o(this,ur,"f").unsubscribeAll(),o(this,dr,"f").unsubscribeAll(),o(this,lr,"m",xr).call(this),window.removeEventListener("popstate",o(this,pr,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,cr,"f")&&e!==n&&Br.observedAttributes.includes(t)){o(this,lr,"m",wr).call(this);const r=null===e;o(this,ur,"f").update((({stepId:e,executionId:o})=>{let i=e,s=o;return r||(s=null,i=null,_()),{[P(t)]:n,stepId:i,executionId:s}})),o(this,dr,"f").update({isDebug:this.debug})}}}cr=new WeakMap,ur=new WeakMap,dr=new WeakMap,hr=new WeakMap,pr=new WeakMap,fr=new WeakMap,Ir=new WeakMap,lr=new WeakSet,gr=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ar.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},vr=function(){const t=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);return!this.shadowRoot.host.closest("form")&&t},br=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},wr=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"];if(Br.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[P(e)])throw Error(`${e} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},mr=function(){const{stepId:t,executionId:e}=U();o(this,ur,"f").update({stepId:t,executionId:e})},yr=function(t,e,o){const r=o||void 0,i=!!r;this.sdk=sr(Object.assign(Object.assign({persistTokens:!0},Br.sdkConfigOverrides),{projectId:t,baseUrl:e,fpKey:r,fpLoad:i})),["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)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},kr=function(t,e,r){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n,telemetryKey:i}=t;if(r("projectId")||r("baseUrl")||r("telemetryKey")){if(!e)return;o(this,lr,"m",yr).call(this,e,n,i)}o(this,fr,"f").call(this,t)}))},Or=function(){var t,e,r,i;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,Ir,"f").call(this);null===(i=null===(r=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t[this.theme])||void 0===e?void 0:e.typography)||void 0===r?void 0:r.fontFamilies)||void 0===i||i.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},jr=function(){o(this,lr,"m",Sr).call(this),o(this,lr,"m",Er).call(this)},Sr=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=C(this.projectId,"theme.css");try{const{body:n}=yield E(e,"text");t.innerText=n}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},Er=function(){this.rootElement.setAttribute("data-theme",this.theme)},xr=function(){var t;null===(t=o(this,hr,"f"))||void 0===t||t.remove(),r(this,hr,null,"f")},Cr=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield import("./debugger-wc-32821102.js"),r(this,hr,document.createElement("descope-debugger"),"f"),Object.assign(o(this,hr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,hr,"f"))):o(this,lr,"m",xr).call(this)}))},Ar=function(t,e){var n;t&&this.debug&&(null===(n=o(this,hr,"f"))||void 0===n||n.updateData({title:t,description:e}))},Ur=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("button");if(1===e.length)return void e[0].click();const n=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));1===n.length&&n[0].click()}},Br.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.0.23"}};class Vr extends Br{constructor(){const t=new K;super(t.update.bind(t)),_r.add(this),this.stepState=new K({},{updateOnlyOnChange:!1}),Pr.set(this,void 0),Rr.set(this,null),Tr.set(this,(()=>{clearInterval(o(this,Pr,"f")),r(this,Pr,null,"f")})),qr.set(this,(t=>{var e,n,r,s,a,l,c,u,d;if(!(null==t?void 0:t.ok)){o(this,Tr,"f").call(this),o(this,_r,"m",Hr).call(this,"error",null==t?void 0:t.error);const i=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.statusText}`;return void this.logger.error((null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorDescription)||i,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const p=null===(u=null===(c=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===u?void 0:u.errorText;p&&this.logger.error(p),(null===(d=t.data)||void 0===d?void 0:d.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:f,authInfo:v,lastAuth:b}=t.data;if("completed"===f)return function(t){(null==t?void 0:t.authMethod)&&i&&localStorage.setItem(h,JSON.stringify(t))}(b),o(this,Tr,"f").call(this),void o(this,_r,"m",Hr).call(this,"success",v);const{executionId:w,stepId:m,action:y,screen:k,redirect:I,webauthn:O}=t.data;y!==g?this.flowState.update({stepId:m,executionId:w,action:y,redirectTo:null==I?void 0:I.url,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options}):this.flowState.update({action:y})})),Mr.set(this,T((()=>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.logger.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.logger.error("Webauthn start failed",t.message)}}))))),this.flowState=t}static set sdkConfigOverrides(t){Br.sdkConfigOverrides=t}connectedCallback(){const t=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var e,o;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield t.connectedCallback.call(this)}))}disconnectedCallback(){super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll()}onFlowChange(t,e,i){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:l,flowId:c,tenant:u,stepId:d,executionId:p,action:w,screenId:k,screenState:I,redirectTo:O,redirectUrl:j,token:S,code:E,exchangeError:x,webauthnTransactionId:U,webauthnOptions:_}=t;let P,R;o(this,Pr,"f")&&o(this,Tr,"f").call(this);const T=this.sdk.getLastUserLoginId();if(!p){if(!c)return;const t=yield this.getFlowConfig();if(({startScreenId:P=t.startScreenId,conditionInteractionId:R}=((t,e)=>{var n;const o=null===(n=W[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const r=o(e)?t.met:t.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})(t.condition,{loginId:T,code:E})),!P){const t=E?{exchangeCode:E,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(c,Object.assign({tenant:u},j&&{redirectUrl:j}),R,"",t);return o(this,qr,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0}))}}if(p&&(i("token")&&S||i("code")&&E||i("exchangeError")&&x)){const t=yield this.sdk.flow.next(p,d,m,{token:S,exchangeCode:E,exchangeError:x});return o(this,qr,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(w===f)return O||this.logger.error("Did not get redirect url"),void window.location.assign(O);if(w===v||w===b){if(!U||!_)return void this.logger.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,Rr,"f"))||void 0===a||a.abort(),r(this,Rr,null,"f");try{t=w===v?yield this.sdk.webauthn.helpers.create(_):yield this.sdk.webauthn.helpers.get(_)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const n=yield this.sdk.flow.next(p,d,m,{transactionId:U,response:t,cancelWebauthn:e});o(this,qr,"f").call(this,n)}if(w===g&&r(this,Pr,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,d,y,{});o(this,qr,"f").call(this,t)}))),2e3),"f"),!k&&!P)return void this.logger.info("Refreshing the page during a flow is not supported yet");const q={direction:A(+d,+e.stepId),screenState:Object.assign(Object.assign({},I),{lastAuth:{loginId:T,name:this.sdk.getLastUserDisplayName()||T}}),htmlUrl:C(l,`${P||k}.html`)},M=function(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(h)))}catch(t){}return e}(T);P?q.next=(t,e)=>this.sdk.flow.start(c,Object.assign({tenant:u,lastAuth:M},j&&{redirectUrl:j}),R,t,Object.assign(Object.assign({},e),E&&{exchangeCode:E,idpInitiated:!0})):(i("projectId")||i("baseUrl")||i("executionId")||i("stepId"))&&(q.next=(...t)=>this.sdk.flow.next(p,d,...t)),this.stepState.update(q)}))}onStepChange(t,e){var r;return n(this,void 0,void 0,(function*(){const{htmlUrl:i,direction:s,next:a,screenState:l}=t,c=document.createElement("template"),{body:u}=yield E(i,"text");c.innerHTML=u;const d=c.content.cloneNode(!0),h=((t,e)=>{var n;const o=Array.from(t.querySelectorAll("script[data-id]")).map((n=>{var o;const r=n.getAttribute("data-id"),i=null===(o=t.getElementById(r))||void 0===o?void 0:o.innerHTML,s=Function(i).bind(n.previousSibling,e);return n.remove(),s}));return null===(n=t.querySelector("scripts"))||void 0===n||n.remove(),o})(d,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield o(this,_r,"m",Lr).call(this,d,a):d.querySelectorAll(`button[${p}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),J(d,l),((t,e)=>{var n;e&&(null===(n=null==t?void 0:t.style)||void 0===n||n.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(d.querySelector("div"),null===(r=null==l?void 0:l.totp)||void 0===r?void 0:r.image);const f=()=>n(this,void 0,void 0,(function*(){try{h.forEach((t=>{t()}))}catch(t){this.logger.error(t.message)}this.rootElement.replaceChildren(d);const t=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector('input:not([aria-hidden="true"])');null==e||e.focus()}})(this.rootElement,this.autoFocus,t),o(this,_r,"m",Fr).call(this,a),o(this,_r,"m",Hr).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${p}="polling"]`)){const t=yield a(y,{});o(this,qr,"f").call(this,t)}}));s?o(this,_r,"m",Wr).call(this,f,s):f()}))}}Pr=new WeakMap,Rr=new WeakMap,Tr=new WeakMap,qr=new WeakMap,Mr=new WeakMap,_r=new WeakSet,$r=function(t){const e=t.name;if(!["email"].includes(e)){const n=`user-${e}`;t.name=n,t.addEventListener("input",(()=>{t.name=t.value?e:n}))}},Lr=function(t,e){var i;return n(this,void 0,void 0,(function*(){null===(i=o(this,Rr,"f"))||void 0===i||i.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield F())){const{options:t,transactionId:i}=(yield o(this,Mr,"f").call(this))||{};t&&i&&(o(this,_r,"m",$r).call(this,s),r(this,Rr,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,Rr,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:i,response:t});o(this,qr,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Dr=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Nr=function(){return Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${d}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e.value}):t),{})},Kr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{var o,r;n?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(r=null==t?void 0:t.classList)||void 0===r||r.remove("loading"))}))},Jr=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,_r,"m",Dr).call(this)){const r=null==t?void 0:t.getAttribute("id");o(this,_r,"m",Kr).call(this,t);const i=o(this,_r,"m",Nr).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=Object.assign(Object.assign(Object.assign({},s),i),{origin:window.location.origin}),l=yield e(r,a);o(this,qr,"f").call(this,l)}var n}))},Fr=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,_r,"m",Jr).call(this,e,t)}}))},Wr=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===k.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")},Hr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",Vr);export{Vr as D,K as S,o as _,r as a};
1
+ var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(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 r(t,e,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(t,n):r?r.value=n:e.set(t,n),n}const i="undefined"!=typeof localStorage,s=i&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",a="descope-login-flow",l="t",c="code",u="err",d="data-exclude-field",h="dls_last_auth",p="data-type",f="redirect",g="poll",v="webauthnCreate",b="webauthnGet",w="v2-alpha",m="submit",y="polling";var k,I,O;function j(t){return new URLSearchParams(window.location.search).get(t)}function S(t){if(window.history.replaceState&&j(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 E(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}`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(k||(k={}));const x=(...t)=>t.join("/").replace(/\/+/g,"/");function C(t,e){const n=new URL(s);return n.pathname=x(n.pathname,t,w,e),n.toString()}function A(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?k.forward:t<e?k.backward:void 0}const U=()=>{const[t="",e=""]=(j(a)||"").split("_");return{executionId:t,stepId:e}};function _(){S(a)}const P=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),R=()=>{const{executionId:t,stepId:e}=U();(t||e)&&_();const n=j(l)||void 0;n&&S(l);const o=j(c)||void 0;o&&S(c);const r=j(u)||void 0;return r&&S(u),{executionId:t,stepId:e,token:n,code:o,exchangeError:r}},T=t=>{let e,n;return(...o)=>{return e&&(i=o,(r=e).length===i.length&&r.every(((t,e)=>t===i[e])))||(e=o,n=t(...o)),n;var r,i}},q=null===(O=null===(I=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===I?void 0:I.brands)||void 0===O?void 0:O.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));var M,$,L,D;function N(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 r=n[o],i=t[r],s=e[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!N(i,s))return!1}else if(i!==s)return!1}return!0}class K{constructor(t={},{updateOnlyOnChange:e=!0}={}){M.set(this,void 0),$.set(this,{}),L.set(this,0),D.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,M,"f")):t,n=Object.assign(Object.assign({},o(this,M,"f")),e);if(!o(this,D,"f")||!N(o(this,M,"f"),n)){const t=o(this,M,"f");r(this,M,n,"f"),Object.freeze(o(this,M,"f")),setTimeout((()=>{Object.values(o(this,$,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},r(this,M,t,"f"),r(this,D,e,"f")}get current(){return Object.assign({},o(this,M,"f"))}subscribe(t){return r(this,L,o(this,L,"f")+1,"f"),o(this,$,"f")[o(this,L,"f")]=t,o(this,L,"f").toString()}unsubscribe(t){const e=!!o(this,$,"f")[t];return e&&delete o(this,$,"f")[t],e}unsubscribeAll(){return r(this,$,{},"f"),!0}}M=new WeakMap,$=new WeakMap,L=new WeakMap,D=new WeakMap;const J=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[${p}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${d}])`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(`[${p}="totp-link"]`).forEach((t=>{t.href=e}))})(t,null===(n=null==e?void 0:e.totp)||void 0===n?void 0:n.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},F=T((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return console.warn("webauthn","Conditional UI is not supported"),!1;try{const r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),i=108;return yield Promise.race([r,(n=100,new Promise(((t,e)=>{const r=setTimeout((()=>{e(new Error(`Promise timed out after ${n} ms`))}),n);null==o||o((e=>{clearTimeout(r),t(e)}),(t=>{clearTimeout(r),e(t)}))}))).catch((()=>q()>=i))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),W={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function H(t){this.message=t}H.prototype=new Error,H.prototype.name="InvalidCharacterError";var B="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new H("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,r=0,i=0,s="";o=e.charAt(i++);~o&&(n=r%4?64*n+o:o,r++%4)?s+=String.fromCharCode(255&n>>(-2*r&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function V(t){this.message=t}function z(t,e){if("string"!=typeof t)throw new V("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(B(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return B(e)}}(t.split(".")[n]))}catch(t){throw new V("Invalid token specified: "+t.message)}}V.prototype=new Error,V.prototype.name="InvalidTokenError";var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Z="Expected a function",Q="__lodash_hash_undefined__",Y=1/0,X="[object Function]",tt="[object GeneratorFunction]",et="[object Symbol]",nt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ot=/^\w*$/,rt=/^\./,it=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,st=/\\(\\)?/g,at=/^\[object .+?Constructor\]$/,lt="object"==typeof G&&G&&G.Object===Object&&G,ct="object"==typeof self&&self&&self.Object===Object&&self,ut=lt||ct||Function("return this")();var dt,ht=Array.prototype,pt=Function.prototype,ft=Object.prototype,gt=ut["__core-js_shared__"],vt=(dt=/[^.]+$/.exec(gt&&gt.keys&&gt.keys.IE_PROTO||""))?"Symbol(src)_1."+dt:"",bt=pt.toString,wt=ft.hasOwnProperty,mt=ft.toString,yt=RegExp("^"+bt.call(wt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),kt=ut.Symbol,It=ht.splice,Ot=Tt(ut,"Map"),jt=Tt(Object,"create"),St=kt?kt.prototype:void 0,Et=St?St.toString:void 0;function xt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Ct(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function At(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Ut(t,e){for(var n,o,r=t.length;r--;)if((n=t[r][0])===(o=e)||n!=n&&o!=o)return r;return-1}function _t(t,e){var n;e=function(t,e){if(Lt(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Nt(t))return!0;return ot.test(t)||!nt.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Lt(n=e)?n:qt(n);for(var o=0,r=e.length;null!=t&&o<r;)t=t[Mt(e[o++])];return o&&o==r?t:void 0}function Pt(t){if(!Dt(t)||(e=t,vt&&vt in e))return!1;var e,n=function(t){var e=Dt(t)?mt.call(t):"";return e==X||e==tt}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?yt:at;return n.test(function(t){if(null!=t){try{return bt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Rt(t,e){var n,o,r=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof e?"string":"hash"]:r.map}function Tt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Pt(n)?n:void 0}xt.prototype.clear=function(){this.__data__=jt?jt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(jt){var n=e[t];return n===Q?void 0:n}return wt.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return jt?void 0!==e[t]:wt.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=jt&&void 0===e?Q:e,this},Ct.prototype.clear=function(){this.__data__=[]},Ct.prototype.delete=function(t){var e=this.__data__,n=Ut(e,t);return!(n<0)&&(n==e.length-1?e.pop():It.call(e,n,1),!0)},Ct.prototype.get=function(t){var e=this.__data__,n=Ut(e,t);return n<0?void 0:e[n][1]},Ct.prototype.has=function(t){return Ut(this.__data__,t)>-1},Ct.prototype.set=function(t,e){var n=this.__data__,o=Ut(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},At.prototype.clear=function(){this.__data__={hash:new xt,map:new(Ot||Ct),string:new xt}},At.prototype.delete=function(t){return Rt(this,t).delete(t)},At.prototype.get=function(t){return Rt(this,t).get(t)},At.prototype.has=function(t){return Rt(this,t).has(t)},At.prototype.set=function(t,e){return Rt(this,t).set(t,e),this};var qt=$t((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Nt(t))return Et?Et.call(t):"";var e=t+"";return"0"==e&&1/t==-Y?"-0":e}(e);var n=[];return rt.test(t)&&n.push(""),t.replace(it,(function(t,e,o,r){n.push(o?r.replace(st,"$1"):e||t)})),n}));function Mt(t){if("string"==typeof t||Nt(t))return t;var e=t+"";return"0"==e&&1/t==-Y?"-0":e}function $t(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(Z);var n=function(){var o=arguments,r=e?e.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var s=t.apply(this,o);return n.cache=i.set(r,s),s};return n.cache=new($t.Cache||At),n}$t.Cache=At;var Lt=Array.isArray;function Dt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Nt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&mt.call(t)==et}var Kt=function(t,e,n){var o=null==t?void 0:_t(t,e);return void 0===o?n:o},Jt="/v1/auth/accesskey/exchange",Ft="/v1/auth/otp/verify",Wt="/v1/auth/otp/signin",Ht="/v1/auth/otp/signup",Bt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Vt="/v1/auth/otp/signup-in",zt="/v1/auth/magiclink/verify",Gt="/v1/auth/magiclink/signin",Zt="/v1/auth/magiclink/signup",Qt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},Yt="/v1/auth/magiclink/signup-in",Xt="/v1/auth/enchantedlink/verify",te="/v1/auth/enchantedlink/signin",ee="/v1/auth/enchantedlink/signup",ne="/v1/auth/enchantedlink/pending-session",oe={email:"/v1/auth/enchantedlink/update/email"},re="/v1/auth/enchantedlink/signup-in",ie="/v1/auth/oauth/authorize",se="/v1/auth/oauth/exchange",ae="/v1/auth/saml/authorize",le="/v1/auth/saml/exchange",ce="/v1/auth/totp/verify",ue="/v1/auth/totp/signup",de="/v1/auth/totp/update",he={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},pe={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},fe={start:"/v1/auth/webauthn/signup-in/start"},ge={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},ve="/v1/auth/password/signup",be="/v1/auth/password/signin",we="/v1/auth/password/reset",me="/v1/auth/password/update",ye="/v1/auth/password/replace",ke="/v1/auth/password/policy",Ie="/v1/auth/refresh",Oe="/v1/auth/logout",je="/v1/auth/logoutall",Se="/v1/auth/me",Ee="/v1/flow/start",xe="/v1/flow/next";const Ce=6e5,Ae=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};var Ue;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Ue||(Ue={}));const _e=(...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}),{})),Pe=t=>void 0===t?void 0:JSON.stringify(t),Re=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Te=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,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=>Ae().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 Ae().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=>{const s=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:l,body:c,headers:u,queryParams:d,method:h,token:p}=s,f=await a((({path:t,baseUrl:e,queryParams:n})=>{const o=new URL(t,e);return n&&(o.search=new URLSearchParams(n).toString()),o})({path:l,baseUrl:t,queryParams:d}),{headers:_e(Re(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.0.17"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:Pe(c),credentials:i||"include"});return(null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Ue.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.post,token:r}),put:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.put,token:r}),delete:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.delete,token:r}),hooks:r}};var qe={TOO_MANY_REQUESTS:429};function Me(t,e,n){var o;let r=$e(t);e&&(r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[e]);const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function $e(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return z(t)}function Le(t){const{exp:e}=$e(t);return(new Date).getTime()/1e3>e}function De(t,e){return Me(t,e,"permissions")}function Ne(t,e){return Me(t,e,"roles")}const Ke=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Je(t,e){var n;const o=await t,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=e?e(i):i:(r.error=i,o.status===qe.TOO_MANY_REQUESTS&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const Fe=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),We=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),He=t=>e=>t.test(e),Be=He(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ve=He(/^\+[1-9]{1}[0-9]{3,14}$/),ze=Fe(Be,'"{val}" is not a valid email'),Ge=Fe(Ve,'"{val}" is not a valid phone number'),Ze=Fe((1,t=>t.length>=1),"Minimum length is 1");const Qe=Fe((t=>"string"==typeof t),"Input is not a string"),Ye=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>We(...t).validate(n[e]))),e(...n)),Xe=t=>[Qe(`"${t}" must be a string`),Ze(`"${t}" must not be empty`)],tn=t=>[Qe(`"${t}" must be a string`),ze()],en=t=>[Qe(`"${t}" must be a string`),Ge()],nn=Ye(Xe("accessKey")),on=t=>({exchange:nn((e=>Je(t.post(Jt,{},{token:e}))))});var rn,sn;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(rn||(rn={})),(sn||(sn={})).email="email";const an=Object.assign(Object.assign({},rn),sn);var ln;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(ln||(ln={}));const cn=Xe("loginId"),un=Ye(Xe("token")),dn=Ye(cn),hn=Ye(Xe("pendingRef")),pn=Ye(cn,tn("email")),fn=t=>({verify:un((e=>Je(t.post(Xt,{token:e})))),signIn:dn(((e,n,o,r)=>Je(t.post(Ke(te,an.email),{loginId:e,URI:n,loginOptions:o},{token:r})))),signUpOrIn:dn(((e,n)=>Je(t.post(Ke(re,an.email),{loginId:e,URI:n})))),signUp:dn(((e,n,o)=>Je(t.post(Ke(ee,an.email),{loginId:e,URI:n,user:o})))),waitForSession:hn(((e,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||Ce,Ce)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(ne,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Je(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:pn(((e,n,o,r)=>Je(t.post(oe.email,{loginId:e,email:n,URI:o},{token:r}))))}}),gn=Ye(Xe("flowId")),vn=Ye(Xe("executionId"),Xe("stepId"),Xe("interactionId")),bn=t=>({start:gn(((e,n,o,r,i)=>Je(t.post(Ee,{flowId:e,options:n,conditionInteractionId:o,interactionId:r,input:i})))),next:vn(((e,n,o,r)=>Je(t.post(xe,{executionId:e,stepId:n,interactionId:o,input:r}))))}),wn=Xe("loginId"),mn=Ye(Xe("token")),yn=Ye(wn),kn=Ye(wn,en("phone")),In=Ye(wn,tn("email")),On=t=>({verify:mn((e=>Je(t.post(zt,{token:e})))),signIn:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:yn(((e,o,r,i)=>Je(t.post(Ke(Gt,n),{loginId:e,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:yn(((e,o,r)=>Je(t.post(Ke(Zt,n),{loginId:e,URI:o,user:r}))))})),{}),signUpOrIn:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:yn(((e,o)=>Je(t.post(Ke(Yt,n),{loginId:e,URI:o}))))})),{}),update:{email:In(((e,n,o,r)=>Je(t.post(Qt.email,{loginId:e,email:n,URI:o},{token:r})))),phone:Object.keys(rn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:kn(((e,o,r,i)=>Je(t.post(Ke(Qt.phone,n),{loginId:e,phone:o,URI:r},{token:i}))))})),{})}});var jn;!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"}(jn||(jn={}));const Sn=Ye(Xe("code")),En=t=>({start:Object.keys(jn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:o=!1}={},r,i)=>{const s=await t.post(ie,r||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i});if(!o||!s.ok)return Je(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:Sn((e=>Je(t.post(se,{code:e}))))}),xn=Xe("loginId"),Cn=Ye(xn,Xe("code")),An=Ye(xn),Un=Ye(xn,en("phone")),_n=Ye(xn,tn("email")),Pn=t=>({verify:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Cn(((e,o)=>Je(t.post(Ke(Ft,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An(((e,o,r)=>Je(t.post(Ke(Wt,n),{loginId:e,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An(((e,o)=>Je(t.post(Ke(Ht,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An((e=>Je(t.post(Ke(Vt,n),{loginId:e}))))})),{}),update:{email:_n(((e,n,o)=>Je(t.post(Bt.email,{loginId:e,email:n},{token:o})))),phone:Object.keys(rn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Un(((e,o,r)=>Je(t.post(Ke(Bt.phone,n),{loginId:e,phone:o},{token:r}))))})),{})}}),Rn=Ye(Xe("tenant")),Tn=Ye(Xe("code")),qn=t=>({start:Rn(((e,n,o,r)=>Je(t.post(ae,o||{},{queryParams:{tenant:e,redirectURL:n},token:r})))),exchange:Tn((e=>Je(t.post(le,{code:e}))))}),Mn=Xe("loginId"),$n=Ye(Mn,Xe("code")),Ln=Ye(Mn),Dn=Ye(Mn),Nn=t=>({signUp:Ln(((e,n)=>Je(t.post(ue,{loginId:e,user:n})))),verify:$n(((e,n,o,r)=>Je(t.post(ce,{loginId:e,code:n,loginOptions:o},{token:r})))),update:Dn(((e,n)=>Je(t.post(de,{loginId:e},{token:n}))))}),Kn=Xe("loginId"),Jn=Xe("newPassword"),Fn=Ye(Kn,Xe("password")),Wn=Ye(Kn),Hn=Ye(Kn,Jn),Bn=Ye(Kn,Xe("oldPassword"),Jn),Vn=t=>({signUp:Fn(((e,n,o)=>Je(t.post(ve,{loginId:e,password:n,user:o})))),signIn:Fn(((e,n)=>Je(t.post(be,{loginId:e,password:n})))),sendReset:Wn(((e,n)=>Je(t.post(we,{loginId:e,redirectUrl:n})))),update:Hn(((e,n,o)=>Je(t.post(me,{loginId:e,newPassword:n},{token:o})))),replace:Bn(((e,n,o)=>Je(t.post(ye,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>Je(t.get(ke))}),zn=[Qe('"loginId" must be a string')],Gn=Xe("loginId"),Zn=Xe("origin"),Qn=Ye(Gn,Zn,Xe("name")),Yn=Ye(Gn,Zn),Xn=Ye(zn,Zn),to=Ye(Gn,Zn,Xe("token")),eo=Ye(Xe("transactionId"),Xe("response")),no=t=>({signUp:{start:Qn(((e,n,o)=>Je(t.post(he.start,{user:{loginId:e,name:o},origin:n})))),finish:eo(((e,n)=>Je(t.post(he.finish,{transactionId:e,response:n}))))},signIn:{start:Xn(((e,n,o,r)=>Je(t.post(pe.start,{loginId:e,origin:n,loginOptions:o},{token:r})))),finish:eo(((e,n)=>Je(t.post(pe.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Yn(((e,n)=>Je(t.post(fe.start,{loginId:e,origin:n}))))},update:{start:to(((e,n,o)=>Je(t.post(ge.start,{loginId:e,origin:n},{token:o})))),finish:eo(((e,n)=>Je(t.post(ge.finish,{transactionId:e,response:n}))))}}),oo=Ye(Xe("token"));var ro,io=Ye([("projectId",ro=Xe("projectId"),Fe(((t,e)=>n=>We(...e).validate(Kt(n,t)))("projectId",ro))())])((t=>{var e,n;const o=[].concat((null===(e=t.hooks)||void 0===e?void 0:e.beforeRequest)||[]),r=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:s})=>{return a=Te({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:on(a),otp:Pn(a),magicLink:On(a),enchantedLink:fn(a),oauth:En(a),saml:qn(a),totp:Nn(a),webauthn:no(a),password:Vn(a),flow:bn(a),refresh:t=>Je(a.post(Ie,{},{token:t})),logout:t=>Je(a.post(Oe,{},{token:t})),logoutAll:t=>Je(a.post(je,{},{token:t})),me:t=>Je(a.get(Se,{token:t})),isJwtExpired:oo(Le),getJwtPermissions:oo(De),getJwtRoles:oo(Ne),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:t=>null==o?void 0:o.reduce(((t,e)=>e(t)),t),afterRequest:async(e,n)=>{(await Promise.allSettled(null==r?void 0:r.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))}))}}}))}));const so=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let r=o.shift(),i=t;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${e}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${e}" is not a function`);const s=i[r];i[r]=n(s)})),t);var ao=Object.assign(io,{DeliveryMethods:an});var lo="Blocked by CSP",co="API key required",uo="3.8.2",ho="9319";function po(t,e){var n=[];return function(t,e){var n,o,r=(o=function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}([],t,!0),{current:function(){return o[0]},postpone:function(){var t=o.shift();void 0!==t&&o.push(t)},exclude:function(){o.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=r.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return e===lo||e===ho}(t)?r.postpone():r.exclude();var e,o=r.current();if(void 0===o)throw t;return(e=i(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(t,(function(t){var o=new Date,r=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},i=e(t);return i.then(r,r),i})).then((function(t){return[t,{attempts:n}]}))}var fo="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",go="Failed to load the JS script of the agent";function vo(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,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:fo;return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error(co);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(uo):t}))}(String(t),e)}))}(l,s);return po(t,bo).catch(mo)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function bo(t){return function(t,e,n,o){var r,i=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||(r=e,l())};i.addEventListener(s,a);var l=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(l(),r)return function(){throw new Error(lo)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){var o=document.createElement("script"),r=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),e()},o.onerror=function(){r(),n(new Error(go))},o.async=!0,o.src=t,i.appendChild(o)}))}(t)})).then(wo)}function wo(){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(ho);return n}function mo(t){throw t instanceof Error&&t.message===ho?new Error(go):t}
2
+ /*! js-cookie v3.0.1 | MIT */function yo(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 ko=function t(e,n){function o(t,o,r){if("undefined"!=typeof document){"number"==typeof(r=yo({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=t+"="+e.write(o,t)+i}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",yo({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,yo({},this.attributes,e))},withConverter:function(e){return t(yo({},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:"/"});const Io=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=t.hooks)||void 0===r?void 0:r[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},Oo=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||{}},jo=async t=>{const e=await Oo(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},So="undefined"!=typeof localStorage,Eo=(t,e)=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),xo=t=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Co=t=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Ao="undefined"!=typeof window,Uo=Ao&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",_o=(t="",e="")=>({vsid:t,vrid:e}),Po=(t=!1)=>{const e=localStorage.getItem("fp");if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Ro=t=>(t.body&&(t.body.fpData=Po(!0)||_o()),t),To="dls_last_user_login_id",qo="dls_last_user_display_name",Mo=()=>xo(To),$o=()=>xo(qo),Lo=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,r=Mo(),i=$o();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await t(...e)},Do=t=>async(...e)=>{const n=await t(...e);return Co(To),Co(qo),n};function No(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Ko="DS",Jo="DSR",Fo=(t={},n)=>{var{refreshJwt:o,sessionJwt:r}=t,i=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&Eo(Jo,o),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(e){const i=new Date(1e3*r);ko.set(t,e,{path:n,domain:o,expires:i,sameSite:"Strict",secure:!0})}}(Ko,r,i):Eo(Ko,r))};function Wo(){return xo(Jo)||""}function Ho(){return ko.get(Ko)||xo(Ko)||""}function Bo(){Co(Jo),Co(Ko),ko.remove(Ko)}const Vo=t=>Object.assign(t,{token:t.token||Wo()}),zo=t=>async(...e)=>{const n=await t(...e);return Bo(),n};async function Go(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=er(n.publicKey.challenge),n.publicKey.user.id=er(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=er(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:nr(n.rawId),type:n.type,response:{attestationObject:nr(n.response.attestationObject),clientDataJSON:nr(n.response.clientDataJSON)}});var n}async function Zo(t){const e=Xo(t);return tr(await navigator.credentials.get(e))}async function Qo(t,e){const n=Xo(t);return n.signal=e.signal,n.mediation="conditional",tr(await navigator.credentials.get(n))}async function Yo(t=!1){if(!Ao)return Promise.resolve(!1);const e=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Xo(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=er(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=er(t.id)})),n}function tr(t){return JSON.stringify({id:t.id,rawId:nr(t.rawId),type:t.type,response:{authenticatorData:nr(t.response.authenticatorData),clientDataJSON:nr(t.response.clientDataJSON),signature:nr(t.response.signature),userHandle:t.response.userHandle?nr(t.response.userHandle):void 0}})}function er(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function nr(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var or,rr=(or=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const r=await Go(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await Zo(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await Go(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Zo(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const r=await Go(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Go,get:Zo,isSupported:Yo,conditional:Qo}}),(...t)=>{const e=or(...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}),ir=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await Yo(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const sr=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:r}=n,i=e(n,["fpKey","fpLoad"]);return o?(Ao?r&&(async t=>{try{if(Po())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=vo({apiKey:t,endpoint:Uo}),o=await n,{requestId:r}=await o.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(_o(e,r))}catch(t){global.FB_DEBUG&&console.error(t)}})(o).catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(Io(i,{beforeRequest:Ro}))):t(Object.assign({},i))}),(t=>n=>{var{autoRefresh:o}=n,r=e(n,["autoRefresh"]);if(!o)return t(r);const{clearAllTimers:i,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})(),a=t(Io(r,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await Oo(e);if(401===(null==e?void 0:e.status))i();else if(o){const t=((r=(t=>{const e=t.split(".");try{if(3===e.length){const t=JSON.parse(window.atob(e[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(t){}return null})(o))?r.getTime()-(new Date).getTime():0)-2e4;i(),s((()=>a.refresh(n)),t)}var r}}));return so(a,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return i(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.0.18"},e.baseHeaders)}))),(t=>e=>{const n=No(),o=No(),r=t(Io(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await jo(e);t&&o.pub(t);const{sessionJwt:r}=await Oo(e);r&&n.pub(r)}}})),i=so(r,["logout","logoutAll"],(t=>async(...e)=>{const r=await t(...e);return n.pub(null),o.pub(null),r}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>e=>{const n=t(Io(e,{afterRequest:async(t,e)=>{var n;const o=await jo(e),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((t=>{Eo(To,t)})(r),(t=>{Eo(qo,t)})(i))}}));let o=so(n,["flow.start"],Lo);return o=so(o,["logout","logoutAll"],Do),Object.assign(o,{getLastUserLoginId:Mo,getLastUserDisplayName:$o})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:r}=n,i=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!Ao)return o&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),t(i);const s=t(Io(i,{beforeRequest:Vo,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?Bo():Fo(await Oo(e),r)}})),a=so(s,["logout","logoutAll"],zo);return Object.assign(a,{getRefreshToken:Wo,getSessionToken:Ho})}))(((...t)=>{const e=ao(...t);return Object.assign(Object.assign({},e),{flow:ir(e),webauthn:rr(e)})})),ar=document.createElement("template");var lr,cr,ur,dr,hr,pr,fr,gr,vr,br,wr,mr,yr,kr,Ir,Or,jr,Sr,Er,xr,Cr,Ar,Ur,_r,Pr,Rr,Tr,qr,Mr,$r,Lr,Dr,Nr,Kr,Jr,Fr,Wr,Hr;ar.innerHTML='\n\t<style>\n\t\t:host {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<div id="wc-root"></div>\n\t';class Br extends HTMLElement{constructor(t){super(),lr.add(this),cr.set(this,!1),ur.set(this,new K),dr.set(this,new K),this.nextRequestStatus=new K({isLoading:!1}),hr.set(this,void 0),pr.set(this,{popstate:o(this,lr,"m",mr).bind(this)}),fr.set(this,void 0),Ir.set(this,T((()=>n(this,void 0,void 0,(function*(){const t=C(this.projectId,"config.json");try{const{body:e,headers:n}=yield E(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){this.logger.error("Cannot get config file","make sure that your projectId & flowId are correct")}return{}}))))),this.logger={error:(t,e="")=>{console.error(t,e,new Error),o(this,lr,"m",Ar).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},r(this,fr,t,"f"),o(this,lr,"m",gr).call(this)}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"]}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get baseUrl(){return this.getAttribute("base-url")||void 0}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 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 telemetryKey(){return this.getAttribute("telemetryKey")||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}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,Ir,"f").call(this);return t}))}getFlowConfig(){var t;return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,Ir,"f").call(this);return(null===(t=null==e?void 0:e.flows)||void 0===t?void 0:t[this.flowId])||{}}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,lr,"m",vr).call(this))return void o(this,lr,"m",br).call(this);o(this,lr,"m",wr).call(this),o(this,lr,"m",jr).call(this),o(this,lr,"m",Or).call(this),o(this,lr,"m",Ur).call(this);const{executionId:t,stepId:e,token:n,code:i,exchangeError:s}=R();window.addEventListener("popstate",o(this,pr,"f").popstate),o(this,ur,"f").subscribe(o(this,lr,"m",kr).bind(this)),o(this,dr,"f").subscribe(o(this,lr,"m",Cr).bind(this)),o(this,ur,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:e,executionId:t,token:n,code:i,exchangeError:s,telemetryKey:this.telemetryKey}),o(this,dr,"f").update({isDebug:this.debug}),r(this,cr,!0,"f")}}))}disconnectedCallback(){o(this,ur,"f").unsubscribeAll(),o(this,dr,"f").unsubscribeAll(),o(this,lr,"m",xr).call(this),window.removeEventListener("popstate",o(this,pr,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,cr,"f")&&e!==n&&Br.observedAttributes.includes(t)){o(this,lr,"m",wr).call(this);const r=null===e;o(this,ur,"f").update((({stepId:e,executionId:o})=>{let i=e,s=o;return r||(s=null,i=null,_()),{[P(t)]:n,stepId:i,executionId:s}})),o(this,dr,"f").update({isDebug:this.debug})}}}cr=new WeakMap,ur=new WeakMap,dr=new WeakMap,hr=new WeakMap,pr=new WeakMap,fr=new WeakMap,Ir=new WeakMap,lr=new WeakSet,gr=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ar.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},vr=function(){const t=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);return!this.shadowRoot.host.closest("form")&&t},br=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},wr=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"];if(Br.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[P(e)])throw Error(`${e} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},mr=function(){const{stepId:t,executionId:e}=U();o(this,ur,"f").update({stepId:t,executionId:e})},yr=function(t,e,o){const r=o||void 0,i=!!r;this.sdk=sr(Object.assign(Object.assign({persistTokens:!0},Br.sdkConfigOverrides),{projectId:t,baseUrl:e,fpKey:r,fpLoad:i})),["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)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},kr=function(t,e,r){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n,telemetryKey:i}=t;if(r("projectId")||r("baseUrl")||r("telemetryKey")){if(!e)return;o(this,lr,"m",yr).call(this,e,n,i)}o(this,fr,"f").call(this,t)}))},Or=function(){var t,e,r,i;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,Ir,"f").call(this);null===(i=null===(r=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t[this.theme])||void 0===e?void 0:e.typography)||void 0===r?void 0:r.fontFamilies)||void 0===i||i.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},jr=function(){o(this,lr,"m",Sr).call(this),o(this,lr,"m",Er).call(this)},Sr=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=C(this.projectId,"theme.css");try{const{body:n}=yield E(e,"text");t.innerText=n}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},Er=function(){this.rootElement.setAttribute("data-theme",this.theme)},xr=function(){var t;null===(t=o(this,hr,"f"))||void 0===t||t.remove(),r(this,hr,null,"f")},Cr=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield import("./debugger-wc-086a31a2.js"),r(this,hr,document.createElement("descope-debugger"),"f"),Object.assign(o(this,hr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,hr,"f"))):o(this,lr,"m",xr).call(this)}))},Ar=function(t,e){var n;t&&this.debug&&(null===(n=o(this,hr,"f"))||void 0===n||n.updateData({title:t,description:e}))},Ur=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("button");if(1===e.length)return void e[0].click();const n=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));1===n.length&&n[0].click()}},Br.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.0.25"}};class Vr extends Br{constructor(){const t=new K;super(t.update.bind(t)),_r.add(this),this.stepState=new K({},{updateOnlyOnChange:!1}),Pr.set(this,void 0),Rr.set(this,null),Tr.set(this,(()=>{clearInterval(o(this,Pr,"f")),r(this,Pr,null,"f")})),qr.set(this,(t=>{var e,n,r,s,a,l,c,u,d;if(!(null==t?void 0:t.ok)){o(this,Tr,"f").call(this),o(this,_r,"m",Hr).call(this,"error",null==t?void 0:t.error);const i=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.statusText}`;return void this.logger.error((null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorDescription)||i,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const p=null===(u=null===(c=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===u?void 0:u.errorText;p&&this.logger.error(p),(null===(d=t.data)||void 0===d?void 0:d.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:f,authInfo:v,lastAuth:b}=t.data;if("completed"===f)return function(t){(null==t?void 0:t.authMethod)&&i&&localStorage.setItem(h,JSON.stringify(t))}(b),o(this,Tr,"f").call(this),void o(this,_r,"m",Hr).call(this,"success",v);const{executionId:w,stepId:m,action:y,screen:k,redirect:I,webauthn:O}=t.data;y!==g?this.flowState.update({stepId:m,executionId:w,action:y,redirectTo:null==I?void 0:I.url,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options}):this.flowState.update({action:y})})),Mr.set(this,T((()=>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.logger.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.logger.error("Webauthn start failed",t.message)}}))))),this.flowState=t}static set sdkConfigOverrides(t){Br.sdkConfigOverrides=t}connectedCallback(){const t=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var e,o;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield t.connectedCallback.call(this)}))}disconnectedCallback(){super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll()}onFlowChange(t,e,i){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:l,flowId:c,tenant:u,stepId:d,executionId:p,action:w,screenId:k,screenState:I,redirectTo:O,redirectUrl:j,token:S,code:E,exchangeError:x,webauthnTransactionId:U,webauthnOptions:_}=t;let P,R;o(this,Pr,"f")&&o(this,Tr,"f").call(this);const T=this.sdk.getLastUserLoginId();if(!p){if(!c)return;const t=yield this.getFlowConfig();if(({startScreenId:P=t.startScreenId,conditionInteractionId:R}=((t,e)=>{var n;const o=null===(n=W[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const r=o(e)?t.met:t.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})(t.condition,{loginId:T,code:E})),!P){const t=E?{exchangeCode:E,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(c,Object.assign({tenant:u},j&&{redirectUrl:j}),R,"",t);return o(this,qr,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0}))}}if(p&&(i("token")&&S||i("code")&&E||i("exchangeError")&&x)){const t=yield this.sdk.flow.next(p,d,m,{token:S,exchangeCode:E,exchangeError:x});return o(this,qr,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(w===f)return O||this.logger.error("Did not get redirect url"),void window.location.assign(O);if(w===v||w===b){if(!U||!_)return void this.logger.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,Rr,"f"))||void 0===a||a.abort(),r(this,Rr,null,"f");try{t=w===v?yield this.sdk.webauthn.helpers.create(_):yield this.sdk.webauthn.helpers.get(_)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const n=yield this.sdk.flow.next(p,d,m,{transactionId:U,response:t,cancelWebauthn:e});o(this,qr,"f").call(this,n)}if(w===g&&r(this,Pr,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,d,y,{});o(this,qr,"f").call(this,t)}))),2e3),"f"),!k&&!P)return void this.logger.info("Refreshing the page during a flow is not supported yet");const q={direction:A(+d,+e.stepId),screenState:Object.assign(Object.assign({},I),{lastAuth:{loginId:T,name:this.sdk.getLastUserDisplayName()||T}}),htmlUrl:C(l,`${P||k}.html`)},M=function(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(h)))}catch(t){}return e}(T);P?q.next=(t,e)=>this.sdk.flow.start(c,Object.assign({tenant:u,lastAuth:M},j&&{redirectUrl:j}),R,t,Object.assign(Object.assign({},e),E&&{exchangeCode:E,idpInitiated:!0})):(i("projectId")||i("baseUrl")||i("executionId")||i("stepId"))&&(q.next=(...t)=>this.sdk.flow.next(p,d,...t)),this.stepState.update(q)}))}onStepChange(t,e){var r;return n(this,void 0,void 0,(function*(){const{htmlUrl:i,direction:s,next:a,screenState:l}=t,c=document.createElement("template"),{body:u}=yield E(i,"text");c.innerHTML=u;const d=c.content.cloneNode(!0),h=((t,e)=>{var n;const o=Array.from(t.querySelectorAll("script[data-id]")).map((n=>{var o;const r=n.getAttribute("data-id"),i=null===(o=t.getElementById(r))||void 0===o?void 0:o.innerHTML,s=Function(i).bind(n.previousSibling,e);return n.remove(),s}));return null===(n=t.querySelector("scripts"))||void 0===n||n.remove(),o})(d,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield o(this,_r,"m",Lr).call(this,d,a):d.querySelectorAll(`button[${p}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),J(d,l),((t,e)=>{var n;e&&(null===(n=null==t?void 0:t.style)||void 0===n||n.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(d.querySelector("div"),null===(r=null==l?void 0:l.totp)||void 0===r?void 0:r.image);const f=()=>n(this,void 0,void 0,(function*(){try{h.forEach((t=>{t()}))}catch(t){this.logger.error(t.message)}this.rootElement.replaceChildren(d);const t=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector('input:not([aria-hidden="true"])');null==e||e.focus()}})(this.rootElement,this.autoFocus,t),o(this,_r,"m",Fr).call(this,a),o(this,_r,"m",Hr).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${p}="polling"]`)){const t=yield a(y,{});o(this,qr,"f").call(this,t)}}));s?o(this,_r,"m",Wr).call(this,f,s):f()}))}}Pr=new WeakMap,Rr=new WeakMap,Tr=new WeakMap,qr=new WeakMap,Mr=new WeakMap,_r=new WeakSet,$r=function(t){const e=t.name;if(!["email"].includes(e)){const n=`user-${e}`;t.name=n,t.addEventListener("input",(()=>{t.name=t.value?e:n}))}},Lr=function(t,e){var i;return n(this,void 0,void 0,(function*(){null===(i=o(this,Rr,"f"))||void 0===i||i.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield F())){const{options:t,transactionId:i}=(yield o(this,Mr,"f").call(this))||{};t&&i&&(o(this,_r,"m",$r).call(this,s),r(this,Rr,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,Rr,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:i,response:t});o(this,qr,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Dr=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Nr=function(){return Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${d}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e.value}):t),{})},Kr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{var o,r;n?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(r=null==t?void 0:t.classList)||void 0===r||r.remove("loading"))}))},Jr=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,_r,"m",Dr).call(this)){const r=null==t?void 0:t.getAttribute("id");o(this,_r,"m",Kr).call(this,t);const i=o(this,_r,"m",Nr).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=Object.assign(Object.assign(Object.assign({},s),i),{origin:window.location.origin}),l=yield e(r,a);o(this,qr,"f").call(this,l)}var n}))},Fr=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,_r,"m",Jr).call(this,e,t)}}))},Wr=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===k.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")},Hr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",Vr);export{Vr as D,K as S,o as _,r as a};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{D as default}from"./index-d3fa479e.js";
1
+ export{D as default}from"./index-48dfd25f.js";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
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}const r="undefined"!=typeof localStorage,s=r&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",a="descope-login-flow",l="t",c="code",d="err",u="data-exclude-field",h="dls_last_auth",p="data-type",f="redirect",g="poll",v="webauthnCreate",m="webauthnGet",b="v2-alpha",w="submit",y="polling";var k,I,x;function O(t){return new URLSearchParams(window.location.search).get(t)}function j(t){if(window.history.replaceState&&O(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 S(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}`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(k||(k={}));const C=(...t)=>t.join("/").replace(/\/+/g,"/");function E(t,e){const n=new URL(s);return n.pathname=C(n.pathname,t,b,e),n.toString()}function A(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?k.forward:t<e?k.backward:void 0}const _=()=>{const[t="",e=""]=(O(a)||"").split("_");return{executionId:t,stepId:e}};function U(){j(a)}const P=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),R=()=>{const{executionId:t,stepId:e}=_();(t||e)&&U();const n=O(l)||void 0;n&&j(l);const o=O(c)||void 0;o&&j(c);const i=O(d)||void 0;return i&&j(d),{executionId:t,stepId:e,token:n,code:o,exchangeError:i}},T=t=>{let e,n;return(...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}},L=null===(x=null===(I=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===I?void 0:I.brands)||void 0===x?void 0:x.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));var M,q,$,D;function N(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(!N(r,s))return!1}else if(r!==s)return!1}return!0}class W{constructor(t={},{updateOnlyOnChange:e=!0}={}){M.set(this,void 0),q.set(this,{}),$.set(this,0),D.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,M,"f")):t,n=Object.assign(Object.assign({},o(this,M,"f")),e);if(!o(this,D,"f")||!N(o(this,M,"f"),n)){const t=o(this,M,"f");i(this,M,n,"f"),Object.freeze(o(this,M,"f")),setTimeout((()=>{Object.values(o(this,q,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,M,t,"f"),i(this,D,e,"f")}get current(){return Object.assign({},o(this,M,"f"))}subscribe(t){return i(this,$,o(this,$,"f")+1,"f"),o(this,q,"f")[o(this,$,"f")]=t,o(this,$,"f").toString()}unsubscribe(t){const e=!!o(this,q,"f")[t];return e&&delete o(this,q,"f")[t],e}unsubscribeAll(){return i(this,q,{},"f"),!0}}M=new WeakMap,q=new WeakMap,$=new WeakMap,D=new WeakMap;const F=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[${p}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${u}])`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(`[${p}="totp-link"]`).forEach((t=>{t.href=e}))})(t,null===(n=null==e?void 0:e.totp)||void 0===n?void 0:n.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},K=T((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return console.warn("webauthn","Conditional UI is not supported"),!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)))),r=108;return yield Promise.race([i,(n=100,new Promise(((t,e)=>{const i=setTimeout((()=>{e(new Error(`Promise timed out after ${n} ms`))}),n);null==o||o((e=>{clearTimeout(i),t(e)}),(t=>{clearTimeout(i),e(t)}))}))).catch((()=>L()>=r))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),J=(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))]},H={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function z(t){this.message=t}z.prototype=new Error,z.prototype.name="InvalidCharacterError";var B="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new z("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,r=0,s="";o=e.charAt(r++);~o&&(n=i%4?64*n+o:o,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function V(t){this.message=t}function Z(t,e){if("string"!=typeof t)throw new V("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(B(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return B(e)}}(t.split(".")[n]))}catch(t){throw new V("Invalid token specified: "+t.message)}}V.prototype=new Error,V.prototype.name="InvalidTokenError";var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},X="Expected a function",Y="__lodash_hash_undefined__",Q=1/0,tt="[object Function]",et="[object GeneratorFunction]",nt="[object Symbol]",ot=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,it=/^\w*$/,rt=/^\./,st=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,at=/\\(\\)?/g,lt=/^\[object .+?Constructor\]$/,ct="object"==typeof G&&G&&G.Object===Object&&G,dt="object"==typeof self&&self&&self.Object===Object&&self,ut=ct||dt||Function("return this")();var ht,pt=Array.prototype,ft=Function.prototype,gt=Object.prototype,vt=ut["__core-js_shared__"],mt=(ht=/[^.]+$/.exec(vt&&vt.keys&&vt.keys.IE_PROTO||""))?"Symbol(src)_1."+ht:"",bt=ft.toString,wt=gt.hasOwnProperty,yt=gt.toString,kt=RegExp("^"+bt.call(wt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),It=ut.Symbol,xt=pt.splice,Ot=Lt(ut,"Map"),jt=Lt(Object,"create"),St=It?It.prototype:void 0,Ct=St?St.toString:void 0;function Et(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function At(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function _t(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Ut(t,e){for(var n,o,i=t.length;i--;)if((n=t[i][0])===(o=e)||n!=n&&o!=o)return i;return-1}function Pt(t,e){var n;e=function(t,e){if(Dt(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Wt(t))return!0;return it.test(t)||!ot.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Dt(n=e)?n:Mt(n);for(var o=0,i=e.length;null!=t&&o<i;)t=t[qt(e[o++])];return o&&o==i?t:void 0}function Rt(t){if(!Nt(t)||(e=t,mt&&mt in e))return!1;var e,n=function(t){var e=Nt(t)?yt.call(t):"";return e==tt||e==et}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?kt:lt;return n.test(function(t){if(null!=t){try{return bt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Tt(t,e){var n,o,i=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function Lt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Rt(n)?n:void 0}Et.prototype.clear=function(){this.__data__=jt?jt(null):{}},Et.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Et.prototype.get=function(t){var e=this.__data__;if(jt){var n=e[t];return n===Y?void 0:n}return wt.call(e,t)?e[t]:void 0},Et.prototype.has=function(t){var e=this.__data__;return jt?void 0!==e[t]:wt.call(e,t)},Et.prototype.set=function(t,e){return this.__data__[t]=jt&&void 0===e?Y:e,this},At.prototype.clear=function(){this.__data__=[]},At.prototype.delete=function(t){var e=this.__data__,n=Ut(e,t);return!(n<0)&&(n==e.length-1?e.pop():xt.call(e,n,1),!0)},At.prototype.get=function(t){var e=this.__data__,n=Ut(e,t);return n<0?void 0:e[n][1]},At.prototype.has=function(t){return Ut(this.__data__,t)>-1},At.prototype.set=function(t,e){var n=this.__data__,o=Ut(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},_t.prototype.clear=function(){this.__data__={hash:new Et,map:new(Ot||At),string:new Et}},_t.prototype.delete=function(t){return Tt(this,t).delete(t)},_t.prototype.get=function(t){return Tt(this,t).get(t)},_t.prototype.has=function(t){return Tt(this,t).has(t)},_t.prototype.set=function(t,e){return Tt(this,t).set(t,e),this};var Mt=$t((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Wt(t))return Ct?Ct.call(t):"";var e=t+"";return"0"==e&&1/t==-Q?"-0":e}(e);var n=[];return rt.test(t)&&n.push(""),t.replace(st,(function(t,e,o,i){n.push(o?i.replace(at,"$1"):e||t)})),n}));function qt(t){if("string"==typeof t||Wt(t))return t;var e=t+"";return"0"==e&&1/t==-Q?"-0":e}function $t(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(X);var n=function(){var o=arguments,i=e?e.apply(this,o):o[0],r=n.cache;if(r.has(i))return r.get(i);var s=t.apply(this,o);return n.cache=r.set(i,s),s};return n.cache=new($t.Cache||_t),n}$t.Cache=_t;var Dt=Array.isArray;function Nt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Wt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&yt.call(t)==nt}var Ft=function(t,e,n){var o=null==t?void 0:Pt(t,e);return void 0===o?n:o},Kt="/v1/auth/accesskey/exchange",Jt="/v1/auth/otp/verify",Ht="/v1/auth/otp/signin",zt="/v1/auth/otp/signup",Bt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Vt="/v1/auth/otp/signup-in",Zt="/v1/auth/magiclink/verify",Gt="/v1/auth/magiclink/signin",Xt="/v1/auth/magiclink/signup",Yt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},Qt="/v1/auth/magiclink/signup-in",te="/v1/auth/enchantedlink/verify",ee="/v1/auth/enchantedlink/signin",ne="/v1/auth/enchantedlink/signup",oe="/v1/auth/enchantedlink/pending-session",ie={email:"/v1/auth/enchantedlink/update/email"},re="/v1/auth/enchantedlink/signup-in",se="/v1/auth/oauth/authorize",ae="/v1/auth/oauth/exchange",le="/v1/auth/saml/authorize",ce="/v1/auth/saml/exchange",de="/v1/auth/totp/verify",ue="/v1/auth/totp/signup",he="/v1/auth/totp/update",pe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},fe={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},ge={start:"/v1/auth/webauthn/signup-in/start"},ve={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},me="/v1/auth/password/signup",be="/v1/auth/password/signin",we="/v1/auth/password/reset",ye="/v1/auth/password/update",ke="/v1/auth/password/replace",Ie="/v1/auth/password/policy",xe="/v1/auth/refresh",Oe="/v1/auth/logout",je="/v1/auth/logoutall",Se="/v1/auth/me",Ce="/v1/flow/start",Ee="/v1/flow/next";const Ae=6e5,_e=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};var Ue;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Ue||(Ue={}));const Pe=(...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}),{})),Re=t=>void 0===t?void 0:JSON.stringify(t),Te=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Le=({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=>_e().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 _e().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=>{const s=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:l,body:c,headers:d,queryParams:u,method:h,token:p}=s,f=await a((({path:t,baseUrl:e,queryParams:n})=>{const o=new URL(t,e);return n&&(o.search=new URLSearchParams(n).toString()),o})({path:l,baseUrl:t,queryParams:u}),{headers:Pe(Te(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.0.15"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:Re(c),credentials:r||"include"});return(null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Ue.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.post,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.put,token:i}),delete:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.delete,token:i}),hooks:i}};var Me={TOO_MANY_REQUESTS:429};function qe(t,e,n){var o;let i=$e(t);e&&(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 $e(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return Z(t)}function De(t){const{exp:e}=$e(t);return(new Date).getTime()/1e3>e}function Ne(t,e){return qe(t,e,"permissions")}function We(t,e){return qe(t,e,"roles")}const Fe=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Ke(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===Me.TOO_MANY_REQUESTS&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Je=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),He=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),ze=t=>e=>t.test(e),Be=ze(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ve=ze(/^\+[1-9]{1}[0-9]{3,14}$/),Ze=Je(Be,'"{val}" is not a valid email'),Ge=Je(Ve,'"{val}" is not a valid phone number'),Xe=Je((1,t=>t.length>=1),"Minimum length is 1");const Ye=Je((t=>"string"==typeof t),"Input is not a string"),Qe=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>He(...t).validate(n[e]))),e(...n)),tn=t=>[Ye(`"${t}" must be a string`),Xe(`"${t}" must not be empty`)],en=t=>[Ye(`"${t}" must be a string`),Ze()],nn=t=>[Ye(`"${t}" must be a string`),Ge()],on=Qe(tn("accessKey")),rn=t=>({exchange:on((e=>Ke(t.post(Kt,{},{token:e}))))});var sn,an;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(sn||(sn={})),function(t){t.email="email"}(an||(an={}));const ln=Object.assign(Object.assign({},sn),an);var cn;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(cn||(cn={}));const dn=tn("loginId"),un=Qe(tn("token")),hn=Qe(dn),pn=Qe(tn("pendingRef")),fn=Qe(dn,en("email")),gn=t=>({verify:un((e=>Ke(t.post(te,{token:e})))),signIn:hn(((e,n,o,i)=>Ke(t.post(Fe(ee,ln.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:hn(((e,n)=>Ke(t.post(Fe(re,ln.email),{loginId:e,URI:n})))),signUp:hn(((e,n,o)=>Ke(t.post(Fe(ne,ln.email),{loginId:e,URI:n,user:o})))),waitForSession:pn(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||Ae,Ae)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(oe,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Ke(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:fn(((e,n,o,i)=>Ke(t.post(ie.email,{loginId:e,email:n,URI:o},{token:i}))))}}),vn=Qe(tn("flowId")),mn=Qe(tn("executionId"),tn("stepId"),tn("interactionId")),bn=t=>({start:vn(((e,n,o,i,r)=>Ke(t.post(Ce,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,input:r})))),next:mn(((e,n,o,i)=>Ke(t.post(Ee,{executionId:e,stepId:n,interactionId:o,input:i}))))}),wn=tn("loginId"),yn=Qe(tn("token")),kn=Qe(wn),In=Qe(wn,nn("phone")),xn=Qe(wn,en("email")),On=t=>({verify:yn((e=>Ke(t.post(Zt,{token:e})))),signIn:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:kn(((e,o,i,r)=>Ke(t.post(Fe(Gt,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:kn(((e,o,i)=>Ke(t.post(Fe(Xt,n),{loginId:e,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:kn(((e,o)=>Ke(t.post(Fe(Qt,n),{loginId:e,URI:o}))))})),{}),update:{email:xn(((e,n,o,i)=>Ke(t.post(Yt.email,{loginId:e,email:n,URI:o},{token:i})))),phone:Object.keys(sn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:In(((e,o,i,r)=>Ke(t.post(Fe(Yt.phone,n),{loginId:e,phone:o,URI:i},{token:r}))))})),{})}});var jn;!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"}(jn||(jn={}));const Sn=Qe(tn("code")),Cn=t=>({start:Object.keys(jn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:o=!1}={},i,r)=>{const s=await t.post(se,i||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:r});if(!o||!s.ok)return Ke(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:Sn((e=>Ke(t.post(ae,{code:e}))))}),En=tn("loginId"),An=Qe(En,tn("code")),_n=Qe(En),Un=Qe(En,nn("phone")),Pn=Qe(En,en("email")),Rn=t=>({verify:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An(((e,o)=>Ke(t.post(Fe(Jt,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o,i)=>Ke(t.post(Fe(Ht,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o)=>Ke(t.post(Fe(zt,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n((e=>Ke(t.post(Fe(Vt,n),{loginId:e}))))})),{}),update:{email:Pn(((e,n,o)=>Ke(t.post(Bt.email,{loginId:e,email:n},{token:o})))),phone:Object.keys(sn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Un(((e,o,i)=>Ke(t.post(Fe(Bt.phone,n),{loginId:e,phone:o},{token:i}))))})),{})}}),Tn=Qe(tn("tenant")),Ln=Qe(tn("code")),Mn=t=>({start:Tn((async(e,n,{redirect:o=!1}={},i,r)=>{const s=await t.post(le,i||{},{queryParams:{tenant:e,redirectURL:n},token:r});if(!o||!s.ok)return Ke(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a})),exchange:Ln((e=>Ke(t.post(ce,{code:e}))))}),qn=tn("loginId"),$n=Qe(qn,tn("code")),Dn=Qe(qn),Nn=Qe(qn),Wn=t=>({signUp:Dn(((e,n)=>Ke(t.post(ue,{loginId:e,user:n})))),verify:$n(((e,n,o,i)=>Ke(t.post(de,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Nn(((e,n)=>Ke(t.post(he,{loginId:e},{token:n}))))}),Fn=tn("loginId"),Kn=tn("newPassword"),Jn=Qe(Fn,tn("password")),Hn=Qe(Fn),zn=Qe(Fn,Kn),Bn=Qe(Fn,tn("oldPassword"),Kn),Vn=t=>({signUp:Jn(((e,n,o)=>Ke(t.post(me,{loginId:e,password:n,user:o})))),signIn:Jn(((e,n)=>Ke(t.post(be,{loginId:e,password:n})))),sendReset:Hn(((e,n)=>Ke(t.post(we,{loginId:e,redirectUrl:n})))),update:zn(((e,n,o)=>Ke(t.post(ye,{loginId:e,newPassword:n},{token:o})))),replace:Bn(((e,n,o)=>Ke(t.post(ke,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>Ke(t.get(Ie))}),Zn=[Ye('"loginId" must be a string')],Gn=tn("loginId"),Xn=tn("origin"),Yn=Qe(Gn,Xn,tn("name")),Qn=Qe(Gn,Xn),to=Qe(Zn,Xn),eo=Qe(Gn,Xn,tn("token")),no=Qe(tn("transactionId"),tn("response")),oo=t=>({signUp:{start:Yn(((e,n,o)=>Ke(t.post(pe.start,{user:{loginId:e,name:o},origin:n})))),finish:no(((e,n)=>Ke(t.post(pe.finish,{transactionId:e,response:n}))))},signIn:{start:to(((e,n,o,i)=>Ke(t.post(fe.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:no(((e,n)=>Ke(t.post(fe.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Qn(((e,n)=>Ke(t.post(ge.start,{loginId:e,origin:n}))))},update:{start:eo(((e,n,o)=>Ke(t.post(ve.start,{loginId:e,origin:n},{token:o})))),finish:no(((e,n)=>Ke(t.post(ve.finish,{transactionId:e,response:n}))))}}),io=Qe(tn("token"));var ro,so=Qe([("projectId",ro=tn("projectId"),Je(((t,e)=>n=>He(...e).validate(Ft(n,t)))("projectId",ro))())])((t=>{var e,n;const o=[].concat((null===(e=t.hooks)||void 0===e?void 0:e.beforeRequest)||[]),i=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=Le({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:rn(a),otp:Rn(a),magicLink:On(a),enchantedLink:gn(a),oauth:Cn(a),saml:Mn(a),totp:Wn(a),webauthn:oo(a),password:Vn(a),flow:bn(a),refresh:t=>Ke(a.post(xe,{},{token:t})),logout:t=>Ke(a.post(Oe,{},{token:t})),logoutAll:t=>Ke(a.post(je,{},{token:t})),me:t=>Ke(a.get(Se,{token:t})),isJwtExpired:io(De),getJwtPermissions:io(Ne),getJwtRoles:io(We),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:t=>null==o?void 0:o.reduce(((t,e)=>e(t)),t),afterRequest:async(e,n)=>{(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))}))}}}))}));const ao=(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);var lo=Object.assign(so,{DeliveryMethods:ln});var co="Blocked by CSP",uo="API key required",ho="3.8.2",po="9319";function fo(t,e){var n=[];return function(t,e){var n,o,i=(o=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),{current:function(){return o[0]},postpone:function(){var t=o.shift();void 0!==t&&o.push(t)},exclude:function(){o.shift()}}),r=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=i.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return e===co||e===po}(t)?i.postpone():i.exclude();var e,o=i.current();if(void 0===o)throw t;return(e=r(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(t,(function(t){var o=new Date,i=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},r=e(t);return r.then(i,i),r})).then((function(t){return[t,{attempts:n}]}))}var go="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",vo="Failed to load the JS script of the agent";function mo(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:go;return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error(uo);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(ho):t}))}(String(t),e)}))}(l,s);return fo(t,bo).catch(yo)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function bo(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 Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(l(),i)return function(){throw new Error(co)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){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(vo))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)})).then(wo)}function wo(){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(po);return n}function yo(t){throw t instanceof Error&&t.message===po?new Error(vo):t}
2
- /*! js-cookie v3.0.1 | MIT */function ko(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 Io=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=ko({},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,"",ko({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,ko({},this.attributes,e))},withConverter:function(e){return t(ko({},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:"/"});const xo=(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},Oo=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||{}},jo=async t=>{const e=await Oo(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},So="undefined"!=typeof localStorage,Co=(t,e)=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),Eo=t=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Ao=t=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),_o="undefined"!=typeof window,Uo=_o&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",Po=(t="",e="")=>({vsid:t,vrid:e}),Ro=(t=!1)=>{const e=localStorage.getItem("fp");if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},To=t=>(t.body&&(t.body.fpData=Ro(!0)||Po()),t),Lo="dls_last_user_login_id",Mo="dls_last_user_display_name",qo=()=>Eo(Lo),$o=()=>Eo(Mo),Do=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=qo(),r=$o();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)},No=t=>async(...e)=>{const n=await t(...e);return Ao(Lo),Ao(Mo),n};function Wo(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Fo="DS",Ko="DSR",Jo=(t={},n)=>{var{refreshJwt:o,sessionJwt:i}=t,r=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&Co(Ko,o),i&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i);Io.set(t,e,{path:n,domain:o,expires:r,sameSite:"Strict",secure:!0})}}(Fo,i,r):Co(Fo,i))};function Ho(){return Eo(Ko)||""}function zo(){return Io.get(Fo)||Eo(Fo)||""}function Bo(){Ao(Ko),Ao(Fo),Io.remove(Fo)}const Vo=t=>Object.assign(t,{token:t.token||Ho()}),Zo=t=>async(...e)=>{const n=await t(...e);return Bo(),n};async function Go(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ni(n.publicKey.challenge),n.publicKey.user.id=ni(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ni(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:oi(n.rawId),type:n.type,response:{attestationObject:oi(n.response.attestationObject),clientDataJSON:oi(n.response.clientDataJSON)}});var n}async function Xo(t){const e=ti(t);return ei(await navigator.credentials.get(e))}async function Yo(t,e){const n=ti(t);return n.signal=e.signal,n.mediation="conditional",ei(await navigator.credentials.get(n))}async function Qo(t=!1){if(!_o)return Promise.resolve(!1);const e=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function ti(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ni(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ni(t.id)})),n}function ei(t){return JSON.stringify({id:t.id,rawId:oi(t.rawId),type:t.type,response:{authenticatorData:oi(t.response.authenticatorData),clientDataJSON:oi(t.response.clientDataJSON),signature:oi(t.response.signature),userHandle:t.response.userHandle?oi(t.response.userHandle):void 0}})}function ni(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function oi(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ii,ri=(ii=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Go(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await Xo(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await Go(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Xo(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Go(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Go,get:Xo,isSupported:Qo,conditional:Yo}}),(...t)=>{const e=ii(...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}),si=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await Qo(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const ai=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 o?(_o?i&&(async t=>{try{if(Ro())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=mo({apiKey:t,endpoint:Uo}),o=await n,{requestId:i}=await o.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(Po(e,i))}catch(t){global.FB_DEBUG&&console.error(t)}})(o).catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(xo(r,{beforeRequest:To}))):t(Object.assign({},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))}}})(),a=t(xo(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await Oo(e);if(401===(null==e?void 0:e.status))r();else if(o){const t=((i=(t=>{const e=t.split(".");try{if(3===e.length){const t=JSON.parse(window.atob(e[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(t){}return null})(o))?i.getTime()-(new Date).getTime():0)-2e4;r(),s((()=>a.refresh(n)),t)}var i}}));return ao(a,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.0.16"},e.baseHeaders)}))),(t=>e=>{const n=Wo(),o=Wo(),i=t(xo(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await jo(e);t&&o.pub(t);const{sessionJwt:i}=await Oo(e);i&&n.pub(i)}}})),r=ao(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=>e=>{const n=t(xo(e,{afterRequest:async(t,e)=>{var n;const o=await jo(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=>{Co(Lo,t)})(i),(t=>{Co(Mo,t)})(r))}}));let o=ao(n,["flow.start"],Do);return o=ao(o,["logout","logoutAll"],No),Object.assign(o,{getLastUserLoginId:qo,getLastUserDisplayName:$o})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i}=n,r=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!_o)return o&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),t(r);const s=t(xo(r,{beforeRequest:Vo,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?Bo():Jo(await Oo(e),i)}})),a=ao(s,["logout","logoutAll"],Zo);return Object.assign(a,{getRefreshToken:Ho,getSessionToken:zo})}))(((...t)=>{const e=lo(...t);return Object.assign(Object.assign({},e),{flow:si(e),webauthn:ri(e)})})),li=document.createElement("template");var ci,di,ui,hi,pi,fi,gi,vi,mi,bi,wi,yi,ki,Ii,xi,Oi,ji,Si,Ci,Ei,Ai,_i,Ui,Pi,Ri,Ti,Li,Mi,qi,$i,Di,Ni,Wi,Fi,Ki,Ji,Hi,zi,Bi,Vi,Zi,Gi,Xi,Yi,Qi,tr,er,nr;li.innerHTML='\n\t<style>\n\t\t:host {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<div id="wc-root"></div>\n\t';class or extends HTMLElement{constructor(t){super(),ci.add(this),di.set(this,!1),ui.set(this,new W),hi.set(this,new W),this.nextRequestStatus=new W({isLoading:!1}),pi.set(this,void 0),fi.set(this,{popstate:o(this,ci,"m",yi).bind(this)}),gi.set(this,void 0),xi.set(this,T((()=>n(this,void 0,void 0,(function*(){const t=E(this.projectId,"config.json");try{const{body:e,headers:n}=yield S(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){this.logger.error("Cannot get config file","make sure that your projectId & flowId are correct")}return{}}))))),this.logger={error:(t,e="")=>{console.error(t,e,new Error),o(this,ci,"m",_i).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},i(this,gi,t,"f"),o(this,ci,"m",vi).call(this)}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"]}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get baseUrl(){return this.getAttribute("base-url")||void 0}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 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 telemetryKey(){return this.getAttribute("telemetryKey")||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}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,xi,"f").call(this);return t}))}getFlowConfig(){var t;return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,xi,"f").call(this);return(null===(t=null==e?void 0:e.flows)||void 0===t?void 0:t[this.flowId])||{}}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,ci,"m",mi).call(this))return void o(this,ci,"m",bi).call(this);o(this,ci,"m",wi).call(this),o(this,ci,"m",ji).call(this),o(this,ci,"m",Oi).call(this),o(this,ci,"m",Ui).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s}=R();window.addEventListener("popstate",o(this,fi,"f").popstate),o(this,ui,"f").subscribe(o(this,ci,"m",Ii).bind(this)),o(this,hi,"f").subscribe(o(this,ci,"m",Ai).bind(this)),o(this,ui,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:e,executionId:t,token:n,code:r,exchangeError:s,telemetryKey:this.telemetryKey}),o(this,hi,"f").update({isDebug:this.debug}),i(this,di,!0,"f")}}))}disconnectedCallback(){o(this,ui,"f").unsubscribeAll(),o(this,hi,"f").unsubscribeAll(),o(this,ci,"m",Ei).call(this),window.removeEventListener("popstate",o(this,fi,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,di,"f")&&e!==n&&or.observedAttributes.includes(t)){o(this,ci,"m",wi).call(this);const i=null===e;o(this,ui,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,U()),{[P(t)]:n,stepId:r,executionId:s}})),o(this,hi,"f").update({isDebug:this.debug})}}}di=new WeakMap,ui=new WeakMap,hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,xi=new WeakMap,ci=new WeakSet,vi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(li.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},mi=function(){const t=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);return!this.shadowRoot.host.closest("form")&&t},bi=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},wi=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"];if(or.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[P(e)])throw Error(`${e} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},yi=function(){const{stepId:t,executionId:e}=_();o(this,ui,"f").update({stepId:t,executionId:e})},ki=function(t,e,o){const i=o||void 0,r=!!i;this.sdk=ai(Object.assign(Object.assign({persistTokens:!0},or.sdkConfigOverrides),{projectId:t,baseUrl:e,fpKey:i,fpLoad:r})),["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)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Ii=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n,telemetryKey:r}=t;if(i("projectId")||i("baseUrl")||i("telemetryKey")){if(!e)return;o(this,ci,"m",ki).call(this,e,n,r)}o(this,gi,"f").call(this,t)}))},Oi=function(){var t,e,i,r;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,xi,"f").call(this);null===(r=null===(i=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t[this.theme])||void 0===e?void 0:e.typography)||void 0===i?void 0:i.fontFamilies)||void 0===r||r.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},ji=function(){o(this,ci,"m",Si).call(this),o(this,ci,"m",Ci).call(this)},Si=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=E(this.projectId,"theme.css");try{const{body:n}=yield S(e,"text");t.innerText=n}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},Ci=function(){this.rootElement.setAttribute("data-theme",this.theme)},Ei=function(){var t;null===(t=o(this,pi,"f"))||void 0===t||t.remove(),i(this,pi,null,"f")},Ai=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield Promise.resolve().then((function(){return ar})),i(this,pi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,pi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,pi,"f"))):o(this,ci,"m",Ei).call(this)}))},_i=function(t,e){var n;t&&this.debug&&(null===(n=o(this,pi,"f"))||void 0===n||n.updateData({title:t,description:e}))},Ui=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("button");if(1===e.length)return void e[0].click();const n=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));1===n.length&&n[0].click()}},or.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.0.23"}};class ir extends or{constructor(){const t=new W;super(t.update.bind(t)),Pi.add(this),this.stepState=new W({},{updateOnlyOnChange:!1}),Ri.set(this,void 0),Ti.set(this,null),Li.set(this,(()=>{clearInterval(o(this,Ri,"f")),i(this,Ri,null,"f")})),Mi.set(this,(t=>{var e,n,i,s,a,l,c,d,u;if(!(null==t?void 0:t.ok)){o(this,Li,"f").call(this),o(this,Pi,"m",zi).call(this,"error",null==t?void 0:t.error);const r=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;return void this.logger.error((null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorDescription)||r,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const p=null===(d=null===(c=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===d?void 0:d.errorText;p&&this.logger.error(p),(null===(u=t.data)||void 0===u?void 0:u.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:f,authInfo:v,lastAuth:m}=t.data;if("completed"===f)return function(t){(null==t?void 0:t.authMethod)&&r&&localStorage.setItem(h,JSON.stringify(t))}(m),o(this,Li,"f").call(this),void o(this,Pi,"m",zi).call(this,"success",v);const{executionId:b,stepId:w,action:y,screen:k,redirect:I,webauthn:x}=t.data;y!==g?this.flowState.update({stepId:w,executionId:b,action:y,redirectTo:null==I?void 0:I.url,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options}):this.flowState.update({action:y})})),qi.set(this,T((()=>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.logger.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.logger.error("Webauthn start failed",t.message)}}))))),this.flowState=t}static set sdkConfigOverrides(t){or.sdkConfigOverrides=t}connectedCallback(){const t=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var e,o;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield t.connectedCallback.call(this)}))}disconnectedCallback(){super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll()}onFlowChange(t,e,r){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:l,flowId:c,tenant:d,stepId:u,executionId:p,action:b,screenId:k,screenState:I,redirectTo:x,redirectUrl:O,token:j,code:S,exchangeError:C,webauthnTransactionId:_,webauthnOptions:U}=t;let P,R;o(this,Ri,"f")&&o(this,Li,"f").call(this);const T=this.sdk.getLastUserLoginId();if(!p){if(!c)return;const t=yield this.getFlowConfig();if(({startScreenId:P=t.startScreenId,conditionInteractionId:R}=((t,e)=>{var n;const o=null===(n=H[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(t.condition,{loginId:T,code:S})),!P){const t=S?{exchangeCode:S,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(c,Object.assign({tenant:d},O&&{redirectUrl:O}),R,"",t);return o(this,Mi,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0}))}}if(p&&(r("token")&&j||r("code")&&S||r("exchangeError")&&C)){const t=yield this.sdk.flow.next(p,u,w,{token:j,exchangeCode:S,exchangeError:C});return o(this,Mi,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(b===f)return x||this.logger.error("Did not get redirect url"),void window.location.assign(x);if(b===v||b===m){if(!_||!U)return void this.logger.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,Ti,"f"))||void 0===a||a.abort(),i(this,Ti,null,"f");try{t=b===v?yield this.sdk.webauthn.helpers.create(U):yield this.sdk.webauthn.helpers.get(U)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const n=yield this.sdk.flow.next(p,u,w,{transactionId:_,response:t,cancelWebauthn:e});o(this,Mi,"f").call(this,n)}if(b===g&&i(this,Ri,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,u,y,{});o(this,Mi,"f").call(this,t)}))),2e3),"f"),!k&&!P)return void this.logger.info("Refreshing the page during a flow is not supported yet");const L={direction:A(+u,+e.stepId),screenState:Object.assign(Object.assign({},I),{lastAuth:{loginId:T,name:this.sdk.getLastUserDisplayName()||T}}),htmlUrl:E(l,`${P||k}.html`)},M=function(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(h)))}catch(t){}return e}(T);P?L.next=(t,e)=>this.sdk.flow.start(c,Object.assign({tenant:d,lastAuth:M},O&&{redirectUrl:O}),R,t,Object.assign(Object.assign({},e),S&&{exchangeCode:S,idpInitiated:!0})):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(L.next=(...t)=>this.sdk.flow.next(p,u,...t)),this.stepState.update(L)}))}onStepChange(t,e){var i;return n(this,void 0,void 0,(function*(){const{htmlUrl:r,direction:s,next:a,screenState:l}=t,c=document.createElement("template"),{body:d}=yield S(r,"text");c.innerHTML=d;const u=c.content.cloneNode(!0),h=((t,e)=>{var n;const o=Array.from(t.querySelectorAll("script[data-id]")).map((n=>{var o;const i=n.getAttribute("data-id"),r=null===(o=t.getElementById(i))||void 0===o?void 0:o.innerHTML,s=Function(r).bind(n.previousSibling,e);return n.remove(),s}));return null===(n=t.querySelector("scripts"))||void 0===n||n.remove(),o})(u,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield o(this,Pi,"m",Di).call(this,u,a):u.querySelectorAll(`button[${p}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),F(u,l),((t,e)=>{var n;e&&(null===(n=null==t?void 0:t.style)||void 0===n||n.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(u.querySelector("div"),null===(i=null==l?void 0:l.totp)||void 0===i?void 0:i.image);const f=()=>n(this,void 0,void 0,(function*(){try{h.forEach((t=>{t()}))}catch(t){this.logger.error(t.message)}this.rootElement.replaceChildren(u);const t=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector('input:not([aria-hidden="true"])');null==e||e.focus()}})(this.rootElement,this.autoFocus,t),o(this,Pi,"m",Ji).call(this,a),o(this,Pi,"m",zi).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${p}="polling"]`)){const t=yield a(y,{});o(this,Mi,"f").call(this,t)}}));s?o(this,Pi,"m",Hi).call(this,f,s):f()}))}}Ri=new WeakMap,Ti=new WeakMap,Li=new WeakMap,Mi=new WeakMap,qi=new WeakMap,Pi=new WeakSet,$i=function(t){const e=t.name;if(!["email"].includes(e)){const n=`user-${e}`;t.name=n,t.addEventListener("input",(()=>{t.name=t.value?e:n}))}},Di=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,Ti,"f"))||void 0===r||r.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield K())){const{options:t,transactionId:r}=(yield o(this,qi,"f").call(this))||{};t&&r&&(o(this,Pi,"m",$i).call(this,s),i(this,Ti,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,Ti,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:r,response:t});o(this,Mi,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Ni=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Wi=function(){return Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${u}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e.value}):t),{})},Fi=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{var o,i;n?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(i=null==t?void 0:t.classList)||void 0===i||i.remove("loading"))}))},Ki=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,Pi,"m",Ni).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,Pi,"m",Fi).call(this,t);const r=o(this,Pi,"m",Wi).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=Object.assign(Object.assign(Object.assign({},s),r),{origin:window.location.origin}),l=yield e(i,a);o(this,Mi,"f").call(this,l)}var n}))},Ji=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,Pi,"m",Ki).call(this,e,t)}}))},Hi=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===k.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")},zi=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",ir);const rr=document.createElement("template");rr.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey; \n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n \n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n } \n\n .msg_desc {\n color: #646464;\n cursor: initial;\n } \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 sr extends HTMLElement{constructor(){super(),Bi.add(this),Vi.set(this,new W({messages:[]})),Zi.set(this,void 0),Gi.set(this,void 0),Xi.set(this,void 0),Yi.set(this,{resize:o(this,Bi,"m",nr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(rr.content.cloneNode(!0)),i(this,Zi,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Gi,o(this,Zi,"f").querySelector(".content"),"f"),i(this,Xi,o(this,Zi,"f").querySelector(".header"),"f")}updateData(t){o(this,Vi,"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]=J(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(o(this,Zi,"f"),o(this,Xi,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Yi,"f").resize),(t=o(this,Zi,"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,Zi,"f").onresize=o(this,Bi,"m",er).bind(this),o(this,Vi,"f").subscribe(o(this,Bi,"m",Qi).bind(this))}disconnectedCallback(){o(this,Vi,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Yi,"f").resize)}}Vi=new WeakMap,Zi=new WeakMap,Gi=new WeakMap,Xi=new WeakMap,Yi=new WeakMap,Bi=new WeakSet,Qi=function(t){o(this,Bi,"m",tr).call(this,t),o(this,Bi,"m",er).call(this)},tr=function(t){o(this,Gi,"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("")},er=function(){o(this,Gi,"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)}))},nr=function(){const[t,e]=J(o(this,Zi,"f"),Number.parseInt(o(this,Zi,"f").style.left,10),Number.parseInt(o(this,Zi,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Zi,"f").style.top=`${e}px`,o(this,Zi,"f").style.left=`${t}px`},customElements.define("descope-debugger",sr);var ar=Object.freeze({__proto__:null,default:sr})}();
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}const r="undefined"!=typeof localStorage,s=r&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",a="descope-login-flow",l="t",c="code",d="err",u="data-exclude-field",h="dls_last_auth",p="data-type",f="redirect",g="poll",v="webauthnCreate",m="webauthnGet",b="v2-alpha",w="submit",y="polling";var k,I,x;function O(t){return new URLSearchParams(window.location.search).get(t)}function j(t){if(window.history.replaceState&&O(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 S(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}`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(k||(k={}));const C=(...t)=>t.join("/").replace(/\/+/g,"/");function E(t,e){const n=new URL(s);return n.pathname=C(n.pathname,t,b,e),n.toString()}function A(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?k.forward:t<e?k.backward:void 0}const _=()=>{const[t="",e=""]=(O(a)||"").split("_");return{executionId:t,stepId:e}};function U(){j(a)}const P=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),R=()=>{const{executionId:t,stepId:e}=_();(t||e)&&U();const n=O(l)||void 0;n&&j(l);const o=O(c)||void 0;o&&j(c);const i=O(d)||void 0;return i&&j(d),{executionId:t,stepId:e,token:n,code:o,exchangeError:i}},T=t=>{let e,n;return(...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}},L=null===(x=null===(I=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===I?void 0:I.brands)||void 0===x?void 0:x.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));var M,q,$,D;function N(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(!N(r,s))return!1}else if(r!==s)return!1}return!0}class W{constructor(t={},{updateOnlyOnChange:e=!0}={}){M.set(this,void 0),q.set(this,{}),$.set(this,0),D.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,M,"f")):t,n=Object.assign(Object.assign({},o(this,M,"f")),e);if(!o(this,D,"f")||!N(o(this,M,"f"),n)){const t=o(this,M,"f");i(this,M,n,"f"),Object.freeze(o(this,M,"f")),setTimeout((()=>{Object.values(o(this,q,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,M,t,"f"),i(this,D,e,"f")}get current(){return Object.assign({},o(this,M,"f"))}subscribe(t){return i(this,$,o(this,$,"f")+1,"f"),o(this,q,"f")[o(this,$,"f")]=t,o(this,$,"f").toString()}unsubscribe(t){const e=!!o(this,q,"f")[t];return e&&delete o(this,q,"f")[t],e}unsubscribeAll(){return i(this,q,{},"f"),!0}}M=new WeakMap,q=new WeakMap,$=new WeakMap,D=new WeakMap;const F=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[${p}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${u}])`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(`[${p}="totp-link"]`).forEach((t=>{t.href=e}))})(t,null===(n=null==e?void 0:e.totp)||void 0===n?void 0:n.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},K=T((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return console.warn("webauthn","Conditional UI is not supported"),!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)))),r=108;return yield Promise.race([i,(n=100,new Promise(((t,e)=>{const i=setTimeout((()=>{e(new Error(`Promise timed out after ${n} ms`))}),n);null==o||o((e=>{clearTimeout(i),t(e)}),(t=>{clearTimeout(i),e(t)}))}))).catch((()=>L()>=r))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),J=(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))]},H={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function z(t){this.message=t}z.prototype=new Error,z.prototype.name="InvalidCharacterError";var B="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new z("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,r=0,s="";o=e.charAt(r++);~o&&(n=i%4?64*n+o:o,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function V(t){this.message=t}function Z(t,e){if("string"!=typeof t)throw new V("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(B(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return B(e)}}(t.split(".")[n]))}catch(t){throw new V("Invalid token specified: "+t.message)}}V.prototype=new Error,V.prototype.name="InvalidTokenError";var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},X="Expected a function",Y="__lodash_hash_undefined__",Q=1/0,tt="[object Function]",et="[object GeneratorFunction]",nt="[object Symbol]",ot=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,it=/^\w*$/,rt=/^\./,st=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,at=/\\(\\)?/g,lt=/^\[object .+?Constructor\]$/,ct="object"==typeof G&&G&&G.Object===Object&&G,dt="object"==typeof self&&self&&self.Object===Object&&self,ut=ct||dt||Function("return this")();var ht,pt=Array.prototype,ft=Function.prototype,gt=Object.prototype,vt=ut["__core-js_shared__"],mt=(ht=/[^.]+$/.exec(vt&&vt.keys&&vt.keys.IE_PROTO||""))?"Symbol(src)_1."+ht:"",bt=ft.toString,wt=gt.hasOwnProperty,yt=gt.toString,kt=RegExp("^"+bt.call(wt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),It=ut.Symbol,xt=pt.splice,Ot=Lt(ut,"Map"),jt=Lt(Object,"create"),St=It?It.prototype:void 0,Ct=St?St.toString:void 0;function Et(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function At(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function _t(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Ut(t,e){for(var n,o,i=t.length;i--;)if((n=t[i][0])===(o=e)||n!=n&&o!=o)return i;return-1}function Pt(t,e){var n;e=function(t,e){if(Dt(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Wt(t))return!0;return it.test(t)||!ot.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Dt(n=e)?n:Mt(n);for(var o=0,i=e.length;null!=t&&o<i;)t=t[qt(e[o++])];return o&&o==i?t:void 0}function Rt(t){if(!Nt(t)||(e=t,mt&&mt in e))return!1;var e,n=function(t){var e=Nt(t)?yt.call(t):"";return e==tt||e==et}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?kt:lt;return n.test(function(t){if(null!=t){try{return bt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Tt(t,e){var n,o,i=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function Lt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Rt(n)?n:void 0}Et.prototype.clear=function(){this.__data__=jt?jt(null):{}},Et.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Et.prototype.get=function(t){var e=this.__data__;if(jt){var n=e[t];return n===Y?void 0:n}return wt.call(e,t)?e[t]:void 0},Et.prototype.has=function(t){var e=this.__data__;return jt?void 0!==e[t]:wt.call(e,t)},Et.prototype.set=function(t,e){return this.__data__[t]=jt&&void 0===e?Y:e,this},At.prototype.clear=function(){this.__data__=[]},At.prototype.delete=function(t){var e=this.__data__,n=Ut(e,t);return!(n<0)&&(n==e.length-1?e.pop():xt.call(e,n,1),!0)},At.prototype.get=function(t){var e=this.__data__,n=Ut(e,t);return n<0?void 0:e[n][1]},At.prototype.has=function(t){return Ut(this.__data__,t)>-1},At.prototype.set=function(t,e){var n=this.__data__,o=Ut(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},_t.prototype.clear=function(){this.__data__={hash:new Et,map:new(Ot||At),string:new Et}},_t.prototype.delete=function(t){return Tt(this,t).delete(t)},_t.prototype.get=function(t){return Tt(this,t).get(t)},_t.prototype.has=function(t){return Tt(this,t).has(t)},_t.prototype.set=function(t,e){return Tt(this,t).set(t,e),this};var Mt=$t((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Wt(t))return Ct?Ct.call(t):"";var e=t+"";return"0"==e&&1/t==-Q?"-0":e}(e);var n=[];return rt.test(t)&&n.push(""),t.replace(st,(function(t,e,o,i){n.push(o?i.replace(at,"$1"):e||t)})),n}));function qt(t){if("string"==typeof t||Wt(t))return t;var e=t+"";return"0"==e&&1/t==-Q?"-0":e}function $t(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(X);var n=function(){var o=arguments,i=e?e.apply(this,o):o[0],r=n.cache;if(r.has(i))return r.get(i);var s=t.apply(this,o);return n.cache=r.set(i,s),s};return n.cache=new($t.Cache||_t),n}$t.Cache=_t;var Dt=Array.isArray;function Nt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Wt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&yt.call(t)==nt}var Ft=function(t,e,n){var o=null==t?void 0:Pt(t,e);return void 0===o?n:o},Kt="/v1/auth/accesskey/exchange",Jt="/v1/auth/otp/verify",Ht="/v1/auth/otp/signin",zt="/v1/auth/otp/signup",Bt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Vt="/v1/auth/otp/signup-in",Zt="/v1/auth/magiclink/verify",Gt="/v1/auth/magiclink/signin",Xt="/v1/auth/magiclink/signup",Yt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},Qt="/v1/auth/magiclink/signup-in",te="/v1/auth/enchantedlink/verify",ee="/v1/auth/enchantedlink/signin",ne="/v1/auth/enchantedlink/signup",oe="/v1/auth/enchantedlink/pending-session",ie={email:"/v1/auth/enchantedlink/update/email"},re="/v1/auth/enchantedlink/signup-in",se="/v1/auth/oauth/authorize",ae="/v1/auth/oauth/exchange",le="/v1/auth/saml/authorize",ce="/v1/auth/saml/exchange",de="/v1/auth/totp/verify",ue="/v1/auth/totp/signup",he="/v1/auth/totp/update",pe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},fe={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},ge={start:"/v1/auth/webauthn/signup-in/start"},ve={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},me="/v1/auth/password/signup",be="/v1/auth/password/signin",we="/v1/auth/password/reset",ye="/v1/auth/password/update",ke="/v1/auth/password/replace",Ie="/v1/auth/password/policy",xe="/v1/auth/refresh",Oe="/v1/auth/logout",je="/v1/auth/logoutall",Se="/v1/auth/me",Ce="/v1/flow/start",Ee="/v1/flow/next";const Ae=6e5,_e=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};var Ue;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Ue||(Ue={}));const Pe=(...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}),{})),Re=t=>void 0===t?void 0:JSON.stringify(t),Te=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Le=({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=>_e().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 _e().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=>{const s=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:l,body:c,headers:d,queryParams:u,method:h,token:p}=s,f=await a((({path:t,baseUrl:e,queryParams:n})=>{const o=new URL(t,e);return n&&(o.search=new URLSearchParams(n).toString()),o})({path:l,baseUrl:t,queryParams:u}),{headers:Pe(Te(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.0.17"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:Re(c),credentials:r||"include"});return(null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Ue.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.post,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.put,token:i}),delete:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Ue.delete,token:i}),hooks:i}};var Me={TOO_MANY_REQUESTS:429};function qe(t,e,n){var o;let i=$e(t);e&&(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 $e(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return Z(t)}function De(t){const{exp:e}=$e(t);return(new Date).getTime()/1e3>e}function Ne(t,e){return qe(t,e,"permissions")}function We(t,e){return qe(t,e,"roles")}const Fe=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Ke(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===Me.TOO_MANY_REQUESTS&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Je=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),He=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),ze=t=>e=>t.test(e),Be=ze(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ve=ze(/^\+[1-9]{1}[0-9]{3,14}$/),Ze=Je(Be,'"{val}" is not a valid email'),Ge=Je(Ve,'"{val}" is not a valid phone number'),Xe=Je((1,t=>t.length>=1),"Minimum length is 1");const Ye=Je((t=>"string"==typeof t),"Input is not a string"),Qe=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>He(...t).validate(n[e]))),e(...n)),tn=t=>[Ye(`"${t}" must be a string`),Xe(`"${t}" must not be empty`)],en=t=>[Ye(`"${t}" must be a string`),Ze()],nn=t=>[Ye(`"${t}" must be a string`),Ge()],on=Qe(tn("accessKey")),rn=t=>({exchange:on((e=>Ke(t.post(Kt,{},{token:e}))))});var sn,an;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(sn||(sn={})),function(t){t.email="email"}(an||(an={}));const ln=Object.assign(Object.assign({},sn),an);var cn;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(cn||(cn={}));const dn=tn("loginId"),un=Qe(tn("token")),hn=Qe(dn),pn=Qe(tn("pendingRef")),fn=Qe(dn,en("email")),gn=t=>({verify:un((e=>Ke(t.post(te,{token:e})))),signIn:hn(((e,n,o,i)=>Ke(t.post(Fe(ee,ln.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:hn(((e,n)=>Ke(t.post(Fe(re,ln.email),{loginId:e,URI:n})))),signUp:hn(((e,n,o)=>Ke(t.post(Fe(ne,ln.email),{loginId:e,URI:n,user:o})))),waitForSession:pn(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||Ae,Ae)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(oe,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Ke(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:fn(((e,n,o,i)=>Ke(t.post(ie.email,{loginId:e,email:n,URI:o},{token:i}))))}}),vn=Qe(tn("flowId")),mn=Qe(tn("executionId"),tn("stepId"),tn("interactionId")),bn=t=>({start:vn(((e,n,o,i,r)=>Ke(t.post(Ce,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,input:r})))),next:mn(((e,n,o,i)=>Ke(t.post(Ee,{executionId:e,stepId:n,interactionId:o,input:i}))))}),wn=tn("loginId"),yn=Qe(tn("token")),kn=Qe(wn),In=Qe(wn,nn("phone")),xn=Qe(wn,en("email")),On=t=>({verify:yn((e=>Ke(t.post(Zt,{token:e})))),signIn:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:kn(((e,o,i,r)=>Ke(t.post(Fe(Gt,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:kn(((e,o,i)=>Ke(t.post(Fe(Xt,n),{loginId:e,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:kn(((e,o)=>Ke(t.post(Fe(Qt,n),{loginId:e,URI:o}))))})),{}),update:{email:xn(((e,n,o,i)=>Ke(t.post(Yt.email,{loginId:e,email:n,URI:o},{token:i})))),phone:Object.keys(sn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:In(((e,o,i,r)=>Ke(t.post(Fe(Yt.phone,n),{loginId:e,phone:o,URI:i},{token:r}))))})),{})}});var jn;!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"}(jn||(jn={}));const Sn=Qe(tn("code")),Cn=t=>({start:Object.keys(jn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:o=!1}={},i,r)=>{const s=await t.post(se,i||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:r});if(!o||!s.ok)return Ke(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:Sn((e=>Ke(t.post(ae,{code:e}))))}),En=tn("loginId"),An=Qe(En,tn("code")),_n=Qe(En),Un=Qe(En,nn("phone")),Pn=Qe(En,en("email")),Rn=t=>({verify:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An(((e,o)=>Ke(t.post(Fe(Jt,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o,i)=>Ke(t.post(Fe(Ht,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o)=>Ke(t.post(Fe(zt,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n((e=>Ke(t.post(Fe(Vt,n),{loginId:e}))))})),{}),update:{email:Pn(((e,n,o)=>Ke(t.post(Bt.email,{loginId:e,email:n},{token:o})))),phone:Object.keys(sn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Un(((e,o,i)=>Ke(t.post(Fe(Bt.phone,n),{loginId:e,phone:o},{token:i}))))})),{})}}),Tn=Qe(tn("tenant")),Ln=Qe(tn("code")),Mn=t=>({start:Tn(((e,n,o,i)=>Ke(t.post(le,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:Ln((e=>Ke(t.post(ce,{code:e}))))}),qn=tn("loginId"),$n=Qe(qn,tn("code")),Dn=Qe(qn),Nn=Qe(qn),Wn=t=>({signUp:Dn(((e,n)=>Ke(t.post(ue,{loginId:e,user:n})))),verify:$n(((e,n,o,i)=>Ke(t.post(de,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Nn(((e,n)=>Ke(t.post(he,{loginId:e},{token:n}))))}),Fn=tn("loginId"),Kn=tn("newPassword"),Jn=Qe(Fn,tn("password")),Hn=Qe(Fn),zn=Qe(Fn,Kn),Bn=Qe(Fn,tn("oldPassword"),Kn),Vn=t=>({signUp:Jn(((e,n,o)=>Ke(t.post(me,{loginId:e,password:n,user:o})))),signIn:Jn(((e,n)=>Ke(t.post(be,{loginId:e,password:n})))),sendReset:Hn(((e,n)=>Ke(t.post(we,{loginId:e,redirectUrl:n})))),update:zn(((e,n,o)=>Ke(t.post(ye,{loginId:e,newPassword:n},{token:o})))),replace:Bn(((e,n,o)=>Ke(t.post(ke,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>Ke(t.get(Ie))}),Zn=[Ye('"loginId" must be a string')],Gn=tn("loginId"),Xn=tn("origin"),Yn=Qe(Gn,Xn,tn("name")),Qn=Qe(Gn,Xn),to=Qe(Zn,Xn),eo=Qe(Gn,Xn,tn("token")),no=Qe(tn("transactionId"),tn("response")),oo=t=>({signUp:{start:Yn(((e,n,o)=>Ke(t.post(pe.start,{user:{loginId:e,name:o},origin:n})))),finish:no(((e,n)=>Ke(t.post(pe.finish,{transactionId:e,response:n}))))},signIn:{start:to(((e,n,o,i)=>Ke(t.post(fe.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:no(((e,n)=>Ke(t.post(fe.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Qn(((e,n)=>Ke(t.post(ge.start,{loginId:e,origin:n}))))},update:{start:eo(((e,n,o)=>Ke(t.post(ve.start,{loginId:e,origin:n},{token:o})))),finish:no(((e,n)=>Ke(t.post(ve.finish,{transactionId:e,response:n}))))}}),io=Qe(tn("token"));var ro,so=Qe([("projectId",ro=tn("projectId"),Je(((t,e)=>n=>He(...e).validate(Ft(n,t)))("projectId",ro))())])((t=>{var e,n;const o=[].concat((null===(e=t.hooks)||void 0===e?void 0:e.beforeRequest)||[]),i=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=Le({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:rn(a),otp:Rn(a),magicLink:On(a),enchantedLink:gn(a),oauth:Cn(a),saml:Mn(a),totp:Wn(a),webauthn:oo(a),password:Vn(a),flow:bn(a),refresh:t=>Ke(a.post(xe,{},{token:t})),logout:t=>Ke(a.post(Oe,{},{token:t})),logoutAll:t=>Ke(a.post(je,{},{token:t})),me:t=>Ke(a.get(Se,{token:t})),isJwtExpired:io(De),getJwtPermissions:io(Ne),getJwtRoles:io(We),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:t=>null==o?void 0:o.reduce(((t,e)=>e(t)),t),afterRequest:async(e,n)=>{(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))}))}}}))}));const ao=(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);var lo=Object.assign(so,{DeliveryMethods:ln});var co="Blocked by CSP",uo="API key required",ho="3.8.2",po="9319";function fo(t,e){var n=[];return function(t,e){var n,o,i=(o=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),{current:function(){return o[0]},postpone:function(){var t=o.shift();void 0!==t&&o.push(t)},exclude:function(){o.shift()}}),r=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=i.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return e===co||e===po}(t)?i.postpone():i.exclude();var e,o=i.current();if(void 0===o)throw t;return(e=r(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(t,(function(t){var o=new Date,i=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},r=e(t);return r.then(i,i),r})).then((function(t){return[t,{attempts:n}]}))}var go="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",vo="Failed to load the JS script of the agent";function mo(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:go;return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error(uo);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(ho):t}))}(String(t),e)}))}(l,s);return fo(t,bo).catch(yo)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function bo(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 Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(l(),i)return function(){throw new Error(co)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){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(vo))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)})).then(wo)}function wo(){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(po);return n}function yo(t){throw t instanceof Error&&t.message===po?new Error(vo):t}
2
+ /*! js-cookie v3.0.1 | MIT */function ko(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 Io=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=ko({},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,"",ko({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,ko({},this.attributes,e))},withConverter:function(e){return t(ko({},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:"/"});const xo=(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},Oo=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||{}},jo=async t=>{const e=await Oo(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},So="undefined"!=typeof localStorage,Co=(t,e)=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),Eo=t=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Ao=t=>So&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),_o="undefined"!=typeof window,Uo=_o&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",Po=(t="",e="")=>({vsid:t,vrid:e}),Ro=(t=!1)=>{const e=localStorage.getItem("fp");if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},To=t=>(t.body&&(t.body.fpData=Ro(!0)||Po()),t),Lo="dls_last_user_login_id",Mo="dls_last_user_display_name",qo=()=>Eo(Lo),$o=()=>Eo(Mo),Do=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=qo(),r=$o();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)},No=t=>async(...e)=>{const n=await t(...e);return Ao(Lo),Ao(Mo),n};function Wo(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Fo="DS",Ko="DSR",Jo=(t={},n)=>{var{refreshJwt:o,sessionJwt:i}=t,r=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&Co(Ko,o),i&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i);Io.set(t,e,{path:n,domain:o,expires:r,sameSite:"Strict",secure:!0})}}(Fo,i,r):Co(Fo,i))};function Ho(){return Eo(Ko)||""}function zo(){return Io.get(Fo)||Eo(Fo)||""}function Bo(){Ao(Ko),Ao(Fo),Io.remove(Fo)}const Vo=t=>Object.assign(t,{token:t.token||Ho()}),Zo=t=>async(...e)=>{const n=await t(...e);return Bo(),n};async function Go(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ni(n.publicKey.challenge),n.publicKey.user.id=ni(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ni(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:oi(n.rawId),type:n.type,response:{attestationObject:oi(n.response.attestationObject),clientDataJSON:oi(n.response.clientDataJSON)}});var n}async function Xo(t){const e=ti(t);return ei(await navigator.credentials.get(e))}async function Yo(t,e){const n=ti(t);return n.signal=e.signal,n.mediation="conditional",ei(await navigator.credentials.get(n))}async function Qo(t=!1){if(!_o)return Promise.resolve(!1);const e=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function ti(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ni(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ni(t.id)})),n}function ei(t){return JSON.stringify({id:t.id,rawId:oi(t.rawId),type:t.type,response:{authenticatorData:oi(t.response.authenticatorData),clientDataJSON:oi(t.response.clientDataJSON),signature:oi(t.response.signature),userHandle:t.response.userHandle?oi(t.response.userHandle):void 0}})}function ni(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function oi(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ii,ri=(ii=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Go(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await Xo(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await Go(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Xo(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Go(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Go,get:Xo,isSupported:Qo,conditional:Yo}}),(...t)=>{const e=ii(...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}),si=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await Qo(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const ai=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 o?(_o?i&&(async t=>{try{if(Ro())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=mo({apiKey:t,endpoint:Uo}),o=await n,{requestId:i}=await o.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(Po(e,i))}catch(t){global.FB_DEBUG&&console.error(t)}})(o).catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(xo(r,{beforeRequest:To}))):t(Object.assign({},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))}}})(),a=t(xo(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await Oo(e);if(401===(null==e?void 0:e.status))r();else if(o){const t=((i=(t=>{const e=t.split(".");try{if(3===e.length){const t=JSON.parse(window.atob(e[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(t){}return null})(o))?i.getTime()-(new Date).getTime():0)-2e4;r(),s((()=>a.refresh(n)),t)}var i}}));return ao(a,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.0.18"},e.baseHeaders)}))),(t=>e=>{const n=Wo(),o=Wo(),i=t(xo(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await jo(e);t&&o.pub(t);const{sessionJwt:i}=await Oo(e);i&&n.pub(i)}}})),r=ao(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=>e=>{const n=t(xo(e,{afterRequest:async(t,e)=>{var n;const o=await jo(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=>{Co(Lo,t)})(i),(t=>{Co(Mo,t)})(r))}}));let o=ao(n,["flow.start"],Do);return o=ao(o,["logout","logoutAll"],No),Object.assign(o,{getLastUserLoginId:qo,getLastUserDisplayName:$o})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i}=n,r=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!_o)return o&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),t(r);const s=t(xo(r,{beforeRequest:Vo,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?Bo():Jo(await Oo(e),i)}})),a=ao(s,["logout","logoutAll"],Zo);return Object.assign(a,{getRefreshToken:Ho,getSessionToken:zo})}))(((...t)=>{const e=lo(...t);return Object.assign(Object.assign({},e),{flow:si(e),webauthn:ri(e)})})),li=document.createElement("template");var ci,di,ui,hi,pi,fi,gi,vi,mi,bi,wi,yi,ki,Ii,xi,Oi,ji,Si,Ci,Ei,Ai,_i,Ui,Pi,Ri,Ti,Li,Mi,qi,$i,Di,Ni,Wi,Fi,Ki,Ji,Hi,zi,Bi,Vi,Zi,Gi,Xi,Yi,Qi,tr,er,nr;li.innerHTML='\n\t<style>\n\t\t:host {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<div id="wc-root"></div>\n\t';class or extends HTMLElement{constructor(t){super(),ci.add(this),di.set(this,!1),ui.set(this,new W),hi.set(this,new W),this.nextRequestStatus=new W({isLoading:!1}),pi.set(this,void 0),fi.set(this,{popstate:o(this,ci,"m",yi).bind(this)}),gi.set(this,void 0),xi.set(this,T((()=>n(this,void 0,void 0,(function*(){const t=E(this.projectId,"config.json");try{const{body:e,headers:n}=yield S(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){this.logger.error("Cannot get config file","make sure that your projectId & flowId are correct")}return{}}))))),this.logger={error:(t,e="")=>{console.error(t,e,new Error),o(this,ci,"m",_i).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},i(this,gi,t,"f"),o(this,ci,"m",vi).call(this)}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"]}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get baseUrl(){return this.getAttribute("base-url")||void 0}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 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 telemetryKey(){return this.getAttribute("telemetryKey")||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}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,xi,"f").call(this);return t}))}getFlowConfig(){var t;return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,xi,"f").call(this);return(null===(t=null==e?void 0:e.flows)||void 0===t?void 0:t[this.flowId])||{}}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,ci,"m",mi).call(this))return void o(this,ci,"m",bi).call(this);o(this,ci,"m",wi).call(this),o(this,ci,"m",ji).call(this),o(this,ci,"m",Oi).call(this),o(this,ci,"m",Ui).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s}=R();window.addEventListener("popstate",o(this,fi,"f").popstate),o(this,ui,"f").subscribe(o(this,ci,"m",Ii).bind(this)),o(this,hi,"f").subscribe(o(this,ci,"m",Ai).bind(this)),o(this,ui,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:e,executionId:t,token:n,code:r,exchangeError:s,telemetryKey:this.telemetryKey}),o(this,hi,"f").update({isDebug:this.debug}),i(this,di,!0,"f")}}))}disconnectedCallback(){o(this,ui,"f").unsubscribeAll(),o(this,hi,"f").unsubscribeAll(),o(this,ci,"m",Ei).call(this),window.removeEventListener("popstate",o(this,fi,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,di,"f")&&e!==n&&or.observedAttributes.includes(t)){o(this,ci,"m",wi).call(this);const i=null===e;o(this,ui,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,U()),{[P(t)]:n,stepId:r,executionId:s}})),o(this,hi,"f").update({isDebug:this.debug})}}}di=new WeakMap,ui=new WeakMap,hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,xi=new WeakMap,ci=new WeakSet,vi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(li.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},mi=function(){const t=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);return!this.shadowRoot.host.closest("form")&&t},bi=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},wi=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"];if(or.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[P(e)])throw Error(`${e} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},yi=function(){const{stepId:t,executionId:e}=_();o(this,ui,"f").update({stepId:t,executionId:e})},ki=function(t,e,o){const i=o||void 0,r=!!i;this.sdk=ai(Object.assign(Object.assign({persistTokens:!0},or.sdkConfigOverrides),{projectId:t,baseUrl:e,fpKey:i,fpLoad:r})),["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)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Ii=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n,telemetryKey:r}=t;if(i("projectId")||i("baseUrl")||i("telemetryKey")){if(!e)return;o(this,ci,"m",ki).call(this,e,n,r)}o(this,gi,"f").call(this,t)}))},Oi=function(){var t,e,i,r;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,xi,"f").call(this);null===(r=null===(i=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t[this.theme])||void 0===e?void 0:e.typography)||void 0===i?void 0:i.fontFamilies)||void 0===r||r.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},ji=function(){o(this,ci,"m",Si).call(this),o(this,ci,"m",Ci).call(this)},Si=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=E(this.projectId,"theme.css");try{const{body:n}=yield S(e,"text");t.innerText=n}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},Ci=function(){this.rootElement.setAttribute("data-theme",this.theme)},Ei=function(){var t;null===(t=o(this,pi,"f"))||void 0===t||t.remove(),i(this,pi,null,"f")},Ai=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield Promise.resolve().then((function(){return ar})),i(this,pi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,pi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,pi,"f"))):o(this,ci,"m",Ei).call(this)}))},_i=function(t,e){var n;t&&this.debug&&(null===(n=o(this,pi,"f"))||void 0===n||n.updateData({title:t,description:e}))},Ui=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("button");if(1===e.length)return void e[0].click();const n=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));1===n.length&&n[0].click()}},or.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.0.25"}};class ir extends or{constructor(){const t=new W;super(t.update.bind(t)),Pi.add(this),this.stepState=new W({},{updateOnlyOnChange:!1}),Ri.set(this,void 0),Ti.set(this,null),Li.set(this,(()=>{clearInterval(o(this,Ri,"f")),i(this,Ri,null,"f")})),Mi.set(this,(t=>{var e,n,i,s,a,l,c,d,u;if(!(null==t?void 0:t.ok)){o(this,Li,"f").call(this),o(this,Pi,"m",zi).call(this,"error",null==t?void 0:t.error);const r=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;return void this.logger.error((null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorDescription)||r,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const p=null===(d=null===(c=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===d?void 0:d.errorText;p&&this.logger.error(p),(null===(u=t.data)||void 0===u?void 0:u.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:f,authInfo:v,lastAuth:m}=t.data;if("completed"===f)return function(t){(null==t?void 0:t.authMethod)&&r&&localStorage.setItem(h,JSON.stringify(t))}(m),o(this,Li,"f").call(this),void o(this,Pi,"m",zi).call(this,"success",v);const{executionId:b,stepId:w,action:y,screen:k,redirect:I,webauthn:x}=t.data;y!==g?this.flowState.update({stepId:w,executionId:b,action:y,redirectTo:null==I?void 0:I.url,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options}):this.flowState.update({action:y})})),qi.set(this,T((()=>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.logger.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.logger.error("Webauthn start failed",t.message)}}))))),this.flowState=t}static set sdkConfigOverrides(t){or.sdkConfigOverrides=t}connectedCallback(){const t=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var e,o;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield t.connectedCallback.call(this)}))}disconnectedCallback(){super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll()}onFlowChange(t,e,r){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:l,flowId:c,tenant:d,stepId:u,executionId:p,action:b,screenId:k,screenState:I,redirectTo:x,redirectUrl:O,token:j,code:S,exchangeError:C,webauthnTransactionId:_,webauthnOptions:U}=t;let P,R;o(this,Ri,"f")&&o(this,Li,"f").call(this);const T=this.sdk.getLastUserLoginId();if(!p){if(!c)return;const t=yield this.getFlowConfig();if(({startScreenId:P=t.startScreenId,conditionInteractionId:R}=((t,e)=>{var n;const o=null===(n=H[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(t.condition,{loginId:T,code:S})),!P){const t=S?{exchangeCode:S,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(c,Object.assign({tenant:d},O&&{redirectUrl:O}),R,"",t);return o(this,Mi,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0}))}}if(p&&(r("token")&&j||r("code")&&S||r("exchangeError")&&C)){const t=yield this.sdk.flow.next(p,u,w,{token:j,exchangeCode:S,exchangeError:C});return o(this,Mi,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(b===f)return x||this.logger.error("Did not get redirect url"),void window.location.assign(x);if(b===v||b===m){if(!_||!U)return void this.logger.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,Ti,"f"))||void 0===a||a.abort(),i(this,Ti,null,"f");try{t=b===v?yield this.sdk.webauthn.helpers.create(U):yield this.sdk.webauthn.helpers.get(U)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const n=yield this.sdk.flow.next(p,u,w,{transactionId:_,response:t,cancelWebauthn:e});o(this,Mi,"f").call(this,n)}if(b===g&&i(this,Ri,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,u,y,{});o(this,Mi,"f").call(this,t)}))),2e3),"f"),!k&&!P)return void this.logger.info("Refreshing the page during a flow is not supported yet");const L={direction:A(+u,+e.stepId),screenState:Object.assign(Object.assign({},I),{lastAuth:{loginId:T,name:this.sdk.getLastUserDisplayName()||T}}),htmlUrl:E(l,`${P||k}.html`)},M=function(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(h)))}catch(t){}return e}(T);P?L.next=(t,e)=>this.sdk.flow.start(c,Object.assign({tenant:d,lastAuth:M},O&&{redirectUrl:O}),R,t,Object.assign(Object.assign({},e),S&&{exchangeCode:S,idpInitiated:!0})):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(L.next=(...t)=>this.sdk.flow.next(p,u,...t)),this.stepState.update(L)}))}onStepChange(t,e){var i;return n(this,void 0,void 0,(function*(){const{htmlUrl:r,direction:s,next:a,screenState:l}=t,c=document.createElement("template"),{body:d}=yield S(r,"text");c.innerHTML=d;const u=c.content.cloneNode(!0),h=((t,e)=>{var n;const o=Array.from(t.querySelectorAll("script[data-id]")).map((n=>{var o;const i=n.getAttribute("data-id"),r=null===(o=t.getElementById(i))||void 0===o?void 0:o.innerHTML,s=Function(r).bind(n.previousSibling,e);return n.remove(),s}));return null===(n=t.querySelector("scripts"))||void 0===n||n.remove(),o})(u,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield o(this,Pi,"m",Di).call(this,u,a):u.querySelectorAll(`button[${p}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),F(u,l),((t,e)=>{var n;e&&(null===(n=null==t?void 0:t.style)||void 0===n||n.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(u.querySelector("div"),null===(i=null==l?void 0:l.totp)||void 0===i?void 0:i.image);const f=()=>n(this,void 0,void 0,(function*(){try{h.forEach((t=>{t()}))}catch(t){this.logger.error(t.message)}this.rootElement.replaceChildren(u);const t=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector('input:not([aria-hidden="true"])');null==e||e.focus()}})(this.rootElement,this.autoFocus,t),o(this,Pi,"m",Ji).call(this,a),o(this,Pi,"m",zi).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${p}="polling"]`)){const t=yield a(y,{});o(this,Mi,"f").call(this,t)}}));s?o(this,Pi,"m",Hi).call(this,f,s):f()}))}}Ri=new WeakMap,Ti=new WeakMap,Li=new WeakMap,Mi=new WeakMap,qi=new WeakMap,Pi=new WeakSet,$i=function(t){const e=t.name;if(!["email"].includes(e)){const n=`user-${e}`;t.name=n,t.addEventListener("input",(()=>{t.name=t.value?e:n}))}},Di=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,Ti,"f"))||void 0===r||r.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield K())){const{options:t,transactionId:r}=(yield o(this,qi,"f").call(this))||{};t&&r&&(o(this,Pi,"m",$i).call(this,s),i(this,Ti,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,Ti,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:r,response:t});o(this,Mi,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Ni=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Wi=function(){return Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${u}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e.value}):t),{})},Fi=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{var o,i;n?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(i=null==t?void 0:t.classList)||void 0===i||i.remove("loading"))}))},Ki=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,Pi,"m",Ni).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,Pi,"m",Fi).call(this,t);const r=o(this,Pi,"m",Wi).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=Object.assign(Object.assign(Object.assign({},s),r),{origin:window.location.origin}),l=yield e(i,a);o(this,Mi,"f").call(this,l)}var n}))},Ji=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,Pi,"m",Ki).call(this,e,t)}}))},Hi=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===k.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")},zi=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",ir);const rr=document.createElement("template");rr.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey; \n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n \n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n } \n\n .msg_desc {\n color: #646464;\n cursor: initial;\n } \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 sr extends HTMLElement{constructor(){super(),Bi.add(this),Vi.set(this,new W({messages:[]})),Zi.set(this,void 0),Gi.set(this,void 0),Xi.set(this,void 0),Yi.set(this,{resize:o(this,Bi,"m",nr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(rr.content.cloneNode(!0)),i(this,Zi,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Gi,o(this,Zi,"f").querySelector(".content"),"f"),i(this,Xi,o(this,Zi,"f").querySelector(".header"),"f")}updateData(t){o(this,Vi,"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]=J(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(o(this,Zi,"f"),o(this,Xi,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Yi,"f").resize),(t=o(this,Zi,"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,Zi,"f").onresize=o(this,Bi,"m",er).bind(this),o(this,Vi,"f").subscribe(o(this,Bi,"m",Qi).bind(this))}disconnectedCallback(){o(this,Vi,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Yi,"f").resize)}}Vi=new WeakMap,Zi=new WeakMap,Gi=new WeakMap,Xi=new WeakMap,Yi=new WeakMap,Bi=new WeakSet,Qi=function(t){o(this,Bi,"m",tr).call(this,t),o(this,Bi,"m",er).call(this)},tr=function(t){o(this,Gi,"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("")},er=function(){o(this,Gi,"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)}))},nr=function(){const[t,e]=J(o(this,Zi,"f"),Number.parseInt(o(this,Zi,"f").style.left,10),Number.parseInt(o(this,Zi,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Zi,"f").style.top=`${e}px`,o(this,Zi,"f").style.left=`${t}px`},customElements.define("descope-debugger",sr);var ar=Object.freeze({__proto__:null,default:sr})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-component",
3
- "version": "2.0.23",
3
+ "version": "2.0.25",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/web-component",
6
6
  "bugs": {
@@ -36,7 +36,7 @@
36
36
  "eslint-config-airbnb-typescript": "17.0.0",
37
37
  "eslint-config-prettier": "8.8.0",
38
38
  "eslint-config-standard": "17.0.0",
39
- "eslint-import-resolver-typescript": "3.5.4",
39
+ "eslint-import-resolver-typescript": "3.5.5",
40
40
  "eslint-plugin-import": "2.27.5",
41
41
  "eslint-plugin-jest": "27.2.1",
42
42
  "eslint-plugin-jest-dom": "4.0.3",
@@ -65,7 +65,7 @@
65
65
  "typescript": "^4.5.3"
66
66
  },
67
67
  "dependencies": {
68
- "@descope/web-js-sdk": "1.0.16"
68
+ "@descope/web-js-sdk": "1.0.18"
69
69
  },
70
70
  "overrides": {
71
71
  "terser": "5.16.8"