@descope/user-profile-widget 0.4.11 → 0.4.12
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/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/user-profile-widget v0.4.
|
|
3
|
+
* @descope/user-profile-widget v0.4.12
|
|
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{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((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)},c=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 l,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}={}){l.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,l,"f")):e,n=Object.assign(Object.assign({},i(this,l,"f")),t);if(i(this,h,"f")||!p(i(this,l,"f"),n)){const e=i(this,l,"f");o(this,l,n,"f"),Object.freeze(i(this,l,"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,l,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,l,"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}};l=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const g=["error","warn","info","debug"],v=c((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,console))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||console),"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})),m="undefined"!=typeof localStorage,w=m&&localStorage.getItem("base.content.url")||"",b=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,y=c((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})),k=c((e=>{var t,n;const o=r(v,y)(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})),S=e=>t=>{var n,o,s;const a=r(v,y,k)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,i(this,n,"m",o).bind(this))}async init(){var e;c.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};S.missingAttrValidator=b;const I=c((e=>{const t=r(S({"project-id":b}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),C=c((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),x="Trying the next fallback URL...";function j({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i="https://static.descope.com/pages"}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}const O=c((e=>{var t,n,s,a,c;const l=r(v,I,C)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0)}async fetchStaticResource(e,n){const r=i(this,t,"m",a).call(this,e),c=Array.isArray(r)?e=>{if(e!==r.length-1){const{baseUrl:t}=r[e];o(this,s,t,"f")}}: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 fetch(r.toString(),t);if(o.ok)return null==i||i(e),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${x}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${x}`)}}})(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,t=new WeakSet,a=function(e){const t=w||this.baseStaticUrl;if(t)return j({projectId:this.projectId,filename:e,baseUrl:t});const r=i(this,n,"f")!==this.baseUrl,a=r&&!!this.baseUrl;r&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"));const c=j({projectId:this.projectId,filename:e,baseUrl:i(this,s,"f")});if(!a)return c;return[j({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),c]},c})),A=c((e=>{var t,n;const o=r(S({"project-id":b}))(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})),E=c((e=>{var t,n,s,a,c;const l=r(O,A,y)(e);return c=class extends l{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")},c})),U=c((e=>{var t,n,s,a,c,l,d;return d=class extends(r(y,v)(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",c).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",l).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",c).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 Vc})),document.body.appendChild(i(this,n,"f"))},c=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},l=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),R="load-descope-ui",_="base.ui.components.url",T=m&&localStorage.getItem(_)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",M=m&&localStorage.getItem(_)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",L=m&&localStorage.getItem(_)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",P=e=>{const t=document.createElement("script");return t.id=e,t},$=(e,t)=>e.replace("<version>",t),W=c((e=>{var t,n,s,a,c,l,d,u,h,p,f,g;const m=r(v,E)(e);return g=class extends m{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),s.set(this,Symbol("loadCbs")),h.set(this,void 0)}get descopeUi(){return i(this,h,"f")||o(this,h,i(this,t,"m",f).call(this),"f"),i(this,h,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",p).call(this,e))))}get baseCdnUrl(){return this.getAttribute("base-cdn-url")}},n=new WeakMap,s=new WeakMap,h=new WeakMap,t=new WeakSet,a=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},c=function(e){const t=i(this,n,"f"),o=i(this,s,"f");e[t]=[],e[o]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[o].push(t)}})},l=async function(e,n,o,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const s=P(o);document.body.append(s),s.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${s.src}"`)))})),s.addEventListener("load",(()=>{n.forEach((e=>e()))})),s.src=$(r,await i(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[i(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),i(this,t,"m",l).call(this,[i(this,t,"m",l).bind(this,e[i(this,n,"f")],e[i(this,s,"f")],"load-descope-ui-fallback-script-2",L),...e[i(this,n,"f")]],e[i(this,s,"f")],"load-descope-ui-fallback-script",M)})),e.addEventListener("load",(()=>{e[i(this,s,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${R}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=P(R);document.body.append(e),i(this,t,"m",c).call(this,e),i(this,t,"m",d).call(this,e),e.src=$(this.baseCdnUrl||T,await i(this,t,"m",a).call(this))}return document.getElementById(R)},p=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},f=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),i(this,t,"m",u).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),N="content-root",D="root",F=c((e=>class extends e{constructor(...e){var t,n,i,o;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${D}">\n <div id="${N}"></div>\n </div>\n `;const r=new CSSStyleSheet;r.replaceSync(`\n #${D}, #${N} {\n height: 100%;\n }\n #${D} {\n position: relative;\n height: fit-content;\n }\n `),null!==(t=(o=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(o.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],this.contentRootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(N),this.rootElement=null===(i=this.shadowRoot)||void 0===i?void 0:i.getElementById(D)}})),q="descope-modal";var z;let B=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)}};z=new WeakMap;let V=class extends B{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};var K;let H=class extends B{constructor(){super(...arguments),K.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,K,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,K,"f").content.cloneNode(!0)))}setContent(e){o(this,K,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};K=new WeakMap;let J=class extends B{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()}},G=class extends B{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)}}},X=class extends B{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)}}},Y=class extends B{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}},Z=class extends B{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)}}};const Q=c((e=>{var t,n;const o=r(y,F,W)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends H{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(q);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([q]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ee="descope-notification";c((e=>{var t,n;const o=r(y,F,W)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends J{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ee);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([ee])}},t=new WeakMap,n}));const te=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ne=c((e=>{var t,n,s,a,c,l,d,u,h,p,f,g,v,m;const w=r(S({theme:te}),O,y,W,E,F,k)(e);return m=class extends w{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{i(this,t,"m",g).call(this),i(this,v,"f").call(this,"os"===this.getAttribute("theme"))})),v.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",g).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")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this),i(this,t,"m",d).call(this),i(this,f,"f").call(this),this.observeAttributes(["theme"],i(this,f,"f")),this.observeAttributes(["style-id"],(()=>{o(this,s,null,"f"),i(this,t,"m",h).call(this),i(this,t,"m",l).call(this),i(this,t,"m",d).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(_))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(_),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")}},c=function(){return i(this,s,"f")||(o(this,s,i(this,t,"m",a).call(this),"f"),i(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,s,"f")},l=async function(){var e,r,s,a;const l=await i(this,t,"a",c);l&&(i(this,n,"f")||(o(this,n,new CSSStyleSheet,"f"),null!==(e=(a=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(a.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,i(this,n,"f")]),i(this,n,"f").replaceSync(((null===(r=null==l?void 0:l.light)||void 0===r?void 0:r.globals)||"")+((null===(s=null==l?void 0:l.dark)||void 0===s?void 0:s.globals)||"")))},d=async function(){var e,n;const o=Object.assign({},await i(this,t,"a",c));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})},u=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},h=async function(){const e=await i(this,t,"m",u).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")},p=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)},g=function(){i(this,t,"m",h).call(this),i(this,t,"m",p).call(this)},m}));var ie=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),oe=()=>Math.random().toString(36).substring(7).split("").join("."),re={INIT:`@@redux/INIT${oe()}`,REPLACE:`@@redux/REPLACE${oe()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${oe()}`};function se(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 ae(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 ce(e){let t=typeof e;return t=ae(e),t}function le(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${ce(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: '${ce(n)}'`);return n(le)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,c=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(c)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: '${ce(e)}'`);if(c)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;l();const n=a++;return s.set(n,e),function(){if(t){if(c)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,l(),s.delete(n),r=null}}}function h(e){if(!se(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${ce(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: '${ce(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,o=i(o,e)}finally{c=!1}return(r=s).forEach((e=>{e()})),e}h({type:re.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: '${ce(e)}`);i=e,h({type:re.REPLACE})},[ie]: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: '${ce(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[ie](){return this}}}}}function de(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ue(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&de(`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:re.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:re.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 '${re.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===re.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(!se(e))return`The ${r} has unexpected type of "${ce(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===re.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&&de(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],c=n[r],l=e[r],d=c(l,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!==l}return s=s||i.length!==Object.keys(e).length,s?a:e}}function he(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function pe(e){return se(e)&&"type"in e&&"string"==typeof e.type}var fe=Symbol.for("immer-nothing"),ge=Symbol.for("immer-draftable"),ve=Symbol.for("immer-state"),me=[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 we(e,...t){{const n=me[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var be=Object.getPrototypeOf;function ye(e){return!!e&&!!e[ve]}function ke(e){return!!e&&(Ie(e)||Array.isArray(e)||!!e[ge]||!!e.constructor?.[ge]||Ae(e)||Ee(e))}var Se=Object.prototype.constructor.toString();function Ie(e){if(!e||"object"!=typeof e)return!1;const t=be(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)===Se}function Ce(e,t){0===xe(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function xe(e){const t=e[ve];return t?t.type_:Array.isArray(e)?1:Ae(e)?2:Ee(e)?3:0}function je(e,t){return 2===xe(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Oe(e,t,n){const i=xe(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function Ae(e){return e instanceof Map}function Ee(e){return e instanceof Set}function Ue(e){return e.copy_||e.base_}function Re(e,t){if(Ae(e))return new Map(e);if(Ee(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ie(e)){if(!be(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[ve];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(be(e),n)}function _e(e,t=!1){return Me(e)||ye(e)||!ke(e)||(xe(e)>1&&(e.set=e.add=e.clear=e.delete=Te),Object.freeze(e),t&&Ce(e,((e,t)=>_e(t,!0)))),e}function Te(){we(2)}function Me(e){return Object.isFrozen(e)}var Le,Pe={};function $e(e){const t=Pe[e];return t||we(0,e),t}function We(){return Le}function Ne(e,t){t&&($e("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function De(e){Fe(e),e.drafts_.forEach(ze),e.drafts_=null}function Fe(e){e===Le&&(Le=e.parent_)}function qe(e){return Le={drafts_:[],parent_:Le,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ze(e){const t=e[ve];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Be(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[ve].modified_&&(De(t),we(4)),ke(e)&&(e=Ve(t,e),t.parent_||He(t,e)),t.patches_&&$e("Patches").generateReplacementPatches_(n[ve].base_,e,t.patches_,t.inversePatches_)):e=Ve(t,n,[]),De(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==fe?e:void 0}function Ve(e,t,n){if(Me(t))return t;const i=t[ve];if(!i)return Ce(t,((o,r)=>Ke(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return He(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),Ce(o,((o,s)=>Ke(e,i,t,o,s,n,r))),He(e,t,!1),n&&e.patches_&&$e("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function Ke(e,t,n,i,o,r,s){if(o===n&&we(5),ye(o)){const s=Ve(e,o,r&&t&&3!==t.type_&&!je(t.assigned_,i)?r.concat(i):void 0);if(Oe(n,i,s),!ye(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(ke(o)&&!Me(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ve(e,o),t&&t.scope_.parent_||He(e,o)}}function He(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&_e(t,n)}var Je={get(e,t){if(t===ve)return e;const n=Ue(e);if(!je(n,t))return function(e,t,n){const i=Ye(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_||!ke(i)?i:i===Xe(e.base_,t)?(Qe(e),e.copy_[t]=et(i,e)):i},has:(e,t)=>t in Ue(e),ownKeys:e=>Reflect.ownKeys(Ue(e)),set(e,t,n){const i=Ye(Ue(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=Xe(Ue(e),t),o=i?.[ve];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||je(e.base_,t)))return!0;Qe(e),Ze(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!==Xe(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Qe(e),Ze(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ue(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){we(11)},getPrototypeOf:e=>be(e.base_),setPrototypeOf(){we(12)}},Ge={};function Xe(e,t){const n=e[ve];return(n?Ue(n):e)[t]}function Ye(e,t){if(!(t in e))return;let n=be(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=be(n)}}function Ze(e){e.modified_||(e.modified_=!0,e.parent_&&Ze(e.parent_))}function Qe(e){e.copy_||(e.copy_=Re(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ce(Je,((e,t)=>{Ge[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ge.deleteProperty=function(e,t){return isNaN(parseInt(t))&&we(13),Ge.set.call(this,e,t,void 0)},Ge.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&we(14),Je.set.call(this,e[0],t,n,e[0])};function et(e,t){const n=Ae(e)?$e("MapSet").proxyMap_(e,t):Ee(e)?$e("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:We(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=Je;n&&(o=[i],r=Ge);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:We()).drafts_.push(n),n}function tt(e){return ye(e)||we(10,e),nt(e)}function nt(e){if(!ke(e)||Me(e))return e;const t=e[ve];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Re(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Re(e,!0);return Ce(n,((e,t)=>{Oe(n,e,nt(t))})),t&&(t.finalized_=!1),n}var it=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&&we(6),void 0!==n&&"function"!=typeof n&&we(7),ke(e)){const o=qe(this),r=et(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?De(o):Fe(o)}return Ne(o,n),Be(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===fe&&(i=void 0),this.autoFreeze_&&_e(i,!0),n){const t=[],o=[];$e("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}we(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){ke(e)||we(8),ye(e)&&(e=tt(e));const t=qe(this),n=et(e,void 0);return n[ve].isManual_=!0,Fe(t),n}finishDraft(e,t){const n=e&&e[ve];n&&n.isManual_||we(9);const{scope_:i}=n;return Ne(i,t),Be(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=$e("Patches").applyPatches_;return ye(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},ot=it.produce;it.produceWithPatches.bind(it),it.setAutoFreeze.bind(it),it.setUseStrictShallowCopy.bind(it),it.applyPatches.bind(it),it.createDraft.bind(it),it.finishDraft.bind(it);var rt=(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})}}},st=(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})}},at={inputStabilityCheck:"once",identityFunctionCheck:"once"};var ct=e=>Array.isArray(e)?e:[e];function lt(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 dt(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var ut="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},ht=0,pt=1;function ft(){return{s:ht,v:void 0,o:null,p:null}}function gt(e,t={}){let n=ft();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=ft(),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=ft(),e.set(n,t)):t=i}}const a=t;let c;if(t.s===pt)c=t.v;else if(c=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,c)&&(c=e,0!==r&&r--);o="object"==typeof c&&null!==c||"function"==typeof c?new ut(c):c}return a.s=pt,a.v=c,c}return s.clearCache=()=>{n=ft(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function vt(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:c,memoizeOptions:l=[],argsMemoize:d=gt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=ct(l),f=ct(u),g=lt(e),v=c((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const w=d((function(){o++;const e=dt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...at,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:rt},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:st}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=dt(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(w,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:c,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var mt=vt(gt),wt=Object.assign(((e,t=mt)=>{!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:()=>wt});function bt(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var yt=bt(),kt=bt;((...e)=>{const t=vt(...e)})(gt);var St="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?he:he.apply(null,arguments)},It=e=>e&&"function"==typeof e.match;function Ct(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=>pe(t)&&t.type===e,n}function xt(e){return"function"==typeof e&&"type"in e&&It(e)}function jt(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 Ot=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 At(e){return ke(e)?ot(e,(()=>{})):e}function Et(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 Ut(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Rt(e,t,n){const i=_t(e,t,n);return{detectMutations:()=>Tt(e,t,i,n)}}function _t(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]=_t(e,t,n[o],s))}}return r}function Tt(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 c={};for(let e in n.children)c[e]=!0;for(let e in i)c[e]=!0;const l=t.length>0;for(let o in c){const s=r?r+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Tt(e,t,n.children[o],i[o],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function Mt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||se(e)}function Lt(e,t="",n=Mt,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),c=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Lt(l,a,n,i,o,r),s))return s}return r&&Pt(e)&&r.add(e),!1}function Pt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Pt(t))return!1;return!0}function $t(e){return"boolean"==typeof e}var Wt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Ot;if(t&&($t(t)?r.push(yt):r.push(kt(t.extraArgument))),n){let e={};$t(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=Ut,ignoredPaths:o,warnAfter:r=32}=e;const s=Rt.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>c=>{const l=jt(r,"ImmutableStateInvariantMiddleware");l.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(c);return l.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(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(i){let e={};$t(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=Mt,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!pe(u))return l(u);const h=l(u),p=jt(s,"SerializableStateInvariantMiddleware");return c||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Lt(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=Lt(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={};$t(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=xt}=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},Nt=e=>t=>{setTimeout(t,e)},Dt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Nt(10),Ft=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Ot(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,c="tick"===e.type?queueMicrotask:"raf"===e.type?Dt:"callback"===e.type?e.queueNotification:Nt(e.timeout),l=()=>{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,c(l))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function qt(e){const t=Wt(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!se(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=ue(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(c=i(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=he;o&&(l=St({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=he(...a)(o.dispatch),{...o,dispatch:r}}}(...c),u=Ft(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");c.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return le(a,r,l(...h))}function zt(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 Bt(...e){return t=>e.some((e=>((e,t)=>It(e)?e.match(t):e(t))(e,t)))}var Vt=["name","message","stack","code"],Kt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Ht=class{constructor(e,t){this.payload=e,this.meta=t}_type},Jt=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Vt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},Gt=(()=>{function e(e,t,n){const i=Ct(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Ct(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ct(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||Jt)(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,c)=>{const l=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:c});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(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new Kt(e,t),fulfillWithValue:(e,t)=>new Ht(e,t)})).then((t=>{if(t instanceof Kt)throw t;return t instanceof Ht?i(t.payload,l,e,t.meta):i(t,l,e)}))])}catch(t){p=t instanceof Kt?r(null,l,e,t.payload,t.meta):r(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,arg:e,unwrap:()=>p.then(Xt)})}}),{pending:o,rejected:r,fulfilled:i,settled:Bt(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function Xt(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var Yt=Symbol.for("rtk-slice-createasyncthunk");function Zt(e,t){return`${e}/${t}`}function Qt(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 en=function({creators:e}={}){const t=e?.asyncThunk?.[Yt];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 c(){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?zt(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]=zt(t);if(function(e){return"function"==typeof e}(e))n=()=>At(e());else{const t=At(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(ye(e)){const i=n(e,t);return void 0===i?e:i}if(ke(e))return ot(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:Zt(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?Ct(e,s):Ct(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:c,settled:l,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);c&&i.addCase(u.rejected,c);l&&i.addMatcher(u.settled,l);i.exposeCaseReducer(t,{fulfilled:s||tn,pending:a||tn,rejected:c||tn,settled:l||tn})}(s,r,a,t)}));const l=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=c()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=c()),u.getInitialState()),getSelectors(t=l){const n=Et(d,this,{insert:()=>new WeakMap});return Et(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=Qt(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 tn(){}var nn="listenerMiddleware";Ct(`${nn}/add`),Ct(`${nn}/removeAll`),Ct(`${nn}/remove`);const on=e=>c((t=>{const n=en(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(v)(t)){constructor(...e){super(...e);const t=qt({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{Xt(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()))))}}}));c((e=>class extends(v(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 rn=c((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),sn=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),n)})),t};function an(e){return new URLSearchParams(window.location.search).get(e)}const cn=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)}))}))},ln=Gt("users/me",((e,{extra:{api:t}})=>t.user.me())),dn=cn(ln)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(un=e=>e.me,{onFulfilled:e=>{un(e).loading=!1},onPending:e=>{un(e).loading=!0,un(e).error=null},onRejected:(e,t)=>{un(e).loading=!1,un(e).error=t.error}}));var un;const hn={action:ln,reducer:dn},pn=Gt("users/logout",((e,{extra:{api:t}})=>t.user.logout())),fn={action:pn,reducer:cn(pn)({})},gn={me:{loading:!1,error:null,data:{}}};class vn 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 vn("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 vn(`Invalid token specified: missing part #${n+1}`);let o;try{o=mn(i)}catch(e){throw new vn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new vn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}vn.prototype.name="InvalidTokenError";var bn={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"}},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",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 yn="<region>",kn=`https://api.${yn}descope.com`,Sn=6e5,In="dct",Cn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let xn;const jn=()=>{if(xn)return xn;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 xn=`${t}-${n}`,xn};var On;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(On||(On={}));const An=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(yn,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},En=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,i])=>(e[n]=i,e)),e),e}),{})),Un={"Content-Type":"application/json"},Rn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},_n=e=>{const t={"x-descope-sdk-session-id":jn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.40.0"};return e&&(t["x-descope-refresh-cookie-name"]=e),t},Tn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},Mn=({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const c=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Cn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await n(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return Cn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(i)),i}:n})(o,a),l=async o=>{var a;const l=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=l,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:En(Rn(t,g),_n(i),(null==n?void 0:n.baseHeaders)||{},Tn(v)?Un:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const w=await c(An({path:d,baseUrl:e,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==w?void 0:w.clone()),null==r?void 0:r.transformResponse){const e=await w.json(),t=((null===(a=w.headers)||void 0===a?void 0:a.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,i]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:i})}),{}),n=Object.assign(Object.assign({},w),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return w};return{get:(e,{headers:t,queryParams:n,token:i}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:On.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:On.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:On.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:On.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:On.delete,token:i}),hooks:r,buildUrl:(n,i)=>An({projectId:t,baseUrl:e,path:n,queryParams:i})}};var Ln=429;function Pn(e,t,n){var i;let o=$n(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[In])===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 $n(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return wn(e)}function Wn(e){const{exp:t}=$n(e);return(new Date).getTime()/1e3>t}function Nn(e){let t=$n(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Dn(e,t){return Pn(e,t,"permissions")}function Fn(e,t){return Pn(e,t,"roles")}const qn=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function zn(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===Ln&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function Bn(e){var t;return(null===(t=$n(e))||void 0===t?void 0:t[In])||""}const Vn=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Kn=(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 "))},Hn=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Jn=e=>t=>e.test(t),Gn=Jn(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Xn=Jn(/^\+[1-9]{1}[0-9]{3,14}$/),Yn=Vn(Gn,'"{val}" is not a valid email'),Zn=Vn(Xn,'"{val}" is not a valid phone number'),Qn=Vn((e=>e.length>=1),"Minimum length is 1");const ei=Vn((e=>"string"==typeof e),"Input is not a string"),ti=Vn((e=>Array.isArray(e)),"Input is not an array"),ni=Vn((e=>"boolean"==typeof e),"Input is not a boolean"),ii=Vn((e=>void 0===e),"Input is defined"),oi=Kn([ei(),ii()],"Input is not a string or undefined"),ri=Kn([ti(),ni()],"Input is not an array or boolean"),si=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Hn(...e).validate(n[t]))),t(...n)),ai=e=>[ei(`"${e}" must be a string`)],ci=e=>[oi(`"${e}" must be string or undefined`)],li=e=>[ei(`"${e}" must be a string`),Qn(`"${e}" must not be empty`)],di=e=>[ei(`"${e}" must be a string`),Yn()],ui=e=>[ei(`"${e}" must be a string`),Zn()],hi=si(li("accessKey")),pi=e=>({exchange:hi(((t,n)=>zn(e.post(bn.accessKey.exchange,{loginOptions:n},{token:t}))))}),fi=(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),gi=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Sn,Sn)});var vi,mi;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(vi||(vi={})),function(e){e.email="email"}(mi||(mi={}));const wi=Object.assign(Object.assign({},vi),mi);var bi;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(bi||(bi={}));const yi=li("loginId"),ki=si(li("token")),Si=si(yi),Ii=si(li("pendingRef")),Ci=si(yi,di("email")),xi=e=>({verify:ki((t=>zn(e.post(bn.enchantedLink.verify,{token:t})))),signIn:Si(((t,n,i,o)=>zn(e.post(qn(bn.enchantedLink.signIn,wi.email),{loginId:t,URI:n,loginOptions:i},{token:o})))),signUpOrIn:Si(((t,n,i)=>zn(e.post(qn(bn.enchantedLink.signUpOrIn,wi.email),{loginId:t,URI:n,loginOptions:i})))),signUp:Si(((t,n,i,o)=>zn(e.post(qn(bn.enchantedLink.signUp,wi.email),{loginId:t,URI:n,user:i,loginOptions:o})))),waitForSession:Ii(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=gi(n);let s;const a=setInterval((async()=>{const n=await e.post(bn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(zn(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ci(((t,n,i,o,r)=>zn(e.post(bn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),ji=si(li("flowId")),Oi=si(li("executionId"),li("stepId"),li("interactionId")),Ai=e=>({start:ji(((t,n,i,o,r,s,a)=>zn(e.post(bn.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a})))),next:Oi(((t,n,i,o,r,s)=>zn(e.post(bn.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),Ei=li("loginId"),Ui=si(li("token")),Ri=si(Ei),_i=si(Ei,ui("phone")),Ti=si(Ei,di("email")),Mi=Object.keys(wi).filter((e=>e!==vi.voice)),Li=e=>({verify:Ui((t=>zn(e.post(bn.magicLink.verify,{token:t})))),signIn:Mi.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ri(((t,i,o,r)=>zn(e.post(qn(bn.magicLink.signIn,n),{loginId:t,URI:i,loginOptions:o},{token:r}))))})),{}),signUp:Mi.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ri(((t,i,o,r)=>zn(e.post(qn(bn.magicLink.signUp,n),{loginId:t,URI:i,user:o,loginOptions:r}))))})),{}),signUpOrIn:Mi.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ri(((t,i,o)=>zn(e.post(qn(bn.magicLink.signUpOrIn,n),{loginId:t,URI:i,loginOptions:o}))))})),{}),update:{email:Ti(((t,n,i,o,r)=>zn(e.post(bn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(vi).filter((e=>e!==vi.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:_i(((t,i,o,r,s)=>zn(e.post(qn(bn.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Pi;!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"}(Pi||(Pi={}));const $i=si(li("code")),Wi=e=>({start:Object.assign(((t,n,i,o)=>zn(e.post(bn.oauth.start,i||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:o}))),Object.keys(Pi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o)=>zn(e.post(bn.oauth.start,i||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:o}))})),{})),exchange:$i((t=>zn(e.post(bn.oauth.exchange,{code:t})))),startNative:(t,n,i)=>zn(e.post(bn.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>zn(e.post(bn.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>zn(e.get(bn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>zn(e.post(bn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>zn(e.post(bn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Ni=li("loginId"),Di=si(Ni,li("code")),Fi=si(Ni),qi=si(Ni,ui("phone")),zi=si(Ni,di("email")),Bi=e=>({verify:Object.keys(wi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Di(((t,i)=>zn(e.post(qn(bn.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(wi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Fi(((t,i,o)=>zn(e.post(qn(bn.otp.signIn,n),{loginId:t,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(wi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Fi(((t,i,o)=>zn(e.post(qn(bn.otp.signUp,n),{loginId:t,user:i,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(wi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Fi(((t,i)=>zn(e.post(qn(bn.otp.signUpOrIn,n),{loginId:t,loginOptions:i}))))})),{}),update:{email:zi(((t,n,i,o)=>zn(e.post(bn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(vi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:qi(((t,i,o,r)=>zn(e.post(qn(bn.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),Vi=si(li("tenant")),Ki=si(li("code")),Hi=e=>({start:Vi(((t,n,i,o,r)=>zn(e.post(bn.saml.start,i||{},Object.assign({queryParams:Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r})},o&&{token:o}))))),exchange:Ki((t=>zn(e.post(bn.saml.exchange,{code:t}))))}),Ji=li("loginId"),Gi=si(Ji,li("code")),Xi=si(Ji),Yi=si(Ji),Zi=e=>({signUp:Xi(((t,n)=>zn(e.post(bn.totp.signUp,{loginId:t,user:n})))),verify:Gi(((t,n,i,o)=>zn(e.post(bn.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:Yi(((t,n)=>zn(e.post(bn.totp.update,{loginId:t},{token:n}))))}),Qi=li("loginId"),eo=li("newPassword"),to=si(Qi,li("password")),no=si(Qi),io=si(Qi,eo),oo=si(Qi,li("oldPassword"),eo),ro=e=>({signUp:to(((t,n,i,o)=>zn(e.post(bn.password.signUp,{loginId:t,password:n,user:i,loginOptions:o})))),signIn:to(((t,n,i)=>zn(e.post(bn.password.signIn,{loginId:t,password:n,loginOptions:i})))),sendReset:no(((t,n,i)=>zn(e.post(bn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:io(((t,n,i)=>zn(e.post(bn.password.update,{loginId:t,newPassword:n},{token:i})))),replace:oo(((t,n,i)=>zn(e.post(bn.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>zn(e.get(bn.password.policy))}),so=ai("loginId"),ao=li("loginId"),co=li("origin"),lo=si(ao,co,li("name")),uo=si(ao,co),ho=si(so,co),po=si(ao,co,ci("token")),fo=si(li("transactionId"),li("response")),go=e=>({signUp:{start:lo(((t,n,i,o)=>zn(e.post(bn.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,passkeyOptions:o})))),finish:fo(((t,n)=>zn(e.post(bn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:ho(((t,n,i,o,r)=>zn(e.post(bn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:fo(((t,n)=>zn(e.post(bn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:uo(((t,n,i)=>zn(e.post(bn.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:i}))))},update:{start:po(((t,n,i,o)=>zn(e.post(bn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:fo(((t,n)=>zn(e.post(bn.webauthn.update.finish,{transactionId:t,response:n}))))}}),vo=ai("loginId"),mo=si(vo),wo=si(li("pendingRef")),bo=e=>({signUpOrIn:mo(((t,n)=>zn(e.post(bn.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:mo(((t,n,i)=>zn(e.post(bn.notp.signUp,{loginId:t,user:n,loginOptions:i})))),signIn:mo(((t,n,i)=>zn(e.post(bn.notp.signIn,{loginId:t,loginOptions:n},{token:i})))),waitForSession:wo(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=gi(n);let s;const a=setInterval((async()=>{const n=await e.post(bn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(zn(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),yo=si(li("token")),ko=si(ci("token"));var So,Io=si([(So=li("projectId"),Vn(((e,t)=>n=>Hn(...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",So))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a})=>{return c=Mn({baseUrl:n||kn,projectId:e,logger:t,hooks:i,cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:pi(c),otp:Bi(c),magicLink:Li(c),enchantedLink:xi(c),oauth:Wi(c),saml:Hi(c),totp:Zi(c),notp:bo(c),webauthn:go(c),password:ro(c),flow:Ai(c),refresh:ko(((e,t)=>zn(c.post(bn.refresh,{},{token:e,queryParams:t})))),selectTenant:si([ei("tenantId")],[oi('"token" must be string or undefined')])(((e,t)=>zn(c.post(bn.selectTenant,{tenant:e},{token:t})))),logout:ko((e=>zn(c.post(bn.logout,{},{token:e})))),logoutAll:ko((e=>zn(c.post(bn.logoutAll,{},{token:e})))),me:ko((e=>zn(c.get(bn.me,{token:e})))),myTenants:si([ri('"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,zn(c.post(bn.myTenants,n,{token:t}))})),history:ko((e=>zn(c.get(bn.history,{token:e})))),isJwtExpired:yo(Wn),getTenants:yo(Nn),getJwtPermissions:yo(Dn),getJwtRoles:yo(Fn),getCurrentTenant:yo(Bn),httpClient:c};var c})(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}}))})),Co=Object.assign(Io,{DeliveryMethods:wi});
|
|
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{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((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)},c=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 l,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}={}){l.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,l,"f")):e,n=Object.assign(Object.assign({},i(this,l,"f")),t);if(i(this,h,"f")||!p(i(this,l,"f"),n)){const e=i(this,l,"f");o(this,l,n,"f"),Object.freeze(i(this,l,"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,l,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,l,"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}};l=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const g=["error","warn","info","debug"],m=c((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,console))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||console),"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})),v="undefined"!=typeof localStorage,w=v&&localStorage.getItem("base.content.url")||"",b=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,y=c((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})),k=c((e=>{var t,n;const o=r(m,y)(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})),S=e=>t=>{var n,o,s;const a=r(m,y,k)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,i(this,n,"m",o).bind(this))}async init(){var e;c.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};S.missingAttrValidator=b;const I=c((e=>{const t=r(S({"project-id":b}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),C=c((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),x="Trying the next fallback URL...";function j({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i="https://static.descope.com/pages"}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}const O=c((e=>{var t,n,s,a,c;const l=r(m,I,C)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0)}async fetchStaticResource(e,n){const r=i(this,t,"m",a).call(this,e),c=Array.isArray(r)?e=>{if(e!==r.length-1){const{baseUrl:t}=r[e];o(this,s,t,"f")}}: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 fetch(r.toString(),t);if(o.ok)return null==i||i(e),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${x}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${x}`)}}})(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,t=new WeakSet,a=function(e){const t=w||this.baseStaticUrl;if(t)return j({projectId:this.projectId,filename:e,baseUrl:t});const r=i(this,n,"f")!==this.baseUrl,a=r&&!!this.baseUrl;r&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"));const c=j({projectId:this.projectId,filename:e,baseUrl:i(this,s,"f")});if(!a)return c;return[j({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),c]},c})),A=c((e=>{var t,n;const o=r(S({"project-id":b}))(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})),E=c((e=>{var t,n,s,a,c;const l=r(O,A,y)(e);return c=class extends l{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")},c})),U=c((e=>{var t,n,s,a,c,l,d;return d=class extends(r(y,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",c).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",l).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",c).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 Vc})),document.body.appendChild(i(this,n,"f"))},c=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},l=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),R="load-descope-ui",_="base.ui.components.url",T=v&&localStorage.getItem(_)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",M=v&&localStorage.getItem(_)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",L=v&&localStorage.getItem(_)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",P=e=>{const t=document.createElement("script");return t.id=e,t},$=(e,t)=>e.replace("<version>",t),W=c((e=>{var t,n,s,a,c,l,d,u,h,p,f,g;const v=r(m,E)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),s.set(this,Symbol("loadCbs")),h.set(this,void 0)}get descopeUi(){return i(this,h,"f")||o(this,h,i(this,t,"m",f).call(this),"f"),i(this,h,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",p).call(this,e))))}get baseCdnUrl(){return this.getAttribute("base-cdn-url")}},n=new WeakMap,s=new WeakMap,h=new WeakMap,t=new WeakSet,a=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},c=function(e){const t=i(this,n,"f"),o=i(this,s,"f");e[t]=[],e[o]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[o].push(t)}})},l=async function(e,n,o,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const s=P(o);document.body.append(s),s.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${s.src}"`)))})),s.addEventListener("load",(()=>{n.forEach((e=>e()))})),s.src=$(r,await i(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[i(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),i(this,t,"m",l).call(this,[i(this,t,"m",l).bind(this,e[i(this,n,"f")],e[i(this,s,"f")],"load-descope-ui-fallback-script-2",L),...e[i(this,n,"f")]],e[i(this,s,"f")],"load-descope-ui-fallback-script",M)})),e.addEventListener("load",(()=>{e[i(this,s,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${R}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=P(R);document.body.append(e),i(this,t,"m",c).call(this,e),i(this,t,"m",d).call(this,e),e.src=$(this.baseCdnUrl||T,await i(this,t,"m",a).call(this))}return document.getElementById(R)},p=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},f=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),i(this,t,"m",u).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),N="content-root",D="root",F=c((e=>class extends e{constructor(...e){var t,n,i,o;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${D}">\n <div id="${N}"></div>\n </div>\n `;const r=new CSSStyleSheet;r.replaceSync(`\n #${D}, #${N} {\n height: 100%;\n }\n #${D} {\n position: relative;\n height: fit-content;\n }\n `),null!==(t=(o=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(o.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],this.contentRootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(N),this.rootElement=null===(i=this.shadowRoot)||void 0===i?void 0:i.getElementById(D)}})),q="descope-modal";var z;let B=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)}};z=new WeakMap;let V=class extends B{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};var K;let H=class extends B{constructor(){super(...arguments),K.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,K,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,K,"f").content.cloneNode(!0)))}setContent(e){o(this,K,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};K=new WeakMap;let J=class extends B{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()}},G=class extends B{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)}}},X=class extends B{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)}}},Y=class extends B{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}},Z=class extends B{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)}}};const Q=c((e=>{var t,n;const o=r(y,F,W)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends H{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(q);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([q]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ee="descope-notification";c((e=>{var t,n;const o=r(y,F,W)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends J{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ee);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([ee])}},t=new WeakMap,n}));const te=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ne=c((e=>{var t,n,s,a,c,l,d,u,h,p,f,g,m,v;const w=r(S({theme:te}),O,y,W,E,F,k)(e);return v=class extends w{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{i(this,t,"m",g).call(this),i(this,m,"f").call(this,"os"===this.getAttribute("theme"))})),m.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",g).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")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this),i(this,t,"m",d).call(this),i(this,f,"f").call(this),this.observeAttributes(["theme"],i(this,f,"f")),this.observeAttributes(["style-id"],(()=>{o(this,s,null,"f"),i(this,t,"m",h).call(this),i(this,t,"m",l).call(this),i(this,t,"m",d).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,m=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(_))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(_),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")}},c=function(){return i(this,s,"f")||(o(this,s,i(this,t,"m",a).call(this),"f"),i(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,s,"f")},l=async function(){var e,r,s,a;const l=await i(this,t,"a",c);l&&(i(this,n,"f")||(o(this,n,new CSSStyleSheet,"f"),null!==(e=(a=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(a.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,i(this,n,"f")]),i(this,n,"f").replaceSync(((null===(r=null==l?void 0:l.light)||void 0===r?void 0:r.globals)||"")+((null===(s=null==l?void 0:l.dark)||void 0===s?void 0:s.globals)||"")))},d=async function(){var e,n;const o=Object.assign({},await i(this,t,"a",c));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})},u=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},h=async function(){const e=await i(this,t,"m",u).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")},p=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)},g=function(){i(this,t,"m",h).call(this),i(this,t,"m",p).call(this)},v}));var ie=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),oe=()=>Math.random().toString(36).substring(7).split("").join("."),re={INIT:`@@redux/INIT${oe()}`,REPLACE:`@@redux/REPLACE${oe()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${oe()}`};function se(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 ae(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 ce(e){let t=typeof e;return t=ae(e),t}function le(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${ce(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: '${ce(n)}'`);return n(le)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,c=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(c)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: '${ce(e)}'`);if(c)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;l();const n=a++;return s.set(n,e),function(){if(t){if(c)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,l(),s.delete(n),r=null}}}function h(e){if(!se(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${ce(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: '${ce(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,o=i(o,e)}finally{c=!1}return(r=s).forEach((e=>{e()})),e}h({type:re.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: '${ce(e)}`);i=e,h({type:re.REPLACE})},[ie]: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: '${ce(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[ie](){return this}}}}}function de(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ue(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&de(`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:re.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:re.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 '${re.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===re.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(!se(e))return`The ${r} has unexpected type of "${ce(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===re.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&&de(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],c=n[r],l=e[r],d=c(l,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!==l}return s=s||i.length!==Object.keys(e).length,s?a:e}}function he(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function pe(e){return se(e)&&"type"in e&&"string"==typeof e.type}var fe=Symbol.for("immer-nothing"),ge=Symbol.for("immer-draftable"),me=Symbol.for("immer-state"),ve=[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 we(e,...t){{const n=ve[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var be=Object.getPrototypeOf;function ye(e){return!!e&&!!e[me]}function ke(e){return!!e&&(Ie(e)||Array.isArray(e)||!!e[ge]||!!e.constructor?.[ge]||Ae(e)||Ee(e))}var Se=Object.prototype.constructor.toString();function Ie(e){if(!e||"object"!=typeof e)return!1;const t=be(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)===Se}function Ce(e,t){0===xe(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function xe(e){const t=e[me];return t?t.type_:Array.isArray(e)?1:Ae(e)?2:Ee(e)?3:0}function je(e,t){return 2===xe(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Oe(e,t,n){const i=xe(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function Ae(e){return e instanceof Map}function Ee(e){return e instanceof Set}function Ue(e){return e.copy_||e.base_}function Re(e,t){if(Ae(e))return new Map(e);if(Ee(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ie(e)){if(!be(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[me];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(be(e),n)}function _e(e,t=!1){return Me(e)||ye(e)||!ke(e)||(xe(e)>1&&(e.set=e.add=e.clear=e.delete=Te),Object.freeze(e),t&&Ce(e,((e,t)=>_e(t,!0)))),e}function Te(){we(2)}function Me(e){return Object.isFrozen(e)}var Le,Pe={};function $e(e){const t=Pe[e];return t||we(0,e),t}function We(){return Le}function Ne(e,t){t&&($e("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function De(e){Fe(e),e.drafts_.forEach(ze),e.drafts_=null}function Fe(e){e===Le&&(Le=e.parent_)}function qe(e){return Le={drafts_:[],parent_:Le,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ze(e){const t=e[me];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Be(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[me].modified_&&(De(t),we(4)),ke(e)&&(e=Ve(t,e),t.parent_||He(t,e)),t.patches_&&$e("Patches").generateReplacementPatches_(n[me].base_,e,t.patches_,t.inversePatches_)):e=Ve(t,n,[]),De(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==fe?e:void 0}function Ve(e,t,n){if(Me(t))return t;const i=t[me];if(!i)return Ce(t,((o,r)=>Ke(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return He(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),Ce(o,((o,s)=>Ke(e,i,t,o,s,n,r))),He(e,t,!1),n&&e.patches_&&$e("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function Ke(e,t,n,i,o,r,s){if(o===n&&we(5),ye(o)){const s=Ve(e,o,r&&t&&3!==t.type_&&!je(t.assigned_,i)?r.concat(i):void 0);if(Oe(n,i,s),!ye(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(ke(o)&&!Me(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ve(e,o),t&&t.scope_.parent_||He(e,o)}}function He(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&_e(t,n)}var Je={get(e,t){if(t===me)return e;const n=Ue(e);if(!je(n,t))return function(e,t,n){const i=Ye(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_||!ke(i)?i:i===Xe(e.base_,t)?(Qe(e),e.copy_[t]=et(i,e)):i},has:(e,t)=>t in Ue(e),ownKeys:e=>Reflect.ownKeys(Ue(e)),set(e,t,n){const i=Ye(Ue(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=Xe(Ue(e),t),o=i?.[me];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||je(e.base_,t)))return!0;Qe(e),Ze(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!==Xe(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Qe(e),Ze(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ue(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){we(11)},getPrototypeOf:e=>be(e.base_),setPrototypeOf(){we(12)}},Ge={};function Xe(e,t){const n=e[me];return(n?Ue(n):e)[t]}function Ye(e,t){if(!(t in e))return;let n=be(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=be(n)}}function Ze(e){e.modified_||(e.modified_=!0,e.parent_&&Ze(e.parent_))}function Qe(e){e.copy_||(e.copy_=Re(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ce(Je,((e,t)=>{Ge[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ge.deleteProperty=function(e,t){return isNaN(parseInt(t))&&we(13),Ge.set.call(this,e,t,void 0)},Ge.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&we(14),Je.set.call(this,e[0],t,n,e[0])};function et(e,t){const n=Ae(e)?$e("MapSet").proxyMap_(e,t):Ee(e)?$e("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:We(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=Je;n&&(o=[i],r=Ge);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:We()).drafts_.push(n),n}function tt(e){return ye(e)||we(10,e),nt(e)}function nt(e){if(!ke(e)||Me(e))return e;const t=e[me];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Re(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Re(e,!0);return Ce(n,((e,t)=>{Oe(n,e,nt(t))})),t&&(t.finalized_=!1),n}var it=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&&we(6),void 0!==n&&"function"!=typeof n&&we(7),ke(e)){const o=qe(this),r=et(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?De(o):Fe(o)}return Ne(o,n),Be(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===fe&&(i=void 0),this.autoFreeze_&&_e(i,!0),n){const t=[],o=[];$e("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}we(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){ke(e)||we(8),ye(e)&&(e=tt(e));const t=qe(this),n=et(e,void 0);return n[me].isManual_=!0,Fe(t),n}finishDraft(e,t){const n=e&&e[me];n&&n.isManual_||we(9);const{scope_:i}=n;return Ne(i,t),Be(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=$e("Patches").applyPatches_;return ye(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},ot=it.produce;it.produceWithPatches.bind(it),it.setAutoFreeze.bind(it),it.setUseStrictShallowCopy.bind(it),it.applyPatches.bind(it),it.createDraft.bind(it),it.finishDraft.bind(it);var rt=(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})}}},st=(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})}},at={inputStabilityCheck:"once",identityFunctionCheck:"once"};var ct=e=>Array.isArray(e)?e:[e];function lt(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 dt(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var ut="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},ht=0,pt=1;function ft(){return{s:ht,v:void 0,o:null,p:null}}function gt(e,t={}){let n=ft();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=ft(),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=ft(),e.set(n,t)):t=i}}const a=t;let c;if(t.s===pt)c=t.v;else if(c=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,c)&&(c=e,0!==r&&r--);o="object"==typeof c&&null!==c||"function"==typeof c?new ut(c):c}return a.s=pt,a.v=c,c}return s.clearCache=()=>{n=ft(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function mt(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:c,memoizeOptions:l=[],argsMemoize:d=gt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=ct(l),f=ct(u),g=lt(e),m=c((function(){return i++,s.apply(null,arguments)}),...p);let v=!0;const w=d((function(){o++;const e=dt(g,arguments);t=m.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...at,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:rt},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:st}}})(v,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=dt(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}v&&(v=!1)}return t}),...f);return Object.assign(w,{resultFunc:s,memoizedResultFunc:m,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:c,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var vt=mt(gt),wt=Object.assign(((e,t=vt)=>{!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:()=>wt});function bt(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var yt=bt(),kt=bt;((...e)=>{const t=mt(...e)})(gt);var St="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?he:he.apply(null,arguments)},It=e=>e&&"function"==typeof e.match;function Ct(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=>pe(t)&&t.type===e,n}function xt(e){return"function"==typeof e&&"type"in e&&It(e)}function jt(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 Ot=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 At(e){return ke(e)?ot(e,(()=>{})):e}function Et(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 Ut(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Rt(e,t,n){const i=_t(e,t,n);return{detectMutations:()=>Tt(e,t,i,n)}}function _t(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]=_t(e,t,n[o],s))}}return r}function Tt(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 c={};for(let e in n.children)c[e]=!0;for(let e in i)c[e]=!0;const l=t.length>0;for(let o in c){const s=r?r+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Tt(e,t,n.children[o],i[o],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function Mt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||se(e)}function Lt(e,t="",n=Mt,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),c=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Lt(l,a,n,i,o,r),s))return s}return r&&Pt(e)&&r.add(e),!1}function Pt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Pt(t))return!1;return!0}function $t(e){return"boolean"==typeof e}var Wt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Ot;if(t&&($t(t)?r.push(yt):r.push(kt(t.extraArgument))),n){let e={};$t(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=Ut,ignoredPaths:o,warnAfter:r=32}=e;const s=Rt.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>c=>{const l=jt(r,"ImmutableStateInvariantMiddleware");l.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(c);return l.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(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(i){let e={};$t(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=Mt,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!pe(u))return l(u);const h=l(u),p=jt(s,"SerializableStateInvariantMiddleware");return c||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Lt(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=Lt(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={};$t(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=xt}=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},Nt=e=>t=>{setTimeout(t,e)},Dt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Nt(10),Ft=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Ot(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,c="tick"===e.type?queueMicrotask:"raf"===e.type?Dt:"callback"===e.type?e.queueNotification:Nt(e.timeout),l=()=>{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,c(l))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function qt(e){const t=Wt(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!se(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=ue(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(c=i(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=he;o&&(l=St({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=he(...a)(o.dispatch),{...o,dispatch:r}}}(...c),u=Ft(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");c.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return le(a,r,l(...h))}function zt(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 Bt(...e){return t=>e.some((e=>((e,t)=>It(e)?e.match(t):e(t))(e,t)))}var Vt=["name","message","stack","code"],Kt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Ht=class{constructor(e,t){this.payload=e,this.meta=t}_type},Jt=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Vt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},Gt=(()=>{function e(e,t,n){const i=Ct(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Ct(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ct(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||Jt)(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,c)=>{const l=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:c});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(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new Kt(e,t),fulfillWithValue:(e,t)=>new Ht(e,t)})).then((t=>{if(t instanceof Kt)throw t;return t instanceof Ht?i(t.payload,l,e,t.meta):i(t,l,e)}))])}catch(t){p=t instanceof Kt?r(null,l,e,t.payload,t.meta):r(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,arg:e,unwrap:()=>p.then(Xt)})}}),{pending:o,rejected:r,fulfilled:i,settled:Bt(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function Xt(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var Yt=Symbol.for("rtk-slice-createasyncthunk");function Zt(e,t){return`${e}/${t}`}function Qt(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 en=function({creators:e}={}){const t=e?.asyncThunk?.[Yt];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 c(){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?zt(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]=zt(t);if(function(e){return"function"==typeof e}(e))n=()=>At(e());else{const t=At(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(ye(e)){const i=n(e,t);return void 0===i?e:i}if(ke(e))return ot(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:Zt(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?Ct(e,s):Ct(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:c,settled:l,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);c&&i.addCase(u.rejected,c);l&&i.addMatcher(u.settled,l);i.exposeCaseReducer(t,{fulfilled:s||tn,pending:a||tn,rejected:c||tn,settled:l||tn})}(s,r,a,t)}));const l=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=c()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=c()),u.getInitialState()),getSelectors(t=l){const n=Et(d,this,{insert:()=>new WeakMap});return Et(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=Qt(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 tn(){}var nn="listenerMiddleware";Ct(`${nn}/add`),Ct(`${nn}/removeAll`),Ct(`${nn}/remove`);const on=e=>c((t=>{const n=en(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(m)(t)){constructor(...e){super(...e);const t=qt({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{Xt(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()))))}}}));c((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 rn=c((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),sn=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),n)})),t};function an(e){return new URLSearchParams(window.location.search).get(e)}const cn=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)}))}))},ln=Gt("users/me",((e,{extra:{api:t}})=>t.user.me())),dn=cn(ln)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(un=e=>e.me,{onFulfilled:e=>{un(e).loading=!1},onPending:e=>{un(e).loading=!0,un(e).error=null},onRejected:(e,t)=>{un(e).loading=!1,un(e).error=t.error}}));var un;const hn={action:ln,reducer:dn},pn=Gt("users/logout",((e,{extra:{api:t}})=>t.user.logout())),fn={action:pn,reducer:cn(pn)({})},gn={me:{loading:!1,error:null,data:{}}};class mn extends Error{}function vn(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 mn("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 mn(`Invalid token specified: missing part #${n+1}`);let o;try{o=vn(i)}catch(e){throw new mn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new mn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}mn.prototype.name="InvalidTokenError";var bn={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"}},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",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 yn="<region>",kn=`https://api.${yn}descope.com`,Sn=6e5,In="dct",Cn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let xn;const jn=()=>{if(xn)return xn;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 xn=`${t}-${n}`,xn};var On;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(On||(On={}));const An=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(yn,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},En=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,i])=>(e[n]=i,e)),e),e}),{})),Un={"Content-Type":"application/json"},Rn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},_n=e=>{const t={"x-descope-sdk-session-id":jn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.40.0"};return e&&(t["x-descope-refresh-cookie-name"]=e),t},Tn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},Mn=({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const c=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Cn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await n(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return Cn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(i)),i}:n})(o,a),l=async o=>{var a;const l=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=l,m=(e=>void 0===e?void 0:JSON.stringify(e))(u),v={headers:En(Rn(t,g),_n(i),(null==n?void 0:n.baseHeaders)||{},Tn(m)?Un:{},h),method:f,body:m};null!==s&&(v.credentials=s||"include");const w=await c(An({path:d,baseUrl:e,queryParams:p,projectId:t}),v);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==w?void 0:w.clone()),null==r?void 0:r.transformResponse){const e=await w.json(),t=((null===(a=w.headers)||void 0===a?void 0:a.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,i]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:i})}),{}),n=Object.assign(Object.assign({},w),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return w};return{get:(e,{headers:t,queryParams:n,token:i}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:On.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:On.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:On.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:On.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:On.delete,token:i}),hooks:r,buildUrl:(n,i)=>An({projectId:t,baseUrl:e,path:n,queryParams:i})}};var Ln=429;function Pn(e,t,n){var i;let o=$n(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[In])===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 $n(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return wn(e)}function Wn(e){const{exp:t}=$n(e);return(new Date).getTime()/1e3>t}function Nn(e){let t=$n(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Dn(e,t){return Pn(e,t,"permissions")}function Fn(e,t){return Pn(e,t,"roles")}const qn=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function zn(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===Ln&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function Bn(e){var t;return(null===(t=$n(e))||void 0===t?void 0:t[In])||""}const Vn=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Kn=(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 "))},Hn=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Jn=e=>t=>e.test(t),Gn=Jn(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Xn=Jn(/^\+[1-9]{1}[0-9]{3,14}$/),Yn=Vn(Gn,'"{val}" is not a valid email'),Zn=Vn(Xn,'"{val}" is not a valid phone number'),Qn=Vn((e=>e.length>=1),"Minimum length is 1");const ei=Vn((e=>"string"==typeof e),"Input is not a string"),ti=Vn((e=>Array.isArray(e)),"Input is not an array"),ni=Vn((e=>"boolean"==typeof e),"Input is not a boolean"),ii=Vn((e=>void 0===e),"Input is defined"),oi=Kn([ei(),ii()],"Input is not a string or undefined"),ri=Kn([ti(),ni()],"Input is not an array or boolean"),si=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Hn(...e).validate(n[t]))),t(...n)),ai=e=>[ei(`"${e}" must be a string`)],ci=e=>[oi(`"${e}" must be string or undefined`)],li=e=>[ei(`"${e}" must be a string`),Qn(`"${e}" must not be empty`)],di=e=>[ei(`"${e}" must be a string`),Yn()],ui=e=>[ei(`"${e}" must be a string`),Zn()],hi=si(li("accessKey")),pi=e=>({exchange:hi(((t,n)=>zn(e.post(bn.accessKey.exchange,{loginOptions:n},{token:t}))))}),fi=(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),gi=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Sn,Sn)});var mi,vi;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(mi||(mi={})),function(e){e.email="email"}(vi||(vi={}));const wi=Object.assign(Object.assign({},mi),vi);var bi;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(bi||(bi={}));const yi=li("loginId"),ki=si(li("token")),Si=si(yi),Ii=si(li("pendingRef")),Ci=si(yi,di("email")),xi=e=>({verify:ki((t=>zn(e.post(bn.enchantedLink.verify,{token:t})))),signIn:Si(((t,n,i,o)=>zn(e.post(qn(bn.enchantedLink.signIn,wi.email),{loginId:t,URI:n,loginOptions:i},{token:o})))),signUpOrIn:Si(((t,n,i)=>zn(e.post(qn(bn.enchantedLink.signUpOrIn,wi.email),{loginId:t,URI:n,loginOptions:i})))),signUp:Si(((t,n,i,o)=>zn(e.post(qn(bn.enchantedLink.signUp,wi.email),{loginId:t,URI:n,user:i,loginOptions:o})))),waitForSession:Ii(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=gi(n);let s;const a=setInterval((async()=>{const n=await e.post(bn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(zn(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ci(((t,n,i,o,r)=>zn(e.post(bn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),ji=si(li("flowId")),Oi=si(li("executionId"),li("stepId"),li("interactionId")),Ai=e=>({start:ji(((t,n,i,o,r,s,a)=>zn(e.post(bn.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a})))),next:Oi(((t,n,i,o,r,s)=>zn(e.post(bn.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),Ei=li("loginId"),Ui=si(li("token")),Ri=si(Ei),_i=si(Ei,ui("phone")),Ti=si(Ei,di("email")),Mi=Object.keys(wi).filter((e=>e!==mi.voice)),Li=e=>({verify:Ui((t=>zn(e.post(bn.magicLink.verify,{token:t})))),signIn:Mi.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ri(((t,i,o,r)=>zn(e.post(qn(bn.magicLink.signIn,n),{loginId:t,URI:i,loginOptions:o},{token:r}))))})),{}),signUp:Mi.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ri(((t,i,o,r)=>zn(e.post(qn(bn.magicLink.signUp,n),{loginId:t,URI:i,user:o,loginOptions:r}))))})),{}),signUpOrIn:Mi.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ri(((t,i,o)=>zn(e.post(qn(bn.magicLink.signUpOrIn,n),{loginId:t,URI:i,loginOptions:o}))))})),{}),update:{email:Ti(((t,n,i,o,r)=>zn(e.post(bn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(mi).filter((e=>e!==mi.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:_i(((t,i,o,r,s)=>zn(e.post(qn(bn.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Pi;!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"}(Pi||(Pi={}));const $i=si(li("code")),Wi=e=>({start:Object.assign(((t,n,i,o)=>zn(e.post(bn.oauth.start,i||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:o}))),Object.keys(Pi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o)=>zn(e.post(bn.oauth.start,i||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:o}))})),{})),exchange:$i((t=>zn(e.post(bn.oauth.exchange,{code:t})))),startNative:(t,n,i)=>zn(e.post(bn.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>zn(e.post(bn.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>zn(e.get(bn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>zn(e.post(bn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>zn(e.post(bn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Ni=li("loginId"),Di=si(Ni,li("code")),Fi=si(Ni),qi=si(Ni,ui("phone")),zi=si(Ni,di("email")),Bi=e=>({verify:Object.keys(wi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Di(((t,i)=>zn(e.post(qn(bn.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(wi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Fi(((t,i,o)=>zn(e.post(qn(bn.otp.signIn,n),{loginId:t,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(wi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Fi(((t,i,o)=>zn(e.post(qn(bn.otp.signUp,n),{loginId:t,user:i,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(wi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Fi(((t,i)=>zn(e.post(qn(bn.otp.signUpOrIn,n),{loginId:t,loginOptions:i}))))})),{}),update:{email:zi(((t,n,i,o)=>zn(e.post(bn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(mi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:qi(((t,i,o,r)=>zn(e.post(qn(bn.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),Vi=si(li("tenant")),Ki=si(li("code")),Hi=e=>({start:Vi(((t,n,i,o,r)=>zn(e.post(bn.saml.start,i||{},Object.assign({queryParams:Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r})},o&&{token:o}))))),exchange:Ki((t=>zn(e.post(bn.saml.exchange,{code:t}))))}),Ji=li("loginId"),Gi=si(Ji,li("code")),Xi=si(Ji),Yi=si(Ji),Zi=e=>({signUp:Xi(((t,n)=>zn(e.post(bn.totp.signUp,{loginId:t,user:n})))),verify:Gi(((t,n,i,o)=>zn(e.post(bn.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:Yi(((t,n)=>zn(e.post(bn.totp.update,{loginId:t},{token:n}))))}),Qi=li("loginId"),eo=li("newPassword"),to=si(Qi,li("password")),no=si(Qi),io=si(Qi,eo),oo=si(Qi,li("oldPassword"),eo),ro=e=>({signUp:to(((t,n,i,o)=>zn(e.post(bn.password.signUp,{loginId:t,password:n,user:i,loginOptions:o})))),signIn:to(((t,n,i)=>zn(e.post(bn.password.signIn,{loginId:t,password:n,loginOptions:i})))),sendReset:no(((t,n,i)=>zn(e.post(bn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:io(((t,n,i)=>zn(e.post(bn.password.update,{loginId:t,newPassword:n},{token:i})))),replace:oo(((t,n,i)=>zn(e.post(bn.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>zn(e.get(bn.password.policy))}),so=ai("loginId"),ao=li("loginId"),co=li("origin"),lo=si(ao,co,li("name")),uo=si(ao,co),ho=si(so,co),po=si(ao,co,ci("token")),fo=si(li("transactionId"),li("response")),go=e=>({signUp:{start:lo(((t,n,i,o)=>zn(e.post(bn.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,passkeyOptions:o})))),finish:fo(((t,n)=>zn(e.post(bn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:ho(((t,n,i,o,r)=>zn(e.post(bn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:fo(((t,n)=>zn(e.post(bn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:uo(((t,n,i)=>zn(e.post(bn.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:i}))))},update:{start:po(((t,n,i,o)=>zn(e.post(bn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:fo(((t,n)=>zn(e.post(bn.webauthn.update.finish,{transactionId:t,response:n}))))}}),mo=ai("loginId"),vo=si(mo),wo=si(li("pendingRef")),bo=e=>({signUpOrIn:vo(((t,n)=>zn(e.post(bn.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:vo(((t,n,i)=>zn(e.post(bn.notp.signUp,{loginId:t,user:n,loginOptions:i})))),signIn:vo(((t,n,i)=>zn(e.post(bn.notp.signIn,{loginId:t,loginOptions:n},{token:i})))),waitForSession:wo(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=gi(n);let s;const a=setInterval((async()=>{const n=await e.post(bn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(zn(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),yo=si(li("token")),ko=si(ci("token"));var So,Io=si([(So=li("projectId"),Vn(((e,t)=>n=>Hn(...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",So))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a})=>{return c=Mn({baseUrl:n||kn,projectId:e,logger:t,hooks:i,cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:pi(c),otp:Bi(c),magicLink:Li(c),enchantedLink:xi(c),oauth:Wi(c),saml:Hi(c),totp:Zi(c),notp:bo(c),webauthn:go(c),password:ro(c),flow:Ai(c),refresh:ko(((e,t)=>zn(c.post(bn.refresh,{},{token:e,queryParams:t})))),selectTenant:si([ei("tenantId")],[oi('"token" must be string or undefined')])(((e,t)=>zn(c.post(bn.selectTenant,{tenant:e},{token:t})))),logout:ko((e=>zn(c.post(bn.logout,{},{token:e})))),logoutAll:ko((e=>zn(c.post(bn.logoutAll,{},{token:e})))),me:ko((e=>zn(c.get(bn.me,{token:e})))),myTenants:si([ri('"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,zn(c.post(bn.myTenants,n,{token:t}))})),history:ko((e=>zn(c.get(bn.history,{token:e})))),isJwtExpired:yo(Wn),getTenants:yo(Nn),getJwtPermissions:yo(Dn),getJwtRoles:yo(Fn),getCurrentTenant:yo(Bn),httpClient:c};var c})(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}}))})),Co=Object.assign(Io,{DeliveryMethods:wi});
|
|
6
6
|
/*! js-cookie v3.0.5 | MIT */
|
|
7
|
-
function xo(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 jo=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=xo({},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,"",xo({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,xo({},this.attributes,t))},withConverter:function(t){return e(xo({},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 Oo={default:"endpoint"},Ao="Blocked by CSP",Eo="The endpoint parameter is not a valid URL",Uo="Failed to load the JS script of the agent",Ro="9319";function _o(e,t){var n,i,o,r,s,a=[],c=(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===Ao||s===Eo)n.exclude(),r=0;else if(s===Ro)n.exclude();else if(s===Uo){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!o.has(c)&&(o.add(c),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+i()-Date.now()]}]),l=c[0],d=c[1];if(void 0===l)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(l).then((function(e){return[e,a]}))}var To="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Mo=To;function Lo(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),c=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:To,l=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=l[0],u=l[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)}))}(c,s);return _o(e,Po)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Ro?new Error(Uo):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 Po(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(Eo);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(Uo))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(Ao)})).then($o)}function $o(){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(Ro);return n}const Wo=e=>{try{return wn(e).exp}catch(e){return null}},No=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Wo(n)},Do=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?Wo(i):void 0)},Fo=(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},qo=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(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||Do(e),cookieExpiration:e.cookieExpiration||No(e)},s)})((null==n?void 0:n.authInfo)||n||{})},zo=async e=>{const t=await qo(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Bo="undefined"!=typeof localStorage,Vo=(e,t)=>Bo&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Ko=e=>Bo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Ho=e=>Bo&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Jo=(...e)=>{console.debug(...e)},Go="3.2.0",Xo="undefined"!=typeof window,Yo=Math.pow(2,31)-1,Zo=`https://descopecdn.com/npm/oidc-client-ts@${Go}/dist/browser/oidc-client-ts.min.js`,Qo=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Go}/dist/browser/oidc-client-ts.min.js`,er="DS",tr="DSR",nr="DSI";function ir(e=""){return Ko(`${e}${tr}`)||""}function or(e=""){return jo.get(er)||Ko(`${e}${er}`)||""}function rr(e=""){return Ko(`${e}${nr}`)||""}function sr(e=""){Ho(`${e}${tr}`),Ho(`${e}${er}`),Ho(`${e}${nr}`),jo.remove(er)}const ar=Xo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",cr="vsid",lr="vrid",dr="fp",ur=(e=!1)=>{const t=localStorage.getItem(dr);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},hr=async(e,t=ar)=>{try{if(ur())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=Lo({apiKey:e,endpoint:[i.toString(),Oo],scriptUrlPattern:[r,Mo]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[cr]:e,[lr]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(dr,JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},pr=e=>{const t=ur(!0);return t&&e.body&&(e.body.fpData=t),e},fr="dls_last_user_login_id",gr="dls_last_user_display_name",vr=()=>Ko(fr),mr=()=>Ko(gr),wr=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=vr(),r=mr();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function br(){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 yr(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=jr(n.publicKey.challenge),n.publicKey.user.id=jr(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=jr(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Or(n.rawId),type:n.type,response:{attestationObject:Or(n.response.attestationObject),clientDataJSON:Or(n.response.clientDataJSON)}});var n}async function kr(e){const t=Cr(e);return xr(await navigator.credentials.get(t))}async function Sr(e,t){const n=Cr(e);return n.signal=t.signal,n.mediation="conditional",xr(await navigator.credentials.get(n))}async function Ir(e=!1){if(!Xo)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Cr(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=jr(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=jr(e.id)})),n}function xr(e){return JSON.stringify({id:e.id,rawId:Or(e.rawId),type:e.type,response:{authenticatorData:Or(e.response.authenticatorData),clientDataJSON:Or(e.response.clientDataJSON),signature:Or(e.response.signature),userHandle:e.response.userHandle?Or(e.response.userHandle):void 0}})}function jr(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Or(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ar,Er=(Ar=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 yr(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 kr(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 yr(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await kr(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 yr(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:yr,get:kr,isSupported:Ir,conditional:Sr}}),(...e)=>{const t=Ar(...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 Ur="/fedcm/config";async function Rr(e,t){var n,i,o;try{const o=await async function(e,t="google",n,i,o){const r=(()=>{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)})(),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 c=a.data.clientId;return new Promise((e=>{var a,l;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===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,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)}}catch(e){null===(o=null==t?void 0:t.onFailed)||void 0===o||o.call(t,e)}}var _r=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Ir(),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 Tr;const Mr=(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",(()=>{Mr(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Lr=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{Tr||(Tr=(async()=>{try{return require("oidc-client-ts")}catch(e){return Mr([Zo,Qo],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await Tr;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=t,s=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",c=`${r}_user`;let l=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(l=`${l}/${n.applicationId}`);const d={authority:l,client_id:t,redirect_uri:s,response_type:"code",scope:a,stateStore:new o({store:window.localStorage,prefix:r}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new i(d),stateUserKey:c}})(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)))),window.localStorage.setItem(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(e={},t=!1)=>{const{client:n}=await i(),o=await n.createSigninRequest(e),{url:r}=o;return t||(window.location.href=r),{ok:!0,data:o}},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=window.localStorage.getItem(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 c=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(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||rr(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return window.localStorage.removeItem(o),t||window.location.replace(s),r}}},Pr=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Xo?(i&&o&&hr(i).catch((()=>null)),e(Fo(r,{beforeRequest:pr}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i)return e(o);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;Xo&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&a&&new Date>a&&(Jo("Expiration time passed, refreshing session"),l.refresh(ir()||c))}));const l=e(Fo(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o}=await qo(t);if(401===(null==t?void 0:t.status))Jo("Received 401, canceling all timers"),r();else if(n||o){if(a=((e,t)=>{if(t)return new Date(1e3*t);Jo("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),!a)return void Jo("Could not extract expiration time from session token");c=i;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>Yo&&(Jo(`Timeout is too large (${t}ms), setting it to ${Yo}ms`),t=Yo),t})(a);if(r(),e<=2e4)return void Jo("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Jo(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Jo("Refreshing session due to timer"),l.refresh(ir()||i)}),e)}}}));return fi(l,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Jo("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.29.1"},t.baseHeaders)}))),(e=>t=>{const n=br(),i=br(),o=br(),r=e(Fo(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))i.pub(null),o.pub(null),n.pub(null);else{const e=await zo(t);e&&o.pub(e);const{sessionJwt:r,sessionExpiration:s}=await qo(t);r&&i.pub(r),(s||r)&&n.pub(s||42)}}})),s=fi(r,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const r=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r}));return Object.assign(s,{onSessionTokenChange:i.sub,onUserChange:o.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:vr,getLastUserDisplayName:mr});const s=e(Fo(r,{afterRequest:async(e,t)=>{var n;const i=await zo(t),o=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;o&&((e=>{Vo(fr,e)})(o),(e=>{Vo(gr,e)})(r))}}));let a=fi(s,["flow.start"],wr);return a=fi(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Ho(fr),Ho(gr)),i})(o)),Object.assign(a,{getLastUserLoginId:vr,getLastUserDisplayName:mr})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!Xo)return e(s);const a=e(Fo(s,{beforeRequest:(c=r,e=>Object.assign(e,{token:e.token||ir(c)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||sr(r):((e={},t=!1,n="")=>{var i;const{sessionJwt:o,refreshJwt:r}=e;if(r&&Vo(`${n}${tr}`,r),o)if(t){const n=t.sameSite||"Strict",r=null===(i=t.secure)||void 0===i||i;!function(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);jo.set(e,t,{path:o,domain:l?i:void 0,expires:c,sameSite:r,secure:a})}}(er,o,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r}))}else Vo(`${n}${er}`,o);e.idToken&&Vo(`${n}${nr}`,e.idToken)})(await qo(t),o,r)}}));var c;const l=fi(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const i=await t(...n);return sr(e),i})(r));return Object.assign(l,{getRefreshToken:()=>ir(r),getSessionToken:()=>or(r),getIdToken:()=>rr(r)})}))((e=>{const t=Co(e),n=Lr(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async i=>{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()}})}const o=or(),r=ir();return t.refresh(i,{dcs:o?"t":"f",dcr:r?"t":"f"})},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:_r(t),webauthn:Er(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){Rr(i,e)},requestAuthentication(e){Rr(i,e)}},oneTap(e,t,n,o,r){Rr(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+Ur),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Xo&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+Ur);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})),$r={me:"/v1/auth/me"},Wr=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),Nr=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return Wr();const i=yield e.get($r.me);return yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(i),i.json()}))}),Dr=c((e=>{var t,s,a,c;const l=r(I,k,v,C,rn)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return 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=Pr(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.4.11"}}));return{user:Object.assign(Object.assign({},Nr({httpClient:o.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):o.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},c})),Fr=c((e=>{const t=r(on({name:"widget",initialState:gn,reducers:{},extraReducers:e=>{hn.reducer(e),fn.reducer(e)},asyncActions:{getMe:hn.action,logout:fn.action}}),y,v,Dr)(e);return class extends t{constructor(...e){super(...e),this.state=gn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),qr="widget-flow",zr=c((e=>{var t,o,s;return s=class extends(r(y,Q,Fr,rn,v)(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=an(qr);r&&(!function(e){if(window.history.replaceState&&an(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())}}(qr),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(sn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName}));new Z((()=>{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})),Br=e=>e.me.data,Vr=mt(Br,(e=>e.picture)),Kr=mt(Br,(e=>e.email)),Hr=mt(Br,(e=>e.verifiedEmail)),Jr=mt(Br,(e=>e.name)),Gr=mt(Br,(e=>e.phone)),Xr=mt(Br,(e=>e.verifiedPhone)),Yr=mt(Br,(e=>e.webauthn));mt(Br,(e=>e.password));const Zr=mt(Br,(e=>e.TOTP)),Qr=mt(Br,(e=>e.customAttributes)),es=c((e=>{const t=r(O,S({"widget-id":S.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}))}}})),ts=c((e=>{var t,o,a;return a=class extends(r(v,y,W,F,es,Fr)(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 Promise.all([this.actions.getMe(),i(this,t,"m",o).call(this)]),this.onWidgetRootReady()}))}},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})),ns=c((e=>class extends(r(ne,k)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),is=c((e=>{var t,s,c,l,d,u,h,p,f;return f=class extends(r(ns,ne,Fr,v,rn,ts,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.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",l).call(this),i(this,h,"f").call(this,Vr(this.state)),i(this,p,"f").call(this,Jr(this.state)),this.subscribe(i(this,h,"f").bind(this),Vr),this.subscribe(i(this,p,"f").bind(this),Jr)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,l=function(){this.avatar.flowId&&(o(this,s,this.createModal({"data-id":"update-pic"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},d=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),i(this,c,"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})),os=c((e=>{var t,s,c,l,d,u,h,p,f,g,m,w,b;return b=class extends(r(ns,Fr,v,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.emailUserAttr.value=e}))),w.set(this,a((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}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,m,"f").call(this,Kr(this.state)),i(this,w,"f").call(this,Hr(this.state)),this.subscribe(i(this,m,"f").bind(this),Kr),this.subscribe(i(this,w,"f").bind(this),Hr)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,w=new WeakMap,t=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-email"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},h=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(o(this,l,this.createModal({"data-id":"delete-email"}),"f"),o(this,d,new Z((()=>{var e;return null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,l,"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,l,"f").setContent(sn({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,d,"f").onSuccess((()=>{i(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new X((()=>{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,l,"f"))||void 0===e||e.open()}))},b})),rs=c((e=>{var t,o,s;return s=class extends(r(Fr,v,ts,Q)(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 V((()=>{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})),ss=c((e=>{var t,s,c,l,d,u,h,p,f,g,m,w;return w=class extends(r(ns,Fr,v,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});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,m,"f").call(this,Jr(this.state)),this.subscribe(i(this,m,"f").bind(this),Jr)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-name"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},h=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(o(this,l,this.createModal({"data-id":"delete-name"}),"f"),o(this,d,new Z((()=>{var e;return null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,l,"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,l,"f").setContent(sn({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),i(this,d,"f").onSuccess((()=>{i(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new X((()=>{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,l,"f"))||void 0===e||e.open()}))},w})),as=c((e=>{var t,s,c,l,d,u,h,p;return p=class extends(r(ns,Fr,v,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),h.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",u).call(this),i(this,t,"m",l).call(this),i(this,h,"f").call(this,Yr(this.state)),this.subscribe(i(this,h,"f").bind(this),Yr)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,l=function(){this.passkeyUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"passkey"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},d=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new Y((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},p})),cs=c((e=>{var t,s,a,c,l,d;return d=class extends(r(ns,Fr,v,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new Y((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onButtonClick((()=>{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",c).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(){this.passwordUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"password"}),"f"),o(this,a,new Z((()=>{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",l).bind(this),i(this,t,"m",l).call(this),this.syncFlowTheme(i(this,a,"f")))},l=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close()}))},d})),ls=c((e=>{var t,s,c,l,d,u,h,p,f,g,m,w,b;return b=class extends(r(ns,Fr,v,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.phoneUserAttr.value=e}))),w.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}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,m,"f").call(this,Gr(this.state)),i(this,w,"f").call(this,Xr(this.state)),this.subscribe(i(this,m,"f").bind(this),Gr),this.subscribe(i(this,w,"f").bind(this),Xr)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,w=new WeakMap,t=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-phone"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},h=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(o(this,l,this.createModal({"data-id":"delete-phone"}),"f"),o(this,d,new Z((()=>{var e;return null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,l,"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,l,"f").setContent(sn({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),i(this,d,"f").onSuccess((()=>{i(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new X((()=>{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,l,"f"))||void 0===e||e.open()}))},b}));var ds;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(ds||(ds={}));const us=c((e=>{var t,o,s,c,l,d,u,h,p,f,g;return o=class extends(r(ns,Fr,v,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,{}),c.set(this,{}),l.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")||ds.TEXT,a=e[r],c=new X(n,{logger:this.logger});c.value=o.getFormattedValue(s,a),i(this,t,"m",f).call(this,n,r,c),i(this,t,"m",g).call(this,n,r,c)}))})))}static getFormattedValue(e,t){return e===ds.DATE&&t?new Date(t).toLocaleString():e===ds.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,Qr(this.state)),this.subscribe(i(this,p,"f").bind(this),Qr)}))}},s=new WeakMap,c=new WeakMap,l=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(sn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(n=i(this,c,"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,l,"f")[e])||void 0===t||t.setContent(sn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,l,"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,c,"f")[r]=new Z((()=>{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,c,"f")[r]))},g=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,d,"f")[r]=new Z((()=>{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",h).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",h).call(this,r),this.syncFlowTheme(i(this,d,"f")[r]))},o})),hs=c((e=>{var t,s,c,l,d,u,h,p;return p=class extends(r(ns,Fr,v,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),h.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",u).call(this),i(this,t,"m",l).call(this),i(this,h,"f").call(this,Zr(this.state)),this.subscribe(i(this,h,"f").bind(this),Zr)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,l=function(){this.totpUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"totp"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},d=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.totpUserAuthMethod=new Y((()=>{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.onButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},p})),ps=c((e=>class extends(r(U,ne,zr,us,os,is,ss,ls,as,cs,cs,hs,rs)(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)}))}})),fs=r((e=>class extends(ps(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 Rc})).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.4.11"}}}))}}))(HTMLElement),gs="undefined"!=typeof localStorage,vs="J151000",ms=gs&&localStorage.getItem("base.content.url")||"",ws="base.ui.components.url";gs&&localStorage.getItem(ws),gs&&localStorage.getItem(ws);const bs="descope-login-flow",ys="code",ks="data-exclude-field",Ss="data-exclude-next",Is="dls_last_auth",Cs="state_id",xs="saml_idp_state_id",js="saml_idp_username",Os="descope_idp_initiated",As="sso_app_id",Es="third_party_app_id",Us="third_party_app_state_id",Rs="oidc_login_hint",_s="oidc_prompt",Ts="oidc_error_redirect_uri",Ms="application_scopes",Ls="data-type",Ps="redirect",$s="poll",Ws="webauthnCreate",Ns="webauthnGet",Ds="nativeBridge",Fs="loadForm",qs="submit",zs="polling",Bs=["descope-multi-select-combo-box","descope-text-area"],Vs=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Ks;!function(e){e.backward="backward",e.forward="forward"}(Ks||(Ks={}));const Hs=["descope-enriched-text"];function Js(e){return new URLSearchParams(window.location.search).get(e)}function Gs(e){if(window.history.replaceState&&Js(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 Xs(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Ks.forward:n<i?Ks.backward:void 0}const Ys=e=>{let[t="",n=""]=(Js(bs)||"").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 Zs(){Gs(bs)}const Qs=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),ea=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=Ys(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Zs();const r=Js("t")||void 0;r&&Gs("t");const s=Js(ys)||void 0;s&&Gs(ys);const a=Js("err")||void 0;a&&Gs("err");const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:Js("ra-challenge"),redirectAuthCallbackUrl:Js("ra-callback"),redirectAuthBackupCallbackUri:Js("ra-backup-callback"),redirectAuthInitiator:Js("ra-initiator")},h=Js(Cs);h&&Gs(Cs);const p=Js(xs);p&&Gs(xs);const f=Js(js);p&&Gs(js);const g=Js(Os);g&&Gs(Os);const v=Js(As);v&&Gs(As);const m=Js(Es);m&&Gs(Es);const w=Js(Us);w&&Gs(Us);const b=Js(Ms);b&&Gs(Ms);const y=Js(Rs);y&&Gs(Rs);const k=Js(_s);k&&Gs(_s);const S=Js(Ts);return S&&Gs(Ts),{executionId:n,stepId:i,token:r,code:s,exchangeError:a,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u,ssoQueryParams:{oidcIdpStateId:h,samlIdpStateId:p,samlIdpUsername:f,descopeIdpInitiated:"true"===g,ssoAppId:v,oidcLoginHint:y,oidcPrompt:k,oidcErrorRedirectUri:S,thirdPartyAppId:m,thirdPartyAppStateId:w,applicationScopes:b}}},ta=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}})};function na(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 ia=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:c,thirdPartyAppStateId:l,applicationScopes:d})=>!(!e||t||n||i||o||r||s||a||c||l||d),oa=e=>null==e?void 0:e.submit(),ra=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},sa=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function aa(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:""}}var ca,la,da,ua;function ha(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(!ha(r,s))return!1}else if(r!==s)return!1}return!0}let pa=class{constructor(e={},{forceUpdate:t=!1}={}){ca.set(this,void 0),la.set(this,{}),da.set(this,0),ua.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,ca,"f")):e,n=Object.assign(Object.assign({},i(this,ca,"f")),t),r=i(this,ca,"f");o(this,ca,n,"f"),Object.freeze(i(this,ca,"f")),setTimeout((()=>{Object.values(i(this,la,"f")).forEach((({cb:e,selector:t})=>{const o=t(r),s=t(n);!i(this,ua,"f")&&(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?ha(o,s):o===s)||e(s,o,((e,t)=>n=>e[n]!==t[n])(s,o))}))}),0)},o(this,ca,e,"f"),o(this,ua,t,"f")}get current(){return Object.assign({},i(this,ca,"f"))}set forceUpdate(e){o(this,ua,e,"f")}subscribe(e,t=e=>e){return o(this,da,i(this,da,"f")+1,"f"),i(this,la,"f")[i(this,da,"f")]={cb:e,selector:t},i(this,da,"f").toString()}unsubscribe(e){const t=!!i(this,la,"f")[e];return t&&delete i(this,la,"f")[e],t}unsubscribeAll(){return o(this,la,{},"f"),!0}};ca=new WeakMap,la=new WeakMap,da=new WeakMap,ua=new WeakMap;const fa=["*","#","/","(",")","[","]","_","<",">","`"],ga=e=>"string"!=typeof e?e:e.replace((e=>{const t=fa.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),va=["disabled"],ma=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ks}])`)).forEach((e=>{e.value=n}))}))},wa=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),ba=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?ga(wa(t,i)):wa(t,i))),ya=(e,t,n)=>{e.querySelectorAll(`[${Ls}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},ka=(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})`))},Sa=(e,n,i,o,r)=>{var s,a;ya(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),ya(e,"notp-link",null===(a=null==n?void 0:n.notp)||void 0===a?void 0:a.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>Hs.includes(e))(e.localName);e.textContent=ba(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",ba(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,i,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=ba(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])=>{va.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},Ia=ta((()=>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 na(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Ca="dls_ab_testing_id",xa={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}};function ja(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(Is)))}catch(e){}return t}const Oa=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;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),Oa(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}),[]),Aa=c((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 Ea,Ua,Ra,_a,Ta,Ma,La,Pa,$a,Wa,Na,Da,Fa,qa,za,Ba,Va,Ka,Ha,Ja,Ga,Xa,Ya;const Za=r(ne,O,Aa)(HTMLElement);let Qa=class extends Za{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","nonce"]}constructor(e){super(),Ea.add(this),Ra.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,Ea,"m",Ga).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)}},_a.set(this,new pa),Ta.set(this,new pa),Ma.set(this,{}),this.getComponentsContext=()=>i(this,Ma,"f"),this.nextRequestStatus=new pa({isLoading:!1}),La.set(this,void 0),Pa.set(this,{popstate:i(this,Ea,"m",Fa).bind(this),componentsContext:i(this,Ea,"m",Ka).bind(this)}),$a.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,$a,e,"f"),i(this,Ea,"m",Na).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 Oa(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 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()))}))}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,Ta,"f").subscribe(i(this,Ea,"m",Ja).bind(this)),i(this,Ta,"f").update({isDebug:this.debug}),i(this,Ea,"m",Da).call(this),i(this,Ea,"m",Ya).call(this),yield i(this,Ea,"m",Ba).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");i(this,Ea,"m",Xa).call(this);const{executionId:r,stepId:s,token:a,code:c,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p,ssoQueryParams:f}=ea(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,Pa,"f").popstate),window.addEventListener("components-context",i(this,Pa,"f").componentsContext),i(this,_a,"f").subscribe(i(this,Ea,"m",za).bind(this)),i(this,_a,"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:c,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p},f)),o(this,Ra,!0,"f")}))}disconnectedCallback(){i(this,_a,"f").unsubscribeAll(),i(this,Ta,"f").unsubscribeAll(),i(this,Ea,"m",Ha).call(this),window.removeEventListener("popstate",i(this,Pa,"f").popstate),window.removeEventListener("components-context",i(this,Pa,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,Ra,"f")&&t!==n&&Ua.observedAttributes.includes(e)){i(this,Ea,"m",Da).call(this);const o=null===t;"nonce"===e&&i(this,Ea,"m",Ya).call(this),i(this,_a,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Zs()),{[Qs(e)]:n,stepId:r,executionId:s}})),i(this,Ta,"f").update({isDebug:this.debug})}}};function ec(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var tc,nc,ic,oc,rc,sc,ac,cc,lc,dc,uc,hc,pc,fc,gc,vc,mc,wc,bc,yc,kc,Sc,Ic,Cc,xc,jc,Oc,Ac,Ec;Ua=Qa,Ra=new WeakMap,_a=new WeakMap,Ta=new WeakMap,Ma=new WeakMap,La=new WeakMap,Pa=new WeakMap,$a=new WeakMap,Ea=new WeakSet,Wa=function(){var e,t;const n=new CSSStyleSheet;n.replaceSync("\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 "),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n]},Na=function(){i(this,Ea,"m",Wa).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Da=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","nonce"];Ua.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Qs(t)])throw Error(`${t} cannot be empty`)}))},Fa=function(){const{stepId:e,executionId:t}=Ys(this.flowId);i(this,_a,"f").update({stepId:e,executionId:t})},qa=function(e,t){this.sdk=Pr(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Ua.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){try{return yield t(...e)}catch(e){return{error:{errorCode:vs,errorDescription:e.toString()}}}}))}))},za=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,Ea,"m",qa).call(this,t,n)}i(this,$a,"f").call(this,e)}))},Ba=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,Ea,"m",Va).call(this))}))},Va=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(ms||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}}))},Ka=function(e){o(this,Ma,Object.assign(Object.assign({},i(this,Ma,"f")),e.detail),"f")},Ha=function(){var e;null===(e=i(this,La,"f"))||void 0===e||e.remove(),o(this,La,null,"f")},Ja=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,La,document.createElement("descope-debugger"),"f"),Object.assign(i(this,La,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return sl})),document.body.appendChild(i(this,La,"f"))):i(this,Ea,"m",Ha).call(this)}))},Ga=function(e,t){var n;e&&this.debug&&(null===(n=i(this,La,"f"))||void 0===n||n.updateData({title:e,description:t}))},Xa=function(){this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Bs.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 c=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===c.length)"false"!==c[0].getAttribute("auto-submit")&&c[0].click();else if(0===c.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()}}},Ya=function(){this.getAttribute("nonce")&&(window.DESCOPE_NONCE=this.getAttribute("nonce"))},Qa.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.40.7"}};class Uc extends Qa{static set sdkConfigOverrides(e){Qa.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Qa.sdkConfigOverrides}constructor(){const e=new pa({deferredRedirect:!1});super(e.update.bind(e)),tc.add(this),this.stepState=new pa({}),nc.set(this,void 0),ic.set(this,null),oc.set(this,null),rc.set(this,{visibilitychange:i(this,tc,"m",sc).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var n;const o=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=o;e||(e=null===(n=new URL(o.url).searchParams)||void 0===n?void 0:n.get(ys)),this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(o.url),t=e.searchParams.get("t"),n=e.searchParams.get(bs).split("_").pop();i(this,fc,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else this.nativeComplete(o)},uc.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,tc,"m",hc).call(this,t):t()})),pc.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===$s){this.logger.debug("polling - Scheduling polling request");const c=Date.now(),l=a?500:2e3;o(this,nc,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(e,t,zs,r,s,{}),d=document.hidden&&!a&&Date.now()-c>l+500;let u;d&&this.logger.debug("polling - The polling seems to be throttled");try{const e=d?1e3:6e3;u=yield na(e,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,pc,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===vs)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,pc,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),i(this,pc,"f").call(this,e,t,r,s),i(this,gc,"f").call(this,u)}))),l),"f")}})),fc.set(this,(()=>{clearTimeout(i(this,nc,"f")),o(this,nc,null,"f")})),gc.set(this,(e=>{var t,n,r,s,a,c,l,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,l=`${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,tc,"m",Ec).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:l,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)||l);const d=null===(c=null==e?void 0:e.error)||void 0===c?void 0:c.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||i(this,tc,"m",lc).call(this))}null===(d=null===(l=e.data)||void 0===l?void 0:l.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:w,lastAuth:b,action:y}=e.data;if(y!==$s&&i(this,fc,"f").call(this),"completed"===m)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&gs&&localStorage.setItem(Is,JSON.stringify(e))}(b),void i(this,tc,"m",Ec).call(this,"success",w);const{executionId:k,stepId:S,stepName:I,screen:C,redirect:x,openInNewTabUrl:j,webauthn:O,error:A,samlIdpResponse:E,nativeResponse:U}=e.data,R=Date.now();y!==$s?(this.loggerWrapper.info(`Step "${I||`#${S}`}" is ${m}`,"",{screen:C,status:m,stepId:S,stepName:I,action:y,error:A}),(null===(g=C.state)||void 0===g?void 0:g.clientScripts)&&o(this,oc,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:I,executionId:k,action:y,redirectTo:null==x?void 0:x.url,openInNewTabUrl:j,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.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,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload,reqTimestamp:R})):this.flowState.update({action:y,reqTimestamp:R})})),vc.set(this,ta((()=>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)}}))))),jc.set(this,sa(((e,t)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,tc,"m",yc).call(this)){const o=null==e?void 0:e.getAttribute("id");i(this,tc,"m",Sc).call(this,e);const r=yield i(this,tc,"m",kc).call(this),s=(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);if(this.nextRequestStatus.update({isLoading:!0}),i(this,oc,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,oc,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const a=this.loadSdkScriptsModules();if(a.length>0){const e=a.filter((e=>"function"==typeof e.refresh)).map((e=>e.refresh()));e.length>0&&(yield na(5e3,Promise.all(e),null))}const c=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},c),s),r),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(o,l),this.nextRequestStatus.update({isLoading:!1}),i(this,tc,"m",Ic).call(this,r)}}))))),this.flowState=e}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:{[ec(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 i;const o=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(o){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=o;return null===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}const r=yield function(e){return n(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield Promise.resolve().then((function(){return al})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return ll})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return ul})),t.default;case"grecaptcha":return t=yield Promise.resolve().then((function(){return fl})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id);return new Promise(((n,i)=>{try{const i=r(e.initArgs,{baseUrl:this.baseUrl},t(e,n));if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=i.stop)||void 0===t||t.call(i)}))}}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.isDescopeBridge)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,tc,"m",cc).call(this),window.addEventListener("visibilitychange",i(this,rc,"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(),null===(e=i(this,ic,"f"))||void 0===e||e.abort(),o(this,ic,null,"f"),window.removeEventListener("visibilitychange",i(this,rc,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=aa(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,c;const{projectId:l,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,openInNewTabUrl:w,redirectUrl:b,token:y,code:k,exchangeError:S,webauthnTransactionId:I,webauthnOptions:C,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:A,locale:E,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:R,samlIdpResponseRelayState:_,nativeResponseType:T,nativePayload:M,reqTimestamp:L}=e,P=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let $,W,N;const D=(()=>{const e=localStorage.getItem(Ca);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(Ca,e.toString()),e}return Number(e)})(),F=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),z=yield this.getProjectConfig(),B=Object.entries(z.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),V=j&&x?{callbackUrl:j,codeChallenge:x,backupCallbackUri:O}:void 0,K=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let H={};if(!p){const e=[...q.clientScripts||[],...q.sdkScripts||[]];if(q.conditions){let t=[];({startScreenId:$,conditionInteractionId:N,startScreenName:W,clientScripts:t,componentsConfig:H}=((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=xa[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:F,code:k,token:y,abTestingKey:D},q.conditions)),e.push(...t||[])}else q.condition?({startScreenId:$,conditionInteractionId:N}=((e,t)=>{var n;const i=null===(n=xa[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}})(q.condition,{loginId:F,code:k,token:y,abTestingKey:D})):(W=q.startScreenName,$=q.startScreenId);if(o(this,oc,this.loadSdkScripts(e),"f"),q.fingerprintEnabled&&q.fingerprintKey?yield hr(q.fingerprintKey,this.baseUrl):localStorage.removeItem(dr),!ia($,P)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:V},P),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:ja(F),abTestingKey:D,locale:aa(E).locale,nativeOptions:K}),N,"",z.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),P.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),P.oidcLoginHint?{externalId:P.oidcLoginHint}:{}));return i(this,gc,"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(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&S)){const e=yield this.sdk.flow.next(p,h,qs,q.version,z.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return i(this,gc,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Fs&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U||!R)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)})(U,R,_||"",oa)}if(f===Ps&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===A&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(f===Ws||f===Ns){if(!I||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(c=i(this,ic,"f"))||void 0===c||c.abort(),o(this,ic,null,"f");try{e=f===Ws?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}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,qs,q.version,z.componentsVersion,{transactionId:I,response:e,failure:t});i(this,gc,"f").call(this,n)}if(f===Ds)return this.nativeComplete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,qs,q.version,z.componentsVersion,e);i(this,gc,"f").call(this,t)})),void i(this,tc,"m",Ec).call(this,"bridge",{type:T,payload:M});if(s("action")&&i(this,pc,"f").call(this,p,h,q.version,z.componentsVersion),!g&&!$)return void this.loggerWrapper.warn("No screen was found to show");const J=$||g,G=yield this.getHtmlFilenameWithLocale(E,J),{oidcLoginHint:X,oidcPrompt:Y,oidcErrorRedirectUri:Z,samlIdpUsername:Q}=P,ee={direction:Xs(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:F,name:this.sdk.getLastUserDisplayName()||F},componentsConfig:Object.assign(Object.assign(Object.assign({},q.componentsConfig),H),null==v?void 0:v.componentsConfig)}),htmlFilename:`${J}.html`,htmlLocaleFilename:G,screenId:J,stepName:e.stepName||W,samlIdpUsername:Q,oidcLoginHint:X,oidcPrompt:Y,oidcErrorRedirectUri:Z,openInNewTabUrl:w},te=ja(F);ia($,P)?ee.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:V},P),{lastAuth:te,preview:this.preview,abTestingKey:D,client:this.client}),b&&{redirectUrl:b}),{locale:aa(E).locale,nativeOptions:K}),N,e,z.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),t),k&&{exchangeCode:k,idpInitiated:!0}),P.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,gc,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ee.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,e,q.version,z.componentsVersion,t);return i(this,gc,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",ee.screenId),yield i(this,tc,"m",dc).call(this,ee),this.stepState.update(ee)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:c,next:l,screenState:d,openInNewTabUrl:u}=e;this.loggerWrapper.debug("Rendering a flow screen");const h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield i(this,tc,"m",wc).call(this,p,l):(e=>{e.querySelectorAll(`descope-button[${Ls}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(p),!e.samlIdpUsername||(null===(o=d.form)||void 0===o?void 0:o.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),Sa(p,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(p,g);const v=()=>n(this,void 0,void 0,(function*(){var n,o;yield f;const r=this.contentRootElement;((e,t)=>{ka(e,"descope-totp-image",t)})(r,null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image),((e,t)=>{ka(e,"descope-notp-image",t)})(r,null===(o=null==d?void 0:d.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{t.querySelector(o)||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],c=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!c)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 l=a[t];e.style.setProperty(c,l)})):i.info(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,p,d.cssVars,this.loggerWrapper),r.replaceChildren(p);const s=!t.htmlFilename;setTimeout((()=>{i(this,tc,"m",Cc).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const n=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=n}))}))}))})(r),((e,t)=>{ma(e,null==t?void 0:t.inputs),ma(e,null==t?void 0:t.form)})(r,d),i(this,tc,"m",bc).call(this,{isFirstScreen:s,stepName:e.stepName}),((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(r,this.autoFocus,s)})),i(this,tc,"m",Ac).call(this,l),r.querySelector(`[${Ls}="polling"]`)&&l(zs,{}),u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));c?i(this,tc,"m",hc).call(this,v):v()}))}}nc=new WeakMap,ic=new WeakMap,oc=new WeakMap,rc=new WeakMap,uc=new WeakMap,pc=new WeakMap,fc=new WeakMap,gc=new WeakMap,vc=new WeakMap,jc=new WeakMap,tc=new WeakSet,sc=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},ac=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(`[${Ls}="${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()},cc=function(){var e,n;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,tc,"m",ac).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}}))},lc=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")}))},dc=function(e){return n(this,void 0,void 0,(function*(){var n;const o=Object.assign(Object.assign({},this.stepState.current),e),{next:r,stepName:s}=o,a=t(o,["next","stepName"]),c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,s,(e=>{const t=(n=e.screenState,i=(e,t)=>Vs.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(0,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;return(o||r)&&(t.error={text:o,type:r}),t})(a),r,this)),l=!this.stepState.current.htmlFilename;if(i(this,uc,"f").call(this,c),c){this.loggerWrapper.debug("Rendering a custom screen"),i(this,tc,"m",bc).call(this,{isFirstScreen:l,stepName:e.stepName}),this.stepState.unsubscribeAll();const t=this.stepState.subscribe((()=>{this.stepState.unsubscribe(t),i(this,tc,"m",cc).call(this)}))}this.stepState.forceUpdate=c}))},hc=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")},mc=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)}))}},wc=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,ic,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Ia())){const{options:e,transactionId:r}=(yield i(this,vc,"f").call(this))||{};e&&r&&(i(this,tc,"m",mc).call(this,s),o(this,ic,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,ic,"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)})))}}))},bc=function({isFirstScreen:e,stepName:t}){e&&i(this,tc,"m",Ec).call(this,"ready",{}),i(this,tc,"m",Ec).call(this,"page-updated",{screenName:t}),i(this,tc,"m",Ec).call(this,"screen-updated",{screenName:t})},yc=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"!==t.localName&&(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},kc=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${ks}])`));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})),{})}))},Sc=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},Ic=function(e={}){var t,n;const i=ra(e,["externalId","email","phone"]),o=ra(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)}},Cc=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,tc,"m",xc).call(this,e)))},xc=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)}))},Oc=function(e){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&i(this,jc,"f").call(this,t,e)}))}))},Ac=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${Ss}]), [data-type="button"]:not([${Ss}]`).forEach((t=>{t.onclick=()=>{i(this,jc,"f").call(this,t,e)}})),i(this,tc,"m",Oc).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${ks}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Ec=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Uc);var Rc=Object.freeze({__proto__:null,default:Uc});customElements.define("descope-user-profile-widget",fs);const _c=(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 Tc,Mc,Lc,Pc,$c,Wc,Nc,Dc,Fc,qc;const zc=document.createElement("template");zc.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`;class Bc extends HTMLElement{constructor(){var e,t,n;super(),Tc.add(this),Mc.set(this,new f({messages:[]})),Lc.set(this,void 0),Pc.set(this,void 0),$c.set(this,void 0),Wc.set(this,{resize:i(this,Tc,"m",qc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(zc.content.cloneNode(!0));const r=new CSSStyleSheet;r.replaceSync('\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'),null!==(t=(n=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(n.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],o(this,Lc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Pc,i(this,Lc,"f").querySelector(".content"),"f"),o(this,$c,i(this,Lc,"f").querySelector(".header"),"f")}updateData(e){i(this,Mc,"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,c]=_c(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(i(this,Lc,"f"),i(this,$c,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Wc,"f").resize),(e=i(this,Lc,"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,Lc,"f").onresize=i(this,Tc,"m",Fc).bind(this),i(this,Mc,"f").subscribe(i(this,Tc,"m",Nc).bind(this))}disconnectedCallback(){i(this,Mc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Wc,"f").resize)}}Mc=new WeakMap,Lc=new WeakMap,Pc=new WeakMap,$c=new WeakMap,Wc=new WeakMap,Tc=new WeakSet,Nc=function(e){i(this,Tc,"m",Dc).call(this,e),i(this,Tc,"m",Fc).call(this)},Dc=function(e){i(this,Pc,"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("")},Fc=function(){i(this,Pc,"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)}))},qc=function(){const[e,t]=_c(i(this,Lc,"f"),Number.parseInt(i(this,Lc,"f").style.left,10),Number.parseInt(i(this,Lc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Lc,"f").style.top=`${t}px`,i(this,Lc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Bc);var Vc=Object.freeze({__proto__:null,default:Bc});const Kc=(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 Hc,Jc,Gc,Xc,Yc,Zc,Qc,el,tl,nl,il;const ol=document.createElement("template");ol.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';class rl extends HTMLElement{constructor(){super(),Hc.add(this),Jc.set(this,new pa({messages:[]})),Gc.set(this,void 0),Xc.set(this,void 0),Yc.set(this,void 0),Zc.set(this,{resize:i(this,Hc,"m",il).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ol.content.cloneNode(!0)),o(this,Gc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Xc,i(this,Gc,"f").querySelector(".content"),"f"),o(this,Yc,i(this,Gc,"f").querySelector(".header"),"f"),i(this,Hc,"m",Qc).call(this)}updateData(e){i(this,Jc,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){((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,c]=Kc(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(i(this,Gc,"f"),i(this,Yc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Zc,"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,Gc,"f")),i(this,Gc,"f").onresize=i(this,Hc,"m",nl).bind(this),i(this,Jc,"f").subscribe(i(this,Hc,"m",el).bind(this))}disconnectedCallback(){i(this,Jc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Zc,"f").resize)}}Jc=new WeakMap,Gc=new WeakMap,Xc=new WeakMap,Yc=new WeakMap,Zc=new WeakMap,Hc=new WeakSet,Qc=function(){var e,t;const n=new CSSStyleSheet;n.replaceSync('\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'),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n],i(this,Gc,"f").style.top="32px",i(this,Gc,"f").style.left=window.innerWidth-300-32+"px"},el=function(e){i(this,Hc,"m",tl).call(this,e),i(this,Hc,"m",nl).call(this)},tl=function(e){i(this,Xc,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},nl=function(){i(this,Xc,"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)}))},il=function(){const[e,t]=Kc(i(this,Gc,"f"),Number.parseInt(i(this,Gc,"f").style.left,10),Number.parseInt(i(this,Gc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Gc,"f").style.top=`${t}px`,i(this,Gc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",rl);var sl=Object.freeze({__proto__:null,default:rl});var al=Object.freeze({__proto__:null,default:(e,t,i)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n'.replace(/{{SITE_ID}}/g,t),o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("id",t),o.text=n,document.body.appendChild(o),document.addEventListener("ftr:tokenReady",(e=>{i(e.detail)}))}))});const cl=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:o,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,Oo]:[Oo];let a=[];if(n&&o){a=[`${new URL(o).toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,Mo]}else a=[Mo];const c=Lo({apiKey:t,endpoint:s,scriptUrlPattern:a}),l=yield c,{requestId:d}=yield l.get();i(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var ll=Object.freeze({__proto__:null,default:cl,loadFingerprint:cl});const dl=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:o,cloudflareEndpointPath:r,cloudflareScriptPath:s}=e,{baseUrl:a}=t;let c;c=n?`https://${n}`:a||"https://api.descope.com";const l=new URL(c);l.pathname=r;const d=new URL(c);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=Lo({apiKey:o,endpoint:[l.toString(),Oo],scriptUrlPattern:[u,Mo]}),p=yield h,{requestId:f}=yield p.get();i(f)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var ul=Object.freeze({__proto__:null,default:dl,loadFingerprint:dl});const hl=105e3,pl=(e,t,i)=>{let o=(new Date).getTime();const r=()=>{var t;return e.enterprise?null===(t=window.grecaptcha)||void 0===t?void 0:t.enterprise:window.grecaptcha};let s,a;const c=(t,n)=>{t.ready((()=>{e.siteKey&&(null==t||t.execute(a,{action:"load"}).then(((e,n)=>{n?console.warn("could not execute recaptcha",n):(i(e),o=(new Date).getTime(),s=setTimeout((()=>{c(t)}),hl))})))}))},l=()=>{clearTimeout(s)},d=(()=>{const e=document.createElement("div");return e.style.display="none",e.id="recaptcha",document.body.appendChild(e)})(),u=()=>{const e=r();e&&c(e)};return window.onRecaptchaLoadCallback=()=>{const t=d;if(t.hasChildNodes())return;const n=r();n&&setTimeout((()=>{a=n.render(t,{sitekey:e.siteKey,badge:"inline",size:"invisible"}),c(n)}),0)},(()=>{const t=document.createElement("script");t.src=(()=>{const t=new URL("https://www.google.com/recaptcha/");return t.pathname+=(e.enterprise?"enterprise":"api")+".js",t.searchParams.append("onload","onRecaptchaLoadCallback"),t.searchParams.append("render","explicit"),t.toString()})(),t.async=!0,t.id="recaptcha-script",t.defer=!0,document.body.appendChild(t)})(),{stop:l,start:u,refresh:()=>n(void 0,void 0,void 0,(function*(){if(Date.now()-o>hl){l();const e=o;return u(),new Promise((t=>{const n=setTimeout((()=>{console.warn("reCAPTCHA token refresh timed out"),t()}),5e3),i=()=>{o!==e?(clearTimeout(n),t()):setTimeout(i,150)};i()}))}return Promise.resolve()}))}};var fl=Object.freeze({__proto__:null,default:pl,loadGRecaptcha:pl});return fs}();
|
|
7
|
+
function xo(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 jo=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=xo({},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,"",xo({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,xo({},this.attributes,t))},withConverter:function(t){return e(xo({},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 Oo={default:"endpoint"},Ao="Blocked by CSP",Eo="The endpoint parameter is not a valid URL",Uo="Failed to load the JS script of the agent",Ro="9319";function _o(e,t){var n,i,o,r,s,a=[],c=(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===Ao||s===Eo)n.exclude(),r=0;else if(s===Ro)n.exclude();else if(s===Uo){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!o.has(c)&&(o.add(c),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+i()-Date.now()]}]),l=c[0],d=c[1];if(void 0===l)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(l).then((function(e){return[e,a]}))}var To="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Mo=To;function Lo(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),c=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:To,l=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=l[0],u=l[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)}))}(c,s);return _o(e,Po)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Ro?new Error(Uo):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 Po(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(Eo);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(Uo))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(Ao)})).then($o)}function $o(){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(Ro);return n}const Wo=e=>{try{return wn(e).exp}catch(e){return null}},No=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Wo(n)},Do=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?Wo(i):void 0)},Fo=(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},qo=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(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||Do(e),cookieExpiration:e.cookieExpiration||No(e)},s)})((null==n?void 0:n.authInfo)||n||{})},zo=async e=>{const t=await qo(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Bo="undefined"!=typeof localStorage,Vo=(e,t)=>Bo&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Ko=e=>Bo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Ho=e=>Bo&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Jo=(...e)=>{console.debug(...e)},Go="3.2.0",Xo="undefined"!=typeof window,Yo=Math.pow(2,31)-1,Zo=`https://descopecdn.com/npm/oidc-client-ts@${Go}/dist/browser/oidc-client-ts.min.js`,Qo=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Go}/dist/browser/oidc-client-ts.min.js`,er="DS",tr="DSR",nr="DSI";function ir(e=""){return Ko(`${e}${tr}`)||""}function or(e=""){return jo.get(er)||Ko(`${e}${er}`)||""}function rr(e=""){return Ko(`${e}${nr}`)||""}function sr(e=""){Ho(`${e}${tr}`),Ho(`${e}${er}`),Ho(`${e}${nr}`),jo.remove(er)}const ar=Xo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",cr="vsid",lr="vrid",dr="fp",ur=(e=!1)=>{const t=localStorage.getItem(dr);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},hr=async(e,t=ar)=>{try{if(ur())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=Lo({apiKey:e,endpoint:[i.toString(),Oo],scriptUrlPattern:[r,Mo]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[cr]:e,[lr]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(dr,JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},pr=e=>{const t=ur(!0);return t&&e.body&&(e.body.fpData=t),e},fr="dls_last_user_login_id",gr="dls_last_user_display_name",mr=()=>Ko(fr),vr=()=>Ko(gr),wr=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=mr(),r=vr();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function br(){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 yr(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=jr(n.publicKey.challenge),n.publicKey.user.id=jr(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=jr(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Or(n.rawId),type:n.type,response:{attestationObject:Or(n.response.attestationObject),clientDataJSON:Or(n.response.clientDataJSON)}});var n}async function kr(e){const t=Cr(e);return xr(await navigator.credentials.get(t))}async function Sr(e,t){const n=Cr(e);return n.signal=t.signal,n.mediation="conditional",xr(await navigator.credentials.get(n))}async function Ir(e=!1){if(!Xo)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Cr(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=jr(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=jr(e.id)})),n}function xr(e){return JSON.stringify({id:e.id,rawId:Or(e.rawId),type:e.type,response:{authenticatorData:Or(e.response.authenticatorData),clientDataJSON:Or(e.response.clientDataJSON),signature:Or(e.response.signature),userHandle:e.response.userHandle?Or(e.response.userHandle):void 0}})}function jr(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Or(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ar,Er=(Ar=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 yr(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 kr(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 yr(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await kr(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 yr(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:yr,get:kr,isSupported:Ir,conditional:Sr}}),(...e)=>{const t=Ar(...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 Ur="/fedcm/config";async function Rr(e,t){var n,i,o;try{const o=await async function(e,t="google",n,i,o){const r=(()=>{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)})(),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 c=a.data.clientId;return new Promise((e=>{var a,l;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===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,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)}}catch(e){null===(o=null==t?void 0:t.onFailed)||void 0===o||o.call(t,e)}}var _r=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Ir(),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 Tr;const Mr=(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",(()=>{Mr(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Lr=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{Tr||(Tr=(async()=>{try{return require("oidc-client-ts")}catch(e){return Mr([Zo,Qo],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await Tr;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=t,s=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",c=`${r}_user`;let l=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(l=`${l}/${n.applicationId}`);const d={authority:l,client_id:t,redirect_uri:s,response_type:"code",scope:a,stateStore:new o({store:window.localStorage,prefix:r}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new i(d),stateUserKey:c}})(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)))),window.localStorage.setItem(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(e={},t=!1)=>{const{client:n}=await i(),o=await n.createSigninRequest(e),{url:r}=o;return t||(window.location.href=r),{ok:!0,data:o}},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=window.localStorage.getItem(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 c=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(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||rr(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return window.localStorage.removeItem(o),t||window.location.replace(s),r}}},Pr=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Xo?(i&&o&&hr(i).catch((()=>null)),e(Fo(r,{beforeRequest:pr}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i)return e(o);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;Xo&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&a&&new Date>a&&(Jo("Expiration time passed, refreshing session"),l.refresh(ir()||c))}));const l=e(Fo(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o}=await qo(t);if(401===(null==t?void 0:t.status))Jo("Received 401, canceling all timers"),r();else if(n||o){if(a=((e,t)=>{if(t)return new Date(1e3*t);Jo("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),!a)return void Jo("Could not extract expiration time from session token");c=i;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>Yo&&(Jo(`Timeout is too large (${t}ms), setting it to ${Yo}ms`),t=Yo),t})(a);if(r(),e<=2e4)return void Jo("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Jo(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Jo("Refreshing session due to timer"),l.refresh(ir()||i)}),e)}}}));return fi(l,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Jo("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.29.1"},t.baseHeaders)}))),(e=>t=>{const n=br(),i=br(),o=br(),r=e(Fo(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))i.pub(null),o.pub(null),n.pub(null);else{const e=await zo(t);e&&o.pub(e);const{sessionJwt:r,sessionExpiration:s}=await qo(t);r&&i.pub(r),(s||r)&&n.pub(s||42)}}})),s=fi(r,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const r=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r}));return Object.assign(s,{onSessionTokenChange:i.sub,onUserChange:o.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:mr,getLastUserDisplayName:vr});const s=e(Fo(r,{afterRequest:async(e,t)=>{var n;const i=await zo(t),o=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;o&&((e=>{Vo(fr,e)})(o),(e=>{Vo(gr,e)})(r))}}));let a=fi(s,["flow.start"],wr);return a=fi(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Ho(fr),Ho(gr)),i})(o)),Object.assign(a,{getLastUserLoginId:mr,getLastUserDisplayName:vr})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!Xo)return e(s);const a=e(Fo(s,{beforeRequest:(c=r,e=>Object.assign(e,{token:e.token||ir(c)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||sr(r):((e={},t=!1,n="")=>{var i;const{sessionJwt:o,refreshJwt:r}=e;if(r&&Vo(`${n}${tr}`,r),o)if(t){const n=t.sameSite||"Strict",r=null===(i=t.secure)||void 0===i||i;!function(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);jo.set(e,t,{path:o,domain:l?i:void 0,expires:c,sameSite:r,secure:a})}}(er,o,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r}))}else Vo(`${n}${er}`,o);e.idToken&&Vo(`${n}${nr}`,e.idToken)})(await qo(t),o,r)}}));var c;const l=fi(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const i=await t(...n);return sr(e),i})(r));return Object.assign(l,{getRefreshToken:()=>ir(r),getSessionToken:()=>or(r),getIdToken:()=>rr(r)})}))((e=>{const t=Co(e),n=Lr(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async i=>{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()}})}const o=or(),r=ir();return t.refresh(i,{dcs:o?"t":"f",dcr:r?"t":"f"})},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:_r(t),webauthn:Er(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){Rr(i,e)},requestAuthentication(e){Rr(i,e)}},oneTap(e,t,n,o,r){Rr(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+Ur),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Xo&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+Ur);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})),$r={me:"/v1/auth/me"},Wr=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),Nr=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return Wr();const i=yield e.get($r.me);return yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(i),i.json()}))}),Dr=c((e=>{var t,s,a,c;const l=r(I,k,m,C,rn)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return 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=Pr(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.4.12"}}));return{user:Object.assign(Object.assign({},Nr({httpClient:o.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):o.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},c})),Fr=c((e=>{const t=r(on({name:"widget",initialState:gn,reducers:{},extraReducers:e=>{hn.reducer(e),fn.reducer(e)},asyncActions:{getMe:hn.action,logout:fn.action}}),y,m,Dr)(e);return class extends t{constructor(...e){super(...e),this.state=gn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),qr="widget-flow",zr=c((e=>{var t,o,s;return s=class extends(r(y,Q,Fr,rn,m,ne)(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=an(qr);r&&(!function(e){if(window.history.replaceState&&an(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())}}(qr),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(sn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme}));new Z((()=>{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})),Br=e=>e.me.data,Vr=vt(Br,(e=>e.picture)),Kr=vt(Br,(e=>e.email)),Hr=vt(Br,(e=>e.verifiedEmail)),Jr=vt(Br,(e=>e.name)),Gr=vt(Br,(e=>e.phone)),Xr=vt(Br,(e=>e.verifiedPhone)),Yr=vt(Br,(e=>e.webauthn));vt(Br,(e=>e.password));const Zr=vt(Br,(e=>e.TOTP)),Qr=vt(Br,(e=>e.customAttributes)),es=c((e=>{const t=r(O,S({"widget-id":S.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}))}}})),ts=c((e=>{var t,o,a;return a=class extends(r(m,y,W,F,es,Fr)(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 Promise.all([this.actions.getMe(),i(this,t,"m",o).call(this)]),this.onWidgetRootReady()}))}},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})),ns=c((e=>class extends(r(ne,k)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),is=c((e=>{var t,s,c,l,d,u,h,p,f;return f=class extends(r(ns,ne,Fr,m,rn,ts,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.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",l).call(this),i(this,h,"f").call(this,Vr(this.state)),i(this,p,"f").call(this,Jr(this.state)),this.subscribe(i(this,h,"f").bind(this),Vr),this.subscribe(i(this,p,"f").bind(this),Jr)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,l=function(){this.avatar.flowId&&(o(this,s,this.createModal({"data-id":"update-pic"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},d=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,c,"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})),os=c((e=>{var t,s,c,l,d,u,h,p,f,g,v,w,b;return b=class extends(r(ns,Fr,m,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.emailUserAttr.value=e}))),w.set(this,a((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}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)),i(this,w,"f").call(this,Hr(this.state)),this.subscribe(i(this,v,"f").bind(this),Kr),this.subscribe(i(this,w,"f").bind(this),Hr)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,v=new WeakMap,w=new WeakMap,t=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-email"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},h=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(o(this,l,this.createModal({"data-id":"delete-email"}),"f"),o(this,d,new Z((()=>{var e;return null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,l,"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,l,"f").setContent(sn({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,d,"f").onSuccess((()=>{i(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new X((()=>{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,l,"f"))||void 0===e||e.open()}))},b})),rs=c((e=>{var t,o,s;return s=class extends(r(Fr,m,ts,Q)(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 V((()=>{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})),ss=c((e=>{var t,s,c,l,d,u,h,p,f,g,v,w;return w=class extends(r(ns,Fr,m,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.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,Jr(this.state)),this.subscribe(i(this,v,"f").bind(this),Jr)}))}},s=new WeakMap,c=new WeakMap,l=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,c,new Z((()=>{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,c,"f")))},h=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(o(this,l,this.createModal({"data-id":"delete-name"}),"f"),o(this,d,new Z((()=>{var e;return null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,l,"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,l,"f").setContent(sn({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,d,"f").onSuccess((()=>{i(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new X((()=>{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,l,"f"))||void 0===e||e.open()}))},w})),as=c((e=>{var t,s,c,l,d,u,h,p;return p=class extends(r(ns,Fr,m,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),h.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",u).call(this),i(this,t,"m",l).call(this),i(this,h,"f").call(this,Yr(this.state)),this.subscribe(i(this,h,"f").bind(this),Yr)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,l=function(){this.passkeyUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"passkey"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},d=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new Y((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},p})),cs=c((e=>{var t,s,a,c,l,d;return d=class extends(r(ns,Fr,m,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new Y((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onButtonClick((()=>{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",c).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(){this.passwordUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"password"}),"f"),o(this,a,new Z((()=>{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",l).bind(this),i(this,t,"m",l).call(this),this.syncFlowTheme(i(this,a,"f")))},l=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close()}))},d})),ls=c((e=>{var t,s,c,l,d,u,h,p,f,g,v,w,b;return b=class extends(r(ns,Fr,m,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.phoneUserAttr.value=e}))),w.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}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,Gr(this.state)),i(this,w,"f").call(this,Xr(this.state)),this.subscribe(i(this,v,"f").bind(this),Gr),this.subscribe(i(this,w,"f").bind(this),Xr)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,v=new WeakMap,w=new WeakMap,t=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-phone"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},h=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(o(this,l,this.createModal({"data-id":"delete-phone"}),"f"),o(this,d,new Z((()=>{var e;return null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,l,"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,l,"f").setContent(sn({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,d,"f").onSuccess((()=>{i(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new X((()=>{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,l,"f"))||void 0===e||e.open()}))},b}));var ds;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(ds||(ds={}));const us=c((e=>{var t,o,s,c,l,d,u,h,p,f,g;return o=class extends(r(ns,Fr,m,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,{}),c.set(this,{}),l.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")||ds.TEXT,a=e[r],c=new X(n,{logger:this.logger});c.value=o.getFormattedValue(s,a),i(this,t,"m",f).call(this,n,r,c),i(this,t,"m",g).call(this,n,r,c)}))})))}static getFormattedValue(e,t){return e===ds.DATE&&t?new Date(t).toLocaleString():e===ds.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,Qr(this.state)),this.subscribe(i(this,p,"f").bind(this),Qr)}))}},s=new WeakMap,c=new WeakMap,l=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(sn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),null===(n=i(this,c,"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,l,"f")[e])||void 0===t||t.setContent(sn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,l,"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,c,"f")[r]=new Z((()=>{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,c,"f")[r]))},g=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,d,"f")[r]=new Z((()=>{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",h).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",h).call(this,r),this.syncFlowTheme(i(this,d,"f")[r]))},o})),hs=c((e=>{var t,s,c,l,d,u,h,p;return p=class extends(r(ns,Fr,m,ts,rn,Q)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),h.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",u).call(this),i(this,t,"m",l).call(this),i(this,h,"f").call(this,Zr(this.state)),this.subscribe(i(this,h,"f").bind(this),Zr)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,l=function(){this.totpUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"totp"}),"f"),o(this,c,new Z((()=>{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,c,"f")))},d=function(){i(this,s,"f").setContent(sn({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,c,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.totpUserAuthMethod=new Y((()=>{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.onButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},p})),ps=c((e=>class extends(r(U,ne,zr,us,os,is,ss,ls,as,cs,cs,hs,rs)(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)}))}})),fs=r((e=>class extends(ps(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 Rc})).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.4.12"}}}))}}))(HTMLElement),gs="undefined"!=typeof localStorage,ms="J151000",vs=gs&&localStorage.getItem("base.content.url")||"",ws="base.ui.components.url";gs&&localStorage.getItem(ws),gs&&localStorage.getItem(ws);const bs="descope-login-flow",ys="code",ks="data-exclude-field",Ss="data-exclude-next",Is="dls_last_auth",Cs="state_id",xs="saml_idp_state_id",js="saml_idp_username",Os="descope_idp_initiated",As="sso_app_id",Es="third_party_app_id",Us="third_party_app_state_id",Rs="oidc_login_hint",_s="oidc_prompt",Ts="oidc_error_redirect_uri",Ms="application_scopes",Ls="data-type",Ps="redirect",$s="poll",Ws="webauthnCreate",Ns="webauthnGet",Ds="nativeBridge",Fs="loadForm",qs="submit",zs="polling",Bs=["descope-multi-select-combo-box","descope-text-area"],Vs=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Ks;!function(e){e.backward="backward",e.forward="forward"}(Ks||(Ks={}));const Hs=["descope-enriched-text"];function Js(e){return new URLSearchParams(window.location.search).get(e)}function Gs(e){if(window.history.replaceState&&Js(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 Xs(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Ks.forward:n<i?Ks.backward:void 0}const Ys=e=>{let[t="",n=""]=(Js(bs)||"").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 Zs(){Gs(bs)}const Qs=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),ea=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=Ys(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Zs();const r=Js("t")||void 0;r&&Gs("t");const s=Js(ys)||void 0;s&&Gs(ys);const a=Js("err")||void 0;a&&Gs("err");const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:Js("ra-challenge"),redirectAuthCallbackUrl:Js("ra-callback"),redirectAuthBackupCallbackUri:Js("ra-backup-callback"),redirectAuthInitiator:Js("ra-initiator")},h=Js(Cs);h&&Gs(Cs);const p=Js(xs);p&&Gs(xs);const f=Js(js);p&&Gs(js);const g=Js(Os);g&&Gs(Os);const m=Js(As);m&&Gs(As);const v=Js(Es);v&&Gs(Es);const w=Js(Us);w&&Gs(Us);const b=Js(Ms);b&&Gs(Ms);const y=Js(Rs);y&&Gs(Rs);const k=Js(_s);k&&Gs(_s);const S=Js(Ts);return S&&Gs(Ts),{executionId:n,stepId:i,token:r,code:s,exchangeError:a,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u,ssoQueryParams:{oidcIdpStateId:h,samlIdpStateId:p,samlIdpUsername:f,descopeIdpInitiated:"true"===g,ssoAppId:m,oidcLoginHint:y,oidcPrompt:k,oidcErrorRedirectUri:S,thirdPartyAppId:v,thirdPartyAppStateId:w,applicationScopes:b}}},ta=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}})};function na(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 ia=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:c,thirdPartyAppStateId:l,applicationScopes:d})=>!(!e||t||n||i||o||r||s||a||c||l||d),oa=e=>null==e?void 0:e.submit(),ra=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},sa=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function aa(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:""}}var ca,la,da,ua;function ha(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(!ha(r,s))return!1}else if(r!==s)return!1}return!0}let pa=class{constructor(e={},{forceUpdate:t=!1}={}){ca.set(this,void 0),la.set(this,{}),da.set(this,0),ua.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,ca,"f")):e,n=Object.assign(Object.assign({},i(this,ca,"f")),t),r=i(this,ca,"f");o(this,ca,n,"f"),Object.freeze(i(this,ca,"f")),setTimeout((()=>{Object.values(i(this,la,"f")).forEach((({cb:e,selector:t})=>{const o=t(r),s=t(n);!i(this,ua,"f")&&(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?ha(o,s):o===s)||e(s,o,((e,t)=>n=>e[n]!==t[n])(s,o))}))}),0)},o(this,ca,e,"f"),o(this,ua,t,"f")}get current(){return Object.assign({},i(this,ca,"f"))}set forceUpdate(e){o(this,ua,e,"f")}subscribe(e,t=e=>e){return o(this,da,i(this,da,"f")+1,"f"),i(this,la,"f")[i(this,da,"f")]={cb:e,selector:t},i(this,da,"f").toString()}unsubscribe(e){const t=!!i(this,la,"f")[e];return t&&delete i(this,la,"f")[e],t}unsubscribeAll(){return o(this,la,{},"f"),!0}};ca=new WeakMap,la=new WeakMap,da=new WeakMap,ua=new WeakMap;const fa=["*","#","/","(",")","[","]","_","<",">","`"],ga=e=>"string"!=typeof e?e:e.replace((e=>{const t=fa.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),ma=["disabled"],va=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ks}])`)).forEach((e=>{e.value=n}))}))},wa=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),ba=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?ga(wa(t,i)):wa(t,i))),ya=(e,t,n)=>{e.querySelectorAll(`[${Ls}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},ka=(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})`))},Sa=(e,n,i,o,r)=>{var s,a;ya(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),ya(e,"notp-link",null===(a=null==n?void 0:n.notp)||void 0===a?void 0:a.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>Hs.includes(e))(e.localName);e.textContent=ba(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",ba(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,i,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=ba(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])=>{ma.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},Ia=ta((()=>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 na(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Ca="dls_ab_testing_id",xa={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}};function ja(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(Is)))}catch(e){}return t}const Oa=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;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),Oa(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}),[]),Aa=c((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 Ea,Ua,Ra,_a,Ta,Ma,La,Pa,$a,Wa,Na,Da,Fa,qa,za,Ba,Va,Ka,Ha,Ja,Ga,Xa,Ya;const Za=r(ne,O,Aa)(HTMLElement);let Qa=class extends Za{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","nonce"]}constructor(e){super(),Ea.add(this),Ra.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,Ea,"m",Ga).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)}},_a.set(this,new pa),Ta.set(this,new pa),Ma.set(this,{}),this.getComponentsContext=()=>i(this,Ma,"f"),this.nextRequestStatus=new pa({isLoading:!1}),La.set(this,void 0),Pa.set(this,{popstate:i(this,Ea,"m",Fa).bind(this),componentsContext:i(this,Ea,"m",Ka).bind(this)}),$a.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,$a,e,"f"),i(this,Ea,"m",Na).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 Oa(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 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()))}))}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,Ta,"f").subscribe(i(this,Ea,"m",Ja).bind(this)),i(this,Ta,"f").update({isDebug:this.debug}),i(this,Ea,"m",Da).call(this),i(this,Ea,"m",Ya).call(this),yield i(this,Ea,"m",Ba).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");i(this,Ea,"m",Xa).call(this);const{executionId:r,stepId:s,token:a,code:c,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p,ssoQueryParams:f}=ea(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,Pa,"f").popstate),window.addEventListener("components-context",i(this,Pa,"f").componentsContext),i(this,_a,"f").subscribe(i(this,Ea,"m",za).bind(this)),i(this,_a,"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:c,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p},f)),o(this,Ra,!0,"f")}))}disconnectedCallback(){i(this,_a,"f").unsubscribeAll(),i(this,Ta,"f").unsubscribeAll(),i(this,Ea,"m",Ha).call(this),window.removeEventListener("popstate",i(this,Pa,"f").popstate),window.removeEventListener("components-context",i(this,Pa,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,Ra,"f")&&t!==n&&Ua.observedAttributes.includes(e)){i(this,Ea,"m",Da).call(this);const o=null===t;"nonce"===e&&i(this,Ea,"m",Ya).call(this),i(this,_a,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Zs()),{[Qs(e)]:n,stepId:r,executionId:s}})),i(this,Ta,"f").update({isDebug:this.debug})}}};function ec(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var tc,nc,ic,oc,rc,sc,ac,cc,lc,dc,uc,hc,pc,fc,gc,mc,vc,wc,bc,yc,kc,Sc,Ic,Cc,xc,jc,Oc,Ac,Ec;Ua=Qa,Ra=new WeakMap,_a=new WeakMap,Ta=new WeakMap,Ma=new WeakMap,La=new WeakMap,Pa=new WeakMap,$a=new WeakMap,Ea=new WeakSet,Wa=function(){var e,t;const n=new CSSStyleSheet;n.replaceSync("\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 "),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n]},Na=function(){i(this,Ea,"m",Wa).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Da=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","nonce"];Ua.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Qs(t)])throw Error(`${t} cannot be empty`)}))},Fa=function(){const{stepId:e,executionId:t}=Ys(this.flowId);i(this,_a,"f").update({stepId:e,executionId:t})},qa=function(e,t){this.sdk=Pr(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Ua.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){try{return yield t(...e)}catch(e){return{error:{errorCode:ms,errorDescription:e.toString()}}}}))}))},za=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,Ea,"m",qa).call(this,t,n)}i(this,$a,"f").call(this,e)}))},Ba=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,Ea,"m",Va).call(this))}))},Va=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(vs||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}}))},Ka=function(e){o(this,Ma,Object.assign(Object.assign({},i(this,Ma,"f")),e.detail),"f")},Ha=function(){var e;null===(e=i(this,La,"f"))||void 0===e||e.remove(),o(this,La,null,"f")},Ja=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,La,document.createElement("descope-debugger"),"f"),Object.assign(i(this,La,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return sl})),document.body.appendChild(i(this,La,"f"))):i(this,Ea,"m",Ha).call(this)}))},Ga=function(e,t){var n;e&&this.debug&&(null===(n=i(this,La,"f"))||void 0===n||n.updateData({title:e,description:t}))},Xa=function(){this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Bs.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 c=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===c.length)"false"!==c[0].getAttribute("auto-submit")&&c[0].click();else if(0===c.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()}}},Ya=function(){this.getAttribute("nonce")&&(window.DESCOPE_NONCE=this.getAttribute("nonce"))},Qa.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.40.7"}};class Uc extends Qa{static set sdkConfigOverrides(e){Qa.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Qa.sdkConfigOverrides}constructor(){const e=new pa({deferredRedirect:!1});super(e.update.bind(e)),tc.add(this),this.stepState=new pa({}),nc.set(this,void 0),ic.set(this,null),oc.set(this,null),rc.set(this,{visibilitychange:i(this,tc,"m",sc).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var n;const o=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=o;e||(e=null===(n=new URL(o.url).searchParams)||void 0===n?void 0:n.get(ys)),this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(o.url),t=e.searchParams.get("t"),n=e.searchParams.get(bs).split("_").pop();i(this,fc,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else this.nativeComplete(o)},uc.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,tc,"m",hc).call(this,t):t()})),pc.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===$s){this.logger.debug("polling - Scheduling polling request");const c=Date.now(),l=a?500:2e3;o(this,nc,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(e,t,zs,r,s,{}),d=document.hidden&&!a&&Date.now()-c>l+500;let u;d&&this.logger.debug("polling - The polling seems to be throttled");try{const e=d?1e3:6e3;u=yield na(e,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,pc,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===ms)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,pc,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),i(this,pc,"f").call(this,e,t,r,s),i(this,gc,"f").call(this,u)}))),l),"f")}})),fc.set(this,(()=>{clearTimeout(i(this,nc,"f")),o(this,nc,null,"f")})),gc.set(this,(e=>{var t,n,r,s,a,c,l,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,l=`${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,tc,"m",Ec).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:l,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)||l);const d=null===(c=null==e?void 0:e.error)||void 0===c?void 0:c.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||i(this,tc,"m",lc).call(this))}null===(d=null===(l=e.data)||void 0===l?void 0:l.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 m=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}`,`${m?`${m} - `:""}${e.data.error.message}`):m&&this.loggerWrapper.error(m);const{status:v,authInfo:w,lastAuth:b,action:y}=e.data;if(y!==$s&&i(this,fc,"f").call(this),"completed"===v)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&gs&&localStorage.setItem(Is,JSON.stringify(e))}(b),void i(this,tc,"m",Ec).call(this,"success",w);const{executionId:k,stepId:S,stepName:I,screen:C,redirect:x,openInNewTabUrl:j,webauthn:O,error:A,samlIdpResponse:E,nativeResponse:U}=e.data,R=Date.now();y!==$s?(this.loggerWrapper.info(`Step "${I||`#${S}`}" is ${v}`,"",{screen:C,status:v,stepId:S,stepName:I,action:y,error:A}),(null===(g=C.state)||void 0===g?void 0:g.clientScripts)&&o(this,oc,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:I,executionId:k,action:y,redirectTo:null==x?void 0:x.url,openInNewTabUrl:j,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.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,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload,reqTimestamp:R})):this.flowState.update({action:y,reqTimestamp:R})})),mc.set(this,ta((()=>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)}}))))),jc.set(this,sa(((e,t)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,tc,"m",yc).call(this)){const o=null==e?void 0:e.getAttribute("id");i(this,tc,"m",Sc).call(this,e);const r=yield i(this,tc,"m",kc).call(this),s=(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);if(this.nextRequestStatus.update({isLoading:!0}),i(this,oc,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,oc,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const a=this.loadSdkScriptsModules();if(a.length>0){const e=a.filter((e=>"function"==typeof e.refresh)).map((e=>e.refresh()));e.length>0&&(yield na(5e3,Promise.all(e),null))}const c=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},c),s),r),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(o,l),this.nextRequestStatus.update({isLoading:!1}),i(this,tc,"m",Ic).call(this,r)}}))))),this.flowState=e}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:{[ec(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 i;const o=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(o){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=o;return null===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}const r=yield function(e){return n(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield Promise.resolve().then((function(){return al})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return ll})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return ul})),t.default;case"grecaptcha":return t=yield Promise.resolve().then((function(){return fl})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id);return new Promise(((n,i)=>{try{const i=r(e.initArgs,{baseUrl:this.baseUrl},t(e,n));if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=i.stop)||void 0===t||t.call(i)}))}}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.isDescopeBridge)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,tc,"m",cc).call(this),window.addEventListener("visibilitychange",i(this,rc,"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(),null===(e=i(this,ic,"f"))||void 0===e||e.abort(),o(this,ic,null,"f"),window.removeEventListener("visibilitychange",i(this,rc,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=aa(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,c;const{projectId:l,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:m,redirectTo:v,openInNewTabUrl:w,redirectUrl:b,token:y,code:k,exchangeError:S,webauthnTransactionId:I,webauthnOptions:C,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:A,locale:E,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:R,samlIdpResponseRelayState:_,nativeResponseType:T,nativePayload:M,reqTimestamp:L}=e,P=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let $,W,N;const D=(()=>{const e=localStorage.getItem(Ca);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(Ca,e.toString()),e}return Number(e)})(),F=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),z=yield this.getProjectConfig(),B=Object.entries(z.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),V=j&&x?{callbackUrl:j,codeChallenge:x,backupCallbackUri:O}:void 0,K=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let H={};if(!p){const e=[...q.clientScripts||[],...q.sdkScripts||[]];if(q.conditions){let t=[];({startScreenId:$,conditionInteractionId:N,startScreenName:W,clientScripts:t,componentsConfig:H}=((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=xa[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:F,code:k,token:y,abTestingKey:D},q.conditions)),e.push(...t||[])}else q.condition?({startScreenId:$,conditionInteractionId:N}=((e,t)=>{var n;const i=null===(n=xa[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}})(q.condition,{loginId:F,code:k,token:y,abTestingKey:D})):(W=q.startScreenName,$=q.startScreenId);if(o(this,oc,this.loadSdkScripts(e),"f"),q.fingerprintEnabled&&q.fingerprintKey?yield hr(q.fingerprintKey,this.baseUrl):localStorage.removeItem(dr),!ia($,P)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:V},P),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:ja(F),abTestingKey:D,locale:aa(E).locale,nativeOptions:K}),N,"",z.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),P.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),P.oidcLoginHint?{externalId:P.oidcLoginHint}:{}));return i(this,gc,"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(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&S)){const e=yield this.sdk.flow.next(p,h,qs,q.version,z.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return i(this,gc,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Fs&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U||!R)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)})(U,R,_||"",oa)}if(f===Ps&&(s("redirectTo")||s("deferredRedirect")))return v?"android"===A&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(v):void this.loggerWrapper.error("Did not get redirect url");if(f===Ws||f===Ns){if(!I||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(c=i(this,ic,"f"))||void 0===c||c.abort(),o(this,ic,null,"f");try{e=f===Ws?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}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,qs,q.version,z.componentsVersion,{transactionId:I,response:e,failure:t});i(this,gc,"f").call(this,n)}if(f===Ds)return this.nativeComplete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,qs,q.version,z.componentsVersion,e);i(this,gc,"f").call(this,t)})),void i(this,tc,"m",Ec).call(this,"bridge",{type:T,payload:M});if(s("action")&&i(this,pc,"f").call(this,p,h,q.version,z.componentsVersion),!g&&!$)return void this.loggerWrapper.warn("No screen was found to show");const J=$||g,G=yield this.getHtmlFilenameWithLocale(E,J),{oidcLoginHint:X,oidcPrompt:Y,oidcErrorRedirectUri:Z,samlIdpUsername:Q}=P,ee={direction:Xs(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:F,name:this.sdk.getLastUserDisplayName()||F},componentsConfig:Object.assign(Object.assign(Object.assign({},q.componentsConfig),H),null==m?void 0:m.componentsConfig)}),htmlFilename:`${J}.html`,htmlLocaleFilename:G,screenId:J,stepName:e.stepName||W,samlIdpUsername:Q,oidcLoginHint:X,oidcPrompt:Y,oidcErrorRedirectUri:Z,openInNewTabUrl:w},te=ja(F);ia($,P)?ee.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:V},P),{lastAuth:te,preview:this.preview,abTestingKey:D,client:this.client}),b&&{redirectUrl:b}),{locale:aa(E).locale,nativeOptions:K}),N,e,z.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),t),k&&{exchangeCode:k,idpInitiated:!0}),P.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,gc,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ee.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,e,q.version,z.componentsVersion,t);return i(this,gc,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",ee.screenId),yield i(this,tc,"m",dc).call(this,ee),this.stepState.update(ee)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:c,next:l,screenState:d,openInNewTabUrl:u}=e;this.loggerWrapper.debug("Rendering a flow screen");const h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield i(this,tc,"m",wc).call(this,p,l):(e=>{e.querySelectorAll(`descope-button[${Ls}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(p),!e.samlIdpUsername||(null===(o=d.form)||void 0===o?void 0:o.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),Sa(p,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(p,g);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield f;const r=this.contentRootElement;((e,t)=>{ka(e,"descope-totp-image",t)})(r,null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image),((e,t)=>{ka(e,"descope-notp-image",t)})(r,null===(o=null==d?void 0:d.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{t.querySelector(o)||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],c=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!c)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 l=a[t];e.style.setProperty(c,l)})):i.info(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,p,d.cssVars,this.loggerWrapper),r.replaceChildren(p);const s=!t.htmlFilename;setTimeout((()=>{i(this,tc,"m",Cc).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const n=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=n}))}))}))})(r),((e,t)=>{va(e,null==t?void 0:t.inputs),va(e,null==t?void 0:t.form)})(r,d),i(this,tc,"m",bc).call(this,{isFirstScreen:s,stepName:e.stepName}),((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(r,this.autoFocus,s)})),i(this,tc,"m",Ac).call(this,l),r.querySelector(`[${Ls}="polling"]`)&&l(zs,{}),u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));c?i(this,tc,"m",hc).call(this,m):m()}))}}nc=new WeakMap,ic=new WeakMap,oc=new WeakMap,rc=new WeakMap,uc=new WeakMap,pc=new WeakMap,fc=new WeakMap,gc=new WeakMap,mc=new WeakMap,jc=new WeakMap,tc=new WeakSet,sc=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},ac=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(`[${Ls}="${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()},cc=function(){var e,n;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,tc,"m",ac).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}}))},lc=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")}))},dc=function(e){return n(this,void 0,void 0,(function*(){var n;const o=Object.assign(Object.assign({},this.stepState.current),e),{next:r,stepName:s}=o,a=t(o,["next","stepName"]),c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,s,(e=>{const t=(n=e.screenState,i=(e,t)=>Vs.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(0,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;return(o||r)&&(t.error={text:o,type:r}),t})(a),r,this)),l=!this.stepState.current.htmlFilename;if(i(this,uc,"f").call(this,c),c){this.loggerWrapper.debug("Rendering a custom screen"),i(this,tc,"m",bc).call(this,{isFirstScreen:l,stepName:e.stepName}),this.stepState.unsubscribeAll();const t=this.stepState.subscribe((()=>{this.stepState.unsubscribe(t),i(this,tc,"m",cc).call(this)}))}this.stepState.forceUpdate=c}))},hc=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")},vc=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)}))}},wc=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,ic,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Ia())){const{options:e,transactionId:r}=(yield i(this,mc,"f").call(this))||{};e&&r&&(i(this,tc,"m",vc).call(this,s),o(this,ic,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,ic,"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)})))}}))},bc=function({isFirstScreen:e,stepName:t}){e&&i(this,tc,"m",Ec).call(this,"ready",{}),i(this,tc,"m",Ec).call(this,"page-updated",{screenName:t}),i(this,tc,"m",Ec).call(this,"screen-updated",{screenName:t})},yc=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"!==t.localName&&(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},kc=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${ks}])`));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})),{})}))},Sc=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},Ic=function(e={}){var t,n;const i=ra(e,["externalId","email","phone"]),o=ra(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)}},Cc=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,tc,"m",xc).call(this,e)))},xc=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)}))},Oc=function(e){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&i(this,jc,"f").call(this,t,e)}))}))},Ac=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${Ss}]), [data-type="button"]:not([${Ss}]`).forEach((t=>{t.onclick=()=>{i(this,jc,"f").call(this,t,e)}})),i(this,tc,"m",Oc).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${ks}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Ec=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Uc);var Rc=Object.freeze({__proto__:null,default:Uc});customElements.define("descope-user-profile-widget",fs);const _c=(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 Tc,Mc,Lc,Pc,$c,Wc,Nc,Dc,Fc,qc;const zc=document.createElement("template");zc.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`;class Bc extends HTMLElement{constructor(){var e,t,n;super(),Tc.add(this),Mc.set(this,new f({messages:[]})),Lc.set(this,void 0),Pc.set(this,void 0),$c.set(this,void 0),Wc.set(this,{resize:i(this,Tc,"m",qc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(zc.content.cloneNode(!0));const r=new CSSStyleSheet;r.replaceSync('\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'),null!==(t=(n=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(n.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],o(this,Lc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Pc,i(this,Lc,"f").querySelector(".content"),"f"),o(this,$c,i(this,Lc,"f").querySelector(".header"),"f")}updateData(e){i(this,Mc,"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,c]=_c(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(i(this,Lc,"f"),i(this,$c,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Wc,"f").resize),(e=i(this,Lc,"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,Lc,"f").onresize=i(this,Tc,"m",Fc).bind(this),i(this,Mc,"f").subscribe(i(this,Tc,"m",Nc).bind(this))}disconnectedCallback(){i(this,Mc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Wc,"f").resize)}}Mc=new WeakMap,Lc=new WeakMap,Pc=new WeakMap,$c=new WeakMap,Wc=new WeakMap,Tc=new WeakSet,Nc=function(e){i(this,Tc,"m",Dc).call(this,e),i(this,Tc,"m",Fc).call(this)},Dc=function(e){i(this,Pc,"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("")},Fc=function(){i(this,Pc,"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)}))},qc=function(){const[e,t]=_c(i(this,Lc,"f"),Number.parseInt(i(this,Lc,"f").style.left,10),Number.parseInt(i(this,Lc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Lc,"f").style.top=`${t}px`,i(this,Lc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Bc);var Vc=Object.freeze({__proto__:null,default:Bc});const Kc=(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 Hc,Jc,Gc,Xc,Yc,Zc,Qc,el,tl,nl,il;const ol=document.createElement("template");ol.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';class rl extends HTMLElement{constructor(){super(),Hc.add(this),Jc.set(this,new pa({messages:[]})),Gc.set(this,void 0),Xc.set(this,void 0),Yc.set(this,void 0),Zc.set(this,{resize:i(this,Hc,"m",il).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ol.content.cloneNode(!0)),o(this,Gc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Xc,i(this,Gc,"f").querySelector(".content"),"f"),o(this,Yc,i(this,Gc,"f").querySelector(".header"),"f"),i(this,Hc,"m",Qc).call(this)}updateData(e){i(this,Jc,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){((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,c]=Kc(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(i(this,Gc,"f"),i(this,Yc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Zc,"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,Gc,"f")),i(this,Gc,"f").onresize=i(this,Hc,"m",nl).bind(this),i(this,Jc,"f").subscribe(i(this,Hc,"m",el).bind(this))}disconnectedCallback(){i(this,Jc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Zc,"f").resize)}}Jc=new WeakMap,Gc=new WeakMap,Xc=new WeakMap,Yc=new WeakMap,Zc=new WeakMap,Hc=new WeakSet,Qc=function(){var e,t;const n=new CSSStyleSheet;n.replaceSync('\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'),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n],i(this,Gc,"f").style.top="32px",i(this,Gc,"f").style.left=window.innerWidth-300-32+"px"},el=function(e){i(this,Hc,"m",tl).call(this,e),i(this,Hc,"m",nl).call(this)},tl=function(e){i(this,Xc,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},nl=function(){i(this,Xc,"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)}))},il=function(){const[e,t]=Kc(i(this,Gc,"f"),Number.parseInt(i(this,Gc,"f").style.left,10),Number.parseInt(i(this,Gc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Gc,"f").style.top=`${t}px`,i(this,Gc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",rl);var sl=Object.freeze({__proto__:null,default:rl});var al=Object.freeze({__proto__:null,default:(e,t,i)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n'.replace(/{{SITE_ID}}/g,t),o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("id",t),o.text=n,document.body.appendChild(o),document.addEventListener("ftr:tokenReady",(e=>{i(e.detail)}))}))});const cl=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:o,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,Oo]:[Oo];let a=[];if(n&&o){a=[`${new URL(o).toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,Mo]}else a=[Mo];const c=Lo({apiKey:t,endpoint:s,scriptUrlPattern:a}),l=yield c,{requestId:d}=yield l.get();i(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var ll=Object.freeze({__proto__:null,default:cl,loadFingerprint:cl});const dl=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:o,cloudflareEndpointPath:r,cloudflareScriptPath:s}=e,{baseUrl:a}=t;let c;c=n?`https://${n}`:a||"https://api.descope.com";const l=new URL(c);l.pathname=r;const d=new URL(c);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=Lo({apiKey:o,endpoint:[l.toString(),Oo],scriptUrlPattern:[u,Mo]}),p=yield h,{requestId:f}=yield p.get();i(f)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var ul=Object.freeze({__proto__:null,default:dl,loadFingerprint:dl});const hl=105e3,pl=(e,t,i)=>{let o=(new Date).getTime();const r=()=>{var t;return e.enterprise?null===(t=window.grecaptcha)||void 0===t?void 0:t.enterprise:window.grecaptcha};let s,a;const c=(t,n)=>{t.ready((()=>{e.siteKey&&(null==t||t.execute(a,{action:"load"}).then(((e,n)=>{n?console.warn("could not execute recaptcha",n):(i(e),o=(new Date).getTime(),s=setTimeout((()=>{c(t)}),hl))})))}))},l=()=>{clearTimeout(s)},d=(()=>{const e=document.createElement("div");return e.style.display="none",e.id="recaptcha",document.body.appendChild(e)})(),u=()=>{const e=r();e&&c(e)};return window.onRecaptchaLoadCallback=()=>{const t=d;if(t.hasChildNodes())return;const n=r();n&&setTimeout((()=>{a=n.render(t,{sitekey:e.siteKey,badge:"inline",size:"invisible"}),c(n)}),0)},(()=>{const t=document.createElement("script");t.src=(()=>{const t=new URL("https://www.google.com/recaptcha/");return t.pathname+=(e.enterprise?"enterprise":"api")+".js",t.searchParams.append("onload","onRecaptchaLoadCallback"),t.searchParams.append("render","explicit"),t.toString()})(),t.async=!0,t.id="recaptcha-script",t.defer=!0,document.body.appendChild(t)})(),{stop:l,start:u,refresh:()=>n(void 0,void 0,void 0,(function*(){if(Date.now()-o>hl){l();const e=o;return u(),new Promise((t=>{const n=setTimeout((()=>{console.warn("reCAPTCHA token refresh timed out"),t()}),5e3),i=()=>{o!==e?(clearTimeout(n),t()):setTimeout(i,150)};i()}))}return Promise.resolve()}))}};var fl=Object.freeze({__proto__:null,default:pl,loadGRecaptcha:pl});return fs}();
|
|
8
8
|
//# sourceMappingURL=index.js.map
|