@descope/tenant-profile-widget 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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.d.ts +38 -38
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/tenant-profile-widget v0.
|
|
3
|
+
* @descope/tenant-profile-widget v0.4.0
|
|
4
4
|
*/
|
|
5
|
-
this["descope-tenant-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{let t,n;return(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)},l=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}let f=class{constructor(e={},{forceUpdate:t=!1}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,c,"f")):e,n=Object.assign(Object.assign({},i(this,c,"f")),t);if(i(this,h,"f")||!p(i(this,c,"f"),n)){const e=i(this,c,"f");o(this,c,n,"f"),Object.freeze(i(this,c,"f")),setTimeout((()=>{Object.values(i(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,c,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,c,"f"))}subscribe(e){return o(this,u,i(this,u,"f")+1,"f"),i(this,d,"f")[i(this,u,"f")]=e,i(this,u,"f").toString()}unsubscribe(e){const t=!!i(this,d,"f")[e];return t&&delete i(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const g=["error","warn","info","debug"],v=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,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,b=m&&localStorage.getItem("base.content.url")||"",w=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,y=l((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),k=l((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),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},s};S.missingAttrValidator=w;const I=l((e=>{const t=r(S({"project-id":w}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),C=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),x="Trying the next fallback URL...",O=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};function E({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 j=l((e=>{var t,n,s,a,l;const c=r(v,I,C)(e);return l=class extends c{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),l=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 O(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${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:l});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=b||this.baseStaticUrl;if(t)return E({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 l=E({projectId:this.projectId,filename:e,baseUrl:i(this,s,"f")});if(!a)return l;return[E({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),l]},l})),A=l((e=>{var t,n;const o=r(S({"project-id":w}))(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})),R=l((e=>{var t,n,s,a,l;const c=r(j,A,y)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,s,"f")||o(this,s,i(this,a,"f").call(this),"f"),i(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},l})),U=l((e=>{var t,n,s,a,l,c,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",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return _c})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),T=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],_=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},P=(e,t)=>new Promise(((n,i)=>{const o=(e=>{const t=document.createElement("script");return t.id=e,t})(e);o.onerror=e=>{o.setAttribute("status","error"),i(e)},o.onload=()=>{o.setAttribute("status","loaded"),n(o)},o.src=t.toString(),document.body.appendChild(o)})),L=e=>"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))})),$=l((e=>{const t=r(v)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[]){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"`),(async(e,t)=>{for(const i of e){const{id:e,url:o}=i,r=(n=e,document.querySelector(`script#${n}`));if(r)try{return await L(r),i}catch(e){t(i,!0)}else try{return await P(e,o),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="")=>e.reduce(((e,o)=>{const r=o;if(!r)return e;let s;try{s=new URL(r)}catch(e){throw new Error(`Invalid URL: ${r}`)}return"/"!==s.pathname||(s.pathname=`/npm/${t}@${n}/${i}`),[...e,{url:s,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${_(s)}`}]}),[]))([...i,this.baseCdnUrl,...T],e,t,n),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),M="base.ui.components.url",W=m&&localStorage.getItem(M),N=l((e=>{var t,n,s,a,l,c;const d=r(v,R,$)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get descopeUi(){return i(this,s,"f")||o(this,s,i(this,t,"m",l).call(this),"f"),i(this,s,"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",a).call(this,e))))}},s=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},a=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(", ")}"`)},l=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{return await this.injectNpmLib("@descope/web-components-ui",await i(this,t,"m",n).call(this),"dist/umd/index.js",[W]),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},c})),D=l((e=>{var t,n,o;const s=r(y,k)(e);return o=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class F{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const q=l((e=>{const t=r(D)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new F(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),z="content-root",K="root",H=l((e=>{const t=r(q)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${z}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${z} {\n height: 100%;\n }\n #${K} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(z),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),V="descope-modal";var J;let B=class{constructor(e,t){J.set(this,void 0),this.nodeName="",o(this,J,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,J,"f"))}get ele(){var e,t;const n="function"==typeof i(this,J,"f")?i(this,J,"f").call(this):i(this,J,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};J=new WeakMap;let X=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)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}},Y=class extends B{constructor(){super(...arguments),this.nodeName="descope-link"}get ele(){return super.ele}get href(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("href")}set href(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("href",null!=e?e:"")}};var G;let Z=class extends B{constructor(){super(...arguments),G.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,G,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,G,"f").content.cloneNode(!0)))}setContent(e){o(this,G,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};G=new WeakMap;let Q=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()}},ee=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)}}},te=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")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}};const ne=l((e=>{var t,n;const o=r(y,H,N)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Z{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(V);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([V]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ie="descope-notification";l((e=>{var t,n;const o=r(y,H,N)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Q{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ie);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([ie])}},t=new WeakMap,n}));const oe=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',re=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m;const b=r(S({theme:oe}),j,y,N,R,H,k,q)(e);return m=class extends b{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,f,"f").call(this),await Promise.all([i(this,t,"m",c).call(this),i(this,t,"m",d).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",c).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(M))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(M),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")}},l=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")},c=async function(){var e,r;const s=await i(this,t,"a",l);s&&(i(this,n,"f")||o(this,n,this.injectStyle(""),"f"),i(this,n,"f").replaceSync(((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"")))},d=async function(){var e,n;const o=await i(this,t,"a",l);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 se=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ae=()=>Math.random().toString(36).substring(7).split("").join("."),le={INIT:`@@redux/INIT${ae()}`,REPLACE:`@@redux/REPLACE${ae()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ae()}`};function ce(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 de(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 ue(e){let t=typeof e;return t=de(e),t}function he(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${ue(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: '${ue(n)}'`);return n(he)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${ue(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),r=null}}}function h(e){if(!ce(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${ue(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: '${ue(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=i(o,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:le.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: '${ue(e)}`);i=e,h({type:le.REPLACE})},[se]: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: '${ue(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[se](){return this}}}}}function pe(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function fe(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&pe(`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:le.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:le.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 '${le.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===le.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(!ce(e))return`The ${r} has unexpected type of "${ue(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===le.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&&pe(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||i.length!==Object.keys(e).length,s?a:e}}function ge(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function ve(e){return ce(e)&&"type"in e&&"string"==typeof e.type}var me=Symbol.for("immer-nothing"),be=Symbol.for("immer-draftable"),we=Symbol.for("immer-state"),ye=[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 ke(e,...t){{const n=ye[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var Se=Object.getPrototypeOf;function Ie(e){return!!e&&!!e[we]}function Ce(e){return!!e&&(Oe(e)||Array.isArray(e)||!!e[be]||!!e.constructor?.[be]||Ue(e)||Te(e))}var xe=Object.prototype.constructor.toString();function Oe(e){if(!e||"object"!=typeof e)return!1;const t=Se(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)===xe}function Ee(e,t){0===je(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function je(e){const t=e[we];return t?t.type_:Array.isArray(e)?1:Ue(e)?2:Te(e)?3:0}function Ae(e,t){return 2===je(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Re(e,t,n){const i=je(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function Ue(e){return e instanceof Map}function Te(e){return e instanceof Set}function _e(e){return e.copy_||e.base_}function Pe(e,t){if(Ue(e))return new Map(e);if(Te(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Oe(e)){if(!Se(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[we];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(Se(e),n)}function Le(e,t=!1){return Me(e)||Ie(e)||!Ce(e)||(je(e)>1&&(e.set=e.add=e.clear=e.delete=$e),Object.freeze(e),t&&Ee(e,((e,t)=>Le(t,!0)))),e}function $e(){ke(2)}function Me(e){return Object.isFrozen(e)}var We,Ne={};function De(e){const t=Ne[e];return t||ke(0,e),t}function Fe(){return We}function qe(e,t){t&&(De("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ze(e){Ke(e),e.drafts_.forEach(Ve),e.drafts_=null}function Ke(e){e===We&&(We=e.parent_)}function He(e){return We={drafts_:[],parent_:We,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ve(e){const t=e[we];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Je(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[we].modified_&&(ze(t),ke(4)),Ce(e)&&(e=Be(t,e),t.parent_||Ye(t,e)),t.patches_&&De("Patches").generateReplacementPatches_(n[we].base_,e,t.patches_,t.inversePatches_)):e=Be(t,n,[]),ze(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==me?e:void 0}function Be(e,t,n){if(Me(t))return t;const i=t[we];if(!i)return Ee(t,((o,r)=>Xe(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return Ye(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),Ee(o,((o,s)=>Xe(e,i,t,o,s,n,r))),Ye(e,t,!1),n&&e.patches_&&De("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function Xe(e,t,n,i,o,r,s){if(o===n&&ke(5),Ie(o)){const s=Be(e,o,r&&t&&3!==t.type_&&!Ae(t.assigned_,i)?r.concat(i):void 0);if(Re(n,i,s),!Ie(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(Ce(o)&&!Me(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Be(e,o),t&&t.scope_.parent_||Ye(e,o)}}function Ye(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Le(t,n)}var Ge={get(e,t){if(t===we)return e;const n=_e(e);if(!Ae(n,t))return function(e,t,n){const i=et(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_||!Ce(i)?i:i===Qe(e.base_,t)?(nt(e),e.copy_[t]=it(i,e)):i},has:(e,t)=>t in _e(e),ownKeys:e=>Reflect.ownKeys(_e(e)),set(e,t,n){const i=et(_e(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=Qe(_e(e),t),o=i?.[we];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||Ae(e.base_,t)))return!0;nt(e),tt(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!==Qe(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,nt(e),tt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=_e(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){ke(11)},getPrototypeOf:e=>Se(e.base_),setPrototypeOf(){ke(12)}},Ze={};function Qe(e,t){const n=e[we];return(n?_e(n):e)[t]}function et(e,t){if(!(t in e))return;let n=Se(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Se(n)}}function tt(e){e.modified_||(e.modified_=!0,e.parent_&&tt(e.parent_))}function nt(e){e.copy_||(e.copy_=Pe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ee(Ge,((e,t)=>{Ze[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ze.deleteProperty=function(e,t){return isNaN(parseInt(t))&&ke(13),Ze.set.call(this,e,t,void 0)},Ze.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&ke(14),Ge.set.call(this,e[0],t,n,e[0])};function it(e,t){const n=Ue(e)?De("MapSet").proxyMap_(e,t):Te(e)?De("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Fe(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=Ge;n&&(o=[i],r=Ze);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:Fe()).drafts_.push(n),n}function ot(e){return Ie(e)||ke(10,e),rt(e)}function rt(e){if(!Ce(e)||Me(e))return e;const t=e[we];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Pe(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Pe(e,!0);return Ee(n,((e,t)=>{Re(n,e,rt(t))})),t&&(t.finalized_=!1),n}var st=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&&ke(6),void 0!==n&&"function"!=typeof n&&ke(7),Ce(e)){const o=He(this),r=it(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?ze(o):Ke(o)}return qe(o,n),Je(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===me&&(i=void 0),this.autoFreeze_&&Le(i,!0),n){const t=[],o=[];De("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}ke(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){Ce(e)||ke(8),Ie(e)&&(e=ot(e));const t=He(this),n=it(e,void 0);return n[we].isManual_=!0,Ke(t),n}finishDraft(e,t){const n=e&&e[we];n&&n.isManual_||ke(9);const{scope_:i}=n;return qe(i,t),Je(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=De("Patches").applyPatches_;return Ie(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},at=st.produce;st.produceWithPatches.bind(st),st.setAutoFreeze.bind(st),st.setUseStrictShallowCopy.bind(st),st.applyPatches.bind(st),st.createDraft.bind(st),st.finishDraft.bind(st);var lt=(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})}}},ct=(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})}},dt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var ut=e=>Array.isArray(e)?e:[e];function ht(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 pt(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var ft="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},gt=0,vt=1;function mt(){return{s:gt,v:void 0,o:null,p:null}}function bt(e,t={}){let n=mt();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=mt(),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=mt(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===vt)l=t.v;else if(l=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,l)&&(l=e,0!==r&&r--);o="object"==typeof l&&null!==l||"function"==typeof l?new ft(l):l}return a.s=vt,a.v=l,l}return s.clearCache=()=>{n=mt(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function wt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=bt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=ut(c),f=ut(u),g=ht(e),v=l((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){o++;const e=pt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...dt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:lt},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:ct}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=pt(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:l,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var yt=wt(bt),kt=Object.assign(((e,t=yt)=>{!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:()=>kt});function St(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var It=St(),Ct=St;((...e)=>{const t=wt(...e)})(bt);var xt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?ge:ge.apply(null,arguments)},Ot=e=>e&&"function"==typeof e.match;function Et(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=>ve(t)&&t.type===e,n}function jt(e){return"function"==typeof e&&"type"in e&&Ot(e)}function At(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 Rt=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 Ut(e){return Ce(e)?at(e,(()=>{})):e}function Tt(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 _t(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Pt(e,t,n){const i=Lt(e,t,n);return{detectMutations:()=>$t(e,t,i,n)}}function Lt(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]=Lt(e,t,n[o],s))}}return r}function $t(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in i)l[e]=!0;const c=t.length>0;for(let o in l){const s=r?r+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=$t(e,t,n.children[o],i[o],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Mt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||ce(e)}function Wt(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),l=o.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Wt(c,a,n,i,o,r),s))return s}return r&&Nt(e)&&r.add(e),!1}function Nt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Nt(t))return!1;return!0}function Dt(e){return"boolean"==typeof e}var Ft=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Rt;if(t&&(Dt(t)?r.push(It):r.push(Ct(t.extraArgument))),n){let e={};Dt(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=_t,ignoredPaths:o,warnAfter:r=32}=e;const s=Pt.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>l=>{const c=At(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(i){let e={};Dt(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:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!ve(u))return c(u);const h=c(u),p=At(s,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Wt(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=Wt(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={};Dt(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=jt}=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},qt=e=>t=>{setTimeout(t,e)},zt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:qt(10),Kt=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Rt(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?zt:"callback"===e.type?e.queueNotification:qt(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,l(c))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function Ht(e){const t=Ft(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!ce(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=fe(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(l=i(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=ge;o&&(c=xt({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=ge(...a)(o.dispatch),{...o,dispatch:r}}}(...l),u=Kt(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return he(a,r,c(...h))}function Vt(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 Jt(...e){return t=>e.some((e=>((e,t)=>Ot(e)?e.match(t):e(t))(e,t)))}var Bt=["name","message","stack","code"],Xt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Yt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Gt=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Bt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},Zt=(()=>{function e(e,t,n){const i=Et(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Et(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Et(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||Gt)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new Xt(e,t),fulfillWithValue:(e,t)=>new Yt(e,t)})).then((t=>{if(t instanceof Xt)throw t;return t instanceof Yt?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof Xt?r(null,c,e,t.payload,t.meta):r(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(Qt)})}}),{pending:o,rejected:r,fulfilled:i,settled:Jt(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function Qt(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var en=Symbol.for("rtk-slice-createasyncthunk");function tn(e,t){return`${e}/${t}`}function nn(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 on=function({creators:e}={}){const t=e?.asyncThunk?.[en];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?Vt(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]=Vt(t);if(function(e){return"function"==typeof e}(e))n=()=>Ut(e());else{const t=Ut(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(Ie(e)){const i=n(e,t);return void 0===i?e:i}if(Ce(e))return at(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:tn(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?Et(e,s):Et(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);l&&i.addCase(u.rejected,l);c&&i.addMatcher(u.settled,c);i.exposeCaseReducer(t,{fulfilled:s||rn,pending:a||rn,rejected:l||rn,settled:c||rn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=Tt(d,this,{insert:()=>new WeakMap});return Tt(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=nn(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 rn(){}var sn="listenerMiddleware";Et(`${sn}/add`),Et(`${sn}/removeAll`),Et(`${sn}/remove`);const an=e=>l((t=>{const n=on(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(v)(t)){constructor(...e){super(...e);const t=Ht({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{Qt(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(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 ln=l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),cn=(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 dn(e){return new URLSearchParams(window.location.search).get(e)}const un=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)}))}))},hn=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),pn=Zt("users/me",((e,{extra:{api:t}})=>t.user.me())),fn=un(pn)({onFulfilled:(e,t)=>{e.me.data=t.payload}},hn((e=>e.me))),gn={action:pn,reducer:fn},vn=Zt("tenant/details",((e,{extra:{api:t}})=>t.tenant.details())),mn=un(vn)({onFulfilled:(e,t)=>{e.tenant.data=t.payload}},hn((e=>e.tenant))),bn={action:vn,reducer:mn},wn=Zt("tenant/adminLinkSso",((e,{extra:{api:t}})=>t.tenant.adminLinkSso())),yn={action:wn,reducer:un(wn)({onFulfilled:(e,t)=>{var n;e.tenantAdminLinkSSO.data=(null===(n=t.payload)||void 0===n?void 0:n.adminSSOConfigurationLink)||""}},hn((e=>e.tenantAdminLinkSSO)))},kn={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:""}};class Sn extends Error{}function In(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 Cn(e,t){if("string"!=typeof e)throw new Sn("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 Sn(`Invalid token specified: missing part #${n+1}`);let o;try{o=In(i)}catch(e){throw new Sn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new Sn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Sn.prototype.name="InvalidTokenError";var xn={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const On="<region>",En=`https://api.${On}descope.com`,jn=6e5,An="dct",Rn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},Un=[521,524],Tn=e=>async(...t)=>{let n=await e(...t);Un.includes(n.status)&&(n=await e(...t),n.retries=1);const i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n};let _n;const Pn=()=>{if(_n)return _n;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 _n=`${t}-${n}`,_n};var Ln;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(Ln||(Ln={}));const $n=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(On,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},Mn=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),Wn={"Content-Type":"application/json"},Nn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Dn=(e,t)=>{const n={"x-descope-sdk-session-id":Pn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.52.1","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Fn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var qn=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||En,c=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Rn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await Tn(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return Rn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:Tn(n)})(o,a),d=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:Mn(Nn(t,g),Dn(t,i),(null==n?void 0:n.baseHeaders)||{},Fn(v)?Wn:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const b=await c($n({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==b?void 0:b.clone()),null==r?void 0:r.transformResponse){const e=await b.json(),t=((null===(o=b.headers)||void 0===o?void 0:o.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({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return b};return{get:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Ln.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Ln.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Ln.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Ln.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Ln.delete,token:i}),hooks:r,buildUrl:(e,n)=>$n({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},zn=429;function Kn(e,t,n){var i;let o=Hn(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[An])===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 Hn(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Cn(e)}function Vn(e){const{exp:t}=Hn(e);return(new Date).getTime()/1e3>t}function Jn(e){let t=Hn(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Bn(e,t){return Kn(e,t,"permissions")}function Xn(e,t){return Kn(e,t,"roles")}const Yn=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Gn(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===zn&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function Zn(e){var t;return(null===(t=Hn(e))||void 0===t?void 0:t[An])||""}const Qn=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),ei=(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 "))},ti=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ni=e=>t=>e.test(t),ii=ni(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),oi=ni(/^\+[1-9]{1}[0-9]{3,14}$/),ri=Qn(ii,'"{val}" is not a valid email'),si=Qn(oi,'"{val}" is not a valid phone number'),ai=Qn((e=>e.length>=1),"Minimum length is 1");const li=Qn((e=>"string"==typeof e),"Input is not a string"),ci=Qn((e=>Array.isArray(e)),"Input is not an array"),di=Qn((e=>"boolean"==typeof e),"Input is not a boolean"),ui=Qn((e=>void 0===e),"Input is defined"),hi=ei([li(),ui()],"Input is not a string or undefined"),pi=ei([ci(),di()],"Input is not an array or boolean"),fi=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>ti(...e).validate(n[t]))),t(...n)),gi=e=>[li(`"${e}" must be a string`)],vi=e=>[hi(`"${e}" must be string or undefined`)],mi=e=>[li(`"${e}" must be a string`),ai(`"${e}" must not be empty`)],bi=e=>[li(`"${e}" must be a string`),ri()],wi=e=>[li(`"${e}" must be a string`),si()],yi=fi(mi("accessKey")),ki=e=>({exchange:yi(((t,n)=>Gn(e.post(xn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Si=(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),Ii=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||jn,jn)});var Ci,xi;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(Ci||(Ci={})),function(e){e.email="email"}(xi||(xi={}));const Oi=Object.assign(Object.assign({},Ci),xi);var Ei;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ei||(Ei={}));const ji=mi("loginId"),Ai=fi(mi("token")),Ri=fi(ji),Ui=fi(mi("pendingRef")),Ti=fi(ji,bi("email")),_i=e=>({verify:Ai((t=>Gn(e.post(xn.enchantedLink.verify,{token:t})))),signIn:Ri(((n,i,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Gn(e.post(Yn(xn.enchantedLink.signIn,Oi.email),{loginId:n,URI:i,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:Ri(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Gn(e.post(Yn(xn.enchantedLink.signUpOrIn,Oi.email),{loginId:n,URI:i,loginOptions:s,providerId:r}))})),signUp:Ri(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Gn(e.post(Yn(xn.enchantedLink.signUp,Oi.email),{loginId:n,URI:i,user:o,loginOptions:a,providerId:s}))})),waitForSession:Ui(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Ii(n);let s;const a=setInterval((async()=>{const n=await e.post(xn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Gn(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ti(((t,n,i,o,r)=>Gn(e.post(xn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),Pi=fi(mi("flowId")),Li=fi(mi("executionId"),mi("stepId"),mi("interactionId")),$i=e=>({start:Pi(((t,n,i,o,r,s,a)=>Gn(e.post(xn.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a})))),next:Li(((t,n,i,o,r,s)=>Gn(e.post(xn.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),Mi=mi("loginId"),Wi=fi(mi("token")),Ni=fi(Mi),Di=fi(Mi,wi("phone")),Fi=fi(Mi,bi("email")),qi=Object.keys(Oi).filter((e=>e!==Ci.voice)),zi=e=>({verify:Wi((t=>Gn(e.post(xn.magicLink.verify,{token:t})))),signIn:qi.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Ni(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Gn(e.post(Yn(xn.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:qi.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Ni(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Gn(e.post(Yn(xn.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:qi.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Ni(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Gn(e.post(Yn(xn.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:Fi(((t,n,i,o,r)=>Gn(e.post(xn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(Ci).filter((e=>e!==Ci.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Di(((t,i,o,r,s)=>Gn(e.post(Yn(xn.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Ki;!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"}(Ki||(Ki={}));const Hi=fi(mi("code")),Vi=e=>({start:Object.assign(((t,n,i,o,r)=>Gn(e.post(xn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(Ki).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>Gn(e.post(xn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:Hi((t=>Gn(e.post(xn.oauth.exchange,{code:t})))),startNative:(t,n,i)=>Gn(e.post(xn.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>Gn(e.post(xn.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>Gn(e.get(xn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>Gn(e.post(xn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>Gn(e.post(xn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Ji=mi("appId"),Bi=fi(Ji),Xi=e=>({connect:Bi(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Gn(e.post(xn.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),Yi=mi("loginId"),Gi=fi(Yi,mi("code")),Zi=fi(Yi),Qi=fi(Yi,wi("phone")),eo=fi(Yi,bi("email")),to=e=>({verify:Object.keys(Oi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gi(((t,i)=>Gn(e.post(Yn(xn.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Oi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Zi(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Gn(e.post(Yn(xn.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Oi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Zi(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Gn(e.post(Yn(xn.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Oi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Zi(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Gn(e.post(Yn(xn.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:eo(((t,n,i,o)=>Gn(e.post(xn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(Ci).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qi(((t,i,o,r)=>Gn(e.post(Yn(xn.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),no=fi(mi("tenant")),io=fi(mi("code")),oo=e=>({start:no(((t,n,i,o,r,s,a)=>Gn(e.post(xn.saml.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a})},o&&{token:o}))))),exchange:io((t=>Gn(e.post(xn.saml.exchange,{code:t}))))}),ro=mi("loginId"),so=fi(ro,mi("code")),ao=fi(ro),lo=fi(ro),co=e=>({signUp:ao(((t,n)=>Gn(e.post(xn.totp.signUp,{loginId:t,user:n})))),verify:so(((t,n,i,o)=>Gn(e.post(xn.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:lo(((t,n)=>Gn(e.post(xn.totp.update,{loginId:t},{token:n}))))}),uo=mi("loginId"),ho=mi("newPassword"),po=fi(uo,mi("password")),fo=fi(uo),go=fi(uo,ho),vo=fi(uo,mi("oldPassword"),ho),mo=e=>({signUp:po(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Gn(e.post(xn.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:po(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Gn(e.post(xn.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:fo(((t,n,i)=>Gn(e.post(xn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:go(((t,n,i)=>Gn(e.post(xn.password.update,{loginId:t,newPassword:n},{token:i})))),replace:vo(((t,n,i)=>Gn(e.post(xn.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>Gn(e.get(xn.password.policy))}),bo=gi("loginId"),wo=mi("loginId"),yo=mi("origin"),ko=fi(wo,yo,mi("name")),So=fi(wo,yo),Io=fi(bo,yo),Co=fi(wo,yo,vi("token")),xo=fi(mi("transactionId"),mi("response")),Oo=e=>({signUp:{start:ko(((t,n,i,o)=>Gn(e.post(xn.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,passkeyOptions:o})))),finish:xo(((t,n)=>Gn(e.post(xn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Io(((t,n,i,o,r)=>Gn(e.post(xn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:xo(((t,n)=>Gn(e.post(xn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:So(((t,n,i)=>Gn(e.post(xn.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:i}))))},update:{start:Co(((t,n,i,o)=>Gn(e.post(xn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:xo(((t,n)=>Gn(e.post(xn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Eo=gi("loginId"),jo=fi(Eo),Ao=fi(mi("pendingRef")),Ro=e=>({signUpOrIn:jo(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return Gn(e.post(xn.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:jo(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Gn(e.post(xn.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:jo(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return Gn(e.post(xn.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:Ao(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Ii(n);let s;const a=setInterval((async()=>{const n=await e.post(xn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Gn(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Uo=fi(mi("token")),To=fi(vi("token"));var _o,Po=fi([(_o=mi("projectId"),Qn(((e,t)=>n=>ti(...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",_o))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=qn({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:ki(l),otp:to(l),magicLink:zi(l),enchantedLink:_i(l),oauth:Vi(l),outbound:Xi(l),saml:oo(l),totp:co(l),notp:Ro(l),webauthn:Oo(l),password:mo(l),flow:$i(l),refresh:To(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?xn.tryRefresh:xn.refresh;return Gn(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:fi([li("tenantId")],[hi('"token" must be string or undefined')])(((e,t)=>Gn(l.post(xn.selectTenant,{tenant:e},{token:t})))),logout:To((e=>Gn(l.post(xn.logout,{},{token:e})))),logoutAll:To((e=>Gn(l.post(xn.logoutAll,{},{token:e})))),me:To((e=>Gn(l.get(xn.me,{token:e})))),myTenants:fi([pi('"tenants" must a string array or a boolean')],[hi('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Gn(l.post(xn.myTenants,n,{token:t}))})),history:To((e=>Gn(l.get(xn.history,{token:e})))),isJwtExpired:Uo(Vn),getTenants:Uo(Jn),getJwtPermissions:Uo(Bn),getJwtRoles:Uo(Xn),getCurrentTenant:Uo(Zn),httpClient:l};var l})),Lo=Object.assign(Po,{DeliveryMethods:Oi});
|
|
6
|
-
/*! js-cookie v3.0.5 | MIT */function $o(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 Mo=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=$o({},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,"",$o({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,$o({},this.attributes,t))},withConverter:function(t){return e($o({},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 Wo={default:"endpoint"},No="Blocked by CSP",Do="The endpoint parameter is not a valid URL",Fo="Failed to load the JS script of the agent",qo="9319";function zo(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===No||s===Do)n.exclude(),r=0;else if(s===qo)n.exclude();else if(s===Fo){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var Ko="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Ho=Ko;function Vo(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:Ko,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return zo(e,Jo)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===qo?new Error(Fo):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 Jo(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(Do);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(Fo))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(No)})).then(Bo)}function Bo(){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(qo);return n}let Xo;const Yo=e=>{try{return Cn(e).exp}catch(e){return null}},Go=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Yo(n)},Zo=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?Yo(i):void 0)},Qo=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||Zo(e),cookieExpiration:e.cookieExpiration||Go(e)},s)},er=(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},tr=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return Qo(n)},nr=void 0!==Xo||"undefined"!=typeof localStorage,ir=(e,t)=>{var n,i;return null===(i=null===(n=Xo||localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},or=e=>{var t,n;return null===(n=null===(t=Xo||localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},rr=e=>{var t,n;return null===(n=null===(t=Xo||localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},sr=e=>{var t,n,i,o;return null!==(o=null!==(n=null===(t=null==Xo?void 0:Xo.key)||void 0===t?void 0:t.call(Xo,e))&&void 0!==n?n:null===(i=null===localStorage||void 0===localStorage?void 0:localStorage.key)||void 0===i?void 0:i.call(localStorage,e))&&void 0!==o?o:null},ar=(...e)=>{console.debug(...e)},lr="3.2.0",cr="undefined"!=typeof window,dr=Math.pow(2,31)-1,ur=`https://descopecdn.com/npm/oidc-client-ts@${lr}/dist/browser/oidc-client-ts.min.js`,hr=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${lr}/dist/browser/oidc-client-ts.min.js`,pr="DS",fr="DSR",gr="DSI";const vr=e=>(null==e?void 0:e.cookieName)||pr;function mr(e=""){return or(`${e}${fr}`)||""}function br(e="",t){return Mo.get(vr(t))||or(`${e}${pr}`)||""}function wr(e=""){return or(`${e}${gr}`)||""}function yr(e="",t){rr(`${e}${fr}`),rr(`${e}${pr}`),rr(`${e}${gr}`);const n=vr(t);Mo.remove(n)}const kr=cr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Sr="vsid",Ir="vrid",Cr="fp",xr=(e=!1)=>{const t=or(Cr);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Or=async(e,t=kr)=>{try{if(xr())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=Vo({apiKey:e,endpoint:[i.toString(),Wo],scriptUrlPattern:[r,Ho]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Sr]:e,[Ir]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};ir(Cr,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Er=e=>{const t=xr(!0);return t&&e.body&&(e.body.fpData=t),e},jr="descopeFlowNonce",Ar="X-Descope-Flow-Nonce",Rr="/v1/flow/start",Ur="/v1/flow/next",Tr=(e,t=jr)=>`${t}${e}`,_r=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Pr=e=>{var t;return e.path===Ur&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?_r(e.body.executionId):null},Lr="dls_last_user_login_id",$r="dls_last_user_display_name",Mr=e=>ir(Lr,e),Wr=()=>or(Lr),Nr=()=>or($r),Dr=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Wr(),r=Nr();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function Fr(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function qr(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Br(n.publicKey.challenge),n.publicKey.user.id=Br(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Br(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Xr(n.rawId),type:n.type,response:{attestationObject:Xr(n.response.attestationObject),clientDataJSON:Xr(n.response.clientDataJSON)}});var n}async function zr(e){const t=Vr(e);return Jr(await navigator.credentials.get(t))}async function Kr(e,t){const n=Vr(e);return n.signal=t.signal,n.mediation="conditional",Jr(await navigator.credentials.get(n))}async function Hr(e=!1){if(!cr)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 Vr(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Br(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Br(e.id)})),n}function Jr(e){return JSON.stringify({id:e.id,rawId:Xr(e.rawId),type:e.type,response:{authenticatorData:Xr(e.response.authenticatorData),clientDataJSON:Xr(e.response.clientDataJSON),signature:Xr(e.response.signature),userHandle:e.response.userHandle?Xr(e.response.userHandle):void 0}})}function Br(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Xr(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Yr,Gr=(Yr=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 qr(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 zr(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 qr(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await zr(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 qr(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:qr,get:zr,isSupported:Hr,conditional:Kr}}),(...e)=>{const t=Yr(...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 Zr="/fedcm/config",Qr=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function es(e,t){var n;try{await ts(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function ts(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=Qr(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var ns=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Hr(),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 is;const os=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{os(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),rs=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{is||(is=(async()=>{try{return require("oidc-client-ts")}catch(e){return os([ur,hr],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await is;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",l=`${r}_user`;let c=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(c=`${c}/${n.applicationId}`);const d={authority:c,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:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),ir(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=or(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||wr(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return rr(o),t||window.location.replace(s),r}}},ss=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Xo=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return cr?(i&&o&&Or(i).catch((()=>null)),e(er(r,{beforeRequest:Er}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i||"undefined"!=typeof window&&window.descopeBridge)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,l;cr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&a&&new Date>a&&(ar("Expiration time passed, refreshing session"),c.refresh(mr()||l))}));const c=e(er(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o}=await tr(t);if(401===(null==t?void 0:t.status))ar("Received 401, canceling all timers"),r();else if(n||o){if(a=((e,t)=>{if(t)return new Date(1e3*t);ar("Could not extract expiration time from session token, trying to decode the token");try{const t=Cn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!a)return void ar("Could not extract expiration time from session token");l=i;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>dr&&(ar(`Timeout is too large (${t}ms), setting it to ${dr}ms`),t=dr),t})(a);if(r(),e<=2e4)return void ar("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});ar(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{ar("Refreshing session due to timer"),c.refresh(mr()||i)}),e)}}}));return Si(c,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return ar("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.38.1"},t.baseHeaders)}))),(e=>t=>{const n=Fr(),i=Fr(),o=Fr(),r=Fr(),s=e(er(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await tr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await tr(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Si(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:i=!0,nonceStoragePrefix:o=jr}=n,r=t(n,["enableFlowNonce","nonceStoragePrefix"]);return i?(((e=jr)=>{try{if(!nr)return;for(let i=0;i<(void 0,void 0,null!==(n=null!==(t=null==Xo?void 0:Xo.length)&&void 0!==t?t:null===localStorage||void 0===localStorage?void 0:localStorage.length)&&void 0!==n?n:0);i++){const t=sr(i);if(t&&t.startsWith(e)){const n=or(t);if(n)try{JSON.parse(n).expiry<Date.now()&&rr(t)}catch(e){rr(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n})(o),e(er(r,{afterRequest:async(e,t)=>{if(e.path!==Rr&&e.path!==Ur)return;const{nonce:n,executionId:i}=await(async(e,t)=>{try{const n=t.headers.get(Ar);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=Pr(e)),{nonce:n,executionId:_r(i)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&i&&((e,t,n,i=jr)=>{try{const o=Tr(e,i),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};ir(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(i,n,e.path===Rr,o)},beforeRequest:e=>{if(e.path===Ur){const t=Pr(e);if(t){const n=((e,t=jr)=>{try{const n=Tr(e,t),i=or(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(((e,t=jr)=>{try{const n=Tr(e,t);rr(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);n&&(e.headers=e.headers||{},e.headers[Ar]=n)}}return e}}))):e(r)}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:Wr,getLastUserDisplayName:Nr});const s=e(er(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=Qo((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(Mr(r),(e=>{ir($r,e)})(s)):(null==o?void 0:o.loginId)&&Mr(o.loginId)}}));let a=Si(s,["flow.start"],Dr);return a=Si(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(rr(Lr),rr($r)),i})(o)),Object.assign(a,{getLastUserLoginId:Wr,getLastUserDisplayName:Nr})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!cr)return e(s);const a=e(er(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||mr(l)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||yr(r,o):((e={},t=!1,n="")=>{var i,o;const{sessionJwt:r,refreshJwt:s}=e;if(s&&ir(`${n}${fr}`,s),r)if(t){const n=t.sameSite||"Strict",s=null===(i=t.secure)||void 0===i||i,a=null!==(o=t.domain)&&void 0!==o?o:e.cookieDomain;!function(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);Mo.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}(vr(t),r,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:s,cookieDomain:a}))}else ir(`${n}${pr}`,r);e.idToken&&ir(`${n}${gr}`,e.idToken)})(await tr(t),o,r)}}));var l;const c=Si(a,["logout","logoutAll","oidc.logout"],((e,t)=>n=>async(...i)=>{const o=await n(...i);return yr(e,t),o})(r,o));return Object.assign(c,{getRefreshToken:()=>mr(r),getSessionToken:()=>br(r),getIdToken:()=>wr(r)})}))((e=>{const t=Lo(e),n=rs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;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 s=br(),a=mr();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){ar("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:ns(t),webauthn:Gr(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){es(i,e)},requestAuthentication(e){es(i,e)}},async oneTap(e,t,n,o,r){await ts(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+Zr),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>cr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+Zr);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})),as={me:"/v1/auth/me"},ls={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated"},cs=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)})),ds=()=>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})}))})),us=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))})),hs=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({adminSSOConfigurationLink:"_blank"})}))})),ps=({httpClient:e,tenantId:t,mock:i})=>{const o=encodeURIComponent(t||""),r=`?tenant=${o}&id=${o}`;return{details:()=>n(void 0,void 0,void 0,(function*(){if(i)return us();if(!t)throw new Error("tenantId is not defined");const n=`${ls.details}${r}`,o=yield e.get(n);yield cs(o);return yield o.json()})),adminLinkSso:()=>n(void 0,void 0,void 0,(function*(){if(i)return hs();if(!t)throw new Error("tenantId is not defined");const n=yield e.post(`${ls.adminLinkSso}?tenant=${o}`,{tenantId:o},{headers:{"Content-Type":"application/json"}});yield cs(n);return yield n.json()}))}},fs=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return ds();const n=yield e.get(as.me);return yield cs(n),n.json()}))}),gs=l((e=>{var t,s,a,l;const c=r(I,k,v,C,ln)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}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","tenant","mock"],(()=>{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,n,i)=>{const o=ss(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.3.1"}}));return{user:fs({httpClient:o.httpClient,mock:n}),tenant:ps({httpClient:o.httpClient,tenantId:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},l})),vs=l((e=>{const t=r(an({name:"widget",initialState:kn,reducers:{},extraReducers:e=>{gn.reducer(e),bn.reducer(e),yn.reducer(e)},asyncActions:{getMe:gn.action,getTenant:bn.action,getTenantAdminLinkSSO:yn.action}}),y,v,gs)(e);return class extends t{constructor(...e){super(...e),this.state=kn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),ms="widget-flow",bs=l((e=>{var t,o,s;return s=class extends(r(y,ne,vs,ln,v,re)(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=dn(ms);r&&(!function(e){if(window.history.replaceState&&dn(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())}}(ms),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(cn({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme}));new X((()=>{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(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()})),t.afterClose=()=>{t.remove()},t.open()},s})),ws=e=>e.tenant.data,ys=e=>e.tenantAdminLinkSSO.data,ks=yt(ws,(e=>e.customAttributes||{})),Ss=yt(ws,(e=>e.name||"")),Is=yt(ws,(e=>e.selfProvisioningDomains||[])),Cs=yt(ws,(e=>e.enforceSSOExclusions||[])),xs=yt(ws,(e=>e.enforceSSO||!1)),Os=l((e=>class extends(r(re,k)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Es=l((e=>{const t=r(j,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(`tenant-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}}));const js=l((e=>{var t,o,a;return a=class extends(r(v,y,N,H,Es,vs)(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);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()])}catch(e){}const r=this.state.me.error||(e=>e.tenant.error)(this.state)||(e=>e.tenantAdminLinkSSO.error)(this.state);if(r){this.contentRootElement.innerHTML="";const e="object"==typeof r&&null!==r&&"message"in r?r.message:String(r)||"An error occurred";this.contentRootElement.append(function({mainMessage:e="An error occurred"}){const t=document.createElement("div");t.setAttribute("data-id","widget-error"),t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="72px 36px",t.style.background="#fff",t.style.borderRadius="12px",t.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",t.style.margin="32px auto",t.style.maxWidth="400px";const n=document.createElement("div");n.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',n.style.marginBottom="12px",t.appendChild(n);const i=document.createElement("div");return i.textContent=e,i.style.fontWeight="bold",i.style.fontSize="20px",i.style.color="#222",i.style.textAlign="center",i.style.marginTop="8px",t.appendChild(i),t}({mainMessage:e}))}else yield i(this,t,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),As=l((e=>{var t,o,s,l;return l=class extends(r(Os,vs,v,js,ln,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,a((e=>{this.tenantAdminLinkSSODriver.href=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",o).call(this),i(this,s,"f").call(this,ys(this.state)),this.subscribe(i(this,s,"f").bind(this),ys)}))}},s=new WeakMap,t=new WeakSet,o=function(){this.tenantAdminLinkSSODriver=new Y((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},l}));var Rs;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Rs||(Rs={}));const Us=l((e=>{var t,o,s,l,c,d,u,h,p,f,g;return g=class extends(r(Os,vs,v,js,ln,ne)(e)){constructor(){super(...arguments),t.add(this),o.set(this,{}),s.set(this,{}),l.set(this,{}),c.set(this,{}),h.set(this,a((e=>{var n;const o=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(o).forEach((n=>{const o=n.getAttribute("data-id").replace("customAttributes.",""),r=n.getAttribute("data-type")||Rs.TEXT,s=e[o],a=new ee(n,{logger:this.logger});a.value=((e,t)=>e===Rs.DATE&&t?new Date(t).toLocaleString():e===Rs.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString())(r,s),i(this,t,"m",p).call(this,n,o,a,r,o,s),i(this,t,"m",f).call(this,n,o,a)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,h,"f").call(this,ks(this.state)),this.subscribe(i(this,h,"f").bind(this),ks)}))}},o=new WeakMap,s=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,d=function(e,t,n,r){var a,l;const c=t===Rs.ARRAY?(r||[]).join(","):r;null===(a=i(this,o,"f")[e])||void 0===a||a.setContent(cn({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({customAttributes:{[n]:c}})})),null===(l=i(this,s,"f")[e])||void 0===l||l.onSuccess((()=>{var t;null===(t=i(this,o,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},u=function(e){var t,n;null===(t=i(this,l,"f")[e])||void 0===t||t.setContent(cn({projectId:this.projectId,flowId:e,tenant:this.tenantId,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,l,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},p=function(e,n,r,a,l,c){const u=e.getAttribute("edit-flow-id");u&&(i(this,o,"f")[u]=this.createModal({"data-id":`edit-${n}`}),i(this,s,"f")[u]=new X((()=>{var e,t;return null===(t=null===(e=i(this,o,"f")[u])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,o,"f")[u].beforeOpen=i(this,t,"m",d).bind(this,u),r.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,o,"f"))||void 0===e?void 0:e[u])||void 0===t||t.open()})),i(this,t,"m",d).call(this,u,a,l,c),this.syncFlowTheme(i(this,s,"f")[u]))},f=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,l,"f")[r]=this.createModal({"data-id":`delete-${n}`}),i(this,c,"f")[r]=new X((()=>{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].beforeOpen=i(this,t,"m",u).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,l,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r),this.syncFlowTheme(i(this,c,"f")[r]))},g})),Ts=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,b;return b=class extends(r(Os,vs,v,js,ln,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.tenantEmailDomainsDriver.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,Is(this.state)),this.subscribe(i(this,m,"f").bind(this),Is)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.tenantEmailDomainsDriver.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),o(this,l,new X((()=>{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").beforeOpen=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(cn({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({tenantEmailDomains:Is(this.state)})})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),o(this,d,new X((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").beforeOpen=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(cn({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantEmailDomainsDriver=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),_s=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,b;return b=class extends(r(Os,vs,v,js,ln,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.tenantSSOExclusionsDriver.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,Cs(this.state)),this.subscribe(i(this,m,"f").bind(this),Cs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.tenantSSOExclusionsDriver.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),o(this,l,new X((()=>{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").beforeOpen=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(cn({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({enforceSSOExclusions:Cs(this.state)})})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),o(this,d,new X((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").beforeOpen=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(cn({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantSSOExclusionsDriver=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),Ps=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,b;return b=class extends(r(Os,vs,v,js,ln,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.tenantEnforceSSODriver.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,xs(this.state)),this.subscribe(i(this,m,"f").bind(this),xs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.tenantEnforceSSODriver.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),o(this,l,new X((()=>{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").beforeOpen=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(cn({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({enforceSSO:xs(this.state)})})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEnforceSSODriver.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),o(this,d,new X((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").beforeOpen=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(cn({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantEnforceSSODriver=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),Ls=l((e=>{var t,s,l,c,d,u,h,p;return p=class extends(r(Os,vs,v,js,ln,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.tenantNameDriver.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",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Ss(this.state)),this.subscribe(i(this,h,"f").bind(this),Ss)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,t=new WeakSet,c=function(){this.tenantNameDriver.editFlowId&&(o(this,s,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),o(this,l,new X((()=>{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").beforeOpen=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this),this.syncFlowTheme(i(this,l,"f")))},d=function(){i(this,s,"f").setContent(cn({projectId:this.projectId,flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({tenantName:Ss(this.state)})})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getTenant()}))},u=function(){this.tenantNameDriver=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},p})),$s=l((e=>{var t,s,a,l,c,d,u;return u=class extends(r(Os,vs,v,js,ln,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}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",d).call(this),i(this,t,"m",l).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(o(this,s,this.createModal({"data-id":"password-policy"}),"f"),o(this,a,new X((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",c).bind(this),i(this,t,"m",c).call(this),this.syncFlowTheme(i(this,a,"f")))},c=function(){i(this,s,"f").setContent(cn({projectId:this.projectId,flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId,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(),this.actions.getTenant()}))},d=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new te((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},u})),Ms=l((e=>class extends(r(U,re,bs,js,Ls,Ts,_s,Ps,Us,As,$s)(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)}))}})),Ws=r((e=>class extends(Ms(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 bc})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.3.1"}}}))}}))(HTMLElement),Ns="undefined"!=typeof localStorage,Ds="J151000",Fs="E103205",qs=Ns&&localStorage.getItem("base.content.url")||"",zs="base.ui.components.url";Ns&&localStorage.getItem(zs),Ns&&localStorage.getItem(zs);const Ks="descope-login-flow",Hs="code",Vs="redirect_mode",Js="data-exclude-field",Bs="data-exclude-next",Xs="dls_last_auth",Ys="state_id",Gs="saml_idp_state_id",Zs="saml_idp_username",Qs="descope_idp_initiated",ea="sso_app_id",ta="third_party_app_id",na="third_party_app_state_id",ia="oidc_login_hint",oa="oidc_prompt",ra="oidc_resource",sa="oidc_error_redirect_uri",aa="application_scopes",la="data-type",ca="redirect",da="poll",ua="webauthnCreate",ha="webauthnGet",pa="nativeBridge",fa="loadForm",ga="submit",va="polling",ma=["descope-multi-select-combo-box","descope-text-area"],ba=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var wa;!function(e){e.backward="backward",e.forward="forward"}(wa||(wa={}));const ya=["descope-enriched-text"];function ka(e){return new URLSearchParams(window.location.search).get(e)}function Sa(e){if(window.history.replaceState&&ka(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 Ia(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?wa.forward:n<i?wa.backward:void 0}const Ca=e=>{let[t="",n=""]=(ka(Ks)||"").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 xa(){Sa(Ks)}const Oa=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Ea=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=Ca(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&xa();const r=ka("t")||void 0;r&&Sa("t");const s=ka(Hs)||void 0;s&&Sa(Hs);const a="popup"===ka(Vs);a&&Sa(Vs);const l=ka("err")||void 0;l&&Sa("err");const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:ka("ra-challenge"),redirectAuthCallbackUrl:ka("ra-callback"),redirectAuthBackupCallbackUri:ka("ra-backup-callback"),redirectAuthInitiator:ka("ra-initiator")},p=ka(Ys);p&&Sa(Ys);const f=ka(Gs);f&&Sa(Gs);const g=ka(Zs);f&&Sa(Zs);const v=ka(Qs);v&&Sa(Qs);const m=ka(ea);m&&Sa(ea);const b=ka(ta);b&&Sa(ta);const w=ka(na);w&&Sa(na);const y=ka(aa);y&&Sa(aa);const k=ka(ia);k&&Sa(ia);const S=ka(oa);S&&Sa(oa);const I=ka(sa);I&&Sa(sa);const C=ka(ra);return C&&Sa(ra),{executionId:n,stepId:i,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,samlIdpUsername:g,descopeIdpInitiated:"true"===v,ssoAppId:m,oidcLoginHint:k,oidcPrompt:S,oidcErrorRedirectUri:I,oidcResource:C,thirdPartyAppId:b,thirdPartyAppStateId:w,applicationScopes:y}}},ja=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}})},Aa=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}};function Ra(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 Ua=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,oidcResource:l,thirdPartyAppId:c,thirdPartyAppStateId:d,applicationScopes:u})=>!(!e||t||n||i||o||r||s||a||l||c||d||u),Ta=e=>null==e?void 0:e.submit(),_a=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Pa=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function La(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const $a=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Ma(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Wa,Na,Da,Fa;function qa(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(!qa(r,s))return!1}else if(r!==s)return!1}return!0}let za=class{constructor(e={},{forceUpdate:t=!1}={}){Wa.set(this,void 0),Na.set(this,{}),Da.set(this,0),Fa.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,Wa,"f")):e,n=Object.assign(Object.assign({},i(this,Wa,"f")),t),r=i(this,Wa,"f");o(this,Wa,n,"f"),Object.freeze(i(this,Wa,"f")),setTimeout((()=>{Object.values(i(this,Na,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,Fa,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!qa(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,Wa,e,"f"),o(this,Fa,t,"f")}get current(){return Object.assign({},i(this,Wa,"f"))}set forceUpdate(e){o(this,Fa,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,Da,i(this,Da,"f")+1,"f"),i(this,Na,"f")[i(this,Da,"f")]={cb:e,selector:t,forceUpdate:n},i(this,Da,"f").toString()}unsubscribe(e){const t=!!i(this,Na,"f")[e];return t&&delete i(this,Na,"f")[e],t}unsubscribeAll(){return o(this,Na,{},"f"),!0}};Wa=new WeakMap,Na=new WeakMap,Da=new WeakMap,Fa=new WeakMap;const Ka=["*","#","/","(",")","[","]","_","<",">","`"],Ha=e=>"string"!=typeof e?e:e.replace((e=>{const t=Ka.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),Va=["disabled"],Ja=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Js}])`)).forEach((e=>{e.value=n}))}))},Ba=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Xa=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?Ha(Ba(t,i)):Ba(t,i))),Ya=(e,t,n)=>{e.querySelectorAll(`[${la}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Ga=(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})`))},Za=(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=>ya.includes(e))(e.localName);e.textContent=Xa(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",Xa(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=Xa(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)},Qa=ja((()=>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 Ra(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let el;const tl=(e,t)=>{el?el.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},nl=e=>el?el.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,il="dls_ab_testing_id",ol=()=>{const e=nl(il);if(!e){const e=Math.floor(100*Math.random()+1);return tl(il,e.toString()),e}return Number(e)},rl={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function sl(e){const t={};try{Object.assign(t,JSON.parse(nl(Xs)))}catch(e){}return(null==t?void 0:t.loginId)||e?t:{}}function al(e,t){(null==e?void 0:e.authMethod)&&(t&&!(null==e?void 0:e.loginId)||tl(Xs,JSON.stringify(e)))}const ll=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?ll(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),ll(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}),[]),cl=l((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r}));var dl,ul,hl,pl,fl,gl,vl,ml,bl,wl,yl,kl,Sl,Il,Cl,xl,Ol,El,jl,Al,Rl,Ul,Tl;const _l=r(re,j,cl,q)(HTMLElement);class Pl extends _l{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),dl.add(this),hl.set(this,!1),pl.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,dl,"m",Ul).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)}},fl.set(this,new za),gl.set(this,new za),vl.set(this,{}),this.getComponentsContext=()=>i(this,vl,"f"),this.nextRequestStatus=new za({isLoading:!1}),ml.set(this,void 0),bl.set(this,{popstate:i(this,dl,"m",Il).bind(this),componentsContext:i(this,dl,"m",jl).bind(this)}),wl.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,wl,e,"f"),i(this,dl,"m",kl).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 ll(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,pl,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,pl,e,"f"),(e=>{el=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}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,gl,"f").subscribe(i(this,dl,"m",Rl).bind(this)),i(this,gl,"f").update({isDebug:this.debug}),i(this,dl,"m",Sl).call(this),yield i(this,dl,"m",Ol).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,dl,"m",Tl).call(this);const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=Ea(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,bl,"f").popstate),window.addEventListener("components-context",i(this,bl,"f").componentsContext),i(this,fl,"f").subscribe(i(this,dl,"m",xl).bind(this)),i(this,fl,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},g)),o(this,hl,!0,"f")}))}disconnectedCallback(){i(this,fl,"f").unsubscribeAll(),i(this,gl,"f").unsubscribeAll(),i(this,dl,"m",Al).call(this),window.removeEventListener("popstate",i(this,bl,"f").popstate),window.removeEventListener("components-context",i(this,bl,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,hl,"f")&&t!==n&&ul.observedAttributes.includes(e)){i(this,dl,"m",Sl).call(this);const o=null===t;i(this,fl,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,xa()),{[Oa(e)]:n,stepId:r,executionId:s}})),i(this,gl,"f").update({isDebug:this.debug})}}}var Ll,$l,Ml,Wl,Nl,Dl,Fl,ql,zl,Kl,Hl,Vl,Jl,Bl,Xl,Yl,Gl,Zl,Ql,ec,tc,nc,ic,oc,rc,sc,ac,lc,cc,dc,uc,hc,pc,fc,gc,vc;ul=Pl,hl=new WeakMap,pl=new WeakMap,fl=new WeakMap,gl=new WeakMap,vl=new WeakMap,ml=new WeakMap,bl=new WeakMap,wl=new WeakMap,dl=new WeakSet,yl=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},kl=function(){i(this,dl,"m",yl).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Sl=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];ul.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Oa(t)])throw Error(`${t} cannot be empty`)}))},Il=function(){const{stepId:e,executionId:t}=Ca(this.flowId);i(this,fl,"f").update({stepId:e,executionId:t})},Cl=function(e,t){ss&&"function"==typeof ss||this.logger.error("SDK was not loaded properly",ss,JSON.stringify(ss));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},ul.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,pl,"f")&&(o.customStorage=i(this,pl,"f")),this.sdk=ss(o),["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:Ds,errorDescription:e.toString()}}}}))}))},xl=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,dl,"m",Cl).call(this,t,n)}i(this,wl,"f").call(this,e)}))},Ol=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,dl,"m",El).call(this))}))},El=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(qs||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}}))},jl=function(e){o(this,vl,Object.assign(Object.assign({},i(this,vl,"f")),e.detail),"f")},Al=function(){var e;null===(e=i(this,ml,"f"))||void 0===e||e.remove(),o(this,ml,null,"f")},Rl=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,ml,document.createElement("descope-debugger"),"f"),Object.assign(i(this,ml,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Yc})),document.body.appendChild(i(this,ml,"f"))):i(this,dl,"m",Al).call(this)}))},Ul=function(e,t){var n;e&&this.debug&&(null===(n=i(this,ml,"f"))||void 0===n||n.updateData({title:e,description:t}))},Tl=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=ma.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},Pl.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.48.2"}};class mc extends Pl{static set sdkConfigOverrides(e){Pl.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Pl.sdkConfigOverrides}constructor(){const e=new za({deferredRedirect:!1});super(e.update.bind(e)),Ll.add(this),this.stepState=new za({}),$l.set(this,void 0),Ml.set(this,null),Wl.set(this,null),Nl.set(this,{visibilitychange:i(this,Ll,"m",Dl).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},Bl.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Yl.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,Ll,"m",Gl).call(this,t):t()})),Zl.set(this,((e,t,r,s,a=!1)=>{const l=[Fs,"E103202"];if(this.flowState.current.action===da){this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,$l,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,va,r,s,{}),h=document.hidden&&!a&&Date.now()-c>d+500;let p;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;p=yield Ra(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Zl,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===Ds)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Zl,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,Zl,"f").call(this,e,t,r,s),i(this,ec,"f").call(this,p)}))),d),"f")}})),Ql.set(this,(()=>{clearTimeout(i(this,$l,"f")),o(this,$l,null,"f")})),ec.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,f,g;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,Ll,"m",gc).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==Fs||!this.isRestartOnError||i(this,Ll,"m",Jl).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(f=e.data)||void 0===f?void 0:f.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==da&&i(this,Ql,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&al(w);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void i(this,Ll,"m",gc).call(this,"success",t)}this.storeLastAuthenticatedUser&&al(w,!0),k&&window.open(k,"_blank");const{executionId:S,stepId:I,stepName:C,screen:x,redirect:O,webauthn:E,error:j,samlIdpResponse:A,nativeResponse:R}=e.data,U=Date.now();y!==da?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${m}`,"",{screen:x,status:m,stepId:I,stepName:C,action:y,error:j}),(null===(g=x.state)||void 0===g?void 0:g.clientScripts)&&o(this,Wl,this.loadSdkScripts(x.state.clientScripts),"f"),this.flowState.update({stepId:I,stepName:C,executionId:S,action:y,redirectTo:null==O?void 0:O.url,redirectIsPopup:null==O?void 0:O.isPopup,screenId:null==x?void 0:x.id,screenState:null==x?void 0:x.state,webauthnTransactionId:null==E?void 0:E.transactionId,webauthnOptions:null==E?void 0:E.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==R?void 0:R.type,nativePayload:null==R?void 0:R.payload,reqTimestamp:U})):this.flowState.update({action:y,reqTimestamp:U})})),tc.set(this,ja((()=>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)}}))))),ac.set(this,null),hc.set(this,Pa(((e,t)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,Ll,"m",rc).call(this)){const o=null==e?void 0:e.getAttribute("id");i(this,Ll,"m",lc).call(this,e);const r=yield i(this,Ll,"m",sc).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,Wl,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,Wl,"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 Ra(5e3,Promise.all(e),null))}const l=this.getComponentsContext(),c=Object.assign(Object.assign(Object.assign(Object.assign({},l),s),r),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(o,c),this.nextRequestStatus.update({isLoading:!1}),i(this,Ll,"m",cc).call(this,r)}}))))),this.flowState=e}nativeResume(e,t){var n,o,r,s,a;const l=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let{exchangeCode:e}=l;e||(e=null===(n=new URL(l.url).searchParams)||void 0===n?void 0:n.get(Hs)),null===(r=(o=this.nativeCallbacks).complete)||void 0===r||r.call(o,{exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(l.url),t=e.searchParams.get("t"),n=e.searchParams.get(Ks).split("_").pop();i(this,Ql,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=l;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=l,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,l)}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:{[Ma(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i;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===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}yield this.injectNpmLib("@descope/flow-scripts","1.0.11",`dist/${e.id}.js`);const r=null===(i=globalThis.descope)||void 0===i?void 0:i[e.id];return new Promise(((n,i)=>{try{const i=r(e.initArgs,{baseUrl:this.baseUrl,ref:this},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.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,Ll,"m",Hl).call(this),window.addEventListener("visibilitychange",i(this,Nl,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,Ql,"f").call(this),null===(e=i(this,Ml,"f"))||void 0===e||e.abort(),o(this,Ml,null,"f"),window.removeEventListener("visibilitychange",i(this,Nl,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=La(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:S,exchangeError:I,webauthnTransactionId:C,webauthnOptions:x,redirectAuthCodeChallenge:O,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:A,locale:R,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:_,nativeResponseType:P,nativePayload:L,reqTimestamp:$}=e,M=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let W,N,D;const F=ol(),{outboundAppId:q}=this,{outboundAppScopes:z}=this,K=this.sdk.getLastUserLoginId(),H=yield this.getFlowConfig(),V=yield this.getProjectConfig(),J=Object.entries(V.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),B=E&&O?{callbackUrl:E,codeChallenge:O,backupCallbackUri:j}:void 0,X=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let Y={};if(!p){const e=[...H.clientScripts||[],...H.sdkScripts||[]];if(H.conditions){let t=[];({startScreenId:W,conditionInteractionId:D,startScreenName:N,clientScripts:t,componentsConfig:Y}=((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=rl[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:K,code:k,token:y,abTestingKey:F,lastAuth:sl(K)},H.conditions)),e.push(...t||[])}else H.condition?({startScreenId:W,conditionInteractionId:D}=((e,t)=>{var n;const i=null===(n=rl[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}})(H.condition,{loginId:K,code:k,token:y,abTestingKey:F,lastAuth:sl(K)})):(N=H.startScreenName,W=H.startScreenId);if(o(this,Wl,this.loadSdkScripts(e),"f"),H.fingerprintEnabled&&H.fingerprintKey?yield Or(H.fingerprintKey,this.baseUrl):rr(Cr),!Ua(W,M)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},M),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:sl(K),abTestingKey:F,locale:La(R).locale,nativeOptions:X,outboundAppId:q,outboundAppScopes:z}),D,"",V.componentsVersion,J,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),M.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),M.oidcLoginHint?{externalId:M.oidcLoginHint}:{}));return i(this,ec,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:S,code:k,exchangeError:I,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),S&&(s("code")&&k||s("exchangeError")&&I))return void i(this,Ll,"m",vc).call(this,p,k,I);if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const e=yield this.sdk.flow.next(p,h,ga,H.version,V.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return i(this,ec,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===fa&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U||!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(U,T,_||"",Ta)}if(f===ca&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===A&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const n=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const n=t?this.popupOrigin:window.location.origin;if(e.origin!==n)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${n}"`);const{action:i,data:o}=e.data||{};"code"===i&&this.flowState.update({code:o.code,exchangeError:o.exchangeError})};let o;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),i(this,Ll,"m",gc).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(t)window.addEventListener("message",n),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",n)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=n,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),i(this,Ll,"m",gc).call(this,"popupclosed",{});return}if(f===ua||f===ha){if(!C||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,Ml,"f"))||void 0===l||l.abort(),o(this,Ml,null,"f");try{e=f===ua?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const n=yield this.sdk.flow.next(p,h,ga,H.version,V.componentsVersion,{transactionId:C,response:e,failure:t});i(this,ec,"f").call(this,n)}if(f===pa)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,ga,H.version,V.componentsVersion,e);i(this,ec,"f").call(this,t)})),void i(this,Ll,"m",zl).call(this,P,L);if(s("action")&&i(this,Zl,"f").call(this,p,h,H.version,V.componentsVersion),!g&&!W)return void this.loggerWrapper.warn("No screen was found to show");const G=W||g,Z=yield this.getHtmlFilenameWithLocale(R,G),{oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,oidcResource:ne,samlIdpUsername:ie}=M,oe={direction:Ia(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:K,name:this.sdk.getLastUserDisplayName()||K},componentsConfig:Object.assign(Object.assign(Object.assign({},H.componentsConfig),Y),null==v?void 0:v.componentsConfig)}),htmlFilename:`${G}.html`,htmlLocaleFilename:Z,screenId:G,stepName:e.stepName||N,samlIdpUsername:ie,oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,oidcResource:ne,action:f},re=sl(K);Ua(W,M)?oe.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:B},M),{lastAuth:re,preview:this.preview,abTestingKey:F,client:this.client}),w&&{redirectUrl:w}),{locale:La(R).locale,nativeOptions:X,outboundAppId:q,outboundAppScopes:z}),D,e,V.componentsVersion,J,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),$a(t)),k&&{exchangeCode:k,idpInitiated:!0}),M.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,ec,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(oe.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,e,H.version,V.componentsVersion,$a(t));return i(this,ec,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",oe.screenId),yield i(this,Ll,"m",Xl).call(this,oe),this.stepState.update(oe)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d}=e;this.loggerWrapper.debug("Rendering a flow screen");const u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u);this.sdk.webauthn.helpers.isSupported()?yield i(this,Ll,"m",ic).call(this,h,c):(e=>{e.querySelectorAll(`descope-button[${la}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(h),!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),Za(h,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(h,f);const g=()=>n(this,void 0,void 0,(function*(){var n,o;yield p;const r=this.contentRootElement;((e,t)=>{Ga(e,"descope-totp-image",t)})(r,null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image),((e,t)=>{Ga(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=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,h,d.cssVars,this.loggerWrapper),r.replaceChildren(h);const s=!t.htmlFilename;setTimeout((()=>{i(this,Ll,"m",dc).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const i=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void i();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),i(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{Ja(e,null==t?void 0:t.inputs),Ja(e,null==t?void 0:t.form)})(r,d),i(this,Ll,"m",oc).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),Aa(r,this.autoFocus,s)})),i(this,Ll,"m",fc).call(this,c),r.querySelector(`[${la}="polling"]`)&&c(va,{})}));l?i(this,Ll,"m",Gl).call(this,g):g()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Js}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}$l=new WeakMap,Ml=new WeakMap,Wl=new WeakMap,Nl=new WeakMap,Bl=new WeakMap,Yl=new WeakMap,Zl=new WeakMap,Ql=new WeakMap,ec=new WeakMap,tc=new WeakMap,ac=new WeakMap,hc=new WeakMap,Ll=new WeakSet,Dl=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Fl=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,Ll,"m",zl).call(this,"beforeScreen",{screen:e,context:t})}))}))},ql=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,Ll,"m",zl).call(this,"afterScreen",{screen:e})},zl=function(e,t){i(this,Ll,"m",gc).call(this,"bridge",{type:e,payload:t})},Kl=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(`[${la}="${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()},Hl=function(){var e,n,o;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=t(void 0===n?{}:n,["errorText","errorType"]),o=t(e,["screenState"]);return Object.assign(Object.assign({},o),{screenState:i})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,Ll,"m",Kl).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,Ll,"m",Vl).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0})},Vl=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Aa(this.contentRootElement,this.autoFocus,!1))},Jl=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")}))},Xl=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=(e=>{var t,n,i;const o=(r=e.screenState,s=(e,t)=>ba.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(0,e)))));var r,s;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(o.error={text:a,type:l}),e.action&&(o.action=e.action),(null===(i=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===i?void 0:i.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o})(t(r,["next","stepName"]));let c=yield i(this,Ll,"m",Fl).call(this,a,l,s);c||(c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,l,s,this)));const d=!this.stepState.current.htmlFilename;if(i(this,Yl,"f").call(this,c),i(this,Bl,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,Bl,c,"f"),c?this.stepState.unsubscribeAll():i(this,Ll,"m",Hl).call(this)}c&&(this.loggerWrapper.debug("Showing a custom screen"),i(this,Ll,"m",oc).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName})),this.stepState.forceUpdate=c}))},Gl=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")},nc=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)}))}},ic=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,Ml,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Qa())){const{options:e,transactionId:r}=(yield i(this,tc,"f").call(this))||{};e&&r&&(i(this,Ll,"m",nc).call(this,s),o(this,Ml,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,Ml,"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)})))}}))},oc=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,Ll,"m",gc).call(this,"ready",{}),t||i(this,Ll,"m",ql).call(this,n),i(this,Ll,"m",gc).call(this,"page-updated",{screenName:n}),i(this,Ll,"m",gc).call(this,"screen-updated",{screenName:n})},rc=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},sc=function(){return n(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>n(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},lc=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),r=()=>n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",r),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const n=yield this.getFlowConfig(),i=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(i)})),s=()=>{var e;window.removeEventListener("pageshow",i(this,ac,"f")),o(this,ac,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),r())}),"f"),window.addEventListener("pageshow",i(this,ac,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&r(),this.removeEventListener("popupclosed",r),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},a=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?(this.addEventListener("popupclosed",r,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(a),s())}))},cc=function(e={}){var t,n;const i=_a(e,["externalId","email","phone"]),o=_a(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)}},dc=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,Ll,"m",uc).call(this,e)))},uc=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)}))},pc=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,hc,"f").call(this,t,e)}))}))},fc=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${Bs}]), [data-type="button"]:not([${Bs}]`).forEach((t=>{t.onclick=()=>{i(this,hc,"f").call(this,t,e)}})),i(this,Ll,"m",pc).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Js}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},gc=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},vc=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===o&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",mc);var bc=Object.freeze({__proto__:null,default:mc});customElements.define("descope-tenant-profile-widget",Ws);const wc=(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 yc,kc,Sc,Ic,Cc,xc,Oc,Ec,jc,Ac;const Rc=document.createElement("template");Rc.innerHTML=`\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;const Uc=r(q)(HTMLElement);class Tc extends Uc{constructor(){var e;super(),yc.add(this),kc.set(this,new f({messages:[]})),Sc.set(this,void 0),Ic.set(this,void 0),Cc.set(this,void 0),xc.set(this,{resize:i(this,yc,"m",Ac).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Rc.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,Sc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Ic,i(this,Sc,"f").querySelector(".content"),"f"),o(this,Cc,i(this,Sc,"f").querySelector(".header"),"f")}updateData(e){i(this,kc,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=wc(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,Sc,"f"),i(this,Cc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,xc,"f").resize),(e=i(this,Sc,"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,Sc,"f").onresize=i(this,yc,"m",jc).bind(this),i(this,kc,"f").subscribe(i(this,yc,"m",Oc).bind(this))}disconnectedCallback(){i(this,kc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,xc,"f").resize)}}kc=new WeakMap,Sc=new WeakMap,Ic=new WeakMap,Cc=new WeakMap,xc=new WeakMap,yc=new WeakSet,Oc=function(e){i(this,yc,"m",Ec).call(this,e),i(this,yc,"m",jc).call(this)},Ec=function(e){i(this,Ic,"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("")},jc=function(){i(this,Ic,"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)}))},Ac=function(){const[e,t]=wc(i(this,Sc,"f"),Number.parseInt(i(this,Sc,"f").style.left,10),Number.parseInt(i(this,Sc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Sc,"f").style.top=`${t}px`,i(this,Sc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Tc);var _c=Object.freeze({__proto__:null,default:Tc});const Pc=(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))]},Lc=(e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Pc(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c};var $c,Mc,Wc,Nc,Dc,Fc,qc,zc,Kc,Hc,Vc;const Jc=document.createElement("template");Jc.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const Bc=r(q)(HTMLElement);class Xc extends Bc{constructor(){super(),$c.add(this),Mc.set(this,new za({messages:[]})),Wc.set(this,void 0),Nc.set(this,void 0),Dc.set(this,void 0),Fc.set(this,{resize:i(this,$c,"m",Vc).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Jc.content.cloneNode(!0)),o(this,Wc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Nc,i(this,Wc,"f").querySelector(".content"),"f"),o(this,Dc,i(this,Wc,"f").querySelector(".header"),"f"),i(this,$c,"m",qc).call(this)}updateData(e){i(this,Mc,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),Lc(i(this,Wc,"f"),i(this,Dc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Fc,"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,Wc,"f")),i(this,Wc,"f").onresize=i(this,$c,"m",Hc).bind(this),i(this,Mc,"f").subscribe(i(this,$c,"m",zc).bind(this))}))}disconnectedCallback(){i(this,Mc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Fc,"f").resize)}}Mc=new WeakMap,Wc=new WeakMap,Nc=new WeakMap,Dc=new WeakMap,Fc=new WeakMap,$c=new WeakSet,qc=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,Wc,"f").style.top="32px",i(this,Wc,"f").style.left=window.innerWidth-300-32+"px"},zc=function(e){i(this,$c,"m",Kc).call(this,e),i(this,$c,"m",Hc).call(this)},Kc=function(e){i(this,Nc,"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("")},Hc=function(){i(this,Nc,"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)}))},Vc=function(){const[e,t]=Pc(i(this,Wc,"f"),Number.parseInt(i(this,Wc,"f").style.left,10),Number.parseInt(i(this,Wc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Wc,"f").style.top=`${t}px`,i(this,Wc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Xc);var Yc=Object.freeze({__proto__:null,default:Xc});return Ws}();
|
|
5
|
+
this["descope-tenant-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{let t,n;return(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)},l=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}let f=class{constructor(e={},{forceUpdate:t=!1}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,c,"f")):e,n=Object.assign(Object.assign({},i(this,c,"f")),t);if(i(this,h,"f")||!p(i(this,c,"f"),n)){const e=i(this,c,"f");o(this,c,n,"f"),Object.freeze(i(this,c,"f")),setTimeout((()=>{Object.values(i(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,c,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,c,"f"))}subscribe(e){return o(this,u,i(this,u,"f")+1,"f"),i(this,d,"f")[i(this,u,"f")]=e,i(this,u,"f").toString()}unsubscribe(e){const t=!!i(this,d,"f")[e];return t&&delete i(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const g=["error","warn","info","debug"],v=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,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,b=m&&localStorage.getItem("base.content.url")||"",w=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,y=l((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),k=l((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),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},s};S.missingAttrValidator=w;const I=l((e=>{const t=r(S({"project-id":w}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),C=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),x="Trying the next fallback URL...",O=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};function E({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 j=l((e=>{var t,n,s,a,l;const c=r(v,I,C)(e);return l=class extends c{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),l=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 O(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${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:l});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=b||this.baseStaticUrl;if(t)return E({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 l=E({projectId:this.projectId,filename:e,baseUrl:i(this,s,"f")});if(!a)return l;return[E({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),l]},l})),A=l((e=>{var t,n;const o=r(S({"project-id":w}))(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})),R=l((e=>{var t,n,s,a,l;const c=r(j,A,y)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,s,"f")||o(this,s,i(this,a,"f").call(this),"f"),i(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},l})),U=l((e=>{var t,n,s,a,l,c,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",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Pc})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),T=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],_=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},P=(e,t)=>new Promise(((n,i)=>{const o=(e=>{const t=document.createElement("script");return t.id=e,t})(e);o.onerror=e=>{o.setAttribute("status","error"),i(e)},o.onload=()=>{o.setAttribute("status","loaded"),n(o)},o.src=t.toString(),document.body.appendChild(o)})),L=e=>"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))})),$=l((e=>{const t=r(v)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[]){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"`),(async(e,t)=>{for(const i of e){const{id:e,url:o}=i,r=(n=e,document.querySelector(`script#${n}`));if(r)try{return await L(r),i}catch(e){t(i,!0)}else try{return await P(e,o),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="")=>e.reduce(((e,o)=>{const r=o;if(!r)return e;let s;try{s=new URL(r)}catch(e){throw new Error(`Invalid URL: ${r}`)}return"/"!==s.pathname||(s.pathname=`/npm/${t}@${n}/${i}`),[...e,{url:s,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${_(s)}`}]}),[]))([...i,this.baseCdnUrl,...T],e,t,n),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),M="base.ui.components.url",W=m&&localStorage.getItem(M),N=l((e=>{var t,n,s,a,l,c;const d=r(v,R,$)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get descopeUi(){return i(this,s,"f")||o(this,s,i(this,t,"m",l).call(this),"f"),i(this,s,"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",a).call(this,e))))}},s=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},a=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(", ")}"`)},l=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{return await this.injectNpmLib("@descope/web-components-ui",await i(this,t,"m",n).call(this),"dist/umd/index.js",[W]),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},c})),D=l((e=>{var t,n,o;const s=r(y,k)(e);return o=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class F{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const q=l((e=>{const t=r(D)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new F(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),z="content-root",K="root",H=l((e=>{const t=r(q)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${z}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${z} {\n height: 100%;\n }\n #${K} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(z),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),V="descope-modal";var J;let B=class{constructor(e,t){J.set(this,void 0),this.nodeName="",o(this,J,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,J,"f"))}get ele(){var e,t;const n="function"==typeof i(this,J,"f")?i(this,J,"f").call(this):i(this,J,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};J=new WeakMap;let X=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)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}},Y=class extends B{constructor(){super(...arguments),this.nodeName="descope-link"}get ele(){return super.ele}get href(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("href")}set href(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("href",null!=e?e:"")}};var G;let Z=class extends B{constructor(){super(...arguments),G.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,G,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,G,"f").content.cloneNode(!0)))}setContent(e){o(this,G,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};G=new WeakMap;let Q=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()}},ee=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)}}},te=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")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}};const ne=l((e=>{var t,n;const o=r(y,H,N)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Z{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(V);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([V]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ie="descope-notification";l((e=>{var t,n;const o=r(y,H,N)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Q{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ie);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([ie])}},t=new WeakMap,n}));const oe="theme",re=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',se=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m;const b=r(S({theme:re}),j,y,N,R,H,k,q)(e);return m=class extends b{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")||oe}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,f,"f").call(this),await Promise.all([i(this,t,"m",c).call(this),i(this,t,"m",d).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",c).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(M))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(M),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")}},l=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")},c=async function(){var e,r;const s=await i(this,t,"a",l);s&&(i(this,n,"f")||o(this,n,this.injectStyle(""),"f"),i(this,n,"f").replaceSync(((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"")))},d=async function(){var e,n;const o=await i(this,t,"a",l);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 ae=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),le=()=>Math.random().toString(36).substring(7).split("").join("."),ce={INIT:`@@redux/INIT${le()}`,REPLACE:`@@redux/REPLACE${le()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${le()}`};function de(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 ue(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 he(e){let t=typeof e;return t=ue(e),t}function pe(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${he(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: '${he(n)}'`);return n(pe)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${he(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),r=null}}}function h(e){if(!de(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${he(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: '${he(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=i(o,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:ce.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: '${he(e)}`);i=e,h({type:ce.REPLACE})},[ae]: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: '${he(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[ae](){return this}}}}}function fe(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ge(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&fe(`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:ce.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:ce.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 '${ce.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===ce.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(!de(e))return`The ${r} has unexpected type of "${he(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===ce.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&&fe(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||i.length!==Object.keys(e).length,s?a:e}}function ve(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function me(e){return de(e)&&"type"in e&&"string"==typeof e.type}var be=Symbol.for("immer-nothing"),we=Symbol.for("immer-draftable"),ye=Symbol.for("immer-state"),ke=[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 Se(e,...t){{const n=ke[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var Ie=Object.getPrototypeOf;function Ce(e){return!!e&&!!e[ye]}function xe(e){return!!e&&(Ee(e)||Array.isArray(e)||!!e[we]||!!e.constructor?.[we]||Te(e)||_e(e))}var Oe=Object.prototype.constructor.toString();function Ee(e){if(!e||"object"!=typeof e)return!1;const t=Ie(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)===Oe}function je(e,t){0===Ae(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function Ae(e){const t=e[ye];return t?t.type_:Array.isArray(e)?1:Te(e)?2:_e(e)?3:0}function Re(e,t){return 2===Ae(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ue(e,t,n){const i=Ae(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function Te(e){return e instanceof Map}function _e(e){return e instanceof Set}function Pe(e){return e.copy_||e.base_}function Le(e,t){if(Te(e))return new Map(e);if(_e(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ee(e)){if(!Ie(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[ye];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(Ie(e),n)}function $e(e,t=!1){return We(e)||Ce(e)||!xe(e)||(Ae(e)>1&&(e.set=e.add=e.clear=e.delete=Me),Object.freeze(e),t&&je(e,((e,t)=>$e(t,!0)))),e}function Me(){Se(2)}function We(e){return Object.isFrozen(e)}var Ne,De={};function Fe(e){const t=De[e];return t||Se(0,e),t}function qe(){return Ne}function ze(e,t){t&&(Fe("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ke(e){He(e),e.drafts_.forEach(Je),e.drafts_=null}function He(e){e===Ne&&(Ne=e.parent_)}function Ve(e){return Ne={drafts_:[],parent_:Ne,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Je(e){const t=e[ye];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[ye].modified_&&(Ke(t),Se(4)),xe(e)&&(e=Xe(t,e),t.parent_||Ge(t,e)),t.patches_&&Fe("Patches").generateReplacementPatches_(n[ye].base_,e,t.patches_,t.inversePatches_)):e=Xe(t,n,[]),Ke(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==be?e:void 0}function Xe(e,t,n){if(We(t))return t;const i=t[ye];if(!i)return je(t,((o,r)=>Ye(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return Ge(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),je(o,((o,s)=>Ye(e,i,t,o,s,n,r))),Ge(e,t,!1),n&&e.patches_&&Fe("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function Ye(e,t,n,i,o,r,s){if(o===n&&Se(5),Ce(o)){const s=Xe(e,o,r&&t&&3!==t.type_&&!Re(t.assigned_,i)?r.concat(i):void 0);if(Ue(n,i,s),!Ce(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(xe(o)&&!We(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Xe(e,o),t&&t.scope_.parent_||Ge(e,o)}}function Ge(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&$e(t,n)}var Ze={get(e,t){if(t===ye)return e;const n=Pe(e);if(!Re(n,t))return function(e,t,n){const i=tt(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_||!xe(i)?i:i===et(e.base_,t)?(it(e),e.copy_[t]=ot(i,e)):i},has:(e,t)=>t in Pe(e),ownKeys:e=>Reflect.ownKeys(Pe(e)),set(e,t,n){const i=tt(Pe(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=et(Pe(e),t),o=i?.[ye];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||Re(e.base_,t)))return!0;it(e),nt(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!==et(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,it(e),nt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Pe(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){Se(11)},getPrototypeOf:e=>Ie(e.base_),setPrototypeOf(){Se(12)}},Qe={};function et(e,t){const n=e[ye];return(n?Pe(n):e)[t]}function tt(e,t){if(!(t in e))return;let n=Ie(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ie(n)}}function nt(e){e.modified_||(e.modified_=!0,e.parent_&&nt(e.parent_))}function it(e){e.copy_||(e.copy_=Le(e.base_,e.scope_.immer_.useStrictShallowCopy_))}je(Ze,((e,t)=>{Qe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Qe.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Se(13),Qe.set.call(this,e,t,void 0)},Qe.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Se(14),Ze.set.call(this,e[0],t,n,e[0])};function ot(e,t){const n=Te(e)?Fe("MapSet").proxyMap_(e,t):_e(e)?Fe("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:qe(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=Ze;n&&(o=[i],r=Qe);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:qe()).drafts_.push(n),n}function rt(e){return Ce(e)||Se(10,e),st(e)}function st(e){if(!xe(e)||We(e))return e;const t=e[ye];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Le(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Le(e,!0);return je(n,((e,t)=>{Ue(n,e,st(t))})),t&&(t.finalized_=!1),n}var at=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&&Se(6),void 0!==n&&"function"!=typeof n&&Se(7),xe(e)){const o=Ve(this),r=ot(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?Ke(o):He(o)}return ze(o,n),Be(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===be&&(i=void 0),this.autoFreeze_&&$e(i,!0),n){const t=[],o=[];Fe("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}Se(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){xe(e)||Se(8),Ce(e)&&(e=rt(e));const t=Ve(this),n=ot(e,void 0);return n[ye].isManual_=!0,He(t),n}finishDraft(e,t){const n=e&&e[ye];n&&n.isManual_||Se(9);const{scope_:i}=n;return ze(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=Fe("Patches").applyPatches_;return Ce(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},lt=at.produce;at.produceWithPatches.bind(at),at.setAutoFreeze.bind(at),at.setUseStrictShallowCopy.bind(at),at.applyPatches.bind(at),at.createDraft.bind(at),at.finishDraft.bind(at);var ct=(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})}}},dt=(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})}},ut={inputStabilityCheck:"once",identityFunctionCheck:"once"};var ht=e=>Array.isArray(e)?e:[e];function pt(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 ft(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var gt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},vt=0,mt=1;function bt(){return{s:vt,v:void 0,o:null,p:null}}function wt(e,t={}){let n=bt();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=bt(),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=bt(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===mt)l=t.v;else if(l=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,l)&&(l=e,0!==r&&r--);o="object"==typeof l&&null!==l||"function"==typeof l?new gt(l):l}return a.s=mt,a.v=l,l}return s.clearCache=()=>{n=bt(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function yt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=wt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=ht(c),f=ht(u),g=pt(e),v=l((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){o++;const e=ft(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...ut,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ct},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:dt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=ft(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:l,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var kt=yt(wt),St=Object.assign(((e,t=kt)=>{!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:()=>St});function It(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var Ct=It(),xt=It;((...e)=>{const t=yt(...e)})(wt);var Ot="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?ve:ve.apply(null,arguments)},Et=e=>e&&"function"==typeof e.match;function jt(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=>me(t)&&t.type===e,n}function At(e){return"function"==typeof e&&"type"in e&&Et(e)}function Rt(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 Ut=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 Tt(e){return xe(e)?lt(e,(()=>{})):e}function _t(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 Pt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Lt(e,t,n){const i=$t(e,t,n);return{detectMutations:()=>Mt(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 Mt(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in i)l[e]=!0;const c=t.length>0;for(let o in l){const s=r?r+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Mt(e,t,n.children[o],i[o],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Wt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||de(e)}function Nt(e,t="",n=Wt,i,o=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),l=o.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Nt(c,a,n,i,o,r),s))return s}return r&&Dt(e)&&r.add(e),!1}function Dt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Dt(t))return!1;return!0}function Ft(e){return"boolean"==typeof e}var qt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Ut;if(t&&(Ft(t)?r.push(Ct):r.push(xt(t.extraArgument))),n){let e={};Ft(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=Pt,ignoredPaths:o,warnAfter:r=32}=e;const s=Lt.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>l=>{const c=Rt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(i){let e={};Ft(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=Wt,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!me(u))return c(u);const h=c(u),p=Rt(s,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Nt(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=Nt(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={};Ft(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=At}=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},zt=e=>t=>{setTimeout(t,e)},Kt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:zt(10),Ht=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Ut(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?Kt:"callback"===e.type?e.queueNotification:zt(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,l(c))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function Vt(e){const t=qt(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!de(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=ge(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(l=i(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=ve;o&&(c=Ot({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=ve(...a)(o.dispatch),{...o,dispatch:r}}}(...l),u=Ht(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return pe(a,r,c(...h))}function Jt(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)=>Et(e)?e.match(t):e(t))(e,t)))}var Xt=["name","message","stack","code"],Yt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Gt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Zt=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Xt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},Qt=(()=>{function e(e,t,n){const i=jt(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=jt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=jt(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||Zt)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new Yt(e,t),fulfillWithValue:(e,t)=>new Gt(e,t)})).then((t=>{if(t instanceof Yt)throw t;return t instanceof Gt?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof Yt?r(null,c,e,t.payload,t.meta):r(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(en)})}}),{pending:o,rejected:r,fulfilled:i,settled:Bt(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function en(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var tn=Symbol.for("rtk-slice-createasyncthunk");function nn(e,t){return`${e}/${t}`}function on(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 rn=function({creators:e}={}){const t=e?.asyncThunk?.[tn];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?Jt(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]=Jt(t);if(function(e){return"function"==typeof e}(e))n=()=>Tt(e());else{const t=Tt(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(Ce(e)){const i=n(e,t);return void 0===i?e:i}if(xe(e))return lt(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:nn(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?jt(e,s):jt(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);l&&i.addCase(u.rejected,l);c&&i.addMatcher(u.settled,c);i.exposeCaseReducer(t,{fulfilled:s||sn,pending:a||sn,rejected:l||sn,settled:c||sn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=_t(d,this,{insert:()=>new WeakMap});return _t(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=on(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 sn(){}var an="listenerMiddleware";jt(`${an}/add`),jt(`${an}/removeAll`),jt(`${an}/remove`);const ln=e=>l((t=>{const n=rn(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(v)(t)){constructor(...e){super(...e);const t=Vt({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{en(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(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 cn=l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),dn=(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 un(e){return new URLSearchParams(window.location.search).get(e)}const hn=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)}))}))},pn=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),fn=Qt("users/me",((e,{extra:{api:t}})=>t.user.me())),gn=hn(fn)({onFulfilled:(e,t)=>{e.me.data=t.payload}},pn((e=>e.me))),vn={action:fn,reducer:gn},mn=Qt("tenant/details",((e,{extra:{api:t}})=>t.tenant.details())),bn=hn(mn)({onFulfilled:(e,t)=>{e.tenant.data=t.payload}},pn((e=>e.tenant))),wn={action:mn,reducer:bn},yn=Qt("tenant/adminLinkSso",((e,{extra:{api:t}})=>t.tenant.adminLinkSso())),kn={action:yn,reducer:hn(yn)({onFulfilled:(e,t)=>{var n;e.tenantAdminLinkSSO.data=(null===(n=t.payload)||void 0===n?void 0:n.adminSSOConfigurationLink)||""}},pn((e=>e.tenantAdminLinkSSO)))},Sn={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:""}};class In extends Error{}function Cn(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 xn(e,t){if("string"!=typeof e)throw new In("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 In(`Invalid token specified: missing part #${n+1}`);let o;try{o=Cn(i)}catch(e){throw new In(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new In(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}In.prototype.name="InvalidTokenError";var On={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const En="<region>",jn=`https://api.${En}descope.com`,An=6e5,Rn="dct",Un=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},Tn=[521,524],_n=e=>async(...t)=>{let n=await e(...t);Tn.includes(n.status)&&(n=await e(...t),n.retries=1);const i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n};let Pn;const Ln=()=>{if(Pn)return Pn;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 Pn=`${t}-${n}`,Pn};var $n;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}($n||($n={}));const Mn=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(En,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},Wn=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),Nn={"Content-Type":"application/json"},Dn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Fn=(e,t)=>{const n={"x-descope-sdk-session-id":Ln(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.52.2","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},qn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var zn=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||jn,c=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Un().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await _n(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return Un().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:_n(n)})(o,a),d=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:Wn(Dn(t,g),Fn(t,i),(null==n?void 0:n.baseHeaders)||{},qn(v)?Nn:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const b=await c(Mn({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==b?void 0:b.clone()),null==r?void 0:r.transformResponse){const e=await b.json(),t=((null===(o=b.headers)||void 0===o?void 0:o.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({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return b};return{get:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:$n.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:$n.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:$n.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:$n.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:$n.delete,token:i}),hooks:r,buildUrl:(e,n)=>Mn({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},Kn=429;function Hn(e,t,n){var i;let o=Vn(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[Rn])===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 Vn(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return xn(e)}function Jn(e){const{exp:t}=Vn(e);return(new Date).getTime()/1e3>t}function Bn(e){let t=Vn(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Xn(e,t){return Hn(e,t,"permissions")}function Yn(e,t){return Hn(e,t,"roles")}const Gn=(...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===Kn&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function Qn(e){var t;return(null===(t=Vn(e))||void 0===t?void 0:t[Rn])||""}const ei=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),ti=(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 "))},ni=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ii=e=>t=>e.test(t),oi=ii(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ri=ii(/^\+[1-9]{1}[0-9]{3,14}$/),si=ei(oi,'"{val}" is not a valid email'),ai=ei(ri,'"{val}" is not a valid phone number'),li=ei((e=>e.length>=1),"Minimum length is 1");const ci=ei((e=>"string"==typeof e),"Input is not a string"),di=ei((e=>Array.isArray(e)),"Input is not an array"),ui=ei((e=>"boolean"==typeof e),"Input is not a boolean"),hi=ei((e=>void 0===e),"Input is defined"),pi=ti([ci(),hi()],"Input is not a string or undefined"),fi=ti([di(),ui()],"Input is not an array or boolean"),gi=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>ni(...e).validate(n[t]))),t(...n)),vi=e=>[ci(`"${e}" must be a string`)],mi=e=>[pi(`"${e}" must be string or undefined`)],bi=e=>[ci(`"${e}" must be a string`),li(`"${e}" must not be empty`)],wi=e=>[ci(`"${e}" must be a string`),si()],yi=e=>[ci(`"${e}" must be a string`),ai()],ki=gi(bi("accessKey")),Si=e=>({exchange:ki(((t,n)=>Zn(e.post(On.accessKey.exchange,{loginOptions:n},{token:t}))))}),Ii=(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),Ci=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||An,An)});var xi,Oi;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(xi||(xi={})),function(e){e.email="email"}(Oi||(Oi={}));const Ei=Object.assign(Object.assign({},xi),Oi);var ji;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(ji||(ji={}));const Ai=bi("loginId"),Ri=gi(bi("token")),Ui=gi(Ai),Ti=gi(bi("pendingRef")),_i=gi(Ai,wi("email")),Pi=e=>({verify:Ri((t=>Zn(e.post(On.enchantedLink.verify,{token:t})))),signIn:Ui(((n,i,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Zn(e.post(Gn(On.enchantedLink.signIn,Ei.email),{loginId:n,URI:i,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:Ui(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Zn(e.post(Gn(On.enchantedLink.signUpOrIn,Ei.email),{loginId:n,URI:i,loginOptions:s,providerId:r}))})),signUp:Ui(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zn(e.post(Gn(On.enchantedLink.signUp,Ei.email),{loginId:n,URI:i,user:o,loginOptions:a,providerId:s}))})),waitForSession:Ti(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Ci(n);let s;const a=setInterval((async()=>{const n=await e.post(On.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:_i(((t,n,i,o,r)=>Zn(e.post(On.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),Li=gi(bi("flowId")),$i=gi(bi("executionId"),bi("stepId"),bi("interactionId")),Mi=e=>({start:Li(((t,n,i,o,r,s,a)=>Zn(e.post(On.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a})))),next:$i(((t,n,i,o,r,s)=>Zn(e.post(On.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),Wi=bi("loginId"),Ni=gi(bi("token")),Di=gi(Wi),Fi=gi(Wi,yi("phone")),qi=gi(Wi,wi("email")),zi=Object.keys(Ei).filter((e=>e!==xi.voice)),Ki=e=>({verify:Ni((t=>Zn(e.post(On.magicLink.verify,{token:t})))),signIn:zi.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Di(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Zn(e.post(Gn(On.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:zi.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Di(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Zn(e.post(Gn(On.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:zi.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Di(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zn(e.post(Gn(On.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:qi(((t,n,i,o,r)=>Zn(e.post(On.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(xi).filter((e=>e!==xi.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Fi(((t,i,o,r,s)=>Zn(e.post(Gn(On.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Hi;!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"}(Hi||(Hi={}));const Vi=gi(bi("code")),Ji=e=>({start:Object.assign(((t,n,i,o,r)=>Zn(e.post(On.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(Hi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>Zn(e.post(On.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:Vi((t=>Zn(e.post(On.oauth.exchange,{code:t})))),startNative:(t,n,i)=>Zn(e.post(On.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>Zn(e.post(On.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>Zn(e.get(On.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>Zn(e.post(On.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>Zn(e.post(On.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Bi=bi("appId"),Xi=gi(Bi),Yi=e=>({connect:Xi(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Zn(e.post(On.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),Gi=bi("loginId"),Zi=gi(Gi,bi("code")),Qi=gi(Gi),eo=gi(Gi,yi("phone")),to=gi(Gi,wi("email")),no=e=>({verify:Object.keys(Ei).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Zi(((t,i)=>Zn(e.post(Gn(On.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Ei).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Qi(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Zn(e.post(Gn(On.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Ei).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Qi(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zn(e.post(Gn(On.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Ei).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Qi(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Zn(e.post(Gn(On.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:to(((t,n,i,o)=>Zn(e.post(On.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(xi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:eo(((t,i,o,r)=>Zn(e.post(Gn(On.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),io=gi(bi("tenant")),oo=gi(bi("code")),ro=e=>({start:io(((t,n,i,o,r,s,a)=>Zn(e.post(On.saml.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a})},o&&{token:o}))))),exchange:oo((t=>Zn(e.post(On.saml.exchange,{code:t}))))}),so=bi("loginId"),ao=gi(so,bi("code")),lo=gi(so),co=gi(so),uo=e=>({signUp:lo(((t,n)=>Zn(e.post(On.totp.signUp,{loginId:t,user:n})))),verify:ao(((t,n,i,o)=>Zn(e.post(On.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:co(((t,n)=>Zn(e.post(On.totp.update,{loginId:t},{token:n}))))}),ho=bi("loginId"),po=bi("newPassword"),fo=gi(ho,bi("password")),go=gi(ho),vo=gi(ho,po),mo=gi(ho,bi("oldPassword"),po),bo=e=>({signUp:fo(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zn(e.post(On.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:fo(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Zn(e.post(On.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:go(((t,n,i)=>Zn(e.post(On.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:vo(((t,n,i)=>Zn(e.post(On.password.update,{loginId:t,newPassword:n},{token:i})))),replace:mo(((t,n,i)=>Zn(e.post(On.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>Zn(e.get(On.password.policy))}),wo=vi("loginId"),yo=bi("loginId"),ko=bi("origin"),So=gi(yo,ko,bi("name")),Io=gi(yo,ko),Co=gi(wo,ko),xo=gi(yo,ko,mi("token")),Oo=gi(bi("transactionId"),bi("response")),Eo=e=>({signUp:{start:So(((t,n,i,o)=>Zn(e.post(On.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,passkeyOptions:o})))),finish:Oo(((t,n)=>Zn(e.post(On.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Co(((t,n,i,o,r)=>Zn(e.post(On.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:Oo(((t,n)=>Zn(e.post(On.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Io(((t,n,i)=>Zn(e.post(On.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:i}))))},update:{start:xo(((t,n,i,o)=>Zn(e.post(On.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:Oo(((t,n)=>Zn(e.post(On.webauthn.update.finish,{transactionId:t,response:n}))))}}),jo=vi("loginId"),Ao=gi(jo),Ro=gi(bi("pendingRef")),Uo=e=>({signUpOrIn:Ao(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return Zn(e.post(On.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:Ao(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Zn(e.post(On.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:Ao(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return Zn(e.post(On.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:Ro(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Ci(n);let s;const a=setInterval((async()=>{const n=await e.post(On.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)}))))}),To=gi(bi("token")),_o=gi(mi("token"));var Po,Lo=gi([(Po=bi("projectId"),ei(((e,t)=>n=>ni(...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",Po))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=zn({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:Si(l),otp:no(l),magicLink:Ki(l),enchantedLink:Pi(l),oauth:Ji(l),outbound:Yi(l),saml:ro(l),totp:uo(l),notp:Uo(l),webauthn:Eo(l),password:bo(l),flow:Mi(l),refresh:_o(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?On.tryRefresh:On.refresh;return Zn(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:gi([ci("tenantId")],[pi('"token" must be string or undefined')])(((e,t)=>Zn(l.post(On.selectTenant,{tenant:e},{token:t})))),logout:_o((e=>Zn(l.post(On.logout,{},{token:e})))),logoutAll:_o((e=>Zn(l.post(On.logoutAll,{},{token:e})))),me:_o((e=>Zn(l.get(On.me,{token:e})))),myTenants:gi([fi('"tenants" must a string array or a boolean')],[pi('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Zn(l.post(On.myTenants,n,{token:t}))})),history:_o((e=>Zn(l.get(On.history,{token:e})))),isJwtExpired:To(Jn),getTenants:To(Bn),getJwtPermissions:To(Xn),getJwtRoles:To(Yn),getCurrentTenant:To(Qn),httpClient:l};var l})),$o=Object.assign(Lo,{DeliveryMethods:Ei});
|
|
6
|
+
/*! js-cookie v3.0.5 | MIT */function Mo(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 Wo=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=Mo({},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,"",Mo({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Mo({},this.attributes,t))},withConverter:function(t){return e(Mo({},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 No={default:"endpoint"},Do="Blocked by CSP",Fo="The endpoint parameter is not a valid URL",qo="Failed to load the JS script of the agent",zo="9319";function Ko(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Do||s===Fo)n.exclude(),r=0;else if(s===zo)n.exclude();else if(s===qo){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var Ho="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Vo=Ho;function Jo(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:Ho,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return Ko(e,Bo)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===zo?new Error(qo):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function Bo(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(Fo);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(qo))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(Do)})).then(Xo)}function Xo(){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(zo);return n}let Yo;const Go=e=>{try{return xn(e).exp}catch(e){return null}},Zo=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Go(n)},Qo=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?Go(i):void 0)},er=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||Qo(e),cookieExpiration:e.cookieExpiration||Zo(e)},s)},tr=(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},nr=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return er(n)},ir=void 0!==Yo||"undefined"!=typeof localStorage,or=(e,t)=>{var n,i;return null===(i=null===(n=Yo||localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},rr=e=>{var t,n;return null===(n=null===(t=Yo||localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},sr=e=>{var t,n;return null===(n=null===(t=Yo||localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},ar=e=>{var t,n,i,o;return null!==(o=null!==(n=null===(t=null==Yo?void 0:Yo.key)||void 0===t?void 0:t.call(Yo,e))&&void 0!==n?n:null===(i=null===localStorage||void 0===localStorage?void 0:localStorage.key)||void 0===i?void 0:i.call(localStorage,e))&&void 0!==o?o:null},lr=(...e)=>{console.debug(...e)},cr="3.2.0",dr="undefined"!=typeof window,ur=Math.pow(2,31)-1,hr=`https://descopecdn.com/npm/oidc-client-ts@${cr}/dist/browser/oidc-client-ts.min.js`,pr=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${cr}/dist/browser/oidc-client-ts.min.js`,fr="DS",gr="DSR",vr="DSI";const mr=e=>(null==e?void 0:e.cookieName)||fr;function br(e=""){return rr(`${e}${gr}`)||""}function wr(e="",t){return Wo.get(mr(t))||rr(`${e}${fr}`)||""}function yr(e=""){return rr(`${e}${vr}`)||""}function kr(e="",t){sr(`${e}${gr}`),sr(`${e}${fr}`),sr(`${e}${vr}`);const n=mr(t);Wo.remove(n)}const Sr=dr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Ir="vsid",Cr="vrid",xr="fp",Or=(e=!1)=>{const t=rr(xr);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Er=async(e,t=Sr)=>{try{if(Or())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=Jo({apiKey:e,endpoint:[i.toString(),No],scriptUrlPattern:[r,Vo]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Ir]:e,[Cr]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};or(xr,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},jr=e=>{const t=Or(!0);return t&&e.body&&(e.body.fpData=t),e},Ar="descopeFlowNonce",Rr="X-Descope-Flow-Nonce",Ur="/v1/flow/start",Tr="/v1/flow/next",_r=(e,t=Ar)=>`${t}${e}`,Pr=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Lr=e=>{var t;return e.path===Tr&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Pr(e.body.executionId):null},$r="dls_last_user_login_id",Mr="dls_last_user_display_name",Wr=e=>or($r,e),Nr=()=>rr($r),Dr=()=>rr(Mr),Fr=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Nr(),r=Dr();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function qr(){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 zr(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Xr(n.publicKey.challenge),n.publicKey.user.id=Xr(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Xr(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Yr(n.rawId),type:n.type,response:{attestationObject:Yr(n.response.attestationObject),clientDataJSON:Yr(n.response.clientDataJSON)}});var n}async function Kr(e){const t=Jr(e);return Br(await navigator.credentials.get(t))}async function Hr(e,t){const n=Jr(e);return n.signal=t.signal,n.mediation="conditional",Br(await navigator.credentials.get(n))}async function Vr(e=!1){if(!dr)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 Jr(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Xr(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Xr(e.id)})),n}function Br(e){return JSON.stringify({id:e.id,rawId:Yr(e.rawId),type:e.type,response:{authenticatorData:Yr(e.response.authenticatorData),clientDataJSON:Yr(e.response.clientDataJSON),signature:Yr(e.response.signature),userHandle:e.response.userHandle?Yr(e.response.userHandle):void 0}})}function Xr(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Yr(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Gr,Zr=(Gr=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 zr(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 zr(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 zr(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:zr,get:Kr,isSupported:Vr,conditional:Hr}}),(...e)=>{const t=Gr(...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 Qr="/fedcm/config",es=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function ts(e,t){var n;try{await ns(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function ns(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=es(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var is=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Vr(),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 os;const rs=(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",(()=>{rs(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),ss=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{os||(os=(async()=>{try{return require("oidc-client-ts")}catch(e){return rs([hr,pr],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await os;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",l=`${r}_user`;let c=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(c=`${c}/${n.applicationId}`);const d={authority:c,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:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),or(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=rr(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||yr(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return sr(o),t||window.location.replace(s),r}}},as=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Yo=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return dr?(i&&o&&Er(i).catch((()=>null)),e(tr(r,{beforeRequest:jr}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i||"undefined"!=typeof window&&window.descopeBridge)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,l;dr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&a&&new Date>a&&(lr("Expiration time passed, refreshing session"),c.refresh(br()||l))}));const c=e(tr(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o}=await nr(t);if(401===(null==t?void 0:t.status))lr("Received 401, canceling all timers"),r();else if(n||o){if(a=((e,t)=>{if(t)return new Date(1e3*t);lr("Could not extract expiration time from session token, trying to decode the token");try{const t=xn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!a)return void lr("Could not extract expiration time from session token");l=i;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>ur&&(lr(`Timeout is too large (${t}ms), setting it to ${ur}ms`),t=ur),t})(a);if(r(),e<=2e4)return void lr("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});lr(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{lr("Refreshing session due to timer"),c.refresh(br()||i)}),e)}}}));return Ii(c,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return lr("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.38.2"},t.baseHeaders)}))),(e=>t=>{const n=qr(),i=qr(),o=qr(),r=qr(),s=e(tr(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await nr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await nr(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Ii(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:i=!0,nonceStoragePrefix:o=Ar}=n,r=t(n,["enableFlowNonce","nonceStoragePrefix"]);return i?(((e=Ar)=>{try{if(!ir)return;for(let i=0;i<(void 0,void 0,null!==(n=null!==(t=null==Yo?void 0:Yo.length)&&void 0!==t?t:null===localStorage||void 0===localStorage?void 0:localStorage.length)&&void 0!==n?n:0);i++){const t=ar(i);if(t&&t.startsWith(e)){const n=rr(t);if(n)try{JSON.parse(n).expiry<Date.now()&&sr(t)}catch(e){sr(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n})(o),e(tr(r,{afterRequest:async(e,t)=>{if(e.path!==Ur&&e.path!==Tr)return;const{nonce:n,executionId:i}=await(async(e,t)=>{try{const n=t.headers.get(Rr);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=Lr(e)),{nonce:n,executionId:Pr(i)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&i&&((e,t,n,i=Ar)=>{try{const o=_r(e,i),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};or(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(i,n,e.path===Ur,o)},beforeRequest:e=>{if(e.path===Tr){const t=Lr(e);if(t){const n=((e,t=Ar)=>{try{const n=_r(e,t),i=rr(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(((e,t=Ar)=>{try{const n=_r(e,t);sr(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);n&&(e.headers=e.headers||{},e.headers[Rr]=n)}}return e}}))):e(r)}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:Nr,getLastUserDisplayName:Dr});const s=e(tr(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=er((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(Wr(r),(e=>{or(Mr,e)})(s)):(null==o?void 0:o.loginId)&&Wr(o.loginId)}}));let a=Ii(s,["flow.start"],Fr);return a=Ii(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(sr($r),sr(Mr)),i})(o)),Object.assign(a,{getLastUserLoginId:Nr,getLastUserDisplayName:Dr})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!dr)return e(s);const a=e(tr(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||br(l)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||kr(r,o):((e={},t=!1,n="")=>{var i,o;const{sessionJwt:r,refreshJwt:s}=e;if(s&&or(`${n}${gr}`,s),r)if(t){const n=t.sameSite||"Strict",s=null===(i=t.secure)||void 0===i||i,a=null!==(o=t.domain)&&void 0!==o?o:e.cookieDomain;!function(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);Wo.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}(mr(t),r,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:s,cookieDomain:a}))}else or(`${n}${fr}`,r);e.idToken&&or(`${n}${vr}`,e.idToken)})(await nr(t),o,r)}}));var l;const c=Ii(a,["logout","logoutAll","oidc.logout"],((e,t)=>n=>async(...i)=>{const o=await n(...i);return kr(e,t),o})(r,o));return Object.assign(c,{getRefreshToken:()=>br(r),getSessionToken:()=>wr(r),getIdToken:()=>yr(r)})}))((e=>{const t=$o(e),n=ss(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;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 s=wr(),a=br();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){lr("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:is(t),webauthn:Zr(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){ts(i,e)},requestAuthentication(e){ts(i,e)}},async oneTap(e,t,n,o,r){await ns(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+Qr),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>dr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+Qr);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})),ls={me:"/v1/auth/me"},cs={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated"},ds=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)})),us=()=>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})}))})),hs=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))})),ps=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({adminSSOConfigurationLink:"_blank"})}))})),fs=({httpClient:e,tenantId:t,mock:i})=>{const o=encodeURIComponent(t||""),r=`?tenant=${o}&id=${o}`;return{details:()=>n(void 0,void 0,void 0,(function*(){if(i)return hs();if(!t)throw new Error("tenantId is not defined");const n=`${cs.details}${r}`,o=yield e.get(n);yield ds(o);return yield o.json()})),adminLinkSso:()=>n(void 0,void 0,void 0,(function*(){if(i)return ps();if(!t)throw new Error("tenantId is not defined");const n=yield e.post(`${cs.adminLinkSso}?tenant=${o}`,{tenantId:o},{headers:{"Content-Type":"application/json"}});yield ds(n);return yield n.json()}))}},gs=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return us();const n=yield e.get(ls.me);return yield ds(n),n.json()}))}),vs=l((e=>{var t,s,a,l;const c=r(I,k,v,C,cn)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||oe}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","tenant","mock"],(()=>{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,n,i)=>{const o=as(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.4.0"}}));return{user:gs({httpClient:o.httpClient,mock:n}),tenant:fs({httpClient:o.httpClient,tenantId:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},l})),ms=l((e=>{const t=r(ln({name:"widget",initialState:Sn,reducers:{},extraReducers:e=>{vn.reducer(e),wn.reducer(e),kn.reducer(e)},asyncActions:{getMe:vn.action,getTenant:wn.action,getTenantAdminLinkSSO:kn.action}}),y,v,vs)(e);return class extends t{constructor(...e){super(...e),this.state=Sn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),bs="widget-flow",ws=l((e=>{var t,o,s;return s=class extends(r(y,ne,ms,cn,v,se)(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=un(bs);r&&(!function(e){if(window.history.replaceState&&un(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())}}(bs),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(dn({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));new X((()=>{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(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()})),t.afterClose=()=>{t.remove()},t.open()},s})),ys=e=>e.tenant.data,ks=e=>e.tenantAdminLinkSSO.data,Ss=kt(ys,(e=>e.customAttributes||{})),Is=kt(ys,(e=>e.name||"")),Cs=kt(ys,(e=>e.selfProvisioningDomains||[])),xs=kt(ys,(e=>e.enforceSSOExclusions||[])),Os=kt(ys,(e=>e.enforceSSO||!1)),Es=l((e=>class extends(r(se,k)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),js=l((e=>{const t=r(j,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(`tenant-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}}));const As=l((e=>{var t,o,a;return a=class extends(r(v,y,N,H,js,ms)(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);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()])}catch(e){}const r=this.state.me.error||(e=>e.tenant.error)(this.state)||(e=>e.tenantAdminLinkSSO.error)(this.state);if(r){this.contentRootElement.innerHTML="";const e="object"==typeof r&&null!==r&&"message"in r?r.message:String(r)||"An error occurred";this.contentRootElement.append(function({mainMessage:e="An error occurred"}){const t=document.createElement("div");t.setAttribute("data-id","widget-error"),t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="72px 36px",t.style.background="#fff",t.style.borderRadius="12px",t.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",t.style.margin="32px auto",t.style.maxWidth="400px";const n=document.createElement("div");n.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',n.style.marginBottom="12px",t.appendChild(n);const i=document.createElement("div");return i.textContent=e,i.style.fontWeight="bold",i.style.fontSize="20px",i.style.color="#222",i.style.textAlign="center",i.style.marginTop="8px",t.appendChild(i),t}({mainMessage:e}))}else yield i(this,t,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),Rs=l((e=>{var t,o,s,l;return l=class extends(r(Es,ms,v,As,cn,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,a((e=>{this.tenantAdminLinkSSODriver.href=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",o).call(this),i(this,s,"f").call(this,ks(this.state)),this.subscribe(i(this,s,"f").bind(this),ks)}))}},s=new WeakMap,t=new WeakSet,o=function(){this.tenantAdminLinkSSODriver=new Y((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},l}));var Us;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Us||(Us={}));const Ts=l((e=>{var t,o,s,l,c,d,u,h,p,f,g;return g=class extends(r(Es,ms,v,As,cn,ne)(e)){constructor(){super(...arguments),t.add(this),o.set(this,{}),s.set(this,{}),l.set(this,{}),c.set(this,{}),h.set(this,a((e=>{var n;const o=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(o).forEach((n=>{const o=n.getAttribute("data-id").replace("customAttributes.",""),r=n.getAttribute("data-type")||Us.TEXT,s=e[o],a=new ee(n,{logger:this.logger});a.value=((e,t)=>e===Us.DATE&&t?new Date(t).toLocaleString():e===Us.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString())(r,s),i(this,t,"m",p).call(this,n,o,a,r,o,s),i(this,t,"m",f).call(this,n,o,a)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,h,"f").call(this,Ss(this.state)),this.subscribe(i(this,h,"f").bind(this),Ss)}))}},o=new WeakMap,s=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,d=function(e,t,n,r){var a,l;const c=t===Us.ARRAY?(r||[]).join(","):r;null===(a=i(this,o,"f")[e])||void 0===a||a.setContent(dn({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({customAttributes:{[n]:c}})})),null===(l=i(this,s,"f")[e])||void 0===l||l.onSuccess((()=>{var t;null===(t=i(this,o,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},u=function(e){var t,n;null===(t=i(this,l,"f")[e])||void 0===t||t.setContent(dn({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(n=i(this,c,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,l,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},p=function(e,n,r,a,l,c){const u=e.getAttribute("edit-flow-id");u&&(i(this,o,"f")[u]=this.createModal({"data-id":`edit-${n}`}),i(this,s,"f")[u]=new X((()=>{var e,t;return null===(t=null===(e=i(this,o,"f")[u])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,o,"f")[u].beforeOpen=i(this,t,"m",d).bind(this,u),r.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,o,"f"))||void 0===e?void 0:e[u])||void 0===t||t.open()})),i(this,t,"m",d).call(this,u,a,l,c),this.syncFlowTheme(i(this,s,"f")[u]))},f=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,l,"f")[r]=this.createModal({"data-id":`delete-${n}`}),i(this,c,"f")[r]=new X((()=>{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].beforeOpen=i(this,t,"m",u).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,l,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r),this.syncFlowTheme(i(this,c,"f")[r]))},g})),_s=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,b;return b=class extends(r(Es,ms,v,As,cn,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.tenantEmailDomainsDriver.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,Cs(this.state)),this.subscribe(i(this,m,"f").bind(this),Cs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.tenantEmailDomainsDriver.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),o(this,l,new X((()=>{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").beforeOpen=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(dn({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({tenantEmailDomains:Cs(this.state)})})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),o(this,d,new X((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").beforeOpen=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(dn({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantEmailDomainsDriver=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),Ps=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,b;return b=class extends(r(Es,ms,v,As,cn,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.tenantSSOExclusionsDriver.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,xs(this.state)),this.subscribe(i(this,m,"f").bind(this),xs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.tenantSSOExclusionsDriver.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),o(this,l,new X((()=>{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").beforeOpen=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(dn({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({enforceSSOExclusions:xs(this.state)})})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),o(this,d,new X((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").beforeOpen=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(dn({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantSSOExclusionsDriver=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),Ls=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,b;return b=class extends(r(Es,ms,v,As,cn,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.tenantEnforceSSODriver.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,Os(this.state)),this.subscribe(i(this,m,"f").bind(this),Os)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.tenantEnforceSSODriver.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),o(this,l,new X((()=>{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").beforeOpen=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(dn({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({enforceSSO:Os(this.state)})})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEnforceSSODriver.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),o(this,d,new X((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").beforeOpen=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(dn({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantEnforceSSODriver=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),$s=l((e=>{var t,s,l,c,d,u,h,p;return p=class extends(r(Es,ms,v,As,cn,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.tenantNameDriver.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",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Is(this.state)),this.subscribe(i(this,h,"f").bind(this),Is)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,t=new WeakSet,c=function(){this.tenantNameDriver.editFlowId&&(o(this,s,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),o(this,l,new X((()=>{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").beforeOpen=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this),this.syncFlowTheme(i(this,l,"f")))},d=function(){i(this,s,"f").setContent(dn({projectId:this.projectId,flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({tenantName:Is(this.state)})})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getTenant()}))},u=function(){this.tenantNameDriver=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},p})),Ms=l((e=>{var t,s,a,l,c,d,u;return u=class extends(r(Es,ms,v,As,cn,ne)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}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",d).call(this),i(this,t,"m",l).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(o(this,s,this.createModal({"data-id":"password-policy"}),"f"),o(this,a,new X((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",c).bind(this),i(this,t,"m",c).call(this),this.syncFlowTheme(i(this,a,"f")))},c=function(){i(this,s,"f").setContent(dn({projectId:this.projectId,flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId,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(),this.actions.getTenant()}))},d=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new te((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},u})),Ws=l((e=>class extends(r(U,se,ws,As,$s,_s,Ps,Ls,Ts,Rs,Ms)(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)}))}})),Ns=r((e=>class extends(Ws(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 wc})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.4.0"}}}))}}))(HTMLElement),Ds="undefined"!=typeof localStorage,Fs="J151000",qs="E103205",zs=Ds&&localStorage.getItem("base.content.url")||"",Ks="base.ui.components.url";Ds&&localStorage.getItem(Ks),Ds&&localStorage.getItem(Ks);const Hs="descope-login-flow",Vs="code",Js="redirect_mode",Bs="data-exclude-field",Xs="data-exclude-next",Ys="dls_last_auth",Gs="state_id",Zs="saml_idp_state_id",Qs="saml_idp_username",ea="descope_idp_initiated",ta="sso_app_id",na="third_party_app_id",ia="third_party_app_state_id",oa="oidc_login_hint",ra="oidc_prompt",sa="oidc_resource",aa="oidc_error_redirect_uri",la="application_scopes",ca="data-type",da="redirect",ua="poll",ha="webauthnCreate",pa="webauthnGet",fa="nativeBridge",ga="loadForm",va="submit",ma="polling",ba=["descope-multi-select-combo-box","descope-text-area"],wa=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var ya;!function(e){e.backward="backward",e.forward="forward"}(ya||(ya={}));const ka=["descope-enriched-text"];function Sa(e){return new URLSearchParams(window.location.search).get(e)}function Ia(e){if(window.history.replaceState&&Sa(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 Ca(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?ya.forward:n<i?ya.backward:void 0}const xa=e=>{let[t="",n=""]=(Sa(Hs)||"").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 Oa(){Ia(Hs)}const Ea=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),ja=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=xa(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Oa();const r=Sa("t")||void 0;r&&Ia("t");const s=Sa(Vs)||void 0;s&&Ia(Vs);const a="popup"===Sa(Js);a&&Ia(Js);const l=Sa("err")||void 0;l&&Ia("err");const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:Sa("ra-challenge"),redirectAuthCallbackUrl:Sa("ra-callback"),redirectAuthBackupCallbackUri:Sa("ra-backup-callback"),redirectAuthInitiator:Sa("ra-initiator")},p=Sa(Gs);p&&Ia(Gs);const f=Sa(Zs);f&&Ia(Zs);const g=Sa(Qs);f&&Ia(Qs);const v=Sa(ea);v&&Ia(ea);const m=Sa(ta);m&&Ia(ta);const b=Sa(na);b&&Ia(na);const w=Sa(ia);w&&Ia(ia);const y=Sa(la);y&&Ia(la);const k=Sa(oa);k&&Ia(oa);const S=Sa(ra);S&&Ia(ra);const I=Sa(aa);I&&Ia(aa);const C=Sa(sa);return C&&Ia(sa),{executionId:n,stepId:i,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,samlIdpUsername:g,descopeIdpInitiated:"true"===v,ssoAppId:m,oidcLoginHint:k,oidcPrompt:S,oidcErrorRedirectUri:I,oidcResource:C,thirdPartyAppId:b,thirdPartyAppStateId:w,applicationScopes:y}}},Aa=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}})},Ra=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}};function Ua(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 Ta=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,oidcResource:l,thirdPartyAppId:c,thirdPartyAppStateId:d,applicationScopes:u})=>!(!e||t||n||i||o||r||s||a||l||c||d||u),_a=e=>null==e?void 0:e.submit(),Pa=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},La=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function $a(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const Ma=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Wa(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Na,Da,Fa,qa;function za(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(!za(r,s))return!1}else if(r!==s)return!1}return!0}let Ka=class{constructor(e={},{forceUpdate:t=!1}={}){Na.set(this,void 0),Da.set(this,{}),Fa.set(this,0),qa.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,Na,"f")):e,n=Object.assign(Object.assign({},i(this,Na,"f")),t),r=i(this,Na,"f");o(this,Na,n,"f"),Object.freeze(i(this,Na,"f")),setTimeout((()=>{Object.values(i(this,Da,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,qa,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!za(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,Na,e,"f"),o(this,qa,t,"f")}get current(){return Object.assign({},i(this,Na,"f"))}set forceUpdate(e){o(this,qa,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,Fa,i(this,Fa,"f")+1,"f"),i(this,Da,"f")[i(this,Fa,"f")]={cb:e,selector:t,forceUpdate:n},i(this,Fa,"f").toString()}unsubscribe(e){const t=!!i(this,Da,"f")[e];return t&&delete i(this,Da,"f")[e],t}unsubscribeAll(){return o(this,Da,{},"f"),!0}};Na=new WeakMap,Da=new WeakMap,Fa=new WeakMap,qa=new WeakMap;const Ha=["*","#","/","(",")","[","]","_","<",">","`"],Va=e=>"string"!=typeof e?e:e.replace((e=>{const t=Ha.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),Ja=["disabled"],Ba=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Bs}])`)).forEach((e=>{e.value=n}))}))},Xa=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Ya=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?Va(Xa(t,i)):Xa(t,i))),Ga=(e,t,n)=>{e.querySelectorAll(`[${ca}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Za=(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})`))},Qa=(e,n,i,o,r)=>{var s,a;Ga(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),Ga(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=>ka.includes(e))(e.localName);e.textContent=Ya(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",Ya(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=Ya(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])=>{Ja.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},el=Aa((()=>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 Ua(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let tl;const nl=(e,t)=>{tl?tl.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},il=e=>tl?tl.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,ol="dls_ab_testing_id",rl=()=>{const e=il(ol);if(!e){const e=Math.floor(100*Math.random()+1);return nl(ol,e.toString()),e}return Number(e)},sl={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function al(e){const t={};try{Object.assign(t,JSON.parse(il(Ys)))}catch(e){}return(null==t?void 0:t.loginId)||e?t:{}}function ll(e,t){(null==e?void 0:e.authMethod)&&(t&&!(null==e?void 0:e.loginId)||nl(Ys,JSON.stringify(e)))}const cl=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?cl(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),cl(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}),[]),dl=l((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r}));var ul,hl,pl,fl,gl,vl,ml,bl,wl,yl,kl,Sl,Il,Cl,xl,Ol,El,jl,Al,Rl,Ul,Tl,_l;const Pl=r(se,j,dl,q)(HTMLElement);class Ll extends Pl{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),ul.add(this),pl.set(this,!1),fl.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,ul,"m",Tl).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)}},gl.set(this,new Ka),vl.set(this,new Ka),ml.set(this,{}),this.getComponentsContext=()=>i(this,ml,"f"),this.nextRequestStatus=new Ka({isLoading:!1}),bl.set(this,void 0),wl.set(this,{popstate:i(this,ul,"m",Cl).bind(this),componentsContext:i(this,ul,"m",Al).bind(this)}),yl.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,yl,e,"f"),i(this,ul,"m",Sl).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 cl(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,fl,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,fl,e,"f"),(e=>{tl=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}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,vl,"f").subscribe(i(this,ul,"m",Ul).bind(this)),i(this,vl,"f").update({isDebug:this.debug}),i(this,ul,"m",Il).call(this),yield i(this,ul,"m",El).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,ul,"m",_l).call(this);const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=ja(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,wl,"f").popstate),window.addEventListener("components-context",i(this,wl,"f").componentsContext),i(this,gl,"f").subscribe(i(this,ul,"m",Ol).bind(this)),i(this,gl,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},g)),o(this,pl,!0,"f")}))}disconnectedCallback(){i(this,gl,"f").unsubscribeAll(),i(this,vl,"f").unsubscribeAll(),i(this,ul,"m",Rl).call(this),window.removeEventListener("popstate",i(this,wl,"f").popstate),window.removeEventListener("components-context",i(this,wl,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,pl,"f")&&t!==n&&hl.observedAttributes.includes(e)){i(this,ul,"m",Il).call(this);const o=null===t;i(this,gl,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Oa()),{[Ea(e)]:n,stepId:r,executionId:s}})),i(this,vl,"f").update({isDebug:this.debug})}}}var $l,Ml,Wl,Nl,Dl,Fl,ql,zl,Kl,Hl,Vl,Jl,Bl,Xl,Yl,Gl,Zl,Ql,ec,tc,nc,ic,oc,rc,sc,ac,lc,cc,dc,uc,hc,pc,fc,gc,vc,mc;hl=Ll,pl=new WeakMap,fl=new WeakMap,gl=new WeakMap,vl=new WeakMap,ml=new WeakMap,bl=new WeakMap,wl=new WeakMap,yl=new WeakMap,ul=new WeakSet,kl=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},Sl=function(){i(this,ul,"m",kl).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Il=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];hl.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Ea(t)])throw Error(`${t} cannot be empty`)}))},Cl=function(){const{stepId:e,executionId:t}=xa(this.flowId);i(this,gl,"f").update({stepId:e,executionId:t})},xl=function(e,t){as&&"function"==typeof as||this.logger.error("SDK was not loaded properly",as,JSON.stringify(as));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},hl.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,fl,"f")&&(o.customStorage=i(this,fl,"f")),this.sdk=as(o),["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:Fs,errorDescription:e.toString()}}}}))}))},Ol=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,ul,"m",xl).call(this,t,n)}i(this,yl,"f").call(this,e)}))},El=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,ul,"m",jl).call(this))}))},jl=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(zs||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}}))},Al=function(e){o(this,ml,Object.assign(Object.assign({},i(this,ml,"f")),e.detail),"f")},Rl=function(){var e;null===(e=i(this,bl,"f"))||void 0===e||e.remove(),o(this,bl,null,"f")},Ul=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,bl,document.createElement("descope-debugger"),"f"),Object.assign(i(this,bl,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Gc})),document.body.appendChild(i(this,bl,"f"))):i(this,ul,"m",Rl).call(this)}))},Tl=function(e,t){var n;e&&this.debug&&(null===(n=i(this,bl,"f"))||void 0===n||n.updateData({title:e,description:t}))},_l=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=ba.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},Ll.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.48.3"}};class bc extends Ll{static set sdkConfigOverrides(e){Ll.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Ll.sdkConfigOverrides}constructor(){const e=new Ka({deferredRedirect:!1});super(e.update.bind(e)),$l.add(this),this.stepState=new Ka({}),Ml.set(this,void 0),Wl.set(this,null),Nl.set(this,null),Dl.set(this,{visibilitychange:i(this,$l,"m",Fl).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},Xl.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Gl.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,$l,"m",Zl).call(this,t):t()})),Ql.set(this,((e,t,r,s,a=!1)=>{const l=[qs,"E103202"];if(this.flowState.current.action===ua){this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,Ml,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,ma,r,s,{}),h=document.hidden&&!a&&Date.now()-c>d+500;let p;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;p=yield Ua(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Ql,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===Fs)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Ql,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,Ql,"f").call(this,e,t,r,s),i(this,tc,"f").call(this,p)}))),d),"f")}})),ec.set(this,(()=>{clearTimeout(i(this,Ml,"f")),o(this,Ml,null,"f")})),tc.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,f,g;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,$l,"m",vc).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==qs||!this.isRestartOnError||i(this,$l,"m",Bl).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(f=e.data)||void 0===f?void 0:f.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==ua&&i(this,ec,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&ll(w);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void i(this,$l,"m",vc).call(this,"success",t)}this.storeLastAuthenticatedUser&&ll(w,!0),k&&window.open(k,"_blank");const{executionId:S,stepId:I,stepName:C,screen:x,redirect:O,webauthn:E,error:j,samlIdpResponse:A,nativeResponse:R}=e.data,U=Date.now();y!==ua?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${m}`,"",{screen:x,status:m,stepId:I,stepName:C,action:y,error:j}),(null===(g=x.state)||void 0===g?void 0:g.clientScripts)&&o(this,Nl,this.loadSdkScripts(x.state.clientScripts),"f"),this.flowState.update({stepId:I,stepName:C,executionId:S,action:y,redirectTo:null==O?void 0:O.url,redirectIsPopup:null==O?void 0:O.isPopup,screenId:null==x?void 0:x.id,screenState:null==x?void 0:x.state,webauthnTransactionId:null==E?void 0:E.transactionId,webauthnOptions:null==E?void 0:E.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==R?void 0:R.type,nativePayload:null==R?void 0:R.payload,reqTimestamp:U})):this.flowState.update({action:y,reqTimestamp:U})})),nc.set(this,Aa((()=>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)}}))))),lc.set(this,null),pc.set(this,La(((e,t)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,$l,"m",sc).call(this)){const o=null==e?void 0:e.getAttribute("id");i(this,$l,"m",cc).call(this,e);const r=yield i(this,$l,"m",ac).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,Nl,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,Nl,"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 Ua(5e3,Promise.all(e),null))}const l=this.getComponentsContext(),c=Object.assign(Object.assign(Object.assign(Object.assign({},l),s),r),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(o,c),this.nextRequestStatus.update({isLoading:!1}),i(this,$l,"m",dc).call(this,r)}}))))),this.flowState=e}nativeResume(e,t){var n,o,r,s,a;const l=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let{exchangeCode:e}=l;e||(e=null===(n=new URL(l.url).searchParams)||void 0===n?void 0:n.get(Vs)),null===(r=(o=this.nativeCallbacks).complete)||void 0===r||r.call(o,{exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(l.url),t=e.searchParams.get("t"),n=e.searchParams.get(Hs).split("_").pop();i(this,ec,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=l;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=l,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,l)}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:{[Wa(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i;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===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}yield this.injectNpmLib("@descope/flow-scripts","1.0.11",`dist/${e.id}.js`);const r=null===(i=globalThis.descope)||void 0===i?void 0:i[e.id];return new Promise(((n,i)=>{try{const i=r(e.initArgs,{baseUrl:this.baseUrl,ref:this},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.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,$l,"m",Vl).call(this),window.addEventListener("visibilitychange",i(this,Dl,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,ec,"f").call(this),null===(e=i(this,Wl,"f"))||void 0===e||e.abort(),o(this,Wl,null,"f"),window.removeEventListener("visibilitychange",i(this,Dl,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=$a(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:S,exchangeError:I,webauthnTransactionId:C,webauthnOptions:x,redirectAuthCodeChallenge:O,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:A,locale:R,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:_,nativeResponseType:P,nativePayload:L,reqTimestamp:$}=e,M=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let W,N,D;const F=rl(),{outboundAppId:q}=this,{outboundAppScopes:z}=this,K=this.sdk.getLastUserLoginId(),H=yield this.getFlowConfig(),V=yield this.getProjectConfig(),J=Object.entries(V.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),B=E&&O?{callbackUrl:E,codeChallenge:O,backupCallbackUri:j}:void 0,X=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let Y={};if(!p){const e=[...H.clientScripts||[],...H.sdkScripts||[]];if(H.conditions){let t=[];({startScreenId:W,conditionInteractionId:D,startScreenName:N,clientScripts:t,componentsConfig:Y}=((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=sl[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:K,code:k,token:y,abTestingKey:F,lastAuth:al(K)},H.conditions)),e.push(...t||[])}else H.condition?({startScreenId:W,conditionInteractionId:D}=((e,t)=>{var n;const i=null===(n=sl[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}})(H.condition,{loginId:K,code:k,token:y,abTestingKey:F,lastAuth:al(K)})):(N=H.startScreenName,W=H.startScreenId);if(o(this,Nl,this.loadSdkScripts(e),"f"),H.fingerprintEnabled&&H.fingerprintKey?yield Er(H.fingerprintKey,this.baseUrl):sr(xr),!Ta(W,M)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},M),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:al(K),abTestingKey:F,locale:$a(R).locale,nativeOptions:X,outboundAppId:q,outboundAppScopes:z}),D,"",V.componentsVersion,J,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),M.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),M.oidcLoginHint?{externalId:M.oidcLoginHint}:{}));return i(this,tc,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:S,code:k,exchangeError:I,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),S&&(s("code")&&k||s("exchangeError")&&I))return void i(this,$l,"m",mc).call(this,p,k,I);if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const e=yield this.sdk.flow.next(p,h,va,H.version,V.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return i(this,tc,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===ga&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U||!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(U,T,_||"",_a)}if(f===da&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===A&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const n=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const n=t?this.popupOrigin:window.location.origin;if(e.origin!==n)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${n}"`);const{action:i,data:o}=e.data||{};"code"===i&&this.flowState.update({code:o.code,exchangeError:o.exchangeError})};let o;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),i(this,$l,"m",vc).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(t)window.addEventListener("message",n),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",n)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=n,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),i(this,$l,"m",vc).call(this,"popupclosed",{});return}if(f===ha||f===pa){if(!C||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,Wl,"f"))||void 0===l||l.abort(),o(this,Wl,null,"f");try{e=f===ha?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const n=yield this.sdk.flow.next(p,h,va,H.version,V.componentsVersion,{transactionId:C,response:e,failure:t});i(this,tc,"f").call(this,n)}if(f===fa)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,va,H.version,V.componentsVersion,e);i(this,tc,"f").call(this,t)})),void i(this,$l,"m",Kl).call(this,P,L);if(s("action")&&i(this,Ql,"f").call(this,p,h,H.version,V.componentsVersion),!g&&!W)return void this.loggerWrapper.warn("No screen was found to show");const G=W||g,Z=yield this.getHtmlFilenameWithLocale(R,G),{oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,oidcResource:ne,samlIdpUsername:ie}=M,oe={direction:Ca(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:K,name:this.sdk.getLastUserDisplayName()||K},componentsConfig:Object.assign(Object.assign(Object.assign({},H.componentsConfig),Y),null==v?void 0:v.componentsConfig)}),htmlFilename:`${G}.html`,htmlLocaleFilename:Z,screenId:G,stepName:e.stepName||N,samlIdpUsername:ie,oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,oidcResource:ne,action:f},re=al(K);Ta(W,M)?oe.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:B},M),{lastAuth:re,preview:this.preview,abTestingKey:F,client:this.client}),w&&{redirectUrl:w}),{locale:$a(R).locale,nativeOptions:X,outboundAppId:q,outboundAppScopes:z}),D,e,V.componentsVersion,J,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),Ma(t)),k&&{exchangeCode:k,idpInitiated:!0}),M.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,tc,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(oe.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,e,H.version,V.componentsVersion,Ma(t));return i(this,tc,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",oe.screenId),yield i(this,$l,"m",Yl).call(this,oe),this.stepState.update(oe)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d}=e;this.loggerWrapper.debug("Rendering a flow screen");const u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u);this.sdk.webauthn.helpers.isSupported()?yield i(this,$l,"m",oc).call(this,h,c):(e=>{e.querySelectorAll(`descope-button[${ca}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(h),!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),Qa(h,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(h,f);const g=()=>n(this,void 0,void 0,(function*(){var n,o;yield p;const r=this.contentRootElement;((e,t)=>{Za(e,"descope-totp-image",t)})(r,null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image),((e,t)=>{Za(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=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,h,d.cssVars,this.loggerWrapper),r.replaceChildren(h);const s=!t.htmlFilename;setTimeout((()=>{i(this,$l,"m",uc).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const i=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void i();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),i(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{Ba(e,null==t?void 0:t.inputs),Ba(e,null==t?void 0:t.form)})(r,d),i(this,$l,"m",rc).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),Ra(r,this.autoFocus,s)})),i(this,$l,"m",gc).call(this,c),r.querySelector(`[${ca}="polling"]`)&&c(ma,{})}));l?i(this,$l,"m",Zl).call(this,g):g()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Bs}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}Ml=new WeakMap,Wl=new WeakMap,Nl=new WeakMap,Dl=new WeakMap,Xl=new WeakMap,Gl=new WeakMap,Ql=new WeakMap,ec=new WeakMap,tc=new WeakMap,nc=new WeakMap,lc=new WeakMap,pc=new WeakMap,$l=new WeakSet,Fl=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},ql=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,$l,"m",Kl).call(this,"beforeScreen",{screen:e,context:t})}))}))},zl=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,$l,"m",Kl).call(this,"afterScreen",{screen:e})},Kl=function(e,t){i(this,$l,"m",vc).call(this,"bridge",{type:e,payload:t})},Hl=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(`[${ca}="${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()},Vl=function(){var e,n,o;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=t(void 0===n?{}:n,["errorText","errorType"]),o=t(e,["screenState"]);return Object.assign(Object.assign({},o),{screenState:i})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,$l,"m",Hl).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,$l,"m",Jl).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0})},Jl=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Ra(this.contentRootElement,this.autoFocus,!1))},Bl=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")}))},Yl=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=(e=>{var t,n,i;const o=(r=e.screenState,s=(e,t)=>wa.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(0,e)))));var r,s;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(o.error={text:a,type:l}),e.action&&(o.action=e.action),(null===(i=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===i?void 0:i.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o})(t(r,["next","stepName"]));let c=yield i(this,$l,"m",ql).call(this,a,l,s);c||(c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,l,s,this)));const d=!this.stepState.current.htmlFilename;if(i(this,Gl,"f").call(this,c),i(this,Xl,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,Xl,c,"f"),c?this.stepState.unsubscribeAll():i(this,$l,"m",Vl).call(this)}c&&(this.loggerWrapper.debug("Showing a custom screen"),i(this,$l,"m",rc).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName})),this.stepState.forceUpdate=c}))},Zl=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")},ic=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)}))}},oc=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,Wl,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield el())){const{options:e,transactionId:r}=(yield i(this,nc,"f").call(this))||{};e&&r&&(i(this,$l,"m",ic).call(this,s),o(this,Wl,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,Wl,"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)})))}}))},rc=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,$l,"m",vc).call(this,"ready",{}),t||i(this,$l,"m",zl).call(this,n),i(this,$l,"m",vc).call(this,"page-updated",{screenName:n}),i(this,$l,"m",vc).call(this,"screen-updated",{screenName:n})},sc=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},ac=function(){return n(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>n(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},cc=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),r=()=>n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",r),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const n=yield this.getFlowConfig(),i=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(i)})),s=()=>{var e;window.removeEventListener("pageshow",i(this,lc,"f")),o(this,lc,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),r())}),"f"),window.addEventListener("pageshow",i(this,lc,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&r(),this.removeEventListener("popupclosed",r),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},a=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?(this.addEventListener("popupclosed",r,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(a),s())}))},dc=function(e={}){var t,n;const i=Pa(e,["externalId","email","phone"]),o=Pa(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)}},uc=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,$l,"m",hc).call(this,e)))},hc=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)}))},fc=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,pc,"f").call(this,t,e)}))}))},gc=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${Xs}]), [data-type="button"]:not([${Xs}]`).forEach((t=>{t.onclick=()=>{i(this,pc,"f").call(this,t,e)}})),i(this,$l,"m",fc).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Bs}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},vc=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},mc=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===o&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",bc);var wc=Object.freeze({__proto__:null,default:bc});customElements.define("descope-tenant-profile-widget",Ns);const yc=(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 kc,Sc,Ic,Cc,xc,Oc,Ec,jc,Ac,Rc;const Uc=document.createElement("template");Uc.innerHTML=`\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;const Tc=r(q)(HTMLElement);class _c extends Tc{constructor(){var e;super(),kc.add(this),Sc.set(this,new f({messages:[]})),Ic.set(this,void 0),Cc.set(this,void 0),xc.set(this,void 0),Oc.set(this,{resize:i(this,kc,"m",Rc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Uc.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,Ic,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Cc,i(this,Ic,"f").querySelector(".content"),"f"),o(this,xc,i(this,Ic,"f").querySelector(".header"),"f")}updateData(e){i(this,Sc,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=yc(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,Ic,"f"),i(this,xc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Oc,"f").resize),(e=i(this,Ic,"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,Ic,"f").onresize=i(this,kc,"m",Ac).bind(this),i(this,Sc,"f").subscribe(i(this,kc,"m",Ec).bind(this))}disconnectedCallback(){i(this,Sc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Oc,"f").resize)}}Sc=new WeakMap,Ic=new WeakMap,Cc=new WeakMap,xc=new WeakMap,Oc=new WeakMap,kc=new WeakSet,Ec=function(e){i(this,kc,"m",jc).call(this,e),i(this,kc,"m",Ac).call(this)},jc=function(e){i(this,Cc,"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("")},Ac=function(){i(this,Cc,"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)}))},Rc=function(){const[e,t]=yc(i(this,Ic,"f"),Number.parseInt(i(this,Ic,"f").style.left,10),Number.parseInt(i(this,Ic,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Ic,"f").style.top=`${t}px`,i(this,Ic,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",_c);var Pc=Object.freeze({__proto__:null,default:_c});const Lc=(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))]},$c=(e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Lc(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c};var Mc,Wc,Nc,Dc,Fc,qc,zc,Kc,Hc,Vc,Jc;const Bc=document.createElement("template");Bc.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const Xc=r(q)(HTMLElement);class Yc extends Xc{constructor(){super(),Mc.add(this),Wc.set(this,new Ka({messages:[]})),Nc.set(this,void 0),Dc.set(this,void 0),Fc.set(this,void 0),qc.set(this,{resize:i(this,Mc,"m",Jc).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Bc.content.cloneNode(!0)),o(this,Nc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Dc,i(this,Nc,"f").querySelector(".content"),"f"),o(this,Fc,i(this,Nc,"f").querySelector(".header"),"f"),i(this,Mc,"m",zc).call(this)}updateData(e){i(this,Wc,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),$c(i(this,Nc,"f"),i(this,Fc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,qc,"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,Nc,"f")),i(this,Nc,"f").onresize=i(this,Mc,"m",Vc).bind(this),i(this,Wc,"f").subscribe(i(this,Mc,"m",Kc).bind(this))}))}disconnectedCallback(){i(this,Wc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,qc,"f").resize)}}Wc=new WeakMap,Nc=new WeakMap,Dc=new WeakMap,Fc=new WeakMap,qc=new WeakMap,Mc=new WeakSet,zc=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,Nc,"f").style.top="32px",i(this,Nc,"f").style.left=window.innerWidth-300-32+"px"},Kc=function(e){i(this,Mc,"m",Hc).call(this,e),i(this,Mc,"m",Vc).call(this)},Hc=function(e){i(this,Dc,"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("")},Vc=function(){i(this,Dc,"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)}))},Jc=function(){const[e,t]=Lc(i(this,Nc,"f"),Number.parseInt(i(this,Nc,"f").style.left,10),Number.parseInt(i(this,Nc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Nc,"f").style.top=`${t}px`,i(this,Nc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Yc);var Gc=Object.freeze({__proto__:null,default:Yc});return Ns}();
|
|
7
7
|
//# sourceMappingURL=index.js.map
|