@descope/user-profile-widget 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
- * @descope/user-profile-widget v0.10.2
3
+ * @descope/user-profile-widget v0.11.0
4
4
  */
5
- this["descope-user-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{let t,n;return(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)},l=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}let f=class{constructor(e={},{forceUpdate:t=!1}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,c,"f")):e,n=Object.assign(Object.assign({},i(this,c,"f")),t);if(i(this,h,"f")||!p(i(this,c,"f"),n)){const e=i(this,c,"f");o(this,c,n,"f"),Object.freeze(i(this,c,"f")),setTimeout((()=>{Object.values(i(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,c,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,c,"f"))}subscribe(e){return o(this,u,i(this,u,"f")+1,"f"),i(this,d,"f")[i(this,u,"f")]=e,i(this,u,"f").toString()}unsubscribe(e){const t=!!i(this,d,"f")[e];return t&&delete i(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const g=["error","warn","info","debug"],v={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},m=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,v))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||v),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return g.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},s})),b="undefined"!=typeof localStorage,w="https://static.descope.com/pages",y="https://static2.descope.com/pages",k=b&&localStorage.getItem("base.content.url")||"",I=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,S=l((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),C=l((e=>{var t,n;const o=r(m,S)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),x=e=>t=>{var n,o,s;const a=r(m,S,C)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},s};x.missingAttrValidator=I;const A=l((e=>{const t=r(x({"project-id":I}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),O=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),j="Trying the next fallback URL...",E=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const U=l((e=>{var t,n,s,a,l,c,d;const u=r(m,A,O)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=i(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;i(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await E(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${j}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${j}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=k||this.baseStaticUrl;if(r)return i(this,t,"m",c).call(this,e,r);i(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),i(this,a,"f").clear());const l=[];if(i(this,s,"f"))l.push(i(this,t,"m",c).call(this,e,i(this,s,"f"))),i(this,s,"f")===w&&l.push(i(this,t,"m",c).call(this,e,y));else{const n=this.baseUrl+"/pages";this.baseUrl&&!i(this,a,"f").has(n)&&l.push(i(this,t,"m",c).call(this,e,n)),i(this,a,"f").has(w)||l.push(i(this,t,"m",c).call(this,e,w)),l.push(i(this,t,"m",c).call(this,e,y))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=w}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},d})),R=l((e=>{var t,n;const o=r(x({"project-id":I}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),T=l((e=>{var t,n,s,a,l;const c=r(U,R,S)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,s,"f")||o(this,s,i(this,a,"f").call(this),"f"),i(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},l})),M=l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(S,m)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),"debug"===e&&i(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Td})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),W=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],_=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},$=(e,t,n)=>new Promise(((i,o)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),i(r)},r.src=t.toString(),document.body.appendChild(r)})),L=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},P=l((e=>{const t=r(m)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:r}=i,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await L(s,r),i}catch(e){t(i,!0)}else try{return await $(e,o,r),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${_(a)}`};return o&&(l.integrity=o),[...e,l]}),[]))([...i,this.baseCdnUrl,...W],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),N="base.ui.components.url",D=b&&localStorage.getItem(N),F=l((e=>{var t,n,s,a,l,c,d;const u=r(m,T,P)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return i(this,a,"f")||o(this,a,i(this,t,"m",c).call(this),"f"),i(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await i(this,t,"m",n).call(this),o=await i(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[D],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),q=l((e=>{var t,n,o;const s=r(S,C)(e);return o=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class z{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const V=l((e=>{const t=r(q)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new z(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),H="content-root",K="root",B=l((e=>{const t=r(V)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${H}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${H} {\n height: 100%;\n }\n #${K} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(H),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),J="descope-modal";var Z;let X=class{constructor(e,t){Z.set(this,void 0),this.nodeName="",o(this,Z,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(i(this,Z,"f"))}get ele(){var e,t;const n="function"==typeof i(this,Z,"f")?i(this,Z,"f").call(this):i(this,Z,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};Z=new WeakMap;let G=class extends X{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}},Y=class extends X{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}},Q=class extends X{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}},ee=class extends Y{get flowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id"))||""}get enableMode(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("enable-mode")}};var te;let ne=class extends X{constructor(){super(...arguments),te.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,te,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,te,"f").content.cloneNode(!0)))}setContent(e){o(this,te,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};te=new WeakMap;let ie=class extends X{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},oe=class extends X{constructor(){super(...arguments),this.nodeName="descope-combo-box"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},re=class extends X{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},se=class extends X{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}},ae=class extends X{constructor(){super(...arguments),this.nodeName="descope-trusted-devices"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onRemoveDeviceClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-device-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-device-clicked",n)}}},le=class extends oe{get action(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-action"))||""}get refreshTimeout(){var e;return Number(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-refresh-timeout"))||500}get shouldReload(){return"reload"===this.action}};const ce=l((e=>{var t,n;const o=r(S,B,F)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ne{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(J);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([J]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),de="descope-notification",ue=l((e=>{var t,n;const o=r(S,B,F)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ie{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(de);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([de])}},t=new WeakMap,n})),he="theme",pe=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+pe(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),""),fe=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ge=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,b,w,y;const k=r(x({theme:fe}),U,S,F,T,B,C,V)(e);return y=class extends k{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),l.set(this,void 0),m.set(this,(()=>{i(this,t,"m",b).call(this),i(this,w,"f").call(this,"os"===this.getAttribute("theme"))})),w.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",b).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||he}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,m,"f").call(this),await Promise.all([i(this,t,"m",u).call(this),i(this,t,"m",p).call(this)]),await i(this,t,"m",h).call(this),this.observeAttributes(["theme"],i(this,m,"f")),this.observeAttributes(["theme-override"],(()=>i(this,t,"m",h).call(this))),this.observeAttributes(["style-id"],(()=>{o(this,l,null,"f"),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this)}))}},n=new WeakMap,s=new WeakMap,l=new WeakMap,m=new WeakMap,w=new WeakMap,t=new WeakSet,a=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,r,s,a;const l=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${pe({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},c=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(N))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(N),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},d=function(){return i(this,l,"f")||(o(this,l,i(this,t,"m",c).call(this),"f"),i(this,l,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,l,"f")},u=async function(){var e,r;const s=await i(this,t,"a",d);s&&(i(this,n,"f")||o(this,n,this.injectStyle(""),"f"),i(this,n,"f").replaceSync(((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"")))},h=async function(){var e;this.themeOverride?(i(this,s,"f")||o(this,s,this.injectStyle(""),"f"),i(this,s,"f").replaceSync(i(this,t,"m",a).call(this))):null===(e=i(this,s,"f"))||void 0===e||e.replaceSync("")},p=async function(){var e,n;const o=await i(this,t,"a",d);if(!o)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},f=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},g=async function(){const e=await i(this,t,"m",f).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},v=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},b=function(){i(this,t,"m",g).call(this),i(this,t,"m",v).call(this)},y}));var ve=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),me=()=>Math.random().toString(36).substring(7).split("").join("."),be={INIT:`@@redux/INIT${me()}`,REPLACE:`@@redux/REPLACE${me()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${me()}`};function we(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function ye(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function ke(e){let t=typeof e;return t=ye(e),t}function Ie(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${ke(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${ke(n)}'`);return n(Ie)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${ke(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),r=null}}}function h(e){if(!we(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${ke(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${ke(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=i(o,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:be.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${ke(e)}`);i=e,h({type:be.REPLACE})},[ve]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${ke(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[ve](){return this}}}}}function Se(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Ce(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&Se(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const i=Object.keys(n);let o,r;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:be.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:be.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${be.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const i=function(e,t,n,i){const o=Object.keys(t),r=n&&n.type===be.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!we(e))return`The ${r} has unexpected type of "${ke(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!i[e]));return s.forEach((e=>{i[e]=!0})),n&&n.type===be.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);i&&Se(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||i.length!==Object.keys(e).length,s?a:e}}function xe(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Ae(e){return we(e)&&"type"in e&&"string"==typeof e.type}var Oe=Symbol.for("immer-nothing"),je=Symbol.for("immer-draftable"),Ee=Symbol.for("immer-state"),Ue=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function Re(e,...t){{const n=Ue[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var Te=Object.getPrototypeOf;function Me(e){return!!e&&!!e[Ee]}function We(e){return!!e&&($e(e)||Array.isArray(e)||!!e[je]||!!e.constructor?.[je]||Fe(e)||qe(e))}var _e=Object.prototype.constructor.toString();function $e(e){if(!e||"object"!=typeof e)return!1;const t=Te(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===_e}function Le(e,t){0===Pe(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function Pe(e){const t=e[Ee];return t?t.type_:Array.isArray(e)?1:Fe(e)?2:qe(e)?3:0}function Ne(e,t){return 2===Pe(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function De(e,t,n){const i=Pe(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function Fe(e){return e instanceof Map}function qe(e){return e instanceof Set}function ze(e){return e.copy_||e.base_}function Ve(e,t){if(Fe(e))return new Map(e);if(qe(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&$e(e)){if(!Te(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ee];let i=Reflect.ownKeys(n);for(let t=0;t<i.length;t++){const o=i[t],r=n[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(Te(e),n)}function He(e,t=!1){return Be(e)||Me(e)||!We(e)||(Pe(e)>1&&(e.set=e.add=e.clear=e.delete=Ke),Object.freeze(e),t&&Le(e,((e,t)=>He(t,!0)))),e}function Ke(){Re(2)}function Be(e){return Object.isFrozen(e)}var Je,Ze={};function Xe(e){const t=Ze[e];return t||Re(0,e),t}function Ge(){return Je}function Ye(e,t){t&&(Xe("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Qe(e){et(e),e.drafts_.forEach(nt),e.drafts_=null}function et(e){e===Je&&(Je=e.parent_)}function tt(e){return Je={drafts_:[],parent_:Je,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function nt(e){const t=e[Ee];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function it(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ee].modified_&&(Qe(t),Re(4)),We(e)&&(e=ot(t,e),t.parent_||st(t,e)),t.patches_&&Xe("Patches").generateReplacementPatches_(n[Ee].base_,e,t.patches_,t.inversePatches_)):e=ot(t,n,[]),Qe(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Oe?e:void 0}function ot(e,t,n){if(Be(t))return t;const i=t[Ee];if(!i)return Le(t,((o,r)=>rt(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return st(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const t=i.copy_;let o=t,r=!1;3===i.type_&&(o=new Set(t),t.clear(),r=!0),Le(o,((o,s)=>rt(e,i,t,o,s,n,r))),st(e,t,!1),n&&e.patches_&&Xe("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function rt(e,t,n,i,o,r,s){if(o===n&&Re(5),Me(o)){const s=ot(e,o,r&&t&&3!==t.type_&&!Ne(t.assigned_,i)?r.concat(i):void 0);if(De(n,i,s),!Me(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(We(o)&&!Be(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ot(e,o),t&&t.scope_.parent_||st(e,o)}}function st(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&He(t,n)}var at={get(e,t){if(t===Ee)return e;const n=ze(e);if(!Ne(n,t))return function(e,t,n){const i=dt(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}(e,n,t);const i=n[t];return e.finalized_||!We(i)?i:i===ct(e.base_,t)?(ht(e),e.copy_[t]=pt(i,e)):i},has:(e,t)=>t in ze(e),ownKeys:e=>Reflect.ownKeys(ze(e)),set(e,t,n){const i=dt(ze(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=ct(ze(e),t),o=i?.[Ee];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||Ne(e.base_,t)))return!0;ht(e),ut(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==ct(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,ht(e),ut(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=ze(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){Re(11)},getPrototypeOf:e=>Te(e.base_),setPrototypeOf(){Re(12)}},lt={};function ct(e,t){const n=e[Ee];return(n?ze(n):e)[t]}function dt(e,t){if(!(t in e))return;let n=Te(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Te(n)}}function ut(e){e.modified_||(e.modified_=!0,e.parent_&&ut(e.parent_))}function ht(e){e.copy_||(e.copy_=Ve(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Le(at,((e,t)=>{lt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),lt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Re(13),lt.set.call(this,e,t,void 0)},lt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Re(14),at.set.call(this,e[0],t,n,e[0])};function pt(e,t){const n=Fe(e)?Xe("MapSet").proxyMap_(e,t):qe(e)?Xe("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Ge(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=at;n&&(o=[i],r=lt);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:Ge()).drafts_.push(n),n}function ft(e){return Me(e)||Re(10,e),gt(e)}function gt(e){if(!We(e)||Be(e))return e;const t=e[Ee];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Ve(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Ve(e,!0);return Le(n,((e,t)=>{De(n,e,gt(t))})),t&&(t.finalized_=!1),n}var vt=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const i=this;return function(e=n,...o){return i.produce(e,(e=>t.call(this,e,...o)))}}let i;if("function"!=typeof t&&Re(6),void 0!==n&&"function"!=typeof n&&Re(7),We(e)){const o=tt(this),r=pt(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?Qe(o):et(o)}return Ye(o,n),it(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===Oe&&(i=void 0),this.autoFreeze_&&He(i,!0),n){const t=[],o=[];Xe("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}Re(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,i;const o=this.produce(e,t,((e,t)=>{n=e,i=t}));return[o,n,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){We(e)||Re(8),Me(e)&&(e=ft(e));const t=tt(this),n=pt(e,void 0);return n[Ee].isManual_=!0,et(t),n}finishDraft(e,t){const n=e&&e[Ee];n&&n.isManual_||Re(9);const{scope_:i}=n;return Ye(i,t),it(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const i=Xe("Patches").applyPatches_;return Me(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},mt=vt.produce;vt.produceWithPatches.bind(vt),vt.setAutoFreeze.bind(vt),vt.setUseStrictShallowCopy.bind(vt),vt.applyPatches.bind(vt),vt.createDraft.bind(vt),vt.finishDraft.bind(vt);var bt=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},wt=(e,t,n)=>{const{memoize:i,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=i((()=>({})),...o);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},yt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var kt=e=>Array.isArray(e)?e:[e];function It(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function St(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var Ct="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},xt=0,At=1;function Ot(){return{s:xt,v:void 0,o:null,p:null}}function jt(e,t={}){let n=Ot();const{resultEqualityCheck:i}=t;let o,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const i=e.get(n);void 0===i?(t=Ot(),e.set(n,t)):t=i}else{let e=t.p;null===e&&(t.p=e=new Map);const i=e.get(n);void 0===i?(t=Ot(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===At)l=t.v;else if(l=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,l)&&(l=e,0!==r&&r--);o="object"==typeof l&&null!==l||"function"==typeof l?new Ct(l):l}return a.s=At,a.v=l,l}return s.clearCache=()=>{n=Ot(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Et(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=jt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=kt(c),f=kt(u),g=It(e),v=l((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){o++;const e=St(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...yt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:bt},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:wt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=St(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:l,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var Ut=Et(jt),Rt=Object.assign(((e,t=Ut)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e),i=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,i)=>(e[n[i]]=t,e)),{})));return i}),{withTypes:()=>Rt});function Tt(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var Mt=Tt(),Wt=Tt;((...e)=>{const t=Et(...e)})(jt);var _t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?xe:xe.apply(null,arguments)},$t=e=>e&&"function"==typeof e.match;function Lt(e,t){function n(...n){if(t){let i=t(...n);if(!i)throw new Error("prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Ae(t)&&t.type===e,n}function Pt(e){return"function"==typeof e&&"type"in e&&$t(e)}function Nt(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Dt=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Ft(e){return We(e)?mt(e,(()=>{})):e}function qt(e,t,n){if(e.has(t)){let i=e.get(t);return n.update&&(i=n.update(i,t,e),e.set(t,i)),i}if(!n.insert)throw new Error("No insert provided for key not already in map");const i=n.insert(t,e);return e.set(t,i),i}function zt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Vt(e,t,n){const i=Ht(e,t,n);return{detectMutations:()=>Kt(e,t,i,n)}}function Ht(e,t=[],n,i="",o=new Set){const r={value:n};if(!e(n)&&!o.has(n)){o.add(n),r.children={};for(const o in n){const s=i?i+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=Ht(e,t,n[o],s))}}return r}function Kt(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in i)l[e]=!0;const c=t.length>0;for(let o in l){const s=r?r+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Kt(e,t,n.children[o],i[o],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Bt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||we(e)}function Jt(e,t="",n=Bt,i,o=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),l=o.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Jt(c,a,n,i,o,r),s))return s}return r&&Zt(e)&&r.add(e),!1}function Zt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Zt(t))return!1;return!0}function Xt(e){return"boolean"==typeof e}var Gt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Dt;if(t&&(Xt(t)?r.push(Mt):r.push(Wt(t.extraArgument))),n){let e={};Xt(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,i,o){return JSON.stringify(e,n(t,o),i)},n=function(e,t){let n=[],i=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?i.splice(s,1/0,o):i.push(o),~n.indexOf(r)&&(r=t.call(this,o,r))}else n.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:i=zt,ignoredPaths:o,warnAfter:r=32}=e;const s=Vt.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>l=>{const c=Nt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(i){let e={};Xt(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=Bt,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!Ae(u))return c(u);const h=c(u),p=Nt(s,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Jt(u,"",t,n,o,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const i=Jt(e.getState(),"",t,n,r,d);if(i){const{keyPath:e,value:t}=i;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};Xt(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=Pt}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},Yt=e=>t=>{setTimeout(t,e)},Qt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Yt(10),en=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Dt(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?Qt:"callback"===e.type?e.queueNotification:Yt(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,l(c))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function tn(e){const t=Gt(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!we(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=Ce(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(l=i(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=xe;o&&(c=_t({trace:!0,..."object"==typeof o&&o}));const d=function(...e){return t=>(n,i)=>{const o=t(n,i);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=xe(...a)(o.dispatch),{...o,dispatch:r}}}(...l),u=en(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Ie(a,r,c(...h))}function nn(e){const t={},n=[];let i;const o={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if(i)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(i)throw new Error("`builder.addDefaultCase` can only be called once");return i=e,o}};return e(o),[t,n,i]}function on(...e){return t=>e.some((e=>((e,t)=>$t(e)?e.match(t):e(t))(e,t)))}var rn=["name","message","stack","code"],sn=class{constructor(e,t){this.payload=e,this.meta=t}_type},an=class{constructor(e,t){this.payload=e,this.meta=t}_type},ln=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of rn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},cn=(()=>{function e(e,t,n){const i=Lt(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Lt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Lt(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||ln)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new sn(e,t),fulfillWithValue:(e,t)=>new an(e,t)})).then((t=>{if(t instanceof sn)throw t;return t instanceof an?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof sn?r(null,c,e,t.payload,t.meta):r(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(dn)})}}),{pending:o,rejected:r,fulfilled:i,settled:on(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function dn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var un=Symbol.for("rtk-slice-createasyncthunk");function hn(e,t){return`${e}/${t}`}function pn(e,t,n,i){function o(o,...r){let s=n.call(e,o);if(void 0===s){if(!i)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return o.unwrapped=t,o}var fn=function({creators:e}={}){const t=e?.asyncThunk?.[un];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?nn(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[i,o,r]=nn(t);if(function(e){return"function"==typeof e}(e))n=()=>Ft(e());else{const t=Ft(e);n=()=>t}function s(e=n(),t){let s=[i[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(Me(e)){const i=n(e,t);return void 0===i?e:i}if(We(e))return mt(e,(e=>n(e,t)));{const i=n(e,t);if(void 0===i){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return i}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);i&&e.addDefaultCase(i)}))}r.forEach((i=>{const r=o[i],s={reducerName:i,type:hn(n,i),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},i,o){let r,s;if("reducer"in i){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(i))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=i.reducer,s=i.prepare}else r=i;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Lt(e,s):Lt(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);l&&i.addCase(u.rejected,l);c&&i.addMatcher(u.settled,c);i.exposeCaseReducer(t,{fulfilled:s||gn,pending:a||gn,rejected:l||gn,settled:c||gn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=qt(d,this,{insert:()=>new WeakMap});return qt(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=pn(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const i=t??this.reducerPath;return e.inject({reducerPath:i,reducer:this.reducer},n),{...this,reducerPath:i}}};return h}}();function gn(){}var vn="listenerMiddleware";Lt(`${vn}/add`),Lt(`${vn}/removeAll`),Lt(`${vn}/remove`);const mn=e=>l((t=>{const n=fn(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(m)(t)){constructor(...e){super(...e);const t=tn({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const i=await t.dispatch(e(...n));try{dn(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(m(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const bn=l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),wn=e=>"string"==typeof e?e:(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"",yn=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),wn(n))})),t};function kn(e){return new URLSearchParams(window.location.search).get(e)}const In=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Sn=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Cn=cn("users/me",((e,{extra:{api:t}})=>t.user.me())),xn=In(Cn)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Sn((e=>e.me))),An={action:Cn,reducer:xn},On=cn("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),jn=In(On)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},Sn((e=>e.devices))),En={action:On,reducer:jn},Un=cn("users/logout",((e,{extra:{api:t}})=>t.user.logout())),Rn={action:Un,reducer:In(Un)({})};class Tn extends Error{}function Mn(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function Wn(e,t){if("string"!=typeof e)throw new Tn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new Tn(`Invalid token specified: missing part #${n+1}`);let o;try{o=Mn(i)}catch(e){throw new Tn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new Tn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Tn.prototype.name="InvalidTokenError";var _n={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const $n="<region>",Ln=`https://api.${$n}descope.com`,Pn=6e5,Nn="dct",Dn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},Fn=[503,521,522,524,530],qn=[100,5e3,5e3],zn=e=>new Promise((t=>setTimeout(t,e))),Vn=e=>async(...t)=>{let n=await e(...t),i=0;for(;Fn.includes(n.status)&&i<qn.length;)await zn(qn[i]),n=await e(...t),i++;i>0&&(n.retries=i);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let Hn;const Kn=()=>{if(Hn)return Hn;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return Hn=`${t}-${n}`,Hn};var Bn;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(Bn||(Bn={}));const Jn=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace($n,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},Zn=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),Xn={"Content-Type":"application/json"},Gn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Yn=(e,t)=>{const n={"x-descope-sdk-session-id":Kn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.62.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Qn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var ei=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||Ln,c=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Dn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await Vn(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return Dn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:Vn(n)})(o,a),d=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:Zn(Gn(t,g),Yn(t,i),(null==n?void 0:n.baseHeaders)||{},Qn(v)?Xn:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const b=await c(Jn({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==b?void 0:b.clone()),null==r?void 0:r.transformResponse){const e=await b.json(),t=(w=(null===(o=b.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;i();)if(","===e.charAt(n)){for(s=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}var w;return b};return{get:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Bn.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Bn.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Bn.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Bn.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Bn.delete,token:i}),hooks:r,buildUrl:(e,n)=>Jn({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},ti=429;function ni(e,t,n){var i;let o=ii(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[Nn])===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function ii(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Wn(e)}function oi(e){const{exp:t}=ii(e);return(new Date).getTime()/1e3>t}function ri(e){let t=ii(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function si(e,t){return ni(e,t,"permissions")}function ai(e,t){return ni(e,t,"roles")}const li=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function ci(e,t){var n;const i=await e,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=r:(o.error=r,i.status===ti&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function di(e){var t;return(null===(t=ii(e))||void 0===t?void 0:t[Nn])||""}const ui=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),hi=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},pi=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),fi=e=>t=>e.test(t),gi=fi(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),vi=fi(/^\+[1-9]{1}[0-9]{3,14}$/),mi=ui(gi,'"{val}" is not a valid email'),bi=ui(vi,'"{val}" is not a valid phone number'),wi=ui((e=>e.length>=1),"Minimum length is 1");const yi=ui((e=>"string"==typeof e),"Input is not a string"),ki=ui((e=>Array.isArray(e)),"Input is not an array"),Ii=ui((e=>"boolean"==typeof e),"Input is not a boolean"),Si=ui((e=>void 0===e),"Input is defined"),Ci=hi([yi(),Si()],"Input is not a string or undefined"),xi=hi([ki(),Ii()],"Input is not an array or boolean"),Ai=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>pi(...e).validate(n[t]))),t(...n)),Oi=e=>[yi(`"${e}" must be a string`)],ji=e=>[Ci(`"${e}" must be string or undefined`)],Ei=e=>[yi(`"${e}" must be a string`),wi(`"${e}" must not be empty`)],Ui=e=>[yi(`"${e}" must be a string`),mi()],Ri=e=>[yi(`"${e}" must be a string`),bi()],Ti=Ai(Ei("accessKey")),Mi=e=>({exchange:Ti(((t,n)=>ci(e.post(_n.accessKey.exchange,{loginOptions:n},{token:t}))))}),Wi=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),_i=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Pn,Pn)});var $i,Li;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}($i||($i={})),function(e){e.email="email"}(Li||(Li={}));const Pi=Object.assign(Object.assign({},$i),Li);var Ni;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ni||(Ni={}));const Di=Ei("loginId"),Fi=Ai(Ei("token")),qi=Ai(Di),zi=Ai(Ei("pendingRef")),Vi=Ai(Di,Ui("email")),Hi=e=>({verify:Fi((t=>ci(e.post(_n.enchantedLink.verify,{token:t})))),signIn:qi(((n,i,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return ci(e.post(li(_n.enchantedLink.signIn,Pi.email),{loginId:n,URI:i,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:qi(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return ci(e.post(li(_n.enchantedLink.signUpOrIn,Pi.email),{loginId:n,URI:i,loginOptions:s,providerId:r}))})),signUp:qi(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ci(e.post(li(_n.enchantedLink.signUp,Pi.email),{loginId:n,URI:i,user:o,loginOptions:a,providerId:s}))})),waitForSession:zi(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=_i(n);let s;const a=setInterval((async()=>{const n=await e.post(_n.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(ci(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Vi(((t,n,i,o,r)=>ci(e.post(_n.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),Ki=Ai(Ei("flowId")),Bi=Ai(Ei("executionId"),Ei("stepId"),Ei("interactionId")),Ji=e=>({start:Ki(((t,n,i,o,r,s,a,l=!1)=>ci(e.post(_n.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:Bi(((t,n,i,o,r,s,a=!1)=>ci(e.post(_n.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a}))))}),Zi=Ei("loginId"),Xi=Ai(Ei("token")),Gi=Ai(Zi),Yi=Ai(Zi,Ri("phone")),Qi=Ai(Zi,Ui("email")),eo=Object.keys(Pi).filter((e=>e!==$i.voice&&e!==$i.im)),to=e=>({verify:Xi((t=>ci(e.post(_n.magicLink.verify,{token:t})))),signIn:eo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Gi(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return ci(e.post(li(_n.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:eo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Gi(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return ci(e.post(li(_n.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:eo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Gi(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ci(e.post(li(_n.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:Qi(((t,n,i,o,r)=>ci(e.post(_n.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys($i).filter((e=>e!==$i.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Yi(((t,i,o,r,s)=>ci(e.post(li(_n.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var no;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(no||(no={}));const io=Ai(Ei("code")),oo=e=>({start:Object.assign(((t,n,i,o,r)=>ci(e.post(_n.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(no).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>ci(e.post(_n.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:io((t=>ci(e.post(_n.oauth.exchange,{code:t})))),startNative:(t,n,i)=>ci(e.post(_n.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>ci(e.post(_n.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>ci(e.get(_n.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>ci(e.post(_n.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>ci(e.post(_n.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),ro=Ei("appId"),so=Ai(ro),ao=e=>({connect:so(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,ci(e.post(_n.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),lo=Ei("loginId"),co=Ai(lo,Ei("code")),uo=Ai(lo),ho=Ai(lo,Ri("phone")),po=Ai(lo,Ui("email")),fo=e=>({verify:Object.keys(Pi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:co(((t,i)=>ci(e.post(li(_n.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Pi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:uo(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return ci(e.post(li(_n.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Pi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:uo(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ci(e.post(li(_n.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Pi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:uo(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return ci(e.post(li(_n.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:po(((t,n,i,o)=>ci(e.post(_n.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys($i).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ho(((t,i,o,r)=>ci(e.post(li(_n.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),go=Ai(Ei("tenant")),vo=Ai(Ei("code")),mo=e=>({start:go(((t,n,i,o,r,s,a,l)=>ci(e.post(_n.saml.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},o&&{token:o}))))),exchange:vo((t=>ci(e.post(_n.saml.exchange,{code:t}))))}),bo=Ei("loginId"),wo=Ai(bo,Ei("code")),yo=Ai(bo),ko=Ai(bo),Io=e=>({signUp:yo(((t,n)=>ci(e.post(_n.totp.signUp,{loginId:t,user:n})))),verify:wo(((t,n,i,o)=>ci(e.post(_n.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:ko(((t,n)=>ci(e.post(_n.totp.update,{loginId:t},{token:n}))))}),So=Ei("loginId"),Co=Ei("newPassword"),xo=Ai(So,Ei("password")),Ao=Ai(So),Oo=Ai(So,Co),jo=Ai(So,Ei("oldPassword"),Co),Eo=e=>({signUp:xo(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ci(e.post(_n.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:xo(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return ci(e.post(_n.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:Ao(((t,n,i)=>ci(e.post(_n.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:Oo(((t,n,i)=>ci(e.post(_n.password.update,{loginId:t,newPassword:n},{token:i})))),replace:jo(((t,n,i)=>ci(e.post(_n.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>ci(e.get(_n.password.policy))}),Uo=Oi("loginId"),Ro=Ei("loginId"),To=Ei("origin"),Mo=Ai(Ro,To,Ei("name")),Wo=Ai(Ro,To),_o=Ai(Uo,To),$o=Ai(Ro,To,ji("token")),Lo=Ai(Ei("transactionId"),Ei("response")),Po=e=>({signUp:{start:Mo(((t,n,i,o,r)=>ci(e.post(_n.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:Lo(((t,n)=>ci(e.post(_n.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:_o(((t,n,i,o,r)=>ci(e.post(_n.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:Lo(((t,n)=>ci(e.post(_n.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Wo(((t,n,i,o)=>ci(e.post(_n.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:$o(((t,n,i,o)=>ci(e.post(_n.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:Lo(((t,n)=>ci(e.post(_n.webauthn.update.finish,{transactionId:t,response:n}))))}}),No=Oi("loginId"),Do=Ai(No),Fo=Ai(Ei("pendingRef")),qo=e=>({signUpOrIn:Do(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return ci(e.post(_n.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:Do(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return ci(e.post(_n.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:Do(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return ci(e.post(_n.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:Fo(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=_i(n);let s;const a=setInterval((async()=>{const n=await e.post(_n.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(ci(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),zo=Ai(Ei("token")),Vo=Ai(ji("token"));var Ho,Ko=Ai([(Ho=Ei("projectId"),ui(((e,t)=>n=>pi(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",Ho))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=ei({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:Mi(l),otp:fo(l),magicLink:to(l),enchantedLink:Hi(l),oauth:oo(l),outbound:ao(l),saml:mo(l),totp:Io(l),notp:qo(l),webauthn:Po(l),password:Eo(l),flow:Ji(l),refresh:Vo(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?_n.tryRefresh:_n.refresh;return ci(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:Ai([yi("tenantId")],[Ci('"token" must be string or undefined')])(((e,t)=>ci(l.post(_n.selectTenant,{tenant:e},{token:t})))),logout:Vo((e=>ci(l.post(_n.logout,{},{token:e})))),logoutAll:Vo((e=>ci(l.post(_n.logoutAll,{},{token:e})))),me:Vo((e=>ci(l.get(_n.me,{token:e})))),myTenants:Ai([xi('"tenants" must a string array or a boolean')],[Ci('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,ci(l.post(_n.myTenants,n,{token:t}))})),history:Vo((e=>ci(l.get(_n.history,{token:e})))),isJwtExpired:zo(oi),getTenants:zo(ri),getJwtPermissions:zo(si),getJwtRoles:zo(ai),getCurrentTenant:zo(di),httpClient:l};var l})),Bo=Object.assign(Ko,{DeliveryMethods:Pi});
6
- /*! js-cookie v3.0.5 | MIT */function Jo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)e[i]=n[i]}return e}var Zo=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=Jo({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(i[a]=t.read(s,a),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",Jo({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Jo({},this.attributes,t))},withConverter:function(t){return e(Jo({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var Xo={default:"endpoint"},Go="Blocked by CSP",Yo="The endpoint parameter is not a valid URL",Qo="Failed to load the JS script of the agent",er="9319";function tr(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Go||s===Yo)n.exclude(),r=0;else if(s===er)n.exclude();else if(s===Qo){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var nr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",ir=nr;function or(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:nr,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return tr(e,rr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===er?new Error(Qo):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function rr(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(Yo);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(Qo))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(Go)})).then(sr)}function sr(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(er);return n}const ar="3.2.0",lr="undefined"!=typeof window,cr=Math.pow(2,31)-1,dr=`https://descopecdn.com/npm/oidc-client-ts@${ar}/dist/browser/oidc-client-ts.min.js`,ur=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${ar}/dist/browser/oidc-client-ts.min.js`,hr=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let pr;const fr=e=>{try{return Wn(e).exp}catch(e){return null}},gr=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:fr(n)},vr=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?fr(i):void 0)},mr=e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||vr(e),cookieExpiration:e.cookieExpiration||gr(e)},s)},br=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},wr=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return mr(n)},yr=()=>lr&&!!window.descopeBridge,kr=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return hr.includes(n)},Ir=void 0!==pr||lr&&void 0!==window.localStorage,Sr=(e,t)=>{var n,i;return null===(i=null===(n=pr||lr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},Cr=e=>{var t,n;return null===(n=null===(t=pr||lr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},xr=e=>{var t,n;return null===(n=null===(t=pr||lr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},Ar=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==pr?void 0:pr.key)||void 0===t?void 0:t.call(pr,e))&&void 0!==n?n:lr&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},Or=(...e)=>{console.debug(...e)},jr=(...e)=>{console.warn(...e)},Er="DS",Ur="DSR",Rr="DSI",Tr="DSRCN";function Mr(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Wr(i);Zo.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}function Wr(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const _r=e=>(null==e?void 0:e.cookieName)||Er,$r=e=>(null==e?void 0:e.cookieName)||Ur;function Lr(e="",t){return Zo.get($r(t))||Cr(`${e}${Ur}`)||""}function Pr(e="",t){return Zo.get(_r(t))||Cr(`${e}${Er}`)||""}function Nr(e=""){return Cr(`${e}${Rr}`)||""}function Dr(e="",t,n,i){xr(`${e}${Ur}`),xr(`${e}${Er}`),xr(`${e}${Rr}`),xr(`${e}${Tr}`);const o=_r(t);Zo.remove(o,null==i?void 0:i.session);const r=$r(n);Zo.remove(r,null==i?void 0:i.refresh)}const Fr=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||Lr(e,t)});if(!n){const t=function(e=""){return Cr(`${e}${Tr}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return Cr(`${e}DTD`)||""}(e);return r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r})),o},qr=lr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",zr="vsid",Vr="vrid",Hr="fp",Kr=(e=!1)=>{const t=Cr(Hr);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Br=async(e,t=qr)=>{try{if(Kr())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=or({apiKey:e,endpoint:[i.toString(),Xo],scriptUrlPattern:[r,ir]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[zr]:e,[Vr]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Sr(Hr,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Jr=e=>{const t=Kr(!0);return t&&e.body&&(e.body.fpData=t),e},Zr="descopeFlowNonce",Xr="X-Descope-Flow-Nonce",Gr="/v1/flow/start",Yr="/v1/flow/next",Qr=(e,t=Zr)=>`${t}${e}`,es=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},ts=e=>{var t;return e.path===Yr&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?es(e.body.executionId):null},ns="dls_last_user_login_id",is="dls_last_user_display_name",os=e=>Sr(ns,e),rs=()=>Cr(ns),ss=()=>Cr(is),as=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=rs(),r=ss();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},ls="DSLI",cs=e=>async(...t)=>{const n=await e(...t);return xr(ls),n};function ds(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function us(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ms(n.publicKey.challenge),n.publicKey.user.id=ms(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=ms(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:bs(n.rawId),type:n.type,response:{attestationObject:bs(n.response.attestationObject),clientDataJSON:bs(n.response.clientDataJSON)}});var n}async function hs(e){const t=gs(e);return vs(await navigator.credentials.get(t))}async function ps(e,t){const n=gs(e);return n.signal=t.signal,n.mediation="conditional",vs(await navigator.credentials.get(n))}async function fs(e=!1){var t,n;if(!lr)return Promise.resolve(!1);if(yr()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function gs(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ms(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=ms(e.id)})),n}function vs(e){return JSON.stringify({id:e.id,rawId:bs(e.rawId),type:e.type,response:{authenticatorData:bs(e.response.authenticatorData),clientDataJSON:bs(e.response.clientDataJSON),signature:bs(e.response.signature),userHandle:e.response.userHandle?bs(e.response.userHandle):void 0}})}function ms(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function bs(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ws,ys=(ws=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await us(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await hs(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await us(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await hs(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await us(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:us,get:hs,isSupported:fs,conditional:ps}}),(...e)=>{const t=ws(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const ks="/fedcm/config",Is=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function Ss(e,t){var n;try{await Cs(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Cs(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=Is(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var xs=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await fs(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let As;const Os=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Os(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),js=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{As||(As=(async()=>{try{return require("oidc-client-ts")}catch(e){return Os([dr,ur],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await As;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),Sr(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=Cr(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||Nr(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return xr(o),t||window.location.replace(s),r}}},Es=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,pr=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return lr?(i&&o&&Br(i).catch((()=>null)),e(br(r,{beforeRequest:Jr}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.49.1"},t.baseHeaders)}))),(e=>t=>{const n=ds(),i=ds(),o=ds(),r=ds(),s=e(br(t,{afterRequest:async(e,t)=>{if(kr(e,t))Or("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await wr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await wr(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Wi(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:i=!0,nonceStoragePrefix:o=Zr}=n,r=t(n,["enableFlowNonce","nonceStoragePrefix"]);return i?(((e=Zr)=>{try{if(!Ir)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==pr?void 0:pr.length)&&void 0!==t?t:lr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=Ar(o);if(t&&t.startsWith(e)){const n=Cr(t);if(n)try{JSON.parse(n).expiry<Date.now()&&xr(t)}catch(e){xr(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(o),e(br(r,{afterRequest:async(e,t)=>{if(e.path!==Gr&&e.path!==Yr)return;const{nonce:n,executionId:i}=await(async(e,t)=>{try{const n=t.headers.get(Xr);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=ts(e)),{nonce:n,executionId:es(i)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&i&&((e,t,n,i=Zr)=>{try{const o=Qr(e,i),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};Sr(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(i,n,e.path===Gr,o)},beforeRequest:e=>{if(e.path===Yr){const t=ts(e);if(t){const n=((e,t=Zr)=>{try{const n=Qr(e,t),i=Cr(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(((e,t=Zr)=>{try{const n=Qr(e,t);xr(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);n&&(e.headers=e.headers||{},e.headers[Xr]=n)}}return e}}))):e(r)}),(e=>t=>{const n=e(br(t,{afterRequest:async(e,t)=>{if(kr(e,t))return void xr(ls);const n=await wr(t);(null==n?void 0:n.sessionExpiration)&&Sr(ls,String(n.sessionExpiration))}}));return Wi(n,["logout","logoutAll","oidc.logout"],cs)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);const r=!!i,s="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!r||yr())return Object.assign(e(o),{markUserActive:()=>{jr("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(Or("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),lr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(Or("Expiration time passed, refreshing session"),f.refresh(Lr()||d))}));const f=e(br(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await wr(t);if(kr(e,t))Or("Session invalidated, canceling all timers"),a();else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);Or("Could not extract expiration time from session token, trying to decode the token");try{const t=Wn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void Or("Could not extract expiration time from session token");d=i,h=r>0;const e=((e,t)=>{let n;var i;return t>0?(n=1e3*t,Or(`Using provided nextRefreshSeconds: ${t}s`)):n=((i=e)?i.getTime()-(new Date).getTime():0)-2e4,n>cr&&(Or(`Timeout is too large (${n}ms), setting it to ${cr}ms`),n=cr),n})(c,r);if(a(),e<=2e4)return void Or("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Or(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(lr&&"hidden"===document.visibilityState)Or("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return Or("Skipping refresh due to timer - user is idle"),void(p=!0);Or("Refreshing session due to timer"),f.refresh(Lr()||i)}}),e)}}}));return Object.assign(Wi(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Or("Clearing all timers"),a(),n})),{markUserActive:u?()=>{Or("markUserActive() called"),h||Or("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(Or("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Lr()||d))}:()=>{jr("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:rs,getLastUserDisplayName:ss});const s=e(br(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=mr((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(os(r),(e=>{Sr(is,e)})(s)):(null==o?void 0:o.loginId)&&os(o.loginId)}}));let a=Wi(s,["flow.start"],as);return a=Wi(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(xr(ns),xr(is)),i})(o)),Object.assign(a,{getLastUserLoginId:rs,getLastUserDisplayName:ss})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!lr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(br(Object.assign({refreshCookieName:a},l),{beforeRequest:Fr(s,r,a),afterRequest:async(e,t)=>{if(kr(e,t))Or("Session invalidated, clearing persisted tokens"),Dr(s,o,r,c);else{const e=await wr(t);e.cookieName?Sr(`${s||""}${Tr}`,e.cookieName):e.refreshJwt&&xr(`${s||""}${Tr}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(i){xr(`${n}${Ur}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,l=$r(i);s&&"https:"!==window.location.protocol&&jr("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Mr(l,c,d);const h=Wr(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=$r(i);Zo.remove(e),Sr(`${n}${Ur}`,c)}if(l)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=_r(t);i&&"https:"!==window.location.protocol&&jr("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});Mr(r,l,c);const d=Wr(o);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?o:void 0}})}else Sr(`${n}${Er}`,l);return e.idToken&&Sr(`${n}${Rr}`,e.idToken),d&&Sr(`${n}DTD`,d),u})(e,o,s,r);n&&(c=n)}}})),u=Wi(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return Dr(e,t,n,null==i?void 0:i()),s})(s,o,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Lr(s,r),getSessionToken:()=>Pr(s,o),getIdToken:()=>Nr(s)})}))((e=>{const t=Bo(e),n=js(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(yr())return Or(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&!Cr(ls)&&!Cr(ns)&&!Cr("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Pr(),a=Lr();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){Or("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:xs(t),webauthn:ys(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){Ss(i,e)},requestAuthentication(e){Ss(i,e)}},async oneTap(e,t,n,o,r){await Cs(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+ks),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>lr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+ks);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),Us=e=>{if(!e)return null;const t=(e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""));return JSON.parse(n)}catch(e){return null}})(e);return(null==t?void 0:t.dct)||null},Rs=e=>e.me.data,Ts=Ut(Rs,(e=>e.userId)),Ms=Ut(Rs,(e=>e.picture)),Ws=Ut(Rs,(e=>e.email)),_s=Ut(Rs,(e=>e.verifiedEmail)),$s=Ut(Rs,(e=>e.name)),Ls=Ut(Rs,(e=>e.phone)),Ps=Ut(Rs,(e=>e.verifiedPhone)),Ns=Ut(Ws,_s,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),Ds=Ut(Ls,Ps,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),Fs=Ut(Rs,(e=>e.webauthn));Ut(Rs,(e=>e.password));const qs=Ut(Rs,(e=>e.TOTP)),zs=Ut(Rs,(e=>e.customAttributes)),Vs=Ut(Rs,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),Hs=Ut((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:n,lastLoginTime:i,isCurrentDevice:o})=>({id:e,name:t,deviceType:n,lastLoginDate:1e3*parseInt(i,10),isCurrent:o}))))),Ks=e=>e.notifications,Bs=Ut(Rs,(e=>e.userTenants||[])),Js=e=>e.tenant.currentTenantId,Zs=cn("tenant/select",((e,t)=>n(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:n}){if(e===Js(n()))return null;const i=yield t.user.setCurrentTenant(e),o=i.sessionJwt||i.sessionToken;try{return{tenantId:Us(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),Xs={action:Zs,reducer:In(Zs)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var n;e.tenant.currentTenantId=null===(n=t.payload)||void 0===n?void 0:n.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},Sn((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{if(t){const i=t(n);i&&e.notifications.push({type:"success",msg:i})}},onRejected:(t,n)=>{if(e){const i=e(n);i&&t.notifications.push({type:"error",msg:i})}}}))({getErrorMsg:e=>{var t,n;const i=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(n=e.error)||void 0===n?void 0:n.name)?i:`${i||"Error"}`}}))},Gs={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},Ys={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",selectTenant:"/v1/auth/tenant/select"},Qs=e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),ea=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],ta=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:ea,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),na=()=>({devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]}),ia=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return ta();const n=yield e.get(Ys.me);return yield Qs(n),n.json()})),setCurrentTenant:t=>n(void 0,void 0,void 0,(function*(){const n=yield e.post(Ys.selectTenant,{tenant:t});return yield Qs(n),n.json()}))}),oa=({httpClient:e,mock:t})=>({devices:i=>n(void 0,[i],void 0,(function*({userId:n}){if(t)return na();const i=yield e.post(Ys.devices,{identifiers:[n]});return yield Qs(i),i.json()}))}),ra=l((e=>{var t,s,a,l;const c=r(A,C,m,O,bn)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||he}get api(){return i(this,s,"f")||i(this,t,"m",a).call(this),i(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{i(this,s,"f")&&i(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,i)=>{const o=Es(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.10.2"}}));return{user:Object.assign(Object.assign({},ia({httpClient:o.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},oa({httpClient:o.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),sa=l((e=>{const t=r(mn({name:"widget",initialState:Gs,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{An.reducer(e),En.reducer(e),Rn.reducer(e),Xs.reducer(e)},asyncActions:{getMe:An.action,listDevices:En.action,logout:Rn.action,selectTenant:Xs.action}}),S,m,ra)(e);return class extends t{constructor(...e){super(...e),this.state=Gs,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),aa="widget-flow",la=l((e=>{var t,o,s;return s=class extends(r(S,ce,sa,bn,m,ge)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const r=kn(aa);r&&(!function(e){if(window.history.replaceState&&kn(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(aa),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(yn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));new Q((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),ca=l((e=>{const t=r(U,x({"widget-id":x.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),da=l((e=>{var t,o,a;return a=class extends(r(m,S,F,B,ca,sa)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield i(this,t,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),ua=l((e=>class extends(r(ge,C)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),ha=l((e=>{var t,s,l,c,d,u,h,p,f;return f=class extends(r(ua,ge,sa,m,bn,da,ce)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.avatar.image=e}))),p.set(this,a((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Ms(this.state)),i(this,p,"f").call(this,$s(this.state)),this.subscribe(i(this,h,"f").bind(this),Ms),this.subscribe(i(this,p,"f").bind(this),$s)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(){this.avatar.flowId&&(o(this,s,this.createModal({"data-id":"update-pic"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this),this.syncFlowTheme(i(this,l,"f")))},d=function(){i(this,s,"f").setContent(yn({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new G((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},f})),pa=l((e=>{var t,s,l,c,d,u,h,p,f,g,v,b,w;return w=class extends(r(ua,sa,m,da,bn,ce)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.emailUserAttr.value=e}))),b.set(this,a((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Ws(this.state)),i(this,b,"f").call(this,Ns(this.state)),this.subscribe(i(this,v,"f").bind(this),Ws),this.subscribe(i(this,b,"f").bind(this),Ns)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,b=new WeakMap,t=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-email"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(yn({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-email"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(yn({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new re((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w})),fa=l((e=>{var t,o,s;return s=class extends(r(sa,m,da,ce)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){this.logout=new Y((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>n(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},s})),ga=l((e=>{var t,s,l,c,d,u,h,p,f,g,v,b;return b=class extends(r(ua,sa,m,da,bn,ce)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,$s(this.state)),this.subscribe(i(this,v,"f").bind(this),$s)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-name"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(yn({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-name"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(yn({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new re((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),va=l((e=>{var t,s,l,c,d,u,h,p,f,g,v,b;return b=class extends(r(ua,sa,m,da,bn,ce)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Fs(this.state)),this.subscribe(i(this,v,"f").bind(this),Fs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.passkeyUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"add-passkey"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(yn({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createModal({"data-id":"remove-passkey"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(yn({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.passkeyUserAuthMethod=new se((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),ma=l((e=>{var t,s,a,l,c,d;return d=class extends(r(ua,sa,m,da,bn,ce)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new se((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.initPasswordAuthMethod(),i(this,t,"m",l).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){this.passwordUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"password"}),"f"),o(this,a,new Q((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",c).bind(this),i(this,t,"m",c).call(this),this.syncFlowTheme(i(this,a,"f")))},c=function(){i(this,s,"f").setContent(yn({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close()}))},d})),ba=l((e=>{var t,s,l,c,d,u,h,p,f,g,v,b,w;return w=class extends(r(ua,sa,m,da,bn,ce)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.phoneUserAttr.value=e}))),b.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Ls(this.state)),i(this,b,"f").call(this,Ds(this.state)),this.subscribe(i(this,v,"f").bind(this),Ls),this.subscribe(i(this,b,"f").bind(this),Ds)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,b=new WeakMap,t=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-phone"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(yn({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-phone"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(yn({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new re((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w})),wa=l((e=>{var t,s,l,c,d,u,h,p,f,g,v,b;return b=class extends(r(ua,sa,m,da,bn,ce)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,qs(this.state)),this.subscribe(i(this,v,"f").bind(this),qs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.totpUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"totp"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(yn({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.totpUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createModal({"data-id":"remove-totp"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(yn({projectId:this.projectId,flowId:this.totpUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.totpUserAuthMethod=new se((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),ya=l((e=>{var t,o,s,l,c,d,u,h,p,f,g;return g=class extends(r(ua,sa,m,da,bn,ce)(e)){constructor(){super(...arguments),t.add(this),o.set(this,{}),s.set(this,{}),l.set(this,{}),c.set(this,{}),h.set(this,a((e=>{var n;const o=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(o).forEach((n=>{const o=n.getAttribute("data-id").replace("builtin.",""),r=e[o],s=new re(n,{logger:this.logger});s.value=(r||"").toString(),i(this,t,"m",p).call(this,n,o,s),i(this,t,"m",f).call(this,n,o,s)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,h,"f").call(this,Vs(this.state)),this.subscribe(i(this,h,"f").bind(this),Vs)}))}},o=new WeakMap,s=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,d=function(e){var t,n;null===(t=i(this,o,"f")[e])||void 0===t||t.setContent(yn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(n=i(this,s,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,o,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},u=function(e){var t,n;null===(t=i(this,l,"f")[e])||void 0===t||t.setContent(yn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(n=i(this,c,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,l,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},p=function(e,n,r){const a=e.getAttribute("edit-flow-id");a&&(i(this,o,"f")[a]=this.createModal({"data-id":`edit-${n}`}),i(this,s,"f")[a]=new Q((()=>{var e,t;return null===(t=null===(e=i(this,o,"f")[a])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,o,"f")[a].afterClose=i(this,t,"m",d).bind(this,a),r.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,o,"f"))||void 0===e?void 0:e[a])||void 0===t||t.open()})),i(this,t,"m",d).call(this,a),this.syncFlowTheme(i(this,s,"f")[a]))},f=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,l,"f")[r]=this.createModal({"data-id":`delete-${n}`}),i(this,c,"f")[r]=new Q((()=>{var e,t;return null===(t=null===(e=i(this,l,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,l,"f")[r].afterClose=i(this,t,"m",u).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,l,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r),this.syncFlowTheme(i(this,c,"f")[r]))},g}));var ka;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(ka||(ka={}));const Ia=l((e=>{var t,o,s,l,c,d,u,h,p,f,g;return o=class extends(r(ua,sa,m,da,bn,ce)(e)){constructor(){super(...arguments),t.add(this),s.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),p.set(this,a((e=>{var n;const r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(r).forEach((n=>{const r=n.getAttribute("data-id").replace("customAttributes.",""),s=n.getAttribute("data-type")||ka.TEXT,a=e[r],l=new re(n,{logger:this.logger});l.value=o.getFormattedValue(s,a),i(this,t,"m",f).call(this,n,r,l),i(this,t,"m",g).call(this,n,r,l)}))})))}static getFormattedValue(e,t){return e===ka.DATE&&t?new Date(t).toLocaleString():e===ka.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,p,"f").call(this,zs(this.state)),this.subscribe(i(this,p,"f").bind(this),zs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,t=new WeakSet,u=function(e){var t,n;null===(t=i(this,s,"f")[e])||void 0===t||t.setContent(yn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(n=i(this,l,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,s,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,n;null===(t=i(this,c,"f")[e])||void 0===t||t.setContent(yn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},f=function(e,n,o){const r=e.getAttribute("edit-flow-id");r&&(i(this,s,"f")[r]=this.createModal({"data-id":`edit-${n}`}),i(this,l,"f")[r]=new Q((()=>{var e,t;return null===(t=null===(e=i(this,s,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,s,"f")[r].afterClose=i(this,t,"m",u).bind(this,r),o.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,s,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r),this.syncFlowTheme(i(this,l,"f")[r]))},g=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,c,"f")[r]=this.createModal({"data-id":`delete-${n}`}),i(this,d,"f")[r]=new Q((()=>{var e,t;return null===(t=null===(e=i(this,c,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,c,"f")[r].afterClose=i(this,t,"m",h).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,c,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",h).call(this,r),this.syncFlowTheme(i(this,d,"f")[r]))},o})),Sa=l((e=>{var t,s,l,c,d,u,h,p;return p=class extends(r(ua,ge,sa,m,bn,da,ce)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),this.updateDeviceList=a((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.deviceList=new ae((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield i(this,t,"m",h).call(this),i(this,t,"m",u).call(this,Hs(this.state)),i(this,t,"m",c).call(this),this.subscribe(this.updateDeviceList.bind(this),Hs))}))}},s=new WeakMap,l=new WeakMap,t=new WeakSet,c=function(){this.deviceList.flowId&&(o(this,s,this.createModal({"data-id":"untrust-device"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=()=>i(this,t,"m",d).call(this,""),this.syncFlowTheme(i(this,l,"f")))},d=function(e=""){i(this,s,"f").setContent(yn({projectId:this.projectId,flowId:this.deviceList.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{deviceId:e}})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.listDevices({userId:Ts(this.state)})}))},u=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var n;i(this,t,"m",d).call(this,e),null===(n=i(this,s,"f"))||void 0===n||n.open()})),this.deviceList.data=e},h=function(){return n(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:Ts(this.state)})}))},p}));const Ca={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},xa=l((e=>{var t,o,s,l,c;return c=class extends(r(m,sa,ue,S)(e)){constructor(){super(...arguments),t.add(this),l.set(this,a((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const r=i(this,t,"m",s).call(this,e);r.setContent(i(this,t,"m",o).call(this,{type:e,msg:n})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(i(this,l,"f").bind(this),Ks)}))}},l=new WeakMap,t=new WeakSet,o=function({type:e,msg:t}){const n=Ca[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},c})),Aa=l((e=>{var t,s,a,l,c,d,u,h,p,f,g;return g=class extends(r(sa,m,da)(e)){constructor(){super(...arguments),t.add(this),s.set(this,null),l.set(this,(e=>n(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),c.set(this,(e=>{const n=Js(e);this.tenantSelector.value!==n&&i(this,t,"m",p).call(this,n);const{loading:r,error:a}=e.selectTenant,l=null!==e.tenant.previousTenantId,c=n!==i(this,s,"f");!n||r||a||l||!c||(o(this,s,n,"f"),i(this,t,"m",d).call(this))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.actions.setCurrentTenantId((()=>{const e=Pr();return Us(e)})()),i(this,t,"m",a).call(this),i(this,t,"m",f).call(this),i(this,t,"m",h).call(this,Bs(this.state)),this.subscribe(i(this,c,"f").bind(this))}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,a=function(){this.tenantSelector=new le((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(i(this,l,"f"))},d=function(){const e=Js(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&i(this,t,"m",u).call(this)},u=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},h=function(e){return n(this,void 0,void 0,(function*(){const t=e.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(t)}))},p=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{i(this,t,"m",p).call(this,Js(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),Oa=l((e=>{var t,s,a,l,c,d,u,h,p,f,g;return g=class extends(r(ua,sa,ce,m,da)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0),l.set(this,[]),c.set(this,null)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",h).call(this),i(this,t,"m",u).call(this),i(this,l,"f").forEach((e=>e.enable()))}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(e){const n=new ee(e,{logger:this.logger});n.onClick((()=>{i(this,t,"m",f).call(this,n.flowId,Ts(this.state))})),i(this,l,"f").push(n)},u=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(n).forEach((e=>{i(this,t,"m",d).call(this,e)}))},h=function(){o(this,s,this.createModal({"data-id":"generic-flow-modal"}),"f"),i(this,s,"f").afterClose=()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.call(this),o(this,c,null,"f")},o(this,a,new Q((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(i(this,a,"f"))},p=function(){var e;i(this,s,"f").open(),null===(e=i(this,c,"f"))||void 0===e||e.call(this)},f=function(e,n){i(this,s,"f").setContent(yn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,client:{userId:n}}));o(this,c,i(this,a,"f").onPageUpdated((()=>i(this,t,"m",p).call(this))),"f"),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},g})),ja=l((e=>class extends(r(M,ge,la,Ia,pa,ha,ga,ba,va,ma,wa,ya,fa,Sa,xa,Aa,Oa)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Ea=r((e=>class extends(ja(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return md})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.10.2"}}}))}}))(HTMLElement),Ua="undefined"!=typeof localStorage,Ra="J151000",Ta="E103205",Ma=Ua&&localStorage.getItem("base.content.url")||"",Wa="base.ui.components.url";Ua&&localStorage.getItem(Wa),Ua&&localStorage.getItem(Wa);const _a="descope-login-flow",$a="code",La="redirect_mode",Pa="err",Na="data-exclude-field",Da="data-exclude-next",Fa="dls_last_auth",qa="state_id",za="saml_idp_state_id",Va="wsfed_idp_state_id",Ha="saml_idp_username",Ka="descope_idp_initiated",Ba="sso_app_id",Ja="custom_app_id",Za="third_party_app_id",Xa="third_party_app_state_id",Ga="oidc_login_hint",Ya="oidc_prompt",Qa="oidc_resource",el="oidc_error_redirect_uri",tl="application_scopes",nl="data-type",il="redirect",ol="poll",rl="webauthnCreate",sl="webauthnGet",al="nativeBridge",ll="loadForm",cl="submit",dl="polling",ul=["descope-multi-select-combo-box","descope-text-area"],hl="dls_last_auth_in_flight",pl=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var fl;!function(e){e.backward="backward",e.forward="forward"}(fl||(fl={}));const gl=["descope-enriched-text"];function vl(e){return new URLSearchParams(window.location.search).get(e)}function ml(e){if(window.history.replaceState&&vl(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function bl(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?fl.forward:n<i?fl.backward:void 0}const wl=e=>{let[t="",n=""]=(vl(_a)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function yl(){ml(_a)}const kl=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Il=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=wl(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&yl();const r=vl("t")||void 0;r&&ml("t");const s=vl($a)||void 0;s&&ml($a);const a="popup"===vl(La);a&&ml(La);const l=vl(Pa)||void 0;l&&ml(Pa);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:vl("ra-challenge"),redirectAuthCallbackUrl:vl("ra-callback"),redirectAuthBackupCallbackUri:vl("ra-backup-callback"),redirectAuthInitiator:vl("ra-initiator")},p=vl(qa);p&&ml(qa);const f=vl(za);f&&ml(za);const g=vl(Va);g&&ml(Va);const v=vl(Ha);f&&ml(Ha);const m=vl(Ka);m&&ml(Ka);const b=vl(Ba);b&&ml(Ba);const w=vl(Ja);w&&ml(Ja);const y=vl(Za);y&&ml(Za);const k=vl(Xa);k&&ml(Xa);const I=vl(tl);I&&ml(tl);const S=vl(Ga);S&&ml(Ga);const C=vl(Ya);C&&ml(Ya);const x=vl(el);x&&ml(el);const A=vl(Qa);return A&&ml(Qa),{executionId:n,stepId:i,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:b,customAppId:w,oidcLoginHint:S,oidcPrompt:C,oidcErrorRedirectUri:x,oidcResource:A,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:I}}},Sl=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},Cl=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function xl(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const Al=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||i||o||r||s||a||l||c||d||u||h||p),Ol=e=>null==e?void 0:e.submit(),jl=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},El=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function Ul(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const Rl=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Tl(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Ml,Wl,_l,$l;function Ll(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Ll(r,s))return!1}else if(r!==s)return!1}return!0}let Pl=class{constructor(e={},{forceUpdate:t=!1}={}){Ml.set(this,void 0),Wl.set(this,{}),_l.set(this,0),$l.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,Ml,"f")):e,n=Object.assign(Object.assign({},i(this,Ml,"f")),t),r=i(this,Ml,"f");o(this,Ml,n,"f"),Object.freeze(i(this,Ml,"f")),setTimeout((()=>{Object.values(i(this,Wl,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,$l,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!Ll(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,Ml,e,"f"),o(this,$l,t,"f")}get current(){return Object.assign({},i(this,Ml,"f"))}set forceUpdate(e){o(this,$l,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,_l,i(this,_l,"f")+1,"f"),i(this,Wl,"f")[i(this,_l,"f")]={cb:e,selector:t,forceUpdate:n},i(this,_l,"f").toString()}unsubscribe(e){const t=!!i(this,Wl,"f")[e];return t&&delete i(this,Wl,"f")[e],t}unsubscribeAll(){return o(this,Wl,{},"f"),!0}};Ml=new WeakMap,Wl=new WeakMap,_l=new WeakMap,$l=new WeakMap;const Nl=["*","#","/","(",")","[","]","_","<",">","`"],Dl=e=>"string"!=typeof e?e:e.replace((e=>{const t=Nl.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),Fl=["disabled"],ql=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Na}])`)).forEach((e=>{e.value=n}))}))},zl=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Vl=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?Dl(zl(t,i)):zl(t,i))),Hl=(e,t,n)=>{e.querySelectorAll(`[${nl}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Kl=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},Bl=(e,n,i,o)=>{var r,s;Hl(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),Hl(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>gl.includes(e))(e.localName);e.textContent=Vl(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",Vl(i,t))}))})(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==n?void 0:n.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Vl(e.value,t)}))}))})(e,n),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{Fl.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i),((e,t={},n)=>{Object.entries(t).forEach((([t,i])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(i){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;default:null==n||n.error(`Unknown component state "${i}" for component with id "${t}"`,'Valid states are "disable" and "hide"')}}))}))})(e,null==n?void 0:n.componentsState,o)},Jl=Sl((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield xl(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let Zl;const Xl=(e,t)=>{Zl?Zl.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Gl=e=>Zl?Zl.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Yl="dls_ab_testing_id",Ql={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function ec(e,t){const n={};try{Object.assign(n,JSON.parse(Gl(Fa)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function tc(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Xl(Fa,JSON.stringify(e)))}function nc(){try{return JSON.parse(Gl(hl)||"{}")}catch(e){return{}}}function ic(e){try{(e=>{Zl?Zl.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(hl)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const oc=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?oc(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),oc(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),rc=l((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r}));var sc,ac,lc,cc,dc,uc,hc,pc,fc,gc,vc,mc,bc,wc,yc,kc,Ic,Sc,Cc,xc,Ac,Oc;const jc=r(ge,U,rc,V)(HTMLElement);class Ec extends jc{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),sc.add(this),lc.set(this,!1),cc.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,sc,"m",Oc).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},dc.set(this,new Pl),uc.set(this,new Pl),hc.set(this,{}),this.getComponentsContext=()=>i(this,hc,"f"),this.nextRequestStatus=new Pl({isLoading:!1}),pc.set(this,void 0),fc.set(this,{popstate:i(this,sc,"m",wc).bind(this),componentsContext:i(this,sc,"m",Cc).bind(this)}),gc.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,gc,e,"f"),i(this,sc,"m",mc).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return oc(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,cc,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,cc,e,"f"),(e=>{Zl=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=ul.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,uc,"f").subscribe(i(this,sc,"m",Ac).bind(this)),i(this,uc,"f").update({isDebug:this.debug}),i(this,sc,"m",bc).call(this),yield i(this,sc,"m",Ic).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=Il(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,fc,"f").popstate),window.addEventListener("components-context",i(this,fc,"f").componentsContext),i(this,dc,"f").subscribe(i(this,sc,"m",kc).bind(this)),i(this,dc,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},g)),o(this,lc,!0,"f")}))}disconnectedCallback(){i(this,dc,"f").unsubscribeAll(),i(this,uc,"f").unsubscribeAll(),i(this,sc,"m",xc).call(this),window.removeEventListener("popstate",i(this,fc,"f").popstate),window.removeEventListener("components-context",i(this,fc,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,lc,"f")&&t!==n&&ac.observedAttributes.includes(e)){i(this,sc,"m",bc).call(this);const o=null===t;i(this,dc,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,yl()),{[kl(e)]:n,stepId:r,executionId:s}})),i(this,uc,"f").update({isDebug:this.debug})}}}var Uc,Rc,Tc,Mc,Wc,_c,$c,Lc,Pc,Nc,Dc,Fc,qc,zc,Vc,Hc,Kc,Bc,Jc,Zc,Xc,Gc,Yc,Qc,ed,td,nd,id,od,rd,sd,ad,ld,cd,dd,ud,hd,pd,fd,gd;ac=Ec,lc=new WeakMap,cc=new WeakMap,dc=new WeakMap,uc=new WeakMap,hc=new WeakMap,pc=new WeakMap,fc=new WeakMap,gc=new WeakMap,sc=new WeakSet,vc=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},mc=function(){i(this,sc,"m",vc).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},bc=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];ac.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[kl(t)])throw Error(`${t} cannot be empty`)}))},wc=function(){const{stepId:e,executionId:t}=wl(this.flowId);i(this,dc,"f").update({stepId:e,executionId:t})},yc=function(e,t){Es&&"function"==typeof Es||this.logger.error("SDK was not loaded properly",Es,JSON.stringify(Es));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},ac.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,cc,"f")&&(o.customStorage=i(this,cc,"f")),this.sdk=Es(o),["start","next"].forEach((e=>{const t=function(e,t,i){return(...o)=>n(this,void 0,void 0,(function*(){let n;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...o)}catch(e){n=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...i)=>n(this,void 0,void 0,(function*(){try{return yield t(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:Ra,errorDescription:t.toString()}}}}))}))},kc=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,sc,"m",yc).call(this,t,n)}i(this,gc,"f").call(this,e)}))},Ic=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,sc,"m",Sc).call(this))}))},Sc=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Ma||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Cc=function(e){o(this,hc,Object.assign(Object.assign({},i(this,hc,"f")),e.detail),"f")},xc=function(){var e;null===(e=i(this,pc,"f"))||void 0===e||e.remove(),o(this,pc,null,"f")},Ac=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,pc,document.createElement("descope-debugger"),"f"),Object.assign(i(this,pc,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Zd})),document.body.appendChild(i(this,pc,"f"))):i(this,sc,"m",xc).call(this)}))},Oc=function(e,t){var n;e&&this.debug&&(null===(n=i(this,pc,"f"))||void 0===n||n.updateData({title:e,description:t}))},Ec.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.64.0"}};class vd extends Ec{static set sdkConfigOverrides(e){Ec.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Ec.sdkConfigOverrides}constructor(){const e=new Pl({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Uc.add(this),this.stepState=new Pl({}),Rc.set(this,void 0),Tc.set(this,null),Mc.set(this,null),Wc.set(this,{visibilitychange:i(this,Uc,"m",_c).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},zc.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Hc.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,Uc,"m",Kc).call(this,t):t()})),Bc.set(this,((e,t,r,s,a=!1)=>{const l=[Ta,"E103202"];if(this.flowState.current.action===ol){if(i(this,Zc,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,Rc,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,dl,r,s,{}),h=document.hidden&&!a&&Date.now()-c>d+500;let p;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;p=yield xl(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Bc,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===Ra)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Bc,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,Bc,"f").call(this,e,t,r,s),i(this,Xc,"f").call(this,p)}))),d),"f")}})),Jc.set(this,(()=>{clearTimeout(i(this,Rc,"f")),o(this,Rc,null,"f")})),Zc.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),Xc.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,f,g;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,Uc,"m",fd).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==Ta||!this.isRestartOnError||i(this,Uc,"m",qc).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(f=e.data)||void 0===f?void 0:f.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==ol&&i(this,Jc,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&tc(Object.assign(Object.assign({},w),{lastUsedPerScreen:nc()})),ic(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void i(this,Uc,"m",fd).call(this,"success",t)}this.storeLastAuthenticatedUser&&tc(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:x,redirect:A,webauthn:O,error:j,samlIdpResponse:E,wsFedIdpResponse:U,nativeResponse:R}=e.data,T=Date.now();y!==ol?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:x,status:m,stepId:S,stepName:C,action:y,error:j}),(null===(g=x.state)||void 0===g?void 0:g.clientScripts)&&o(this,Mc,this.loadSdkScripts(x.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==A?void 0:A.url,redirectIsPopup:null==A?void 0:A.isPopup,screenId:null==x?void 0:x.id,screenState:null==x?void 0:x.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,wsFedIdpResponseUrl:null==U?void 0:U.url,wsFedIdpResponseWresult:null==U?void 0:U.wresult,wsFedIdpResponseWctx:null==U?void 0:U.wctx,nativeResponseType:null==R?void 0:R.type,nativePayload:null==R?void 0:R.payload,reqTimestamp:T})):this.flowState.update({action:y,reqTimestamp:T})})),Gc.set(this,Sl((()=>n(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),id.set(this,null),ld.set(this,El(((e,t,o)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,Uc,"m",td).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,Uc,"m",ud).call(this,e,r,o),i(this,Uc,"m",od).call(this,e);const s=yield i(this,Uc,"m",nd).call(this),a=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const l=Object.assign(Object.assign(Object.assign({},a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,l),this.nextRequestStatus.update({isLoading:!1}),i(this,Uc,"m",rd).call(this,s)}}))))),this.flowState=e}nativeResume(e,t){var n,o,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const i=new URL(c.url);t=null===(n=i.searchParams)||void 0===n?void 0:n.get($a),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get(Pa))||void 0}null===(s=(r=this.nativeCallbacks).complete)||void 0===s||s.call(r,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(c.url),t=e.searchParams.get("t"),n=e.searchParams.get(_a).split("_").pop();i(this,Jc,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=c;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=c,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(l=(a=this.nativeCallbacks).complete)||void 0===l||l.call(a,c)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Tl(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(i=globalThis.descope)||void 0===i?void 0:i[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.16",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,i)=>{try{const i=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t);const n=this.nextRequestStatus.subscribe((()=>{var o;this.loggerWrapper.debug("Stopping script",e.id),(null===(o=i.stop)||void 0===o?void 0:o.call(i))&&(this.nextRequestStatus.unsubscribe(n),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){i(e)}}))}))))),o=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,o])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,Uc,"m",Dc).call(this),window.addEventListener("visibilitychange",i(this,Wc,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,Jc,"f").call(this),null===(e=i(this,Tc,"f"))||void 0===e||e.abort(),o(this,Tc,null,"f"),window.removeEventListener("visibilitychange",i(this,Wc,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=Ul(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:I,exchangeError:S,webauthnTransactionId:C,webauthnOptions:x,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:O,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:E,locale:U,samlIdpResponseUrl:R,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:M,wsFedIdpResponseUrl:W,wsFedIdpResponseWresult:_,wsFedIdpResponseWctx:$,nativeResponseType:L,nativePayload:P,reqTimestamp:N}=e,D=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let F,q,z;const V=(()=>{const e=Gl(Yl);if(!e){const e=Math.floor(100*Math.random()+1);return Xl(Yl,e.toString()),e}return Number(e)})(),{outboundAppId:H}=this,{outboundAppScopes:K}=this,B=this.sdk.getLastUserLoginId(),J=yield this.getFlowConfig(),Z=yield this.getProjectConfig(),X=Object.entries(Z.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),G=O&&A?{callbackUrl:O,codeChallenge:A,backupCallbackUri:j}:void 0,Y=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let Q={};if(!p){ic(this.loggerWrapper);const e=[...J.clientScripts||[],...J.sdkScripts||[]];if(J.conditions){let t=[];({startScreenId:F,conditionInteractionId:z,startScreenName:q,clientScripts:t,componentsConfig:Q}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=Ql[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:B,code:k,token:y,abTestingKey:V,lastAuth:ec(B,this.loggerWrapper)},J.conditions)),e.push(...t||[])}else J.condition?({startScreenId:F,conditionInteractionId:z}=((e,t)=>{var n;const i=null===(n=Ql[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(J.condition,{loginId:B,code:k,token:y,abTestingKey:V,lastAuth:ec(B,this.loggerWrapper)})):(q=J.startScreenName,F=J.startScreenId);if(o(this,Mc,this.loadSdkScripts(e),"f"),J.fingerprintEnabled&&J.fingerprintKey?yield Br(J.fingerprintKey,this.baseUrl):xr(Hr),!Al(F,D)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:G},D),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:ec(B,this.loggerWrapper),abTestingKey:V,locale:Ul(U).locale,nativeOptions:Y,outboundAppId:H,outboundAppScopes:K}),z,"",Z.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),D.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),D.oidcLoginHint?{externalId:D.oidcLoginHint}:{}));return i(this,Xc,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:I,code:k,exchangeError:S,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&k||s("exchangeError")&&S))return void i(this,Uc,"m",gd).call(this,p,k,S);if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&S)){const e=yield this.sdk.flow.next(p,h,cl,J.version,Z.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return i(this,Xc,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===ll&&R&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(R,T,M||"",Ol)}if(f===ll&&W&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!_)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e;const r=(e,t)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n};o.appendChild(r("wa","wsignin1.0")),o.appendChild(r("wresult",t)),o.appendChild(r("wctx",n));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",o.appendChild(s),document.body.appendChild(o),i(o)})(W,_,$||"",Ol)}if(f===il&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const n=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const n=t?this.popupOrigin:window.location.origin;if(e.origin!==n)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${n}"`);const{action:i,data:o}=e.data||{};"code"===i&&this.flowState.update({code:o.code,exchangeError:o.exchangeError})};let o;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),i(this,Uc,"m",fd).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(t)window.addEventListener("message",n),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",n)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=n,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),i(this,Uc,"m",fd).call(this,"popupclosed",{});return}if(f===rl||f===sl){if(!C||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,Tc,"f"))||void 0===l||l.abort(),o(this,Tc,null,"f");try{e=f===rl?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const n=yield this.sdk.flow.next(p,h,cl,J.version,Z.componentsVersion,{transactionId:C,response:e,failure:t});i(this,Xc,"f").call(this,n)}if(f===al)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,cl,J.version,Z.componentsVersion,e);i(this,Xc,"f").call(this,t)})),i(this,Uc,"m",Pc).call(this,L,P),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&i(this,Bc,"f").call(this,p,h,J.version,Z.componentsVersion),!g&&!F)return void this.loggerWrapper.warn("No screen was found to show");const ee=F||g,te=yield this.getHtmlFilenameWithLocale(U,ee),{oidcLoginHint:ne,oidcPrompt:ie,oidcErrorRedirectUri:oe,oidcResource:re,samlIdpUsername:se}=D,ae={direction:bl(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:B,name:this.sdk.getLastUserDisplayName()||B},componentsConfig:Object.assign(Object.assign(Object.assign({},J.componentsConfig),Q),null==v?void 0:v.componentsConfig)}),htmlFilename:`${ee}.html`,htmlLocaleFilename:te,screenId:ee,stepName:e.stepName||q,samlIdpUsername:se,oidcLoginHint:ne,oidcPrompt:ie,oidcErrorRedirectUri:oe,oidcResource:re,action:f,locale:Ul(U).locale},le=ec(B,this.loggerWrapper);Al(F,D)?ae.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==J?void 0:J.clientScripts)||[];yield i(this,Uc,"m",cd).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:G},D),{lastAuth:le,preview:this.preview,abTestingKey:V,client:this.client}),w&&{redirectUrl:w}),{locale:Ul(U).locale,nativeOptions:Y,outboundAppId:H,outboundAppScopes:K}),z,e,Z.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Rl(t)),k&&{exchangeCode:k,idpInitiated:!0}),D.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}),ae.next.isCustomScreen);return i(this,Xc,"f").call(this,o),o})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ae.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==v?void 0:v.clientScripts)||[];yield i(this,Uc,"m",cd).call(this,n);const o=yield this.sdk.flow.next(p,h,e,J.version,Z.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Rl(t)),ae.next.isCustomScreen);return i(this,Xc,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",ae.screenId),yield i(this,Uc,"m",Vc).call(this,ae),this.stepState.update(ae)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen");const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const f=p.content.cloneNode(!0),g=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield i(this,Uc,"m",Qc).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${nl}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),Bl(f,u,this.formConfig,this.loggerWrapper);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(f,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield g;const r=this.contentRootElement;((e,t)=>{Kl(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{Kl(e,"descope-notp-image",t)})(r,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,f,u.cssVars,this.loggerWrapper),r.replaceChildren(f);const s=!t.htmlFilename;setTimeout((()=>{i(this,Uc,"m",sd).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const i=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void i();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),i(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{ql(e,null==t?void 0:t.inputs),ql(e,null==t?void 0:t.form)})(r,u),i(this,Uc,"m",ed).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),Cl(r,this.autoFocus,s),i(this,Uc,"m",hd).call(this,h)})),i(this,Uc,"m",pd).call(this,d,h),r.querySelector(`[${nl}="polling"]`)&&d(dl,{})}));c?i(this,Uc,"m",Kc).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Na}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}Rc=new WeakMap,Tc=new WeakMap,Mc=new WeakMap,Wc=new WeakMap,zc=new WeakMap,Hc=new WeakMap,Bc=new WeakMap,Jc=new WeakMap,Zc=new WeakMap,Xc=new WeakMap,Gc=new WeakMap,id=new WeakMap,ld=new WeakMap,Uc=new WeakSet,_c=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},$c=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,Uc,"m",Pc).call(this,"beforeScreen",{screen:e,context:t})}))}))},Lc=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,Uc,"m",Pc).call(this,"afterScreen",{screen:e})},Pc=function(e,t){i(this,Uc,"m",fd).call(this,"bridge",{type:e,payload:t})},Nc=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${nl}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},Dc=function(){var e,n,o;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=t(void 0===n?{}:n,["errorText","errorType"]),o=t(e,["screenState"]);return Object.assign(Object.assign({},o),{screenState:i})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,Uc,"m",Nc).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,Uc,"m",Fc).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0})},Fc=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Cl(this.contentRootElement,this.autoFocus,!1))},qc=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},Vc=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=(e=>{var t,n,i;const o=(r=e.screenState,s=(e,t)=>pl.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(0,e)))));var r,s;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(o.error={text:a,type:l}),e.action&&(o.action=e.action),(null===(i=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===i?void 0:i.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o})(t(r,["next","stepName"]));let c=yield i(this,Uc,"m",$c).call(this,a,l,s);c||(c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,l,s,this)));const d=!this.stepState.current.htmlFilename;if(i(this,Hc,"f").call(this,c),s&&(s.isCustomScreen=c),i(this,zc,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,zc,c,"f"),c?this.stepState.unsubscribeAll():i(this,Uc,"m",Dc).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),i(this,Uc,"m",ed).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},Kc=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},Yc=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},Qc=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,Tc,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Jl())){const{options:e,transactionId:r}=(yield i(this,Gc,"f").call(this))||{};e&&r&&(i(this,Uc,"m",Yc).call(this,s),o(this,Tc,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,Tc,"f")).then((e=>n(this,void 0,void 0,(function*(){t(s.id,{transactionId:r,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},ed=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,Uc,"m",fd).call(this,"ready",{}),t||i(this,Uc,"m",Lc).call(this,n),i(this,Uc,"m",fd).call(this,"page-updated",{screenName:n}),i(this,Uc,"m",fd).call(this,"screen-updated",{screenName:n})},td=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"===t.localName||t.classList.contains("hidden")||(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)))})),e},nd=function(){return n(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>n(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},od=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),r=()=>n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",r),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const n=yield this.getFlowConfig(),i=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(i)})),s=()=>{var e;window.removeEventListener("pageshow",i(this,id,"f")),o(this,id,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),r())}),"f"),window.addEventListener("pageshow",i(this,id,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&r(),this.removeEventListener("popupclosed",r),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},a=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?(this.addEventListener("popupclosed",r,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(a),s())}))},rd=function(e={}){var t,n;const i=jl(e,["externalId","email","phone"]),o=jl(e,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},sd=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,Uc,"m",ad).call(this,e)))},ad=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},cd=function(e){return n(this,void 0,void 0,(function*(){if(i(this,Mc,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,Mc,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const o=[];for(const e of t)"function"==typeof e.refresh&&o.push(e.refresh());if(o.length>0)try{yield xl(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},dd=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var o;(null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))&&i(this,ld,"f").call(this,n,e,t)}))}))},ud=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=nc();n[e]=t,Xl(hl,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},hd=function(e){var t;const n=null===(t=ec(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},pd=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Da}]), [data-type="button"]:not([${Da}]`).forEach((n=>{n.onclick=()=>{i(this,ld,"f").call(this,n,e,t)}})),i(this,Uc,"m",dd).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Na}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},fd=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},gd=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===o&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",vd);var md=Object.freeze({__proto__:null,default:vd});customElements.define("descope-user-profile-widget",Ea);const bd=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var wd,yd,kd,Id,Sd,Cd,xd,Ad,Od,jd;const Ed=document.createElement("template");Ed.innerHTML=`\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`;const Ud=r(V)(HTMLElement);class Rd extends Ud{constructor(){var e;super(),wd.add(this),yd.set(this,new f({messages:[]})),kd.set(this,void 0),Id.set(this,void 0),Sd.set(this,void 0),Cd.set(this,{resize:i(this,wd,"m",jd).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Ed.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,kd,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Id,i(this,kd,"f").querySelector(".content"),"f"),o(this,Sd,i(this,kd,"f").querySelector(".header"),"f")}updateData(e){i(this,yd,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=bd(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,kd,"f"),i(this,Sd,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Cd,"f").resize),(e=i(this,kd,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},i(this,kd,"f").onresize=i(this,wd,"m",Od).bind(this),i(this,yd,"f").subscribe(i(this,wd,"m",xd).bind(this))}disconnectedCallback(){i(this,yd,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Cd,"f").resize)}}yd=new WeakMap,kd=new WeakMap,Id=new WeakMap,Sd=new WeakMap,Cd=new WeakMap,wd=new WeakSet,xd=function(e){i(this,wd,"m",Ad).call(this,e),i(this,wd,"m",Od).call(this)},Ad=function(e){i(this,Id,"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("")},Od=function(){i(this,Id,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},jd=function(){const[e,t]=bd(i(this,kd,"f"),Number.parseInt(i(this,kd,"f").style.left,10),Number.parseInt(i(this,kd,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,kd,"f").style.top=`${t}px`,i(this,kd,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Rd);var Td=Object.freeze({__proto__:null,default:Rd});const Md=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},Wd=(e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Md(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c};var _d,$d,Ld,Pd,Nd,Dd,Fd,qd,zd,Vd,Hd;const Kd=document.createElement("template");Kd.innerHTML='\n<div 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';const Bd=r(V)(HTMLElement);class Jd extends Bd{constructor(){super(),_d.add(this),$d.set(this,new Pl({messages:[]})),Ld.set(this,void 0),Pd.set(this,void 0),Nd.set(this,void 0),Dd.set(this,{resize:i(this,_d,"m",Hd).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Kd.content.cloneNode(!0)),o(this,Ld,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Pd,i(this,Ld,"f").querySelector(".content"),"f"),o(this,Nd,i(this,Ld,"f").querySelector(".header"),"f"),i(this,_d,"m",Fd).call(this)}updateData(e){i(this,$d,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),Wd(i(this,Ld,"f"),i(this,Nd,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Dd,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(i(this,Ld,"f")),i(this,Ld,"f").onresize=i(this,_d,"m",Vd).bind(this),i(this,$d,"f").subscribe(i(this,_d,"m",qd).bind(this))}))}disconnectedCallback(){i(this,$d,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Dd,"f").resize)}}$d=new WeakMap,Ld=new WeakMap,Pd=new WeakMap,Nd=new WeakMap,Dd=new WeakMap,_d=new WeakSet,Fd=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,Ld,"f").style.top="32px",i(this,Ld,"f").style.left=window.innerWidth-300-32+"px"},qd=function(e){i(this,_d,"m",zd).call(this,e),i(this,_d,"m",Vd).call(this)},zd=function(e){i(this,Pd,"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("")},Vd=function(){i(this,Pd,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Hd=function(){const[e,t]=Md(i(this,Ld,"f"),Number.parseInt(i(this,Ld,"f").style.left,10),Number.parseInt(i(this,Ld,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Ld,"f").style.top=`${t}px`,i(this,Ld,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Jd);var Zd=Object.freeze({__proto__:null,default:Jd});return Ea}();
5
+ this["descope-user-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function s(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const r=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{let t,n;return(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)},l=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],s=e[o],r=t[o];if(null===s||null===r){if(s!==r)return!1}else if("object"==typeof s&&"object"==typeof r){if(!p(s,r))return!1}else if(s!==r)return!1}return!0}let f=class{constructor(e={},{forceUpdate:t=!1}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,c,"f")):e,n=Object.assign(Object.assign({},i(this,c,"f")),t);if(i(this,h,"f")||!p(i(this,c,"f"),n)){const e=i(this,c,"f");o(this,c,n,"f"),Object.freeze(i(this,c,"f")),setTimeout((()=>{Object.values(i(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,c,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,c,"f"))}subscribe(e){return o(this,u,i(this,u,"f")+1,"f"),i(this,d,"f")[i(this,u,"f")]=e,i(this,u,"f").toString()}unsubscribe(e){const t=!!i(this,d,"f")[e];return t&&delete i(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const g=["error","warn","info","debug"],v={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},m=l((e=>{var t,n,s,r;return r=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",s).call(this,v))}set logger(e){o(this,n,i(this,t,"m",s).call(this,e||v),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,s=function(e){return g.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},r})),b="undefined"!=typeof localStorage,w="https://static.descope.com/pages",y="https://static2.descope.com/pages",k=b&&localStorage.getItem("base.content.url")||"",I=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,S=l((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),C=l((e=>{var t,n;const o=s(m,S)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),x=e=>t=>{var n,o,r;const a=s(m,S,C)(t),l=Object.keys(e);return r=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},r};x.missingAttrValidator=I;const A=l((e=>{const t=s(x({"project-id":I}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),j=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),O="Trying the next fallback URL...",E=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const U=l((e=>{var t,n,r,a,l,c,d;const u=s(m,A,j)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const s=i(this,t,"m",l).call(this,e),c=Array.isArray(s)?e=>{const{baseUrl:t}=s[e];o(this,r,t,"f");for(let t=0;t<e;t++){const e=s[t].baseUrl;i(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const s=o[e],r=e===o.length-1;try{const o=await E(s.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${s}`),o;const a=`Error fetching URL ${s} [${o.status}]`;if(r)throw new Error(a);null==n||n.debug(`${a}. ${O}`)}catch(e){const t=`Error fetching URL ${s} [${e.message}]`;if(r)throw new Error(t);null==n||n.debug(`${t}. ${O}`)}}})(s,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,r=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const s=k||this.baseStaticUrl;if(s)return i(this,t,"m",c).call(this,e,s);i(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,r,void 0,"f"),i(this,a,"f").clear());const l=[];if(i(this,r,"f"))l.push(i(this,t,"m",c).call(this,e,i(this,r,"f"))),i(this,r,"f")===w&&l.push(i(this,t,"m",c).call(this,e,y));else{const n=this.baseUrl+"/pages";this.baseUrl&&!i(this,a,"f").has(n)&&l.push(i(this,t,"m",c).call(this,e,n)),i(this,a,"f").has(w)||l.push(i(this,t,"m",c).call(this,e,w)),l.push(i(this,t,"m",c).call(this,e,y))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=w}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},d})),R=l((e=>{var t,n;const o=s(x({"project-id":I}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),T=l((e=>{var t,n,r,a,l;const c=s(U,R,S)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),r.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,r,"f")||o(this,r,i(this,a,"f").call(this),"f"),i(this,r,"f")}},r=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,r,void 0,"f")},l})),M=l((e=>{var t,n,r,a,l,c,d;return d=class extends(s(S,m)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var s;null===(s=super.attributeChangedCallback)||void 0===s||s.call(this,e,n,o),"debug"===e&&i(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,r=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Dd})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",r).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),W=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],P=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},_=(e,t,n)=>new Promise(((i,o)=>{const s=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);s.onerror=e=>{s.setAttribute("status","error"),o(e)},s.onload=()=>{s.setAttribute("status","loaded"),i(s)},s.src=t.toString(),document.body.appendChild(s)})),L=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},$=l((e=>{const t=s(m)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:s}=i,r=(n=e,document.querySelector(`script#${n}`));if(r)try{return await L(r,s),i}catch(e){t(i,!0)}else try{return await _(e,o,s),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,s)=>{const r=s;if(!r)return e;let a;try{a=new URL(r)}catch(e){throw new Error(`Invalid URL: ${r}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${P(a)}`};return o&&(l.integrity=o),[...e,l]}),[]))([...i,this.baseCdnUrl,...W],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),N="base.ui.components.url",D=b&&localStorage.getItem(N),F=l((e=>{var t,n,r,a,l,c,d;const u=s(m,T,$)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return i(this,a,"f")||o(this,a,i(this,t,"m",c).call(this),"f"),i(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},r=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await i(this,t,"m",n).call(this),o=await i(this,t,"m",r).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[D],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),q=l((e=>{var t,n,o;const r=s(S,C)(e);return o=class extends r{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class z{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const V=l((e=>{const t=s(q)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new z(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),H="content-root",K="root",B=l((e=>{const t=s(V)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${H}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${H} {\n height: 100%;\n }\n #${K} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(H),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),J="descope-modal";var Z;let X=class{constructor(e,t){Z.set(this,void 0),this.nodeName="",o(this,Z,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(i(this,Z,"f"))}get ele(){var e,t;const n="function"==typeof i(this,Z,"f")?i(this,Z,"f").call(this):i(this,Z,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};Z=new WeakMap;let G=class extends X{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}},Y=class extends X{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}},Q=class extends X{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}},ee=class extends Y{get flowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id"))||""}get enableMode(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("enable-mode")}};var te;let ne=class extends X{constructor(){super(...arguments),te.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,te,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,te,"f").content.cloneNode(!0)))}setContent(e){o(this,te,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};te=new WeakMap;let ie=class extends X{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},oe=class extends X{constructor(){super(...arguments),this.nodeName="descope-combo-box"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},se=class extends X{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},re=class extends X{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}},ae=class extends X{constructor(){super(...arguments),this.nodeName="descope-trusted-devices"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onRemoveDeviceClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-device-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-device-clicked",n)}}},le=class extends oe{get action(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-action"))||""}get refreshTimeout(){var e;return Number(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-refresh-timeout"))||500}get shouldReload(){return"reload"===this.action}},ce=class extends X{constructor(){super(...arguments),this.nodeName="descope-user-passkeys"}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get addPasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("add-passkey-flow-id")}get removePasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("remove-passkey-flow-id")}onAddPasskeyClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("add-passkey-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("add-passkey-clicked",e)}}onRemovePasskeyClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-passkey-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-passkey-clicked",n)}}};const de=l((e=>{var t,n;const o=s(S,B,F)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ne{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(J);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([J]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ue="descope-notification",he=l((e=>{var t,n;const o=s(S,B,F)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ie{setContent(t){const n="string"==typeof t?r(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ue);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([ue])}},t=new WeakMap,n})),pe="theme",fe=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const s=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+fe(o,t,s);const r=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===r?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${s}:${r};`}),""),ge=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ve=l((e=>{var t,n,r,a,l,c,d,u,h,p,f,g,v,m,b,w,y;const k=s(x({theme:ge}),U,S,F,T,B,C,V)(e);return y=class extends k{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0),l.set(this,void 0),m.set(this,(()=>{i(this,t,"m",b).call(this),i(this,w,"f").call(this,"os"===this.getAttribute("theme"))})),w.set(this,(e=>{var n,o,s;const r=e?"addEventListener":"removeEventListener";null===(s=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[r])||void 0===s||s.call(o,"change",(()=>i(this,t,"m",b).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||pe}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,m,"f").call(this),await Promise.all([i(this,t,"m",u).call(this),i(this,t,"m",p).call(this)]),await i(this,t,"m",h).call(this),this.observeAttributes(["theme"],i(this,m,"f")),this.observeAttributes(["theme-override"],(()=>i(this,t,"m",h).call(this))),this.observeAttributes(["style-id"],(()=>{o(this,l,null,"f"),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this)}))}},n=new WeakMap,r=new WeakMap,l=new WeakMap,m=new WeakMap,w=new WeakMap,t=new WeakSet,a=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,s,r,a;const l=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,c=null===(a=null===(r=null===(s=e[t])||void 0===s?void 0:s.globals)||void 0===r?void 0:r.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${fe({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},c=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(N))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(N),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},d=function(){return i(this,l,"f")||(o(this,l,i(this,t,"m",c).call(this),"f"),i(this,l,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,l,"f")},u=async function(){var e,s;const r=await i(this,t,"a",d);r&&(i(this,n,"f")||o(this,n,this.injectStyle(""),"f"),i(this,n,"f").replaceSync(((null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.globals)||"")+((null===(s=null==r?void 0:r.dark)||void 0===s?void 0:s.globals)||"")))},h=async function(){var e;this.themeOverride?(i(this,r,"f")||o(this,r,this.injectStyle(""),"f"),i(this,r,"f").replaceSync(i(this,t,"m",a).call(this))):null===(e=i(this,r,"f"))||void 0===e||e.replaceSync("")},p=async function(){var e,n;const o=await i(this,t,"a",d);if(!o)return;const s=await this.descopeUi;(null==s?void 0:s.componentsThemeManager)&&(s.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},f=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,s=i||o;return null===(t=null==s?void 0:s[this.theme])||void 0===t?void 0:t.fonts},g=async function(){const e=await i(this,t,"m",f).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},v=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},b=function(){i(this,t,"m",g).call(this),i(this,t,"m",v).call(this)},y}));var me=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),be=()=>Math.random().toString(36).substring(7).split("").join("."),we={INIT:`@@redux/INIT${be()}`,REPLACE:`@@redux/REPLACE${be()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${be()}`};function ye(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function ke(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function Ie(e){let t=typeof e;return t=ke(e),t}function Se(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Ie(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${Ie(n)}'`);return n(Se)(e,t)}let i=e,o=t,s=new Map,r=s,a=0,l=!1;function c(){r===s&&(r=new Map,s.forEach(((e,t)=>{r.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Ie(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return r.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),r.delete(n),s=null}}}function h(e){if(!ye(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Ie(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${Ie(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=i(o,e)}finally{l=!1}return(s=r).forEach((e=>{e()})),e}h({type:we.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${Ie(e)}`);i=e,h({type:we.REPLACE})},[me]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${Ie(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[me](){return this}}}}}function Ce(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function xe(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&Ce(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const i=Object.keys(n);let o,s;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:we.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:we.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${we.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){s=e}return function(e={},t){if(s)throw s;{const i=function(e,t,n,i){const o=Object.keys(t),s=n&&n.type===we.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!ye(e))return`The ${s} has unexpected type of "${Ie(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const r=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!i[e]));return r.forEach((e=>{i[e]=!0})),n&&n.type===we.REPLACE?void 0:r.length>0?`Unexpected ${r.length>1?"keys":"key"} "${r.join('", "')}" found in ${s}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);i&&Ce(i)}let r=!1;const a={};for(let o=0;o<i.length;o++){const s=i[o],l=n[s],c=e[s],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${s}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[s]=d,r=r||d!==c}return r=r||i.length!==Object.keys(e).length,r?a:e}}function Ae(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function je(e){return ye(e)&&"type"in e&&"string"==typeof e.type}var Oe=Symbol.for("immer-nothing"),Ee=Symbol.for("immer-draftable"),Ue=Symbol.for("immer-state"),Re=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function Te(e,...t){{const n=Re[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var Me=Object.getPrototypeOf;function We(e){return!!e&&!!e[Ue]}function Pe(e){return!!e&&(Le(e)||Array.isArray(e)||!!e[Ee]||!!e.constructor?.[Ee]||qe(e)||ze(e))}var _e=Object.prototype.constructor.toString();function Le(e){if(!e||"object"!=typeof e)return!1;const t=Me(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===_e}function $e(e,t){0===Ne(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function Ne(e){const t=e[Ue];return t?t.type_:Array.isArray(e)?1:qe(e)?2:ze(e)?3:0}function De(e,t){return 2===Ne(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Fe(e,t,n){const i=Ne(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function qe(e){return e instanceof Map}function ze(e){return e instanceof Set}function Ve(e){return e.copy_||e.base_}function He(e,t){if(qe(e))return new Map(e);if(ze(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Le(e)){if(!Me(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ue];let i=Reflect.ownKeys(n);for(let t=0;t<i.length;t++){const o=i[t],s=n[o];!1===s.writable&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(n[o]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[o]})}return Object.create(Me(e),n)}function Ke(e,t=!1){return Je(e)||We(e)||!Pe(e)||(Ne(e)>1&&(e.set=e.add=e.clear=e.delete=Be),Object.freeze(e),t&&$e(e,((e,t)=>Ke(t,!0)))),e}function Be(){Te(2)}function Je(e){return Object.isFrozen(e)}var Ze,Xe={};function Ge(e){const t=Xe[e];return t||Te(0,e),t}function Ye(){return Ze}function Qe(e,t){t&&(Ge("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function et(e){tt(e),e.drafts_.forEach(it),e.drafts_=null}function tt(e){e===Ze&&(Ze=e.parent_)}function nt(e){return Ze={drafts_:[],parent_:Ze,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function it(e){const t=e[Ue];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function ot(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ue].modified_&&(et(t),Te(4)),Pe(e)&&(e=st(t,e),t.parent_||at(t,e)),t.patches_&&Ge("Patches").generateReplacementPatches_(n[Ue].base_,e,t.patches_,t.inversePatches_)):e=st(t,n,[]),et(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Oe?e:void 0}function st(e,t,n){if(Je(t))return t;const i=t[Ue];if(!i)return $e(t,((o,s)=>rt(e,i,t,o,s,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return at(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const t=i.copy_;let o=t,s=!1;3===i.type_&&(o=new Set(t),t.clear(),s=!0),$e(o,((o,r)=>rt(e,i,t,o,r,n,s))),at(e,t,!1),n&&e.patches_&&Ge("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function rt(e,t,n,i,o,s,r){if(o===n&&Te(5),We(o)){const r=st(e,o,s&&t&&3!==t.type_&&!De(t.assigned_,i)?s.concat(i):void 0);if(Fe(n,i,r),!We(r))return;e.canAutoFreeze_=!1}else r&&n.add(o);if(Pe(o)&&!Je(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;st(e,o),t&&t.scope_.parent_||at(e,o)}}function at(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ke(t,n)}var lt={get(e,t){if(t===Ue)return e;const n=Ve(e);if(!De(n,t))return function(e,t,n){const i=ut(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}(e,n,t);const i=n[t];return e.finalized_||!Pe(i)?i:i===dt(e.base_,t)?(pt(e),e.copy_[t]=ft(i,e)):i},has:(e,t)=>t in Ve(e),ownKeys:e=>Reflect.ownKeys(Ve(e)),set(e,t,n){const i=ut(Ve(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=dt(Ve(e),t),o=i?.[Ue];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||De(e.base_,t)))return!0;pt(e),ht(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==dt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,pt(e),ht(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ve(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){Te(11)},getPrototypeOf:e=>Me(e.base_),setPrototypeOf(){Te(12)}},ct={};function dt(e,t){const n=e[Ue];return(n?Ve(n):e)[t]}function ut(e,t){if(!(t in e))return;let n=Me(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Me(n)}}function ht(e){e.modified_||(e.modified_=!0,e.parent_&&ht(e.parent_))}function pt(e){e.copy_||(e.copy_=He(e.base_,e.scope_.immer_.useStrictShallowCopy_))}$e(lt,((e,t)=>{ct[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ct.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Te(13),ct.set.call(this,e,t,void 0)},ct.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Te(14),lt.set.call(this,e[0],t,n,e[0])};function ft(e,t){const n=qe(e)?Ge("MapSet").proxyMap_(e,t):ze(e)?Ge("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Ye(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,s=lt;n&&(o=[i],s=ct);const{revoke:r,proxy:a}=Proxy.revocable(o,s);return i.draft_=a,i.revoke_=r,a}(e,t);return(t?t.scope_:Ye()).drafts_.push(n),n}function gt(e){return We(e)||Te(10,e),vt(e)}function vt(e){if(!Pe(e)||Je(e))return e;const t=e[Ue];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=He(e,t.scope_.immer_.useStrictShallowCopy_)}else n=He(e,!0);return $e(n,((e,t)=>{Fe(n,e,vt(t))})),t&&(t.finalized_=!1),n}var mt=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const i=this;return function(e=n,...o){return i.produce(e,(e=>t.call(this,e,...o)))}}let i;if("function"!=typeof t&&Te(6),void 0!==n&&"function"!=typeof n&&Te(7),Pe(e)){const o=nt(this),s=ft(e,void 0);let r=!0;try{i=t(s),r=!1}finally{r?et(o):tt(o)}return Qe(o,n),ot(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===Oe&&(i=void 0),this.autoFreeze_&&Ke(i,!0),n){const t=[],o=[];Ge("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}Te(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,i;const o=this.produce(e,t,((e,t)=>{n=e,i=t}));return[o,n,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Pe(e)||Te(8),We(e)&&(e=gt(e));const t=nt(this),n=ft(e,void 0);return n[Ue].isManual_=!0,tt(t),n}finishDraft(e,t){const n=e&&e[Ue];n&&n.isManual_||Te(9);const{scope_:i}=n;return Qe(i,t),ot(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const i=Ge("Patches").applyPatches_;return We(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},bt=mt.produce;mt.produceWithPatches.bind(mt),mt.setAutoFreeze.bind(mt),mt.setUseStrictShallowCopy.bind(mt),mt.applyPatches.bind(mt),mt.createDraft.bind(mt),mt.finishDraft.bind(mt);var wt=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},yt=(e,t,n)=>{const{memoize:i,memoizeOptions:o}=t,{inputSelectorResults:s,inputSelectorResultsCopy:r}=e,a=i((()=>({})),...o);if(!(a.apply(null,s)===a.apply(null,r))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:s,secondInputs:r,stack:e})}},kt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var It=e=>Array.isArray(e)?e:[e];function St(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Ct(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var xt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},At=0,jt=1;function Ot(){return{s:At,v:void 0,o:null,p:null}}function Et(e,t={}){let n=Ot();const{resultEqualityCheck:i}=t;let o,s=0;function r(){let t=n;const{length:r}=arguments;for(let e=0,n=r;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const i=e.get(n);void 0===i?(t=Ot(),e.set(n,t)):t=i}else{let e=t.p;null===e&&(t.p=e=new Map);const i=e.get(n);void 0===i?(t=Ot(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===jt)l=t.v;else if(l=e.apply(null,arguments),s++,i){const e=o?.deref?.()??o;null!=e&&i(e,l)&&(l=e,0!==s&&s--);o="object"==typeof l&&null!==l||"function"==typeof l?new xt(l):l}return a.s=jt,a.v=l,l}return r.clearCache=()=>{n=Ot(),r.resetResultsCount()},r.resultsCount=()=>s,r.resetResultsCount=()=>{s=0},r}function Ut(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,s={},r=e.pop();"object"==typeof r&&(s=r,r=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(r,`createSelector expects an output function after the inputs, but received: [${typeof r}]`);const a={...n,...s},{memoize:l,memoizeOptions:c=[],argsMemoize:d=Et,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=It(c),f=It(u),g=St(e),v=l((function(){return i++,r.apply(null,arguments)}),...p);let m=!0;const b=d((function(){o++;const e=Ct(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...kt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:wt},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:yt}}})(m,h);if(n.shouldRun&&n.run(r,e,t),i.shouldRun){const t=Ct(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(b,{resultFunc:r,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:l,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var Rt=Ut(Et),Tt=Object.assign(((e,t=Rt)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e),i=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,i)=>(e[n[i]]=t,e)),{})));return i}),{withTypes:()=>Tt});function Mt(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var Wt=Mt(),Pt=Mt;((...e)=>{const t=Ut(...e)})(Et);var _t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ae:Ae.apply(null,arguments)},Lt=e=>e&&"function"==typeof e.match;function $t(e,t){function n(...n){if(t){let i=t(...n);if(!i)throw new Error("prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>je(t)&&t.type===e,n}function Nt(e){return"function"==typeof e&&"type"in e&&Lt(e)}function Dt(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Ft=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function qt(e){return Pe(e)?bt(e,(()=>{})):e}function zt(e,t,n){if(e.has(t)){let i=e.get(t);return n.update&&(i=n.update(i,t,e),e.set(t,i)),i}if(!n.insert)throw new Error("No insert provided for key not already in map");const i=n.insert(t,e);return e.set(t,i),i}function Vt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Ht(e,t,n){const i=Kt(e,t,n);return{detectMutations:()=>Bt(e,t,i,n)}}function Kt(e,t=[],n,i="",o=new Set){const s={value:n};if(!e(n)&&!o.has(n)){o.add(n),s.children={};for(const o in n){const r=i?i+"."+o:o;t.length&&-1!==t.indexOf(r)||(s.children[o]=Kt(e,t,n[o],r))}}return s}function Bt(e,t=[],n,i,o=!1,s=""){const r=n?n.value:void 0,a=r===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:s};if(e(r)||e(i))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in i)l[e]=!0;const c=t.length>0;for(let o in l){const r=s?s+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(r):r===e)))continue}const l=Bt(e,t,n.children[o],i[o],a,r);if(l.wasMutated)return l}return{wasMutated:!1}}function Jt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||ye(e)}function Zt(e,t="",n=Jt,i,o=[],s){let r;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(s?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),l=o.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(r=Zt(c,a,n,i,o,s),r))return r}return s&&Xt(e)&&s.add(e),!1}function Xt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Xt(t))return!1;return!0}function Gt(e){return"boolean"==typeof e}var Yt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let s=new Ft;if(t&&(Gt(t)?s.push(Wt):s.push(Pt(t.extraArgument))),n){let e={};Gt(n)||(e=n),s.unshift(function(e={}){{let t=function(e,t,i,o){return JSON.stringify(e,n(t,o),i)},n=function(e,t){let n=[],i=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,s){if(n.length>0){var r=n.indexOf(this);~r?n.splice(r+1):n.push(this),~r?i.splice(r,1/0,o):i.push(o),~n.indexOf(s)&&(s=t.call(this,o,s))}else n.push(s);return null==e?s:e.call(this,o,s)}},{isImmutable:i=Vt,ignoredPaths:o,warnAfter:s=32}=e;const r=Ht.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=r(i);return a=>l=>{const c=Dt(s,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=r(i),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=r(i),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(i){let e={};Gt(i)||(e=i),s.push(function(e={}){{const{isSerializable:t=Jt,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:s=[],warnAfter:r=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!je(u))return c(u);const h=c(u),p=Dt(r,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Zt(u,"",t,n,o,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const i=Zt(e.getState(),"",t,n,s,d);if(i){const{keyPath:e,value:t}=i;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};Gt(o)||(e=o),s.unshift(function(e={}){const{isActionCreator:t=Nt}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return s},Qt=e=>t=>{setTimeout(t,e)},en="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Qt(10),tn=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Ft(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,s=!1,r=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?en:"callback"===e.type?e.queueNotification:Qt(e.timeout),c=()=>{r=!1,s&&(s=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,s=!o,s&&(r||(r=!0,l(c))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function nn(e){const t=Yt(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:s,enhancers:r}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!ye(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=xe(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(l=i(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=Ae;o&&(c=_t({trace:!0,..."object"==typeof o&&o}));const d=function(...e){return t=>(n,i)=>{const o=t(n,i);let s=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const r={getState:o.getState,dispatch:(e,...t)=>s(e,...t)},a=e.map((e=>e(r)));return s=Ae(...a)(o.dispatch),{...o,dispatch:s}}}(...l),u=tn(d);if(r&&"function"!=typeof r)throw new Error("`enhancers` field must be a callback");let h="function"==typeof r?r(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Se(a,s,c(...h))}function on(e){const t={},n=[];let i;const o={addCase(e,s){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const r="string"==typeof e?e:e.type;if(!r)throw new Error("`builder.addCase` cannot be called with an empty action type");if(r in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${r}'`);return t[r]=s,o},addMatcher(e,t){if(i)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(i)throw new Error("`builder.addDefaultCase` can only be called once");return i=e,o}};return e(o),[t,n,i]}function sn(...e){return t=>e.some((e=>((e,t)=>Lt(e)?e.match(t):e(t))(e,t)))}var rn=["name","message","stack","code"],an=class{constructor(e,t){this.payload=e,this.meta=t}_type},ln=class{constructor(e,t){this.payload=e,this.meta=t}_type},cn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of rn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},dn=(()=>{function e(e,t,n){const i=$t(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=$t(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),s=$t(e+"/rejected",((e,t,i,o,s)=>({payload:o,error:(n&&n.serializeError||cn)(e||"Rejected"),meta:{...s||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(r,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let s=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=s)&&"object"==typeof f&&"function"==typeof f.then&&(s=await s),!1===s||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));r(o(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:r,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new an(e,t),fulfillWithValue:(e,t)=>new ln(e,t)})).then((t=>{if(t instanceof an)throw t;return t instanceof ln?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof an?s(null,c,e,t.payload,t.meta):s(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&s.match(p)&&p.meta.condition||r(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(un)})}}),{pending:o,rejected:s,fulfilled:i,settled:sn(s,i),typePrefix:e})}return e.withTypes=()=>e,e})();function un(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var hn=Symbol.for("rtk-slice-createasyncthunk");function pn(e,t){return`${e}/${t}`}function fn(e,t,n,i){function o(o,...s){let r=n.call(e,o);if(void 0===r){if(!i)throw new Error("selectState returned undefined for an uninjected slice reducer");r=e.getInitialState()}return t(r,...s)}return o.unwrapped=t,o}var gn=function({creators:e}={}){const t=e?.asyncThunk?.[hn];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},s=Object.keys(o),r={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in r.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return r.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(r.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(r.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(r.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?on(e.extraReducers):[e.extraReducers],o={...t,...r.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[i,o,s]=on(t);if(function(e){return"function"==typeof e}(e))n=()=>qt(e());else{const t=qt(e);n=()=>t}function r(e=n(),t){let r=[i[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===r.filter((e=>!!e)).length&&(r=[s]),r.reduce(((e,n)=>{if(n){if(We(e)){const i=n(e,t);return void 0===i?e:i}if(Pe(e))return bt(e,(e=>n(e,t)));{const i=n(e,t);if(void 0===i){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return i}}return e}),e)}return r.getInitialState=n,r}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of r.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);i&&e.addDefaultCase(i)}))}s.forEach((i=>{const s=o[i],r={reducerName:i,type:pn(n,i),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(s)?function({type:e,reducerName:t,createNotation:n},i,o){let s,r;if("reducer"in i){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(i))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");s=i.reducer,r=i.prepare}else s=i;o.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,r?$t(e,r):$t(e))}(r,s,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:s,fulfilled:r,pending:a,rejected:l,settled:c,options:d}=n,u=o(e,s,d);i.exposeAction(t,u),r&&i.addCase(u.fulfilled,r);a&&i.addCase(u.pending,a);l&&i.addCase(u.rejected,l);c&&i.addMatcher(u.settled,c);i.exposeCaseReducer(t,{fulfilled:r||vn,pending:a||vn,rejected:l||vn,settled:c||vn})}(r,s,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:r.actionCreators,caseReducers:r.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=zt(d,this,{insert:()=>new WeakMap});return zt(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=fn(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const i=t??this.reducerPath;return e.inject({reducerPath:i,reducer:this.reducer},n),{...this,reducerPath:i}}};return h}}();function vn(){}var mn="listenerMiddleware";$t(`${mn}/add`),$t(`${mn}/removeAll`),$t(`${mn}/remove`);const bn=e=>l((t=>{const n=gn(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(s(m)(t)){constructor(...e){super(...e);const t=nn({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const i=await t.dispatch(e(...n));try{un(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},s=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=s,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(m(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const wn=l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),yn=e=>"string"==typeof e?e:(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"",kn=(e={})=>{const t=r("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),yn(n))})),t};function In(e){return new URLSearchParams(window.location.search).get(e)}const Sn=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Cn=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),xn=dn("users/me",((e,{extra:{api:t}})=>t.user.me())),An=Sn(xn)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Cn((e=>e.me))),jn={action:xn,reducer:An},On=dn("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),En=Sn(On)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},Cn((e=>e.devices))),Un={action:On,reducer:En},Rn=dn("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),Tn=Sn(Rn)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},Cn((e=>e.passkeys))),Mn={action:Rn,reducer:Tn},Wn=dn("users/logout",((e,{extra:{api:t}})=>t.user.logout())),Pn={action:Wn,reducer:Sn(Wn)({})};class _n extends Error{}function Ln(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function $n(e,t){if("string"!=typeof e)throw new _n("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new _n(`Invalid token specified: missing part #${n+1}`);let o;try{o=Ln(i)}catch(e){throw new _n(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new _n(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}_n.prototype.name="InvalidTokenError";var Nn={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const Dn="<region>",Fn=`https://api.${Dn}descope.com`,qn=6e5,zn="dct",Vn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},Hn=[503,521,522,524,530],Kn=[100,5e3,5e3],Bn=e=>new Promise((t=>setTimeout(t,e))),Jn=e=>async(...t)=>{let n=await e(...t),i=0;for(;Hn.includes(n.status)&&i<Kn.length;)await Bn(Kn[i]),n=await e(...t),i++;i>0&&(n.retries=i);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let Zn;const Xn=()=>{if(Zn)return Zn;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return Zn=`${t}-${n}`,Zn};var Gn;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(Gn||(Gn={}));const Yn=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(Dn,o?o+".":"");let s=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{s=`${s}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return s},Qn=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),ei={"Content-Type":"application/json"},ti=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},ni=(e,t)=>{const n={"x-descope-sdk-session-id":Xn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.62.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},ii=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var oi=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:s,cookiePolicy:r,fetch:a})=>{const l=e||Fn,c=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Vn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await Jn(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return Vn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:Jn(n)})(o,a),d=async e=>{var o;const a=(null==s?void 0:s.beforeRequest)?s.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:Qn(ti(t,g),ni(t,i),(null==n?void 0:n.baseHeaders)||{},ii(v)?ei:{},h),method:f,body:v};null!==r&&(m.credentials=r||"include");const b=await c(Yn({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==s?void 0:s.afterRequest)&&await s.afterRequest(e,null==b?void 0:b.clone()),null==s?void 0:s.transformResponse){const e=await b.json(),t=(w=(null===(o=b.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const s=n;let r,a,l=!1;for(;i();)if(","===e.charAt(n)){for(r=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(s,r));break}n=r+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(s,e.length))}return t}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,s.transformResponse(n)}var w;return b};return{get:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Gn.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Gn.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Gn.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Gn.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Gn.delete,token:i}),hooks:s,buildUrl:(e,n)=>Yn({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},si=429;function ri(e,t,n){var i;let o=ai(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[zn])===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const s=null==o?void 0:o[n];return Array.isArray(s)?s:[]}function ai(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return $n(e)}function li(e){const{exp:t}=ai(e);return(new Date).getTime()/1e3>t}function ci(e){let t=ai(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function di(e,t){return ri(e,t,"permissions")}function ui(e,t){return ri(e,t,"roles")}const hi=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function pi(e,t){var n;const i=await e,o={code:i.status,ok:i.ok,response:i},s=await i.clone().json();return i.ok?o.data=s:(o.error=s,i.status===si&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function fi(e){var t;return(null===(t=ai(e))||void 0===t?void 0:t[zn])||""}const gi=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),vi=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},mi=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),bi=e=>t=>e.test(t),wi=bi(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),yi=bi(/^\+[1-9]{1}[0-9]{3,14}$/),ki=gi(wi,'"{val}" is not a valid email'),Ii=gi(yi,'"{val}" is not a valid phone number'),Si=gi((e=>e.length>=1),"Minimum length is 1");const Ci=gi((e=>"string"==typeof e),"Input is not a string"),xi=gi((e=>Array.isArray(e)),"Input is not an array"),Ai=gi((e=>"boolean"==typeof e),"Input is not a boolean"),ji=gi((e=>void 0===e),"Input is defined"),Oi=vi([Ci(),ji()],"Input is not a string or undefined"),Ei=vi([xi(),Ai()],"Input is not an array or boolean"),Ui=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>mi(...e).validate(n[t]))),t(...n)),Ri=e=>[Ci(`"${e}" must be a string`)],Ti=e=>[Oi(`"${e}" must be string or undefined`)],Mi=e=>[Ci(`"${e}" must be a string`),Si(`"${e}" must not be empty`)],Wi=e=>[Ci(`"${e}" must be a string`),ki()],Pi=e=>[Ci(`"${e}" must be a string`),Ii()],_i=Ui(Mi("accessKey")),Li=e=>({exchange:_i(((t,n)=>pi(e.post(Nn.accessKey.exchange,{loginOptions:n},{token:t}))))}),$i=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),s=e;for(;i.length>0;){if(s=s[o],!o||!s)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof s[o])throw Error(`"${t}" is not a function`);const r=s[o];s[o]=n(r)})),e),Ni=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||qn,qn)});var Di,Fi;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Di||(Di={})),function(e){e.email="email"}(Fi||(Fi={}));const qi=Object.assign(Object.assign({},Di),Fi);var zi;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(zi||(zi={}));const Vi=Mi("loginId"),Hi=Ui(Mi("token")),Ki=Ui(Vi),Bi=Ui(Mi("pendingRef")),Ji=Ui(Vi,Wi("email")),Zi=e=>({verify:Hi((t=>pi(e.post(Nn.enchantedLink.verify,{token:t})))),signIn:Ki(((n,i,o={},s)=>{var{providerId:r}=o,a=t(o,["providerId"]);return pi(e.post(hi(Nn.enchantedLink.signIn,qi.email),{loginId:n,URI:i,loginOptions:a,providerId:r},{token:s}))})),signUpOrIn:Ki(((n,i,o={})=>{var{providerId:s}=o,r=t(o,["providerId"]);return pi(e.post(hi(Nn.enchantedLink.signUpOrIn,qi.email),{loginId:n,URI:i,loginOptions:r,providerId:s}))})),signUp:Ki(((n,i,o,s={})=>{var{providerId:r}=s,a=t(s,["providerId"]);return pi(e.post(hi(Nn.enchantedLink.signUp,qi.email),{loginId:n,URI:i,user:o,loginOptions:a,providerId:r}))})),waitForSession:Bi(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:s}=Ni(n);let r;const a=setInterval((async()=>{const n=await e.post(Nn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),r&&clearTimeout(r),i(pi(Promise.resolve(n))))}),o);r=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${s}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),s)})))),update:{email:Ji(((t,n,i,o,s)=>pi(e.post(Nn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},s),{token:o}))))}}),Xi=Ui(Mi("flowId")),Gi=Ui(Mi("executionId"),Mi("stepId"),Mi("interactionId")),Yi=e=>({start:Xi(((t,n,i,o,s,r,a,l=!1)=>pi(e.post(Nn.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:s,flowVersions:r,input:a,isCustomScreen:l})))),next:Gi(((t,n,i,o,s,r,a=!1)=>pi(e.post(Nn.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:s,input:r,isCustomScreen:a}))))}),Qi=Mi("loginId"),eo=Ui(Mi("token")),to=Ui(Qi),no=Ui(Qi,Pi("phone")),io=Ui(Qi,Wi("email")),oo=Object.keys(qi).filter((e=>e!==Di.voice&&e!==Di.im)),so=e=>({verify:eo((t=>pi(e.post(Nn.magicLink.verify,{token:t})))),signIn:oo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:to(((n,o,s={},r)=>{var{providerId:a}=s,l=t(s,["providerId"]);return pi(e.post(hi(Nn.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:r}))}))})),{}),signUp:oo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:to(((n,o,s,r={})=>{var{providerId:a}=r,l=t(r,["providerId"]);return pi(e.post(hi(Nn.magicLink.signUp,i),{loginId:n,URI:o,user:s,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:oo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:to(((n,o,s={})=>{var{providerId:r}=s,a=t(s,["providerId"]);return pi(e.post(hi(Nn.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:r}))}))})),{}),update:{email:io(((t,n,i,o,s)=>pi(e.post(Nn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},s),{token:o})))),phone:Object.keys(Di).filter((e=>e!==Di.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:no(((t,i,o,s,r)=>pi(e.post(hi(Nn.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},r),{token:s}))))})),{})}});var ro;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(ro||(ro={}));const ao=Ui(Mi("code")),lo=e=>({start:Object.assign(((t,n,i,o,s)=>pi(e.post(Nn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),s&&{loginHint:s}),token:o}))),Object.keys(ro).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,s)=>pi(e.post(Nn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),s&&{loginHint:s}),token:o}))})),{})),exchange:ao((t=>pi(e.post(Nn.oauth.exchange,{code:t})))),startNative:(t,n,i)=>pi(e.post(Nn.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,s)=>pi(e.post(Nn.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:s})),getOneTapClientId:t=>pi(e.get(Nn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>pi(e.post(Nn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>pi(e.post(Nn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),co=Mi("appId"),uo=Ui(co),ho=e=>({connect:uo(((t,n,i)=>{const o=null==n?void 0:n.tenantId,s=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,pi(e.post(Nn.outbound.connect,{appId:t,tenantId:o,tenantLevel:s,options:n},{token:i}))}))}),po=Mi("loginId"),fo=Ui(po,Mi("code")),go=Ui(po),vo=Ui(po,Pi("phone")),mo=Ui(po,Wi("email")),bo=e=>({verify:Object.keys(qi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:fo(((t,i)=>pi(e.post(hi(Nn.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(qi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:go(((n,o={},s)=>{var{providerId:r}=o,a=t(o,["providerId"]);return pi(e.post(hi(Nn.otp.signIn,i),{loginId:n,loginOptions:a,providerId:r},{token:s}))}))})),{}),signUp:Object.keys(qi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:go(((n,o,s={})=>{var{providerId:r}=s,a=t(s,["providerId"]);return pi(e.post(hi(Nn.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:r}))}))})),{}),signUpOrIn:Object.keys(qi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:go(((n,o={})=>{var{providerId:s}=o,r=t(o,["providerId"]);return pi(e.post(hi(Nn.otp.signUpOrIn,i),{loginId:n,loginOptions:r,providerId:s}))}))})),{}),update:{email:mo(((t,n,i,o)=>pi(e.post(Nn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(Di).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vo(((t,i,o,s)=>pi(e.post(hi(Nn.otp.update.phone,n),Object.assign({loginId:t,phone:i},s),{token:o}))))})),{})}}),wo=Ui(Mi("tenant")),yo=Ui(Mi("code")),ko=e=>({start:wo(((t,n,i,o,s,r,a,l)=>pi(e.post(Nn.saml.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),s&&{ssoId:s}),r&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},o&&{token:o}))))),exchange:yo((t=>pi(e.post(Nn.saml.exchange,{code:t}))))}),Io=Mi("loginId"),So=Ui(Io,Mi("code")),Co=Ui(Io),xo=Ui(Io),Ao=e=>({signUp:Co(((t,n)=>pi(e.post(Nn.totp.signUp,{loginId:t,user:n})))),verify:So(((t,n,i,o)=>pi(e.post(Nn.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:xo(((t,n)=>pi(e.post(Nn.totp.update,{loginId:t},{token:n}))))}),jo=Mi("loginId"),Oo=Mi("newPassword"),Eo=Ui(jo,Mi("password")),Uo=Ui(jo),Ro=Ui(jo,Oo),To=Ui(jo,Mi("oldPassword"),Oo),Mo=e=>({signUp:Eo(((n,i,o,s={})=>{var{providerId:r}=s,a=t(s,["providerId"]);return pi(e.post(Nn.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:r}))})),signIn:Eo(((n,i,o={})=>{var{providerId:s}=o,r=t(o,["providerId"]);return pi(e.post(Nn.password.signIn,{loginId:n,password:i,loginOptions:r,providerId:s}))})),sendReset:Uo(((t,n,i)=>pi(e.post(Nn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:Ro(((t,n,i)=>pi(e.post(Nn.password.update,{loginId:t,newPassword:n},{token:i})))),replace:To(((t,n,i)=>pi(e.post(Nn.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>pi(e.get(Nn.password.policy))}),Wo=Ri("loginId"),Po=Mi("loginId"),_o=Mi("origin"),Lo=Ui(Po,_o,Mi("name")),$o=Ui(Po,_o),No=Ui(Wo,_o),Do=Ui(Po,_o,Ti("token")),Fo=Ui(Mi("transactionId"),Mi("response")),qo=e=>({signUp:{start:Lo(((t,n,i,o,s)=>pi(e.post(Nn.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:s,passkeyOptions:o})))),finish:Fo(((t,n)=>pi(e.post(Nn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:No(((t,n,i,o,s)=>pi(e.post(Nn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:s},{token:o})))),finish:Fo(((t,n)=>pi(e.post(Nn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:$o(((t,n,i,o)=>pi(e.post(Nn.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:Do(((t,n,i,o)=>pi(e.post(Nn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:Fo(((t,n)=>pi(e.post(Nn.webauthn.update.finish,{transactionId:t,response:n}))))}}),zo=Ri("loginId"),Vo=Ui(zo),Ho=Ui(Mi("pendingRef")),Ko=e=>({signUpOrIn:Vo(((n,i={})=>{var{providerId:o}=i,s=t(i,["providerId"]);return pi(e.post(Nn.notp.signUpOrIn,{loginId:n,loginOptions:s,providerId:o}))})),signUp:Vo(((n,i,o={})=>{var{providerId:s}=o,r=t(o,["providerId"]);return pi(e.post(Nn.notp.signUp,{loginId:n,user:i,providerId:s,loginOptions:r}))})),signIn:Vo(((n,i={},o)=>{var{providerId:s}=i,r=t(i,["providerId"]);return pi(e.post(Nn.notp.signIn,{loginId:n,loginOptions:r,providerId:s},{token:o}))})),waitForSession:Ho(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:s}=Ni(n);let r;const a=setInterval((async()=>{const n=await e.post(Nn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),r&&clearTimeout(r),i(pi(Promise.resolve(n))))}),o);r=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${s}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),s)}))))}),Bo=Ui(Mi("token")),Jo=Ui(Ti("token"));var Zo,Xo=Ui([(Zo=Mi("projectId"),gi(((e,t)=>n=>mi(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,s=e===Object(e)?e:void 0;for(;null!=s&&o<i;)s=s[n[o++]];return o&&o===i&&void 0!==s?s:void 0})(n,e)))("projectId",Zo))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:s={},refreshCookieName:r,fetch:a}=e;return l=oi({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:s},refreshCookieName:r,fetch:a}),{accessKey:Li(l),otp:bo(l),magicLink:so(l),enchantedLink:Zi(l),oauth:lo(l),outbound:ho(l),saml:ko(l),totp:Ao(l),notp:Ko(l),webauthn:qo(l),password:Mo(l),flow:Yi(l),refresh:Jo(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const s=i?Nn.tryRefresh:Nn.refresh;return pi(l.post(s,o,{token:e,queryParams:t}))})),selectTenant:Ui([Ci("tenantId")],[Oi('"token" must be string or undefined')])(((e,t)=>pi(l.post(Nn.selectTenant,{tenant:e},{token:t})))),logout:Jo((e=>pi(l.post(Nn.logout,{},{token:e})))),logoutAll:Jo((e=>pi(l.post(Nn.logoutAll,{},{token:e})))),me:Jo((e=>pi(l.get(Nn.me,{token:e})))),myTenants:Ui([Ei('"tenants" must a string array or a boolean')],[Oi('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,pi(l.post(Nn.myTenants,n,{token:t}))})),history:Jo((e=>pi(l.get(Nn.history,{token:e})))),isJwtExpired:Bo(li),getTenants:Bo(ci),getJwtPermissions:Bo(di),getJwtRoles:Bo(ui),getCurrentTenant:Bo(fi),httpClient:l};var l})),Go=Object.assign(Xo,{DeliveryMethods:qi});
6
+ /*! js-cookie v3.0.5 | MIT */function Yo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)e[i]=n[i]}return e}var Qo=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=Yo({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var r in o)o[r]&&(s+="; "+r,!0!==o[r]&&(s+="="+o[r].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+s}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var s=n[o].split("="),r=s.slice(1).join("=");try{var a=decodeURIComponent(s[0]);if(i[a]=t.read(r,a),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",Yo({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Yo({},this.attributes,t))},withConverter:function(t){return e(Yo({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var es={default:"endpoint"},ts="Blocked by CSP",ns="The endpoint parameter is not a valid URL",is="Failed to load the JS script of the agent",os="9319";function ss(e,t){var n,i,o,s,r,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,s=t.length;o<s;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),s=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,s++))},o=new Set,[n.current(),function(e,t){var s,r=t instanceof Error?t.message:"";if(r===ts||r===ns)n.exclude(),s=0;else if(r===os)n.exclude();else if(r===is){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),s=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=s?s:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=r||(r=e),a.length>=5)throw r;var t=d(n,e);if(!t)throw r;var i,o=t[0],s=t[1];return(i=s,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var rs="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",as=rs;function ls(n){var i;n.scriptUrlPattern;var o=n.token,s=n.apiKey,r=void 0===s?o:s,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:rs,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!r||"string"!=typeof r)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,r);return ss(e,cs)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===os?new Error(is):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function cs(e){return function(e,t,n){var i,o=document,s="securitypolicyviolation",r=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(s,r);var a=function(){return o.removeEventListener(s,r)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(ns);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},s=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(is))},i.async=!0,i.src=e,s.appendChild(i)}))}(e)}),(function(){throw new Error(ts)})).then(ds)}function ds(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(os);return n}const us="3.2.0",hs="undefined"!=typeof window,ps=Math.pow(2,31)-1,fs=`https://descopecdn.com/npm/oidc-client-ts@${us}/dist/browser/oidc-client-ts.min.js`,gs=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${us}/dist/browser/oidc-client-ts.min.js`,vs=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let ms;const bs=e=>{try{return $n(e).exp}catch(e){return null}},ws=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:bs(n)},ys=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?bs(i):void 0)},ks=e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:s}=e,r=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||ys(e),cookieExpiration:e.cookieExpiration||ws(e)},r)},Is=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Ss=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return ks(n)},Cs=()=>hs&&!!window.descopeBridge,xs=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return vs.includes(n)},As=void 0!==ms||hs&&void 0!==window.localStorage,js=(e,t)=>{var n,i;return null===(i=null===(n=ms||hs&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},Os=e=>{var t,n;return null===(n=null===(t=ms||hs&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Es=e=>{var t,n;return null===(n=null===(t=ms||hs&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},Us=e=>{var t,n,i,o,s;return null!==(s=null!==(n=null===(t=null==ms?void 0:ms.key)||void 0===t?void 0:t.call(ms,e))&&void 0!==n?n:hs&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==s?s:null},Rs=(...e)=>{console.debug(...e)},Ts=(...e)=>{console.warn(...e)},Ms="DS",Ws="DSR",Ps="DSI",_s="DSRCN";function Ls(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:s,cookieExpiration:r,cookieSecure:a}=n,l=new Date(1e3*r),c=$s(i);Qo.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:s,secure:a})}}function $s(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const Ns=e=>(null==e?void 0:e.cookieName)||Ms,Ds=e=>(null==e?void 0:e.cookieName)||Ws;function Fs(e="",t){return Qo.get(Ds(t))||Os(`${e}${Ws}`)||""}function qs(e="",t){return Qo.get(Ns(t))||Os(`${e}${Ms}`)||""}function zs(e=""){return Os(`${e}${Ps}`)||""}function Vs(e="",t,n,i){Es(`${e}${Ws}`),Es(`${e}${Ms}`),Es(`${e}${Ps}`),Es(`${e}${_s}`);const o=Ns(t);Qo.remove(o,null==i?void 0:i.session);const s=Ds(n);Qo.remove(s,null==i?void 0:i.refresh)}const Hs=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||Fs(e,t)});if(!n){const t=function(e=""){return Os(`${e}${_s}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const s=function(e=""){return Os(`${e}DTD`)||""}(e);return s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":s})),o},Ks=hs&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Bs="vsid",Js="vrid",Zs="fp",Xs=(e=!1)=>{const t=Os(Zs);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Gs=async(e,t=Ks)=>{try{if(Xs())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const s=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",r=ls({apiKey:e,endpoint:[i.toString(),es],scriptUrlPattern:[s,as]}),a=await r,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Bs]:e,[Js]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};js(Zs,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Ys=e=>{const t=Xs(!0);return t&&e.body&&(e.body.fpData=t),e},Qs="descopeFlowNonce",er="X-Descope-Flow-Nonce",tr="/v1/flow/start",nr="/v1/flow/next",ir=(e,t=Qs)=>`${t}${e}`,or=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},sr=e=>{var t;return e.path===nr&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?or(e.body.executionId):null},rr="dls_last_user_login_id",ar="dls_last_user_display_name",lr=e=>js(rr,e),cr=()=>Os(rr),dr=()=>Os(ar),ur=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=cr(),s=dr();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=s),await e(...t)},hr="DSLI",pr=e=>async(...t)=>{const n=await e(...t);return Es(hr),n};function fr(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function gr(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=kr(n.publicKey.challenge),n.publicKey.user.id=kr(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=kr(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Ir(n.rawId),type:n.type,response:{attestationObject:Ir(n.response.attestationObject),clientDataJSON:Ir(n.response.clientDataJSON)}});var n}async function vr(e){const t=wr(e);return yr(await navigator.credentials.get(t))}async function mr(e,t){const n=wr(e);return n.signal=t.signal,n.mediation="conditional",yr(await navigator.credentials.get(n))}async function br(e=!1){var t,n;if(!hs)return Promise.resolve(!1);if(Cs()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function wr(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=kr(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=kr(e.id)})),n}function yr(e){return JSON.stringify({id:e.id,rawId:Ir(e.rawId),type:e.type,response:{authenticatorData:Ir(e.response.authenticatorData),clientDataJSON:Ir(e.response.clientDataJSON),signature:Ir(e.response.signature),userHandle:e.response.userHandle?Ir(e.response.userHandle):void 0}})}function kr(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ir(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Sr,Cr=(Sr=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const s=await gr(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,s)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await vr(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await gr(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await vr(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const s=await gr(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,s)},helpers:{create:gr,get:vr,isSupported:br,conditional:mr}}),(...e)=>{const t=Sr(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const xr="/fedcm/config",Ar=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function jr(e,t){var n;try{await Or(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Or(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const s=Ar(),r=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:s,credential:null==n?void 0:n.credential})};r.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:s})),r.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var Er=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await br(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let Ur;const Rr=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const s=e.shift(),r=document.createElement("script");r.src=s,r.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(s),r.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},r.addEventListener("error",(()=>{Rr(e,t),r.setAttribute("data-error","true")})),document.body.appendChild(r)})),Tr=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{Ur||(Ur=(async()=>{try{return require("oidc-client-ts")}catch(e){return Rr([fs,gs],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await Ur;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const s=(null==n?void 0:n.redirectUri)||window.location.href;let r,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");r=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(r=e.httpClient.buildUrl(t),r=`${r}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(r=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:r,client_id:a,redirect_uri:s,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:s}=await i(),r=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(r)))),js(s,JSON.stringify({id_token:(a=r).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),r};return{loginWithRedirect:async(t={},n=!1)=>{var o;const{client:s}=await i(),r=await s.createSigninRequest(t),{url:a}=r;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(r)))),window.location.href=a),{ok:!0,data:r}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:s}=await i(),r=(e=>{const t=Os(e);return t?JSON.parse(t):null})(s);if(!r)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:r.session_state,profile:r.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||zs(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const s=await n.createSignoutRequest(e),{url:r}=s;return Es(o),t||window.location.replace(r),s}}},Mr=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,ms=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,s=t(n,["fpKey","fpLoad"]);return hs?(i&&o&&Gs(i).catch((()=>null)),e(Is(s,{beforeRequest:Ys}))):e(s)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.50.0"},t.baseHeaders)}))),(e=>t=>{const n=fr(),i=fr(),o=fr(),s=fr(),r=e(Is(t,{afterRequest:async(e,t)=>{if(xs(e,t))Rs("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),s.pub(null);else{const e=await(async e=>{const t=await Ss(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:r,sessionExpiration:a,claims:l}=await Ss(t);r&&i.pub(r),l&&s.pub(l),(a||r)&&n.pub(a||42)}}})),a=$i(r,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const r=await e(...t);return i.pub(null),o.pub(null),n.pub(null),s.pub(null),r}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:s.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:i=!0,nonceStoragePrefix:o=Qs}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);return i?(((e=Qs)=>{try{if(!As)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==ms?void 0:ms.length)&&void 0!==t?t:hs&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=Us(o);if(t&&t.startsWith(e)){const n=Os(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Es(t)}catch(e){Es(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(o),e(Is(s,{afterRequest:async(e,t)=>{if(e.path!==tr&&e.path!==nr)return;const{nonce:n,executionId:i}=await(async(e,t)=>{try{const n=t.headers.get(er);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=sr(e)),{nonce:n,executionId:or(i)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&i&&((e,t,n,i=Qs)=>{try{const o=ir(e,i),s=n?172800:10800,r={value:t,expiry:Date.now()+1e3*s,isStart:n};js(o,JSON.stringify(r))}catch(e){console.error("Error setting flow nonce:",e)}})(i,n,e.path===tr,o)},beforeRequest:e=>{if(e.path===nr){const t=sr(e);if(t){const n=((e,t=Qs)=>{try{const n=ir(e,t),i=Os(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(((e,t=Qs)=>{try{const n=ir(e,t);Es(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);n&&(e.headers=e.headers||{},e.headers[er]=n)}}return e}}))):e(s)}),(e=>t=>{const n=e(Is(t,{afterRequest:async(e,t)=>{if(xs(e,t))return void Es(hr);const n=await Ss(t);(null==n?void 0:n.sessionExpiration)&&js(hr,String(n.sessionExpiration))}}));return $i(n,["logout","logoutAll","oidc.logout"],pr)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);const s=!!i,r="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!s||Cs())return Object.assign(e(o),{markUserActive:()=>{Ts("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;r&&(Rs("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),hs&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(Rs("Expiration time passed, refreshing session"),f.refresh(Fs()||d))}));const f=e(Is(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:s}=await Ss(t);if(xs(e,t))Rs("Session invalidated, canceling all timers"),a();else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);Rs("Could not extract expiration time from session token, trying to decode the token");try{const t=$n(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void Rs("Could not extract expiration time from session token");d=i,h=s>0;const e=((e,t)=>{let n;var i;return t>0?(n=1e3*t,Rs(`Using provided nextRefreshSeconds: ${t}s`)):n=((i=e)?i.getTime()-(new Date).getTime():0)-2e4,n>ps&&(Rs(`Timeout is too large (${n}ms), setting it to ${ps}ms`),n=ps),n})(c,s);if(a(),e<=2e4)return void Rs("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Rs(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(hs&&"hidden"===document.visibilityState)Rs("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return Rs("Skipping refresh due to timer - user is idle"),void(p=!0);Rs("Refreshing session due to timer"),f.refresh(Fs()||i)}}),e)}}}));return Object.assign($i(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Rs("Clearing all timers"),a(),n})),{markUserActive:u?()=>{Rs("markUserActive() called"),h||Rs("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(Rs("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Fs()||d))}:()=>{Ts("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,s=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(s),{getLastUserLoginId:cr,getLastUserDisplayName:dr});const r=e(Is(s,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=ks((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),s=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;s?(lr(s),(e=>{js(ar,e)})(r)):(null==o?void 0:o.loginId)&&lr(o.loginId)}}));let a=$i(r,["flow.start"],ur);return a=$i(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Es(rr),Es(ar)),i})(o)),Object.assign(a,{getLastUserLoginId:cr,getLastUserDisplayName:dr})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:s,storagePrefix:r,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!hs)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(Is(Object.assign({refreshCookieName:a},l),{beforeRequest:Hs(r,s,a),afterRequest:async(e,t)=>{if(xs(e,t))Rs("Session invalidated, clearing persisted tokens"),Vs(r,o,s,c);else{const e=await Ss(t);e.cookieName?js(`${r||""}${_s}`,e.cookieName):e.refreshJwt&&Es(`${r||""}${_s}`);const n=((e={},t=!1,n="",i=!1)=>{var o,s,r,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(i){Es(`${n}${Ws}`);const t=i.sameSite||"Strict",r=null===(o=i.secure)||void 0===o||o,a=null!==(s=i.domain)&&void 0!==s?s:e.cookieDomain,l=Ds(i);r&&"https:"!==window.location.protocol&&Ts("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:r,cookieDomain:a});Ls(l,c,d);const h=$s(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=Ds(i);Qo.remove(e),js(`${n}${Ws}`,c)}if(l)if(t){const n=t.sameSite||"Strict",i=null===(r=t.secure)||void 0===r||r,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,s=Ns(t);i&&"https:"!==window.location.protocol&&Ts("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});Ls(s,l,c);const d=$s(o);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?o:void 0}})}else js(`${n}${Ms}`,l);return e.idToken&&js(`${n}${Ps}`,e.idToken),d&&js(`${n}DTD`,d),u})(e,o,r,s);n&&(c=n)}}})),u=$i(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...s)=>{const r=await o(...s);return Vs(e,t,n,null==i?void 0:i()),r})(r,o,s,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Fs(r,s),getSessionToken:()=>qs(r,o),getIdToken:()=>zs(r)})}))((e=>{const t=Go(e),n=Tr(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var s;if(Cs())return Rs(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&!Os(hr)&&!Os(rr)&&!Os("DSLI_DISABLED"))return Promise.resolve({ok:!0});const r=qs(),a=Fs();let l="";if(e.getExternalToken)try{l=await(null===(s=e.getExternalToken)||void 0===s?void 0:s.call(e))}catch(e){Rs("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:r?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:Er(t),webauthn:Cr(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){jr(i,e)},requestAuthentication(e){jr(i,e)}},async oneTap(e,t,n,o,s){await Or(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:s})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+xr),clientId:o}]}},s=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(s.token)},isSupported:()=>hs&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+xr);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},s=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!s&&!!s.token}catch(e){return!1}}}),oidc:n});var i,o})),Wr=e=>{if(!e)return null;const t=(e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""));return JSON.parse(n)}catch(e){return null}})(e);return(null==t?void 0:t.dct)||null},Pr=e=>e.me.data,_r=Rt(Pr,(e=>e.userId)),Lr=Rt(Pr,(e=>e.picture)),$r=Rt(Pr,(e=>e.email)),Nr=Rt(Pr,(e=>e.verifiedEmail)),Dr=Rt(Pr,(e=>e.name)),Fr=Rt(Pr,(e=>e.phone)),qr=Rt(Pr,(e=>e.verifiedPhone)),zr=Rt($r,Nr,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),Vr=Rt(Fr,qr,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),Hr=Rt(Pr,(e=>e.webauthn));Rt(Pr,(e=>e.password));const Kr=Rt(Pr,(e=>e.TOTP)),Br=Rt(Pr,(e=>e.customAttributes)),Jr=Rt(Pr,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),Zr=Rt((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:n,lastLoginTime:i,isCurrentDevice:o})=>({id:e,name:t,deviceType:n,lastLoginDate:1e3*parseInt(i,10),isCurrent:o}))))),Xr=Rt((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:n,createdTime:i})=>({id:e,name:t,passkeyType:n,createdAt:1e3*i}))))),Gr=e=>e.notifications,Yr=Rt(Pr,(e=>e.userTenants||[])),Qr=e=>e.tenant.currentTenantId,ea=dn("tenant/select",((e,t)=>n(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:n}){if(e===Qr(n()))return null;const i=yield t.user.setCurrentTenant(e),o=i.sessionJwt||i.sessionToken;try{return{tenantId:Wr(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),ta={action:ea,reducer:Sn(ea)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var n;e.tenant.currentTenantId=null===(n=t.payload)||void 0===n?void 0:n.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},Cn((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{if(t){const i=t(n);i&&e.notifications.push({type:"success",msg:i})}},onRejected:(t,n)=>{if(e){const i=e(n);i&&t.notifications.push({type:"error",msg:i})}}}))({getErrorMsg:e=>{var t,n;const i=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(n=e.error)||void 0===n?void 0:n.name)?i:`${i||"Error"}`}}))},na={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},ia={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",passkeys:"/v1/mgmt/user/passkeys/list",selectTenant:"/v1/auth/tenant/select"},oa=e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),sa=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],ra=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:sa,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),aa=()=>({devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]}),la=()=>({passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]}),ca=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return ra();const n=yield e.get(ia.me);return yield oa(n),n.json()})),setCurrentTenant:t=>n(void 0,void 0,void 0,(function*(){const n=yield e.post(ia.selectTenant,{tenant:t});return yield oa(n),n.json()}))}),da=({httpClient:e,mock:t})=>({devices:i=>n(void 0,[i],void 0,(function*({userId:n}){if(t)return aa();const i=yield e.post(ia.devices,{identifiers:[n]});return yield oa(i),i.json()}))}),ua=({httpClient:e,mock:t})=>({listPasskeys:i=>n(void 0,[i],void 0,(function*({userId:n}){if(t)return la();const i=yield e.post(ia.passkeys,{loginId:n});return yield oa(i),i.json()}))}),ha=l((e=>{var t,r,a,l;const c=s(A,C,m,j,wn)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),r.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||pe}get api(){return i(this,r,"f")||i(this,t,"m",a).call(this),i(this,r,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{i(this,r,"f")&&i(this,t,"m",a).call(this)}))}))}},r=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,r,((e,t,i)=>{const o=Mr(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.11.0"}}));return{user:Object.assign(Object.assign({},ca({httpClient:o.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},da({httpClient:o.httpClient,mock:t})),passkey:Object.assign({},ua({httpClient:o.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),pa=l((e=>{const t=s(bn({name:"widget",initialState:na,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{jn.reducer(e),Un.reducer(e),Mn.reducer(e),Pn.reducer(e),ta.reducer(e)},asyncActions:{getMe:jn.action,listDevices:Un.action,listPasskeys:Mn.action,logout:Pn.action,selectTenant:ta.action}}),S,m,ha)(e);return class extends t{constructor(...e){super(...e),this.state=na,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),fa="widget-flow",ga=l((e=>{var t,o,r;return r=class extends(s(S,de,pa,wn,m,ve)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const s=In(fa);s&&(!function(e){if(window.history.replaceState&&In(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(fa),i(this,t,"m",o).call(this,s))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(kn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));new Q((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},r})),va=l((e=>{const t=s(U,x({"widget-id":x.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),ma=l((e=>{var t,o,a;return a=class extends(s(m,S,F,B,va,pa)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield i(this,t,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=r(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),ba=l((e=>class extends(s(ve,C)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),wa=l((e=>{var t,r,l,c,d,u,h,p,f;return f=class extends(s(ba,ve,pa,m,wn,ma,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.avatar.image=e}))),p.set(this,a((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Lr(this.state)),i(this,p,"f").call(this,Dr(this.state)),this.subscribe(i(this,h,"f").bind(this),Lr),this.subscribe(i(this,p,"f").bind(this),Dr)}))}},r=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(){this.avatar.flowId&&(o(this,r,this.createModal({"data-id":"update-pic"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,r,"f").afterClose=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this),this.syncFlowTheme(i(this,l,"f")))},d=function(){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new G((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=i(this,r,"f"))||void 0===e||e.open()}))},f})),ya=l((e=>{var t,r,l,c,d,u,h,p,f,g,v,b,w;return w=class extends(s(ba,pa,m,ma,wn,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.emailUserAttr.value=e}))),b.set(this,a((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,$r(this.state)),i(this,b,"f").call(this,zr(this.state)),this.subscribe(i(this,v,"f").bind(this),$r),this.subscribe(i(this,b,"f").bind(this),zr)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,b=new WeakMap,t=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(o(this,r,this.createModal({"data-id":"edit-email"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,r,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-email"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(kn({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new se((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=i(this,r,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w})),ka=l((e=>{var t,o,r;return r=class extends(s(pa,m,ma,de)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){this.logout=new Y((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>n(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},r})),Ia=l((e=>{var t,r,l,c,d,u,h,p,f,g,v,b;return b=class extends(s(ba,pa,m,ma,wn,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Dr(this.state)),this.subscribe(i(this,v,"f").bind(this),Dr)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(o(this,r,this.createModal({"data-id":"edit-name"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,r,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-name"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(kn({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new se((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=i(this,r,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),Sa=l((e=>{var t,r,l,c,d,u,h,p,f,g,v,b;return b=class extends(s(ba,pa,m,ma,wn,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Hr(this.state)),this.subscribe(i(this,v,"f").bind(this),Hr)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.passkeyUserAuthMethod.flowId&&(o(this,r,this.createModal({"data-id":"add-passkey"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,r,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createModal({"data-id":"remove-passkey"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(kn({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.passkeyUserAuthMethod=new re((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,r,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),Ca=l((e=>{var t,r,a,l,c,d;return d=class extends(s(ba,pa,m,ma,wn,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),a.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new re((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,r,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.initPasswordAuthMethod(),i(this,t,"m",l).call(this)}))}},r=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){this.passwordUserAuthMethod.flowId&&(o(this,r,this.createModal({"data-id":"password"}),"f"),o(this,a,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,r,"f").afterClose=i(this,t,"m",c).bind(this),i(this,t,"m",c).call(this),this.syncFlowTheme(i(this,a,"f")))},c=function(){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,a,"f").onSuccess((()=>{i(this,r,"f").close()}))},d})),xa=l((e=>{var t,r,l,c,d,u,h,p,f,g,v,b,w;return w=class extends(s(ba,pa,m,ma,wn,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.phoneUserAttr.value=e}))),b.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Fr(this.state)),i(this,b,"f").call(this,Vr(this.state)),this.subscribe(i(this,v,"f").bind(this),Fr),this.subscribe(i(this,b,"f").bind(this),Vr)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,b=new WeakMap,t=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(o(this,r,this.createModal({"data-id":"edit-phone"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,r,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-phone"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(kn({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new se((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=i(this,r,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w})),Aa=l((e=>{var t,r,l,c,d,u,h,p,f,g,v,b;return b=class extends(s(ba,pa,m,ma,wn,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Kr(this.state)),this.subscribe(i(this,v,"f").bind(this),Kr)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.totpUserAuthMethod.flowId&&(o(this,r,this.createModal({"data-id":"totp"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,r,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.totpUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createModal({"data-id":"remove-totp"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(kn({projectId:this.projectId,flowId:this.totpUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.totpUserAuthMethod=new re((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,r,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),ja=l((e=>{var t,o,r,l,c,d,u,h,p,f,g;return g=class extends(s(ba,pa,m,ma,wn,de)(e)){constructor(){super(...arguments),t.add(this),o.set(this,{}),r.set(this,{}),l.set(this,{}),c.set(this,{}),h.set(this,a((e=>{var n;const o=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(o).forEach((n=>{const o=n.getAttribute("data-id").replace("builtin.",""),s=e[o],r=new se(n,{logger:this.logger});r.value=(s||"").toString(),i(this,t,"m",p).call(this,n,o,r),i(this,t,"m",f).call(this,n,o,r)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,h,"f").call(this,Jr(this.state)),this.subscribe(i(this,h,"f").bind(this),Jr)}))}},o=new WeakMap,r=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,d=function(e){var t,n;null===(t=i(this,o,"f")[e])||void 0===t||t.setContent(kn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(n=i(this,r,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,o,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},u=function(e){var t,n;null===(t=i(this,l,"f")[e])||void 0===t||t.setContent(kn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(n=i(this,c,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,l,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},p=function(e,n,s){const a=e.getAttribute("edit-flow-id");a&&(i(this,o,"f")[a]=this.createModal({"data-id":`edit-${n}`}),i(this,r,"f")[a]=new Q((()=>{var e,t;return null===(t=null===(e=i(this,o,"f")[a])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,o,"f")[a].afterClose=i(this,t,"m",d).bind(this,a),s.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,o,"f"))||void 0===e?void 0:e[a])||void 0===t||t.open()})),i(this,t,"m",d).call(this,a),this.syncFlowTheme(i(this,r,"f")[a]))},f=function(e,n,o){const s=e.getAttribute("delete-flow-id");s&&(i(this,l,"f")[s]=this.createModal({"data-id":`delete-${n}`}),i(this,c,"f")[s]=new Q((()=>{var e,t;return null===(t=null===(e=i(this,l,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,l,"f")[s].afterClose=i(this,t,"m",u).bind(this,s),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,l,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),i(this,t,"m",u).call(this,s),this.syncFlowTheme(i(this,c,"f")[s]))},g}));var Oa;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Oa||(Oa={}));const Ea=l((e=>{var t,o,r,l,c,d,u,h,p,f,g;return o=class extends(s(ba,pa,m,ma,wn,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),p.set(this,a((e=>{var n;const s=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(s).forEach((n=>{const s=n.getAttribute("data-id").replace("customAttributes.",""),r=n.getAttribute("data-type")||Oa.TEXT,a=e[s],l=new se(n,{logger:this.logger});l.value=o.getFormattedValue(r,a),i(this,t,"m",f).call(this,n,s,l),i(this,t,"m",g).call(this,n,s,l)}))})))}static getFormattedValue(e,t){return e===Oa.DATE&&t?new Date(t).toLocaleString():e===Oa.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,p,"f").call(this,Br(this.state)),this.subscribe(i(this,p,"f").bind(this),Br)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,t=new WeakSet,u=function(e){var t,n;null===(t=i(this,r,"f")[e])||void 0===t||t.setContent(kn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(n=i(this,l,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,r,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,n;null===(t=i(this,c,"f")[e])||void 0===t||t.setContent(kn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},f=function(e,n,o){const s=e.getAttribute("edit-flow-id");s&&(i(this,r,"f")[s]=this.createModal({"data-id":`edit-${n}`}),i(this,l,"f")[s]=new Q((()=>{var e,t;return null===(t=null===(e=i(this,r,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,r,"f")[s].afterClose=i(this,t,"m",u).bind(this,s),o.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,r,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),i(this,t,"m",u).call(this,s),this.syncFlowTheme(i(this,l,"f")[s]))},g=function(e,n,o){const s=e.getAttribute("delete-flow-id");s&&(i(this,c,"f")[s]=this.createModal({"data-id":`delete-${n}`}),i(this,d,"f")[s]=new Q((()=>{var e,t;return null===(t=null===(e=i(this,c,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,c,"f")[s].afterClose=i(this,t,"m",h).bind(this,s),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,c,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),i(this,t,"m",h).call(this,s),this.syncFlowTheme(i(this,d,"f")[s]))},o})),Ua=l((e=>{var t,r,l,c,d,u,h,p;return p=class extends(s(ba,ve,pa,m,wn,ma,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),this.updateDeviceList=a((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.deviceList=new ae((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield i(this,t,"m",h).call(this),i(this,t,"m",u).call(this,Zr(this.state)),i(this,t,"m",c).call(this),this.subscribe(this.updateDeviceList.bind(this),Zr))}))}},r=new WeakMap,l=new WeakMap,t=new WeakSet,c=function(){this.deviceList.flowId&&(o(this,r,this.createModal({"data-id":"untrust-device"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,r,"f").afterClose=()=>i(this,t,"m",d).call(this,""),this.syncFlowTheme(i(this,l,"f")))},d=function(e=""){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:this.deviceList.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{deviceId:e}})),i(this,l,"f").onSuccess((()=>{i(this,r,"f").close(),this.actions.listDevices({userId:_r(this.state)})}))},u=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var n;i(this,t,"m",d).call(this,e),null===(n=i(this,r,"f"))||void 0===n||n.open()})),this.deviceList.data=e},h=function(){return n(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:_r(this.state)})}))},p})),Ra=l((e=>{var t,r,l,c,d,u,h,p,f,g,v,b;return b=class extends(s(ba,pa,m,ma,wn,de)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),g.set(this,a((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=a((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.userPasskeys=new ce((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(i(this,t,"m",v).call(this,Xr(this.state)),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),this.subscribe(i(this,g,"f").bind(this),_r),this.subscribe(this.updatePasskeyList.bind(this),Xr))}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,g=new WeakMap,t=new WeakSet,u=function(){this.userPasskeys.addPasskeyFlowId&&(o(this,r,this.createModal({"data-id":"add-user-passkey"}),"f"),o(this,l,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,r,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:this.userPasskeys.addPasskeyFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,l,"f").onSuccess((()=>{i(this,r,"f").close(),this.actions.getMe(),i(this,g,"f").call(this,_r(this.state))}))},p=function(){this.userPasskeys.removePasskeyFlowId&&(o(this,c,this.createModal({"data-id":"remove-user-passkey"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(i(this,d,"f")))},f=function({externalId:e,credentialId:t}){i(this,c,"f").setContent(kn({projectId:this.projectId,flowId:this.userPasskeys.removePasskeyFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{externalId:e,credentialId:t}})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe(),i(this,g,"f").call(this,_r(this.state))}))},v=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=i(this,r,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var n;const o=_r(this.state);i(this,t,"m",f).call(this,{externalId:o,credentialId:e}),null===(n=i(this,c,"f"))||void 0===n||n.open()}))},b}));const Ta={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Ma=l((e=>{var t,o,r,l,c;return c=class extends(s(m,pa,he,S)(e)){constructor(){super(...arguments),t.add(this),l.set(this,a((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const s=i(this,t,"m",r).call(this,e);s.setContent(i(this,t,"m",o).call(this,{type:e,msg:n})),s.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(i(this,l,"f").bind(this),Gr)}))}},l=new WeakMap,t=new WeakSet,o=function({type:e,msg:t}){const n=Ta[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},r=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},c})),Wa=l((e=>{var t,r,a,l,c,d,u,h,p,f,g;return g=class extends(s(pa,m,ma)(e)){constructor(){super(...arguments),t.add(this),r.set(this,null),l.set(this,(e=>n(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),c.set(this,(e=>{const n=Qr(e);this.tenantSelector.value!==n&&i(this,t,"m",p).call(this,n);const{loading:s,error:a}=e.selectTenant,l=null!==e.tenant.previousTenantId,c=n!==i(this,r,"f");!n||s||a||l||!c||(o(this,r,n,"f"),i(this,t,"m",d).call(this))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.actions.setCurrentTenantId((()=>{const e=qs();return Wr(e)})()),i(this,t,"m",a).call(this),i(this,t,"m",f).call(this),i(this,t,"m",h).call(this,Yr(this.state)),this.subscribe(i(this,c,"f").bind(this))}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,a=function(){this.tenantSelector=new le((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(i(this,l,"f"))},d=function(){const e=Qr(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&i(this,t,"m",u).call(this)},u=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},h=function(e){return n(this,void 0,void 0,(function*(){const t=e.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(t)}))},p=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{i(this,t,"m",p).call(this,Qr(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),Pa=l((e=>{var t,r,a,l,c,d,u,h,p,f,g;return g=class extends(s(ba,pa,de,m,ma)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),a.set(this,void 0),l.set(this,[]),c.set(this,null)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",h).call(this),i(this,t,"m",u).call(this),i(this,l,"f").forEach((e=>e.enable()))}))}},r=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(e){const n=new ee(e,{logger:this.logger});n.onClick((()=>{i(this,t,"m",f).call(this,n.flowId,_r(this.state))})),i(this,l,"f").push(n)},u=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(n).forEach((e=>{i(this,t,"m",d).call(this,e)}))},h=function(){o(this,r,this.createModal({"data-id":"generic-flow-modal"}),"f"),i(this,r,"f").afterClose=()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.call(this),o(this,c,null,"f")},o(this,a,new Q((()=>{var e;return null===(e=i(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(i(this,a,"f"))},p=function(){var e;i(this,r,"f").open(),null===(e=i(this,c,"f"))||void 0===e||e.call(this)},f=function(e,n){i(this,r,"f").setContent(kn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,client:{userId:n}}));o(this,c,i(this,a,"f").onPageUpdated((()=>i(this,t,"m",p).call(this))),"f"),i(this,a,"f").onSuccess((()=>{i(this,r,"f").close(),this.actions.getMe()}))},g})),_a=l((e=>class extends(s(M,ve,ga,Ea,ya,wa,Ia,xa,Sa,Ca,Aa,ja,ka,Ua,Ra,Ma,Wa,Pa)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),La=s((e=>class extends(_a(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return xd})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.11.0"}}}))}}))(HTMLElement),$a="undefined"!=typeof localStorage,Na="J151000",Da="E103205",Fa=$a&&localStorage.getItem("base.content.url")||"",qa="base.ui.components.url";$a&&localStorage.getItem(qa),$a&&localStorage.getItem(qa);const za="descope-login-flow",Va="code",Ha="redirect_mode",Ka="err",Ba="data-exclude-field",Ja="data-exclude-next",Za="dls_last_auth",Xa="state_id",Ga="saml_idp_state_id",Ya="wsfed_idp_state_id",Qa="saml_idp_username",el="descope_idp_initiated",tl="sso_app_id",nl="custom_app_id",il="third_party_app_id",ol="third_party_app_state_id",sl="oidc_login_hint",rl="oidc_prompt",al="oidc_resource",ll="oidc_error_redirect_uri",cl="application_scopes",dl="data-type",ul="redirect",hl="poll",pl="webauthnCreate",fl="webauthnGet",gl="nativeBridge",vl="loadForm",ml="submit",bl="polling",wl=["descope-multi-select-combo-box","descope-text-area"],yl="dls_last_auth_in_flight",kl=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Il;!function(e){e.backward="backward",e.forward="forward"}(Il||(Il={}));const Sl=["descope-enriched-text"];function Cl(e){return new URLSearchParams(window.location.search).get(e)}function xl(e){if(window.history.replaceState&&Cl(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function Al(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Il.forward:n<i?Il.backward:void 0}const jl=e=>{let[t="",n=""]=(Cl(za)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Ol(){xl(za)}const El=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Ul=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=jl(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Ol();const s=Cl("t")||void 0;s&&xl("t");const r=Cl(Va)||void 0;r&&xl(Va);const a="popup"===Cl(Ha);a&&xl(Ha);const l=Cl(Ka)||void 0;l&&xl(Ka);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:Cl("ra-challenge"),redirectAuthCallbackUrl:Cl("ra-callback"),redirectAuthBackupCallbackUri:Cl("ra-backup-callback"),redirectAuthInitiator:Cl("ra-initiator")},p=Cl(Xa);p&&xl(Xa);const f=Cl(Ga);f&&xl(Ga);const g=Cl(Ya);g&&xl(Ya);const v=Cl(Qa);f&&xl(Qa);const m=Cl(el);m&&xl(el);const b=Cl(tl);b&&xl(tl);const w=Cl(nl);w&&xl(nl);const y=Cl(il);y&&xl(il);const k=Cl(ol);k&&xl(ol);const I=Cl(cl);I&&xl(cl);const S=Cl(sl);S&&xl(sl);const C=Cl(rl);C&&xl(rl);const x=Cl(ll);x&&xl(ll);const A=Cl(al);return A&&xl(al),{executionId:n,stepId:i,token:s,code:r,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:b,customAppId:w,oidcLoginHint:S,oidcPrompt:C,oidcErrorRedirectUri:x,oidcResource:A,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:I}}},Rl=e=>{let t,n;return Object.assign(((...i)=>{return t&&(s=i,(o=t).length===s.length&&o.every(((e,t)=>e===s[t])))||(t=i,n=e(...i)),n;var o,s}),{reset:()=>{t=void 0,n=void 0}})},Tl=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function Ml(e,t,n){return new Promise(((i,o)=>{let s=!1;const r=setTimeout((()=>{s=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{s||(clearTimeout(r),i(e))})).catch((e=>{s||(clearTimeout(r),o(e))}))}))}const Wl=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:s,customAppId:r,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||i||o||s||r||a||l||c||d||u||h||p),Pl=e=>null==e?void 0:e.submit(),_l=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Ll=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function $l(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const Nl=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Dl(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Fl,ql,zl,Vl;function Hl(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],s=e[o],r=t[o];if(null===s||null===r){if(s!==r)return!1}else if("object"==typeof s&&"object"==typeof r){if(!Hl(s,r))return!1}else if(s!==r)return!1}return!0}let Kl=class{constructor(e={},{forceUpdate:t=!1}={}){Fl.set(this,void 0),ql.set(this,{}),zl.set(this,0),Vl.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,Fl,"f")):e,n=Object.assign(Object.assign({},i(this,Fl,"f")),t),s=i(this,Fl,"f");o(this,Fl,n,"f"),Object.freeze(i(this,Fl,"f")),setTimeout((()=>{Object.values(i(this,ql,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const r=t(s),a=t(n);(i(this,Vl,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!Hl(r,a):r!==a))&&e(a,r,((e,t)=>n=>e[n]!==t[n])(a,r))}))}),0)},o(this,Fl,e,"f"),o(this,Vl,t,"f")}get current(){return Object.assign({},i(this,Fl,"f"))}set forceUpdate(e){o(this,Vl,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,zl,i(this,zl,"f")+1,"f"),i(this,ql,"f")[i(this,zl,"f")]={cb:e,selector:t,forceUpdate:n},i(this,zl,"f").toString()}unsubscribe(e){const t=!!i(this,ql,"f")[e];return t&&delete i(this,ql,"f")[e],t}unsubscribeAll(){return o(this,ql,{},"f"),!0}};Fl=new WeakMap,ql=new WeakMap,zl=new WeakMap,Vl=new WeakMap;const Bl=["*","#","/","(",")","[","]","_","<",">","`"],Jl=e=>"string"!=typeof e?e:e.replace((e=>{const t=Bl.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),Zl=["disabled"],Xl=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Ba}])`)).forEach((e=>{e.value=n}))}))},Gl=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Yl=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?Jl(Gl(t,i)):Gl(t,i))),Ql=(e,t,n)=>{e.querySelectorAll(`[${dl}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},ec=(e,t,n)=>{var i,o;const s=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&s&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(s,`url(data:image/jpg;base64,${n})`))},tc=(e,n,i,o)=>{var s,r;Ql(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),Ql(e,"notp-link",null===(r=null==n?void 0:n.notp)||void 0===r?void 0:r.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>Sl.includes(e))(e.localName);e.textContent=Yl(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",Yl(i,t))}))})(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,s=t(n,["componentsDynamicAttrs"]),r=Object.keys(s).reduce(((e,t)=>(e[`[name=${t}]`]=s[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(r[e]=n)}})),Object.keys(r).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=r[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==n?void 0:n.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Yl(e.value,t)}))}))})(e,n),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{Zl.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i),((e,t={},n)=>{Object.entries(t).forEach((([t,i])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(i){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;default:null==n||n.error(`Unknown component state "${i}" for component with id "${t}"`,'Valid states are "disable" and "hide"')}}))}))})(e,null==n?void 0:n.componentsState,o)},nc=Rl((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield Ml(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let ic;const oc=(e,t)=>{ic?ic.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},sc=e=>ic?ic.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,rc="dls_ab_testing_id",ac={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function lc(e,t){const n={};try{Object.assign(n,JSON.parse(sc(Za)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function cc(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||oc(Za,JSON.stringify(e)))}function dc(){try{return JSON.parse(sc(yl)||"{}")}catch(e){return{}}}function uc(e){try{(e=>{ic?ic.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(yl)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const hc=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?hc(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),hc(e[i],`${t+i}.`));const s="object"==typeof e[i]?e[i]:{value:e[i]},r=Object.assign(Object.assign({},n),{[t+i]:s,[`form.${t}${i}`]:s});return"displayName"===i?Object.assign(Object.assign({},r),{[`${t}fullName`]:s,[`form.${t}fullName`]:s}):r}),[]),pc=l((e=>{var t,n,o,s;return s=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},s}));var fc,gc,vc,mc,bc,wc,yc,kc,Ic,Sc,Cc,xc,Ac,jc,Oc,Ec,Uc,Rc,Tc,Mc,Wc,Pc;const _c=s(ve,U,pc,V)(HTMLElement);class Lc extends _c{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),fc.add(this),vc.set(this,!1),mc.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,fc,"m",Pc).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},bc.set(this,new Kl),wc.set(this,new Kl),yc.set(this,{}),this.getComponentsContext=()=>i(this,yc,"f"),this.nextRequestStatus=new Kl({isLoading:!1}),kc.set(this,void 0),Ic.set(this,{popstate:i(this,fc,"m",jc).bind(this),componentsContext:i(this,fc,"m",Tc).bind(this)}),Sc.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,Sc,e,"f"),i(this,fc,"m",xc).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return hc(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,mc,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,mc,e,"f"),(e=>{ic=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),s=wl.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||s)return;e.preventDefault();const r=this.rootElement.querySelectorAll("descope-button");if(1===r.length&&"false"!==r[0].getAttribute("auto-submit"))return void r[0].click();const a=Array.from(r).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(r).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(r).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,wc,"f").subscribe(i(this,fc,"m",Wc).bind(this)),i(this,wc,"f").update({isDebug:this.debug}),i(this,fc,"m",Ac).call(this),yield i(this,fc,"m",Uc).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:s,stepId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=Ul(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,Ic,"f").popstate),window.addEventListener("components-context",i(this,Ic,"f").componentsContext),i(this,bc,"f").subscribe(i(this,fc,"m",Ec).bind(this)),i(this,bc,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:r,executionId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},g)),o(this,vc,!0,"f")}))}disconnectedCallback(){i(this,bc,"f").unsubscribeAll(),i(this,wc,"f").unsubscribeAll(),i(this,fc,"m",Mc).call(this),window.removeEventListener("popstate",i(this,Ic,"f").popstate),window.removeEventListener("components-context",i(this,Ic,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,vc,"f")&&t!==n&&gc.observedAttributes.includes(e)){i(this,fc,"m",Ac).call(this);const o=null===t;i(this,bc,"f").update((({stepId:t,executionId:i})=>{let s=t,r=i;return o||(r=null,s=null,Ol()),{[El(e)]:n,stepId:s,executionId:r}})),i(this,wc,"f").update({isDebug:this.debug})}}}var $c,Nc,Dc,Fc,qc,zc,Vc,Hc,Kc,Bc,Jc,Zc,Xc,Gc,Yc,Qc,ed,td,nd,id,od,sd,rd,ad,ld,cd,dd,ud,hd,pd,fd,gd,vd,md,bd,wd,yd,kd,Id,Sd;gc=Lc,vc=new WeakMap,mc=new WeakMap,bc=new WeakMap,wc=new WeakMap,yc=new WeakMap,kc=new WeakMap,Ic=new WeakMap,Sc=new WeakMap,fc=new WeakSet,Cc=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},xc=function(){i(this,fc,"m",Cc).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Ac=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];gc.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[El(t)])throw Error(`${t} cannot be empty`)}))},jc=function(){const{stepId:e,executionId:t}=jl(this.flowId);i(this,bc,"f").update({stepId:e,executionId:t})},Oc=function(e,t){Mr&&"function"==typeof Mr||this.logger.error("SDK was not loaded properly",Mr,JSON.stringify(Mr));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},gc.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,mc,"f")&&(o.customStorage=i(this,mc,"f")),this.sdk=Mr(o),["start","next"].forEach((e=>{const t=function(e,t,i){return(...o)=>n(this,void 0,void 0,(function*(){let n;const s=i+1;for(let r=0;r<s;r++)try{return yield e(...o)}catch(e){n=e,r<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,r+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...i)=>n(this,void 0,void 0,(function*(){try{return yield t(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:Na,errorDescription:t.toString()}}}}))}))},Ec=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,fc,"m",Oc).call(this,t,n)}i(this,Sc,"f").call(this,e)}))},Uc=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,fc,"m",Rc).call(this))}))},Rc=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Fa||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Tc=function(e){o(this,yc,Object.assign(Object.assign({},i(this,yc,"f")),e.detail),"f")},Mc=function(){var e;null===(e=i(this,kc,"f"))||void 0===e||e.remove(),o(this,kc,null,"f")},Wc=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,kc,document.createElement("descope-debugger"),"f"),Object.assign(i(this,kc,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return iu})),document.body.appendChild(i(this,kc,"f"))):i(this,fc,"m",Mc).call(this)}))},Pc=function(e,t){var n;e&&this.debug&&(null===(n=i(this,kc,"f"))||void 0===n||n.updateData({title:e,description:t}))},Lc.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.64.1"}};class Cd extends Lc{static set sdkConfigOverrides(e){Lc.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Lc.sdkConfigOverrides}constructor(){const e=new Kl({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),$c.add(this),this.stepState=new Kl({}),Nc.set(this,void 0),Dc.set(this,null),Fc.set(this,null),qc.set(this,{visibilitychange:i(this,$c,"m",zc).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},Gc.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Qc.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,$c,"m",ed).call(this,t):t()})),td.set(this,((e,t,s,r,a=!1)=>{const l=[Da,"E103202"];if(this.flowState.current.action===hl){if(i(this,id,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,Nc,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,bl,s,r,{}),h=document.hidden&&!a&&Date.now()-c>d+500;let p;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;p=yield Ml(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,td,"f").call(this,e,t,s,r,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===Na)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,td,"f").call(this,e,t,s,r);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,td,"f").call(this,e,t,s,r),i(this,od,"f").call(this,p)}))),d),"f")}})),nd.set(this,(()=>{clearTimeout(i(this,Nc,"f")),o(this,Nc,null,"f")})),id.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),od.set(this,(e=>{var t,n,s,r,a,l,c,d,u,h,p,f,g;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(s=null==e?void 0:e.response)||void 0===s?void 0:s.statusText}`;i(this,$c,"m",Id).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==Da||!this.isRestartOnError||i(this,$c,"m",Xc).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(f=e.data)||void 0===f?void 0:f.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==hl&&i(this,nd,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&cc(Object.assign(Object.assign({},w),{lastUsedPerScreen:dc()})),uc(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void i(this,$c,"m",Id).call(this,"success",t)}this.storeLastAuthenticatedUser&&cc(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:x,redirect:A,webauthn:j,error:O,samlIdpResponse:E,wsFedIdpResponse:U,nativeResponse:R}=e.data,T=Date.now();y!==hl?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:x,status:m,stepId:S,stepName:C,action:y,error:O}),(null===(g=x.state)||void 0===g?void 0:g.clientScripts)&&o(this,Fc,this.loadSdkScripts(x.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==A?void 0:A.url,redirectIsPopup:null==A?void 0:A.isPopup,screenId:null==x?void 0:x.id,screenState:null==x?void 0:x.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,wsFedIdpResponseUrl:null==U?void 0:U.url,wsFedIdpResponseWresult:null==U?void 0:U.wresult,wsFedIdpResponseWctx:null==U?void 0:U.wctx,nativeResponseType:null==R?void 0:R.type,nativePayload:null==R?void 0:R.payload,reqTimestamp:T})):this.flowState.update({action:y,reqTimestamp:T})})),sd.set(this,Rl((()=>n(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),ud.set(this,null),vd.set(this,Ll(((e,t,o)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,$c,"m",cd).call(this)){const s=null==e?void 0:e.getAttribute("id");i(this,$c,"m",wd).call(this,e,s,o),i(this,$c,"m",hd).call(this,e);const r=yield i(this,$c,"m",dd).call(this),a=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const l=Object.assign(Object.assign(Object.assign({},a),r),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(s,l),this.nextRequestStatus.update({isLoading:!1}),i(this,$c,"m",pd).call(this,r)}}))))),this.flowState=e}nativeResume(e,t){var n,o,s,r,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const i=new URL(c.url);t=null===(n=i.searchParams)||void 0===n?void 0:n.get(Va),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get(Ka))||void 0}null===(r=(s=this.nativeCallbacks).complete)||void 0===r||r.call(s,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(c.url),t=e.searchParams.get("t"),n=e.searchParams.get(za).split("_").pop();i(this,nd,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=c;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=c,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(l=(a=this.nativeCallbacks).complete)||void 0===l||l.call(a,c)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Dl(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i,o;const s=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(s){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=s;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(i=globalThis.descope)||void 0===i?void 0:i[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.16",`dist/${e.id}.js`));const r=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,i)=>{try{const i=r(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t);const n=this.nextRequestStatus.subscribe((()=>{var o;this.loggerWrapper.debug("Stopping script",e.id),(null===(o=i.stop)||void 0===o?void 0:o.call(i))&&(this.nextRequestStatus.unsubscribe(n),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){i(e)}}))}))))),o=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,o])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,$c,"m",Jc).call(this),window.addEventListener("visibilitychange",i(this,qc,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,nd,"f").call(this),null===(e=i(this,Dc,"f"))||void 0===e||e.abort(),o(this,Dc,null,"f"),window.removeEventListener("visibilitychange",i(this,qc,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=$l(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,s,r){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:I,exchangeError:S,webauthnTransactionId:C,webauthnOptions:x,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:E,locale:U,samlIdpResponseUrl:R,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:M,wsFedIdpResponseUrl:W,wsFedIdpResponseWresult:P,wsFedIdpResponseWctx:_,nativeResponseType:L,nativePayload:$,reqTimestamp:N}=e,D=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let F,q,z;const V=(()=>{const e=sc(rc);if(!e){const e=Math.floor(100*Math.random()+1);return oc(rc,e.toString()),e}return Number(e)})(),{outboundAppId:H}=this,{outboundAppScopes:K}=this,B=this.sdk.getLastUserLoginId(),J=yield this.getFlowConfig(),Z=yield this.getProjectConfig(),X=Object.entries(Z.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),G=j&&A?{callbackUrl:j,codeChallenge:A,backupCallbackUri:O}:void 0,Y=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let Q={};if(!p){uc(this.loggerWrapper);const e=[...J.clientScripts||[],...J.sdkScripts||[]];if(J.conditions){let t=[];({startScreenId:F,conditionInteractionId:z,startScreenName:q,clientScripts:t,componentsConfig:Q}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const s=null===(o=ac[t])||void 0===o?void 0:o[n];return!!(null==s?void 0:s(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:B,code:k,token:y,abTestingKey:V,lastAuth:lc(B,this.loggerWrapper)},J.conditions)),e.push(...t||[])}else J.condition?({startScreenId:F,conditionInteractionId:z}=((e,t)=>{var n;const i=null===(n=ac[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(J.condition,{loginId:B,code:k,token:y,abTestingKey:V,lastAuth:lc(B,this.loggerWrapper)})):(q=J.startScreenName,F=J.startScreenId);if(o(this,Fc,this.loadSdkScripts(e),"f"),J.fingerprintEnabled&&J.fingerprintKey?yield Gs(J.fingerprintKey,this.baseUrl):Es(Zs),!Wl(F,D)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:G},D),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:lc(B,this.loggerWrapper),abTestingKey:V,locale:$l(U).locale,nativeOptions:Y,outboundAppId:H,outboundAppScopes:K}),z,"",Z.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),D.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),D.oidcLoginHint?{externalId:D.oidcLoginHint}:{}));return i(this,od,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:I,code:k,exchangeError:S,isCodeChanged:r("code"),isExchangeErrorChanged:r("exchangeError")})),I&&(r("code")&&k||r("exchangeError")&&S))return void i(this,$c,"m",Sd).call(this,p,k,S);if(p&&(r("token")&&y||r("code")&&k||r("exchangeError")&&S)){const e=yield this.sdk.flow.next(p,h,ml,J.version,Z.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return i(this,od,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===vl&&R&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>r(e)))){if(!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(R,T,M||"",Pl)}if(f===vl&&W&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>r(e)))){if(!P)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e;const s=(e,t)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n};o.appendChild(s("wa","wsignin1.0")),o.appendChild(s("wresult",t)),o.appendChild(s("wctx",n));const r=document.createElement("input");r.type="submit",r.id="WSFedSubmitButton",r.value="Continue",r.style.display="none",o.appendChild(r),document.body.appendChild(o),i(o)})(W,P,_||"",Pl)}if(f===ul&&(r("redirectTo")||r("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,s=void 0!==window.screenTop?window.screenTop:window.screen.top,r=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+s,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${r},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const n=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const n=t?this.popupOrigin:window.location.origin;if(e.origin!==n)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${n}"`);const{action:i,data:o}=e.data||{};"code"===i&&this.flowState.update({code:o.code,exchangeError:o.exchangeError})};let o;this.loggerWrapper.debug("Starting popup closed detection");const s=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(s),i(this,$c,"m",Id).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(t)window.addEventListener("message",n),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",n)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=n,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),i(this,$c,"m",Id).call(this,"popupclosed",{});return}if(f===pl||f===fl){if(!C||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,Dc,"f"))||void 0===l||l.abort(),o(this,Dc,null,"f");try{e=f===pl?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const n=yield this.sdk.flow.next(p,h,ml,J.version,Z.componentsVersion,{transactionId:C,response:e,failure:t});i(this,od,"f").call(this,n)}if(f===gl)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,ml,J.version,Z.componentsVersion,e);i(this,od,"f").call(this,t)})),i(this,$c,"m",Kc).call(this,L,$),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((r("action")||r("deferredPolling"))&&i(this,td,"f").call(this,p,h,J.version,Z.componentsVersion),!g&&!F)return void this.loggerWrapper.warn("No screen was found to show");const ee=F||g,te=yield this.getHtmlFilenameWithLocale(U,ee),{oidcLoginHint:ne,oidcPrompt:ie,oidcErrorRedirectUri:oe,oidcResource:se,samlIdpUsername:re}=D,ae={direction:Al(h,s.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:B,name:this.sdk.getLastUserDisplayName()||B},componentsConfig:Object.assign(Object.assign(Object.assign({},J.componentsConfig),Q),null==v?void 0:v.componentsConfig)}),htmlFilename:`${ee}.html`,htmlLocaleFilename:te,screenId:ee,stepName:e.stepName||q,samlIdpUsername:re,oidcLoginHint:ne,oidcPrompt:ie,oidcErrorRedirectUri:oe,oidcResource:se,action:f,locale:$l(U).locale},le=lc(B,this.loggerWrapper);Wl(F,D)?ae.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==J?void 0:J.clientScripts)||[];yield i(this,$c,"m",md).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:G},D),{lastAuth:le,preview:this.preview,abTestingKey:V,client:this.client}),w&&{redirectUrl:w}),{locale:$l(U).locale,nativeOptions:Y,outboundAppId:H,outboundAppScopes:K}),z,e,Z.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Nl(t)),k&&{exchangeCode:k,idpInitiated:!0}),D.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}),ae.next.isCustomScreen);return i(this,od,"f").call(this,o),o})):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(ae.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==v?void 0:v.clientScripts)||[];yield i(this,$c,"m",md).call(this,n);const o=yield this.sdk.flow.next(p,h,e,J.version,Z.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Nl(t)),ae.next.isCustomScreen);return i(this,od,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",ae.screenId),yield i(this,$c,"m",Yc).call(this,ae),this.stepState.update(ae)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,s,r;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen");const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const f=p.content.cloneNode(!0),g=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield i(this,$c,"m",ad).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${dl}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(s=u.form)||void 0===s?void 0:s.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),tc(f,u,this.formConfig,this.loggerWrapper);const{geo:v}=null!==(r=yield this.getExecutionContext())&&void 0!==r?r:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(f,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield g;const s=this.contentRootElement;((e,t)=>{ec(e,"descope-totp-image",t)})(s,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{ec(e,"descope-notp-image",t)})(s,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const s=customElements.get(o);s?Object.keys(n[o]).forEach((t=>{var r;const a=n[o],l=null===(r=null==s?void 0:s.cssVarList)||void 0===r?void 0:r[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(s,f,u.cssVars,this.loggerWrapper),s.replaceChildren(f);const r=!t.htmlFilename;setTimeout((()=>{i(this,$c,"m",fd).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const i=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void i();const o={timer:void 0},s=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",s),i(),o.timer=void 0}),150),e.addEventListener("click",s,{once:!0})}))}))})(s),((e,t)=>{Xl(e,null==t?void 0:t.inputs),Xl(e,null==t?void 0:t.form)})(s,u),i(this,$c,"m",ld).call(this,{isFirstScreen:r,isCustomScreen:!1,stepName:e.stepName}),Tl(s,this.autoFocus,r),i(this,$c,"m",yd).call(this,h)})),i(this,$c,"m",kd).call(this,d,h),s.querySelector(`[${dl}="polling"]`)&&d(bl,{})}));c?i(this,$c,"m",ed).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Ba}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}Nc=new WeakMap,Dc=new WeakMap,Fc=new WeakMap,qc=new WeakMap,Gc=new WeakMap,Qc=new WeakMap,td=new WeakMap,nd=new WeakMap,id=new WeakMap,od=new WeakMap,sd=new WeakMap,ud=new WeakMap,vd=new WeakMap,$c=new WeakSet,zc=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},Vc=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,$c,"m",Kc).call(this,"beforeScreen",{screen:e,context:t})}))}))},Hc=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,$c,"m",Kc).call(this,"afterScreen",{screen:e})},Kc=function(e,t){i(this,$c,"m",Id).call(this,"bridge",{type:e,payload:t})},Bc=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${dl}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},Jc=function(){var e,n,o;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=t(void 0===n?{}:n,["errorText","errorType"]),o=t(e,["screenState"]);return Object.assign(Object.assign({},o),{screenState:i})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,$c,"m",Bc).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,$c,"m",Zc).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0})},Zc=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Tl(this.contentRootElement,this.autoFocus,!1))},Xc=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},Yc=function(e){return n(this,void 0,void 0,(function*(){var n;const s=Object.assign(Object.assign({},this.stepState.current),e),{next:r,stepName:a}=s,l=(e=>{var t,n,i;const o=(s=e.screenState,r=(e,t)=>kl.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(s).filter((([e,t])=>!r(0,e)))));var s,r;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(o.error={text:a,type:l}),e.action&&(o.action=e.action),(null===(i=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===i?void 0:i.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o})(t(s,["next","stepName"]));let c=yield i(this,$c,"m",Vc).call(this,a,l,r);c||(c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,l,r,this)));const d=!this.stepState.current.htmlFilename;if(i(this,Qc,"f").call(this,c),r&&(r.isCustomScreen=c),i(this,Gc,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,Gc,c,"f"),c?this.stepState.unsubscribeAll():i(this,$c,"m",Jc).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),i(this,$c,"m",ld).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},ed=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},rd=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},ad=function(e,t){return n(this,void 0,void 0,(function*(){var s;null===(s=i(this,Dc,"f"))||void 0===s||s.abort();const r=e.querySelector('*[autocomplete="webauthn"]');if(r&&(yield nc())){const{options:e,transactionId:s}=(yield i(this,sd,"f").call(this))||{};e&&s&&(i(this,$c,"m",rd).call(this,r),o(this,Dc,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,Dc,"f")).then((e=>n(this,void 0,void 0,(function*(){t(r.id,{transactionId:s,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},ld=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,$c,"m",Id).call(this,"ready",{}),t||i(this,$c,"m",Hc).call(this,n),i(this,$c,"m",Id).call(this,"page-updated",{screenName:n}),i(this,$c,"m",Id).call(this,"screen-updated",{screenName:n})},cd=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"===t.localName||t.classList.contains("hidden")||(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)))})),e},dd=function(){return n(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>n(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},hd=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),s=()=>n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",s),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const n=yield this.getFlowConfig(),i=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(i)})),r=()=>{var e;window.removeEventListener("pageshow",i(this,ud,"f")),o(this,ud,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),s())}),"f"),window.addEventListener("pageshow",i(this,ud,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&s(),this.removeEventListener("popupclosed",s),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},a=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?(this.addEventListener("popupclosed",s,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(a),r())}))},pd=function(e={}){var t,n;const i=_l(e,["externalId","email","phone"]),o=_l(e,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},fd=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,$c,"m",gd).call(this,e)))},gd=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},md=function(e){return n(this,void 0,void 0,(function*(){if(i(this,Fc,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,Fc,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const o=[];for(const e of t)"function"==typeof e.refresh&&o.push(e.refresh());if(o.length>0)try{yield Ml(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},bd=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var o;(null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))&&i(this,vd,"f").call(this,n,e,t)}))}))},wd=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=dc();n[e]=t,oc(yl,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},yd=function(e){var t;const n=null===(t=lc(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},kd=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Ja}]), [data-type="button"]:not([${Ja}]`).forEach((n=>{n.onclick=()=>{i(this,vd,"f").call(this,n,e,t)}})),i(this,$c,"m",bd).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Ba}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Id=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Sd=function(e,t,n){var i;const[o,s]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],r={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===o&&s){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",s);try{window.opener.postMessage(r,s)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(r),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Cd);var xd=Object.freeze({__proto__:null,default:Cd});customElements.define("descope-user-profile-widget",La);const Ad=(e,t,n,i={})=>{var o,s,r,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(s=i.right)&&void 0!==s?s:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(r=i.top)&&void 0!==r?r:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var jd,Od,Ed,Ud,Rd,Td,Md,Wd,Pd,_d;const Ld=document.createElement("template");Ld.innerHTML=`\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`;const $d=s(V)(HTMLElement);class Nd extends $d{constructor(){var e;super(),jd.add(this),Od.set(this,new f({messages:[]})),Ed.set(this,void 0),Ud.set(this,void 0),Rd.set(this,void 0),Td.set(this,{resize:i(this,jd,"m",_d).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Ld.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,Ed,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Ud,i(this,Ed,"f").querySelector(".content"),"f"),o(this,Rd,i(this,Ed,"f").querySelector(".header"),"f")}updateData(e){i(this,Od,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,s=0,r=0;function a(t){t.preventDefault(),i=s-t.clientX,o=r-t.clientY,s=t.clientX,r=t.clientY;const[a,l]=Ad(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),s=e.clientX,r=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,Ed,"f"),i(this,Rd,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Td,"f").resize),(e=i(this,Ed,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},i(this,Ed,"f").onresize=i(this,jd,"m",Pd).bind(this),i(this,Od,"f").subscribe(i(this,jd,"m",Md).bind(this))}disconnectedCallback(){i(this,Od,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Td,"f").resize)}}Od=new WeakMap,Ed=new WeakMap,Ud=new WeakMap,Rd=new WeakMap,Td=new WeakMap,jd=new WeakSet,Md=function(e){i(this,jd,"m",Wd).call(this,e),i(this,jd,"m",Pd).call(this)},Wd=function(e){i(this,Ud,"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("")},Pd=function(){i(this,Ud,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},_d=function(){const[e,t]=Ad(i(this,Ed,"f"),Number.parseInt(i(this,Ed,"f").style.left,10),Number.parseInt(i(this,Ed,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Ed,"f").style.top=`${t}px`,i(this,Ed,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Nd);var Dd=Object.freeze({__proto__:null,default:Nd});const Fd=(e,t,n,i={})=>{var o,s,r,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(s=i.right)&&void 0!==s?s:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(r=i.top)&&void 0!==r?r:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},qd=(e,t,n)=>{let i=0,o=0,s=0,r=0;function a(t){t.preventDefault(),i=s-t.clientX,o=r-t.clientY,s=t.clientX,r=t.clientY;const[a,l]=Fd(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),s=e.clientX,r=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c};var zd,Vd,Hd,Kd,Bd,Jd,Zd,Xd,Gd,Yd,Qd;const eu=document.createElement("template");eu.innerHTML='\n<div 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';const tu=s(V)(HTMLElement);class nu extends tu{constructor(){super(),zd.add(this),Vd.set(this,new Kl({messages:[]})),Hd.set(this,void 0),Kd.set(this,void 0),Bd.set(this,void 0),Jd.set(this,{resize:i(this,zd,"m",Qd).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(eu.content.cloneNode(!0)),o(this,Hd,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Kd,i(this,Hd,"f").querySelector(".content"),"f"),o(this,Bd,i(this,Hd,"f").querySelector(".header"),"f"),i(this,zd,"m",Zd).call(this)}updateData(e){i(this,Vd,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),qd(i(this,Hd,"f"),i(this,Bd,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Jd,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(i(this,Hd,"f")),i(this,Hd,"f").onresize=i(this,zd,"m",Yd).bind(this),i(this,Vd,"f").subscribe(i(this,zd,"m",Xd).bind(this))}))}disconnectedCallback(){i(this,Vd,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Jd,"f").resize)}}Vd=new WeakMap,Hd=new WeakMap,Kd=new WeakMap,Bd=new WeakMap,Jd=new WeakMap,zd=new WeakSet,Zd=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,Hd,"f").style.top="32px",i(this,Hd,"f").style.left=window.innerWidth-300-32+"px"},Xd=function(e){i(this,zd,"m",Gd).call(this,e),i(this,zd,"m",Yd).call(this)},Gd=function(e){i(this,Kd,"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("")},Yd=function(){i(this,Kd,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Qd=function(){const[e,t]=Fd(i(this,Hd,"f"),Number.parseInt(i(this,Hd,"f").style.left,10),Number.parseInt(i(this,Hd,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Hd,"f").style.top=`${t}px`,i(this,Hd,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",nu);var iu=Object.freeze({__proto__:null,default:nu});return La}();
7
7
  //# sourceMappingURL=index.js.map