@descope/outbound-applications-widget 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
- * @descope/outbound-applications-widget v0.3.2
3
+ * @descope/outbound-applications-widget v0.3.4
4
4
  */
5
- this["descope-outbound-applications-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.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=>{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 o=e(n);return o[t]=!0,o}};var l,c,d,u;function h(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!h(r,s))return!1}else if(r!==s)return!1}return!0}let p=class{constructor(e={},{forceUpdate:t=!1}={}){l.set(this,void 0),c.set(this,{}),d.set(this,0),u.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,l,"f")):e,n=Object.assign(Object.assign({},o(this,l,"f")),t);if(o(this,u,"f")||!h(o(this,l,"f"),n)){const e=o(this,l,"f");i(this,l,n,"f"),Object.freeze(o(this,l,"f")),setTimeout((()=>{Object.values(o(this,c,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,l,e,"f"),i(this,u,t,"f")}get current(){return Object.assign({},o(this,l,"f"))}subscribe(e){return i(this,d,o(this,d,"f")+1,"f"),o(this,c,"f")[o(this,d,"f")]=e,o(this,d,"f").toString()}unsubscribe(e){const t=!!o(this,c,"f")[e];return t&&delete o(this,c,"f")[e],t}unsubscribeAll(){return i(this,c,{},"f"),!0}};l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap;const f=["error","warn","info","debug"],g={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},v=a((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,g))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||g),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return f.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),m="undefined"!=typeof localStorage,b="https://static.descope.com/pages",w="https://static2.descope.com/pages",y=m&&localStorage.getItem("base.content.url")||"",k=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,I=a((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)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),S=a((e=>{var t,n;const i=r(v,I)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,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})),C=e=>t=>{var n,i,s;const a=r(v,I,S)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",i).bind(this))}async init(){var e;l.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};C.missingAttrValidator=k;const O=a((e=>{const t=r(C({"project-id":k}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),x=a((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),A="Trying the next fallback URL...",j=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(o){return null==n||n.debug(`Network error fetching URL ${e} [${o.message}], retrying...`),fetch(e,t)}};const E=a((e=>{var t,n,s,a,l,c,d;const u=r(v,O,x)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=o(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];i(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;o(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;e++){const r=i[e],s=e===i.length-1;try{const i=await j(r.toString(),t,{logger:n});if(i.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${r}`),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${A}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${A}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=y||this.baseStaticUrl;if(r)return o(this,t,"m",c).call(this,e,r);o(this,n,"f")!==this.baseUrl&&(i(this,n,this.baseUrl,"f"),i(this,s,void 0,"f"),o(this,a,"f").clear());const l=[];if(o(this,s,"f"))l.push(o(this,t,"m",c).call(this,e,o(this,s,"f"))),o(this,s,"f")===b&&l.push(o(this,t,"m",c).call(this,e,w));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&l.push(o(this,t,"m",c).call(this,e,n)),o(this,a,"f").has(b)||l.push(o(this,t,"m",c).call(this,e,b)),l.push(o(this,t,"m",c).call(this,e,w))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=b}){const i=new URL(o);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=o,i}({projectId:this.projectId,filename:e,baseUrl:t})},d})),R=a((e=>{var t,n;const i=r(C({"project-id":k}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),T=a((e=>{var t,n,s,a,l;const c=r(E,R,I)(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",o(this,t,"m",n).bind(this))}get config(){return o(this,s,"f")||i(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){i(this,s,void 0,"f")},l})),U=a((e=>{var t,n,s,a,l,c,d;return d=class extends(r(I,v)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(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)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return na})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),_=["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,n)=>new Promise(((o,i)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),i(e)},r.onload=()=>{r.setAttribute("status","loaded"),o(r)},r.src=t.toString(),document.body.appendChild(r)})),L=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},M=a((e=>{const t=r(v)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[],i){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${i?" with SRI integrity check":""}`),(async(e,t)=>{for(const o of e){const{id:e,url:i,integrity:r}=o,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await L(s,r),o}catch(e){t(o,!0)}else try{return await P(e,i,r),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="",i)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${o}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${$(a)}`};return i&&(l.integrity=i),[...e,l]}),[]))([...o,this.baseCdnUrl,..._],e,t,n,i),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),N="base.ui.components.url",W=m&&localStorage.getItem(N),D=a((e=>{var t,n,s,a,l,c,d;const u=r(v,T,M)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return o(this,a,"f")||i(this,a,o(this,t,"m",c).call(this),"f"),o(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await o(this,t,"m",n).call(this),i=await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[W],i),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),F=a((e=>{var t,n,i;const s=r(I,S)(e);return i=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",o(this,t,"m",n).bind(this)),o(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},i}));class q{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 z=a((e=>{const t=r(F)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new q(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const o=[...e.adoptedStyleSheets||[]];o[t?"unshift":"push"](n),e.adoptedStyleSheets=o}}return n}}})),V="content-root",K="root",H=a((e=>{const t=r(z)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${V}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${V} {\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(V),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),J="descope-modal";var B;let X=class{constructor(e,t){B.set(this,void 0),this.nodeName="",i(this,B,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,B,"f"))}get ele(){var e,t;const n="function"==typeof o(this,B,"f")?o(this,B,"f").call(this):o(this,B,"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}};B=new WeakMap;let G=class extends X{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}};var Y;let Z=class extends X{constructor(){super(...arguments),Y.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=""),o(this,Y,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,Y,"f").content.cloneNode(!0)))}setContent(e){i(this,Y,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};Y=new WeakMap;let Q=class extends X{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},ee=class extends X{constructor(){super(...arguments),this.nodeName="descope-outbound-apps"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get connectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("connect-flow-id"))||""}get disconnectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("disconnect-flow-id"))||""}onConnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("connect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("connect-clicked",n)}}onDisconnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("disconnect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("disconnect-clicked",n)}}};const te=a((e=>{var t,n;const i=r(I,H,D)(e);return n=class extends i{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(J);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([J]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ne="descope-notification";a((e=>{var t,n;const i=r(I,H,D)(e);return n=class extends i{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(ne);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(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([ne])}},t=new WeakMap,n}));const oe="theme",ie=(e,t,n="")=>Object.entries(e).reduce(((e,[o,i])=>{if(!/^[a-zA-Z0-9-]+$/.test(o))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${o}`:o;if("object"==typeof i&&null!==i)return e+ie(i,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(i);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),""),re=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',se=a((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,b,w,y;const k=r(C({theme:re}),E,I,D,T,H,S,z)(e);return y=class extends k{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),l.set(this,void 0),m.set(this,(()=>{o(this,t,"m",b).call(this),o(this,w,"f").call(this,"os"===this.getAttribute("theme"))})),w.set(this,(e=>{var n,i,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(this,t,"m",b).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||oe}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,m,"f").call(this),await Promise.all([o(this,t,"m",u).call(this),o(this,t,"m",p).call(this)]),await o(this,t,"m",h).call(this),this.observeAttributes(["theme"],o(this,m,"f")),this.observeAttributes(["theme-override"],(()=>o(this,t,"m",h).call(this))),this.observeAttributes(["style-id"],(()=>{i(this,l,null,"f"),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",p).call(this)}))}},n=new WeakMap,s=new WeakMap,l=new WeakMap,m=new WeakMap,w=new WeakMap,t=new WeakSet,a=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,i,r,s,a;const l=null===(i=null===(o=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===o?void 0:o.colors)||void 0===i?void 0:i.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${ie({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},c=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(N))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(N),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},d=function(){return o(this,l,"f")||(i(this,l,o(this,t,"m",c).call(this),"f"),o(this,l,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,l,"f")},u=async function(){var e,r;const s=await o(this,t,"a",d);s&&(o(this,n,"f")||i(this,n,this.injectStyle(""),"f"),o(this,n,"f").replaceSync(((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"")))},h=async function(){var e;this.themeOverride?(o(this,s,"f")||i(this,s,this.injectStyle(""),"f"),o(this,s,"f").replaceSync(o(this,t,"m",a).call(this))):null===(e=o(this,s,"f"))||void 0===e||e.replaceSync("")},p=async function(){var e,n;const i=await o(this,t,"a",d);if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},f=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},g=async function(){const e=await o(this,t,"m",f).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},v=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},b=function(){o(this,t,"m",g).call(this),o(this,t,"m",v).call(this)},y}));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 o=e,i=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 i}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,i=o(i,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)}`);o=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 o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&fe(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};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 o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===ce.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.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: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[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: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&fe(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],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||o.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 Ie(e,...t){{const n=ke[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Se=Object.getPrototypeOf;function Ce(e){return!!e&&!!e[ye]}function Oe(e){return!!e&&(Ae(e)||Array.isArray(e)||!!e[we]||!!e.constructor?.[we]||Ue(e)||_e(e))}var xe=Object.prototype.constructor.toString();function Ae(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 je(e,t){0===Ee(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Ee(e){const t=e[ye];return t?t.type_:Array.isArray(e)?1:Ue(e)?2:_e(e)?3:0}function Re(e,t){return 2===Ee(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Te(e,t,n){const o=Ee(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function Ue(e){return e instanceof Map}function _e(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(_e(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ae(e)){if(!Se(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[ye];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(Se(e),n)}function Le(e,t=!1){return Ne(e)||Ce(e)||!Oe(e)||(Ee(e)>1&&(e.set=e.add=e.clear=e.delete=Me),Object.freeze(e),t&&je(e,((e,t)=>Le(t,!0)))),e}function Me(){Ie(2)}function Ne(e){return Object.isFrozen(e)}var We,De={};function Fe(e){const t=De[e];return t||Ie(0,e),t}function qe(){return We}function ze(e,t){t&&(Fe("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ve(e){Ke(e),e.drafts_.forEach(Je),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 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_&&(Ve(t),Ie(4)),Oe(e)&&(e=Xe(t,e),t.parent_||Ye(t,e)),t.patches_&&Fe("Patches").generateReplacementPatches_(n[ye].base_,e,t.patches_,t.inversePatches_)):e=Xe(t,n,[]),Ve(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==be?e:void 0}function Xe(e,t,n){if(Ne(t))return t;const o=t[ye];if(!o)return je(t,((i,r)=>Ge(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return Ye(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),je(i,((i,s)=>Ge(e,o,t,i,s,n,r))),Ye(e,t,!1),n&&e.patches_&&Fe("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Ge(e,t,n,o,i,r,s){if(i===n&&Ie(5),Ce(i)){const s=Xe(e,i,r&&t&&3!==t.type_&&!Re(t.assigned_,o)?r.concat(o):void 0);if(Te(n,o,s),!Ce(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(Oe(i)&&!Ne(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Xe(e,i),t&&t.scope_.parent_||Ye(e,i)}}function Ye(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Le(t,n)}var Ze={get(e,t){if(t===ye)return e;const n=$e(e);if(!Re(n,t))return function(e,t,n){const o=tt(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!Oe(o)?o:o===et(e.base_,t)?(ot(e),e.copy_[t]=it(o,e)):o},has:(e,t)=>t in $e(e),ownKeys:e=>Reflect.ownKeys($e(e)),set(e,t,n){const o=tt($e(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=et($e(e),t),i=o?.[ye];if(i&&i.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,o)&&(void 0!==n||Re(e.base_,t)))return!0;ot(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,ot(e),nt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=$e(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Ie(11)},getPrototypeOf:e=>Se(e.base_),setPrototypeOf(){Ie(12)}},Qe={};function et(e,t){const n=e[ye];return(n?$e(n):e)[t]}function tt(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 nt(e){e.modified_||(e.modified_=!0,e.parent_&&nt(e.parent_))}function ot(e){e.copy_||(e.copy_=Pe(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))&&Ie(13),Qe.set.call(this,e,t,void 0)},Qe.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Ie(14),Ze.set.call(this,e[0],t,n,e[0])};function it(e,t){const n=Ue(e)?Fe("MapSet").proxyMap_(e,t):_e(e)?Fe("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={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 i=o,r=Ze;n&&(i=[o],r=Qe);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:qe()).drafts_.push(n),n}function rt(e){return Ce(e)||Ie(10,e),st(e)}function st(e){if(!Oe(e)||Ne(e))return e;const t=e[ye];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 je(n,((e,t)=>{Te(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 o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&Ie(6),void 0!==n&&"function"!=typeof n&&Ie(7),Oe(e)){const i=He(this),r=it(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?Ve(i):Ke(i)}return ze(i,n),Be(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===be&&(o=void 0),this.autoFreeze_&&Le(o,!0),n){const t=[],i=[];Fe("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Ie(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Oe(e)||Ie(8),Ce(e)&&(e=rt(e));const t=He(this),n=it(e,void 0);return n[ye].isManual_=!0,Ke(t),n}finishDraft(e,t){const n=e&&e[ye];n&&n.isManual_||Ie(9);const{scope_:o}=n;return ze(o,t),Be(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Fe("Patches").applyPatches_;return Ce(e)?o(e,t):this.produce(e,(e=>o(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:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);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:o}=e;for(let i=0;i<o;i++)n.push(e[i].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:o}=t;let i,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 o=e.get(n);void 0===o?(t=bt(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=bt(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===mt)l=t.v;else if(l=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,l)&&(l=e,0!==r&&r--);i="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,o=(...e)=>{let t,o=0,i=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 o++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){i++;const e=ft(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...ut,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ct},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:dt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=ft(g,arguments);o.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:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var kt=yt(wt),It=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),o=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})));return o}),{withTypes:()=>It});function St(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var Ct=St(),Ot=St;((...e)=>{const t=yt(...e)})(wt);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]?ve:ve.apply(null,arguments)},At=e=>e&&"function"==typeof e.match;function jt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>me(t)&&t.type===e,n}function Et(e){return"function"==typeof e&&"type"in e&&At(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 Tt=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 Oe(e)?lt(e,(()=>{})):e}function _t(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function $t(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Pt(e,t,n){const o=Lt(e,t,n);return{detectMutations:()=>Mt(e,t,o,n)}}function Lt(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=Lt(e,t,n[i],s))}}return r}function Mt(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let i in l){const s=r?r+"."+i:i;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Mt(e,t,n.children[i],o[i],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Nt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||de(e)}function Wt(e,t="",n=Nt,o,i=[],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!=o?o(e):Object.entries(e),l=i.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(i.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,o,i,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:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new Tt;if(t&&(Ft(t)?r.push(Ct):r.push(Ot(t.extraArgument))),n){let e={};Ft(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=$t,ignoredPaths:i,warnAfter:r=32}=e;const s=Pt.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>l=>{const c=Rt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),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(o=e(),n=i.detectMutations(),i=s(o),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(o){let e={};Ft(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=Nt,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["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||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=Wt(u,"",t,n,i,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 o=Wt(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;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(i){let e={};Ft(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Et}=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)},Vt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:zt(10),Kt=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Tt(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let i=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?Vt:"callback"===e.type?e.queueNotification:zt(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,l(c))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function Ht(e){const t=qt(),{reducer:n,middleware:o,devTools:i=!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(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(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;i&&(c=xt({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);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:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=ve(...a)(i.dispatch),{...i,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 pe(a,r,c(...h))}function Jt(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)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,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function Bt(...e){return t=>e.some((e=>((e,t)=>At(e)?e.match(t):e(t))(e,t)))}var Xt=["name","message","stack","code"],Gt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Yt=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 o=jt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=jt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=jt(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||Zt)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,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(i(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 Gt(e,t),fulfillWithValue:(e,t)=>new Yt(e,t)})).then((t=>{if(t instanceof Gt)throw t;return t instanceof Yt?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof Gt?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:i,rejected:r,fulfilled:o,settled:Bt(r,o),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,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var rn=function({creators:e}={}){const t=e?.asyncThunk?.[tn];return function(e){const{name:n,reducerPath:o=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 i=("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(i),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=[],o]="function"==typeof e.extraReducers?Jt(e.extraReducers):[e.extraReducers],i={...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,[o,i,r]=Jt(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=[o[t.type],...i.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 o=n(e,t);return void 0===o?e:o}if(Oe(e))return lt(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:nn(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?jt(e,s):jt(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)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=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.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:o,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[o,i]of Object.entries(e.selectors??{}))n[o]=on(this,i,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 o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function sn(){}var an="listenerMiddleware";jt(`${an}/add`),jt(`${an}/removeAll`),jt(`${an}/remove`);const ln=e=>a((t=>{const n=rn(e),o=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}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{en(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));a((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=a((e=>{const t=r(C({"widget-id":k}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}}));a((e=>{const t=r(T,cn)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}}));const dn=a((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),un=(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 hn(e){return new URLSearchParams(window.location.search).get(e)}const pn=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)}))}))},fn=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}}),gn=Qt("outboundApps/load",((e,{extra:{api:t}})=>t.outboundApps.getAllOutboundApps())),vn=pn(gn)({onFulfilled:(e,t)=>{var n;e.outboundAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},fn((e=>e.outboundAppsList))),mn={action:gn,reducer:vn},bn=Qt("outboundApps/getConnectedOutboundApps",((e,{extra:{api:t}})=>t.outboundApps.getConnectedOutboundApps(e))),wn=pn(bn)({onFulfilled:(e,t)=>{var n;e.connectedOutboundAppsIds.data=null===(n=t.payload)||void 0===n?void 0:n.appIds}},fn((e=>e.connectedOutboundAppsIds))),yn={action:bn,reducer:wn},kn={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}};class In extends Error{}function Sn(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 In("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,o=e.split(".")[n];if("string"!=typeof o)throw new In(`Invalid token specified: missing part #${n+1}`);let i;try{i=Sn(o)}catch(e){throw new In(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}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 xn="<region>",An=`https://api.${xn}descope.com`,jn=6e5,En="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")}},Tn=[503,521,522,524,530],Un=[100,5e3,5e3],_n=e=>new Promise((t=>setTimeout(t,e))),$n=e=>async(...t)=>{let n=await e(...t),o=0;for(;Tn.includes(n.status)&&o<Un.length;)await _n(Un[o]),n=await e(...t),o++;o>0&&(n.retries=o);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 Mn;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(Mn||(Mn={}));const Nn=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(xn,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===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)),{})),Dn={"Content-Type":"application/json"},Fn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},qn=(e,t)=>{const n={"x-descope-sdk-session-id":Ln(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.62.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},zn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var Vn=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||An,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 o=await $n(n)(...t);return e[o.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()})(o)),o}:$n(n)})(i,a),d=async e=>{var i;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(Fn(t,g),qn(t,o),(null==n?void 0:n.baseHeaders)||{},zn(v)?Dn:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const b=await c(Nn({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==b?void 0:b.clone()),null==r?void 0:r.transformResponse){const e=await b.json(),t=(w=(null===(i=b.headers)||void 0===i?void 0:i.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function o(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function i(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;o();)if(","===e.charAt(n)){for(s=n,n+=1,o(),a=n;n<e.length&&i();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}var w;return b};return{get:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Mn.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Mn.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Mn.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Mn.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Mn.delete,token:o}),hooks:r,buildUrl:(e,n)=>Nn({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.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 o;let i=Jn(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[En])===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function Jn(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Cn(e)}function Bn(e){const{exp:t}=Jn(e);return(new Date).getTime()/1e3>t}function Xn(e){let t=Jn(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Gn(e,t){return Hn(e,t,"permissions")}function Yn(e,t){return Hn(e,t,"roles")}const Zn=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Qn(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=r:(i.error=r,o.status===Kn&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function eo(e){var t;return(null===(t=Jn(e))||void 0===t?void 0:t[En])||""}const to=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),no=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},oo=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),io=e=>t=>e.test(t),ro=io(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),so=io(/^\+[1-9]{1}[0-9]{3,14}$/),ao=to(ro,'"{val}" is not a valid email'),lo=to(so,'"{val}" is not a valid phone number'),co=to((e=>e.length>=1),"Minimum length is 1");const uo=to((e=>"string"==typeof e),"Input is not a string"),ho=to((e=>Array.isArray(e)),"Input is not an array"),po=to((e=>"boolean"==typeof e),"Input is not a boolean"),fo=to((e=>void 0===e),"Input is defined"),go=no([uo(),fo()],"Input is not a string or undefined"),vo=no([ho(),po()],"Input is not an array or boolean"),mo=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>oo(...e).validate(n[t]))),t(...n)),bo=e=>[uo(`"${e}" must be a string`)],wo=e=>[go(`"${e}" must be string or undefined`)],yo=e=>[uo(`"${e}" must be a string`),co(`"${e}" must not be empty`)],ko=e=>[uo(`"${e}" must be a string`),ao()],Io=e=>[uo(`"${e}" must be a string`),lo()],So=mo(yo("accessKey")),Co=e=>({exchange:So(((t,n)=>Qn(e.post(On.accessKey.exchange,{loginOptions:n},{token:t}))))}),Oo=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),xo=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||jn,jn)});var Ao,jo;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Ao||(Ao={})),function(e){e.email="email"}(jo||(jo={}));const Eo=Object.assign(Object.assign({},Ao),jo);var Ro;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ro||(Ro={}));const To=yo("loginId"),Uo=mo(yo("token")),_o=mo(To),$o=mo(yo("pendingRef")),Po=mo(To,ko("email")),Lo=e=>({verify:Uo((t=>Qn(e.post(On.enchantedLink.verify,{token:t})))),signIn:_o(((n,o,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return Qn(e.post(Zn(On.enchantedLink.signIn,Eo.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:_o(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Qn(e.post(Zn(On.enchantedLink.signUpOrIn,Eo.email),{loginId:n,URI:o,loginOptions:s,providerId:r}))})),signUp:_o(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Qn(e.post(Zn(On.enchantedLink.signUp,Eo.email),{loginId:n,URI:o,user:i,loginOptions:a,providerId:s}))})),waitForSession:$o(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=xo(n);let s;const a=setInterval((async()=>{const n=await e.post(On.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Qn(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Po(((t,n,o,i,r)=>Qn(e.post(On.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),Mo=mo(yo("flowId")),No=mo(yo("executionId"),yo("stepId"),yo("interactionId")),Wo=e=>({start:Mo(((t,n,o,i,r,s,a,l=!1)=>Qn(e.post(On.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:No(((t,n,o,i,r,s,a=!1)=>Qn(e.post(On.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a}))))}),Do=yo("loginId"),Fo=mo(yo("token")),qo=mo(Do),zo=mo(Do,Io("phone")),Vo=mo(Do,ko("email")),Ko=Object.keys(Eo).filter((e=>e!==Ao.voice&&e!==Ao.im)),Ho=e=>({verify:Fo((t=>Qn(e.post(On.magicLink.verify,{token:t})))),signIn:Ko.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:qo(((n,i,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Qn(e.post(Zn(On.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:Ko.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:qo(((n,i,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Qn(e.post(Zn(On.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:Ko.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:qo(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Qn(e.post(Zn(On.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:Vo(((t,n,o,i,r)=>Qn(e.post(On.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Ao).filter((e=>e!==Ao.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:zo(((t,o,i,r,s)=>Qn(e.post(Zn(On.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var Jo;!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"}(Jo||(Jo={}));const Bo=mo(yo("code")),Xo=e=>({start:Object.assign(((t,n,o,i,r)=>Qn(e.post(On.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(Jo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>Qn(e.post(On.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:Bo((t=>Qn(e.post(On.oauth.exchange,{code:t})))),startNative:(t,n,o)=>Qn(e.post(On.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>Qn(e.post(On.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>Qn(e.get(On.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>Qn(e.post(On.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>Qn(e.post(On.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Go=yo("appId"),Yo=mo(Go),Zo=e=>({connect:Yo(((t,n,o)=>{const i=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Qn(e.post(On.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),Qo=yo("loginId"),ei=mo(Qo,yo("code")),ti=mo(Qo),ni=mo(Qo,Io("phone")),oi=mo(Qo,ko("email")),ii=e=>({verify:Object.keys(Eo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ei(((t,o)=>Qn(e.post(Zn(On.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Eo).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ti(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return Qn(e.post(Zn(On.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Eo).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ti(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Qn(e.post(Zn(On.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Eo).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ti(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Qn(e.post(Zn(On.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:oi(((t,n,o,i)=>Qn(e.post(On.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Ao).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ni(((t,o,i,r)=>Qn(e.post(Zn(On.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),ri=mo(yo("tenant")),si=mo(yo("code")),ai=e=>({start:ri(((t,n,o,i,r,s,a,l)=>Qn(e.post(On.saml.start,o||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},i&&{token:i}))))),exchange:si((t=>Qn(e.post(On.saml.exchange,{code:t}))))}),li=yo("loginId"),ci=mo(li,yo("code")),di=mo(li),ui=mo(li),hi=e=>({signUp:di(((t,n)=>Qn(e.post(On.totp.signUp,{loginId:t,user:n})))),verify:ci(((t,n,o,i)=>Qn(e.post(On.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:ui(((t,n)=>Qn(e.post(On.totp.update,{loginId:t},{token:n}))))}),pi=yo("loginId"),fi=yo("newPassword"),gi=mo(pi,yo("password")),vi=mo(pi),mi=mo(pi,fi),bi=mo(pi,yo("oldPassword"),fi),wi=e=>({signUp:gi(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Qn(e.post(On.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:gi(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Qn(e.post(On.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:vi(((t,n,o)=>Qn(e.post(On.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:mi(((t,n,o)=>Qn(e.post(On.password.update,{loginId:t,newPassword:n},{token:o})))),replace:bi(((t,n,o)=>Qn(e.post(On.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>Qn(e.get(On.password.policy))}),yi=bo("loginId"),ki=yo("loginId"),Ii=yo("origin"),Si=mo(ki,Ii,yo("name")),Ci=mo(ki,Ii),Oi=mo(yi,Ii),xi=mo(ki,Ii,wo("token")),Ai=mo(yo("transactionId"),yo("response")),ji=e=>({signUp:{start:Si(((t,n,o,i,r)=>Qn(e.post(On.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:r,passkeyOptions:i})))),finish:Ai(((t,n)=>Qn(e.post(On.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Oi(((t,n,o,i,r)=>Qn(e.post(On.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:Ai(((t,n)=>Qn(e.post(On.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ci(((t,n,o,i)=>Qn(e.post(On.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:o}))))},update:{start:xi(((t,n,o,i)=>Qn(e.post(On.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i},{token:o})))),finish:Ai(((t,n)=>Qn(e.post(On.webauthn.update.finish,{transactionId:t,response:n}))))}}),Ei=bo("loginId"),Ri=mo(Ei),Ti=mo(yo("pendingRef")),Ui=e=>({signUpOrIn:Ri(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return Qn(e.post(On.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:Ri(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Qn(e.post(On.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:Ri(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return Qn(e.post(On.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:Ti(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=xo(n);let s;const a=setInterval((async()=>{const n=await e.post(On.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Qn(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),_i=mo(yo("token")),$i=mo(wo("token"));var Pi,Li=mo([(Pi=yo("projectId"),to(((e,t)=>n=>oo(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",Pi))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=Vn({baseUrl:o,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:i,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:Co(l),otp:ii(l),magicLink:Ho(l),enchantedLink:Lo(l),oauth:Xo(l),outbound:Zo(l),saml:ai(l),totp:hi(l),notp:Ui(l),webauthn:ji(l),password:wi(l),flow:Wo(l),refresh:$i(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?On.tryRefresh:On.refresh;return Qn(l.post(r,i,{token:e,queryParams:t}))})),selectTenant:mo([uo("tenantId")],[go('"token" must be string or undefined')])(((e,t)=>Qn(l.post(On.selectTenant,{tenant:e},{token:t})))),logout:$i((e=>Qn(l.post(On.logout,{},{token:e})))),logoutAll:$i((e=>Qn(l.post(On.logoutAll,{},{token:e})))),me:$i((e=>Qn(l.get(On.me,{token:e})))),myTenants:mo([vo('"tenants" must a string array or a boolean')],[go('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Qn(l.post(On.myTenants,n,{token:t}))})),history:$i((e=>Qn(l.get(On.history,{token:e})))),isJwtExpired:_i(Bn),getTenants:_i(Xn),getJwtPermissions:_i(Gn),getJwtRoles:_i(Yn),getCurrentTenant:_i(eo),httpClient:l};var l})),Mi=Object.assign(Li,{DeliveryMethods:Eo});
6
- /*! js-cookie v3.0.5 | MIT */function Ni(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var Wi=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=Ni({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",Ni({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Ni({},this.attributes,t))},withConverter:function(t){return e(Ni({},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 Di={default:"endpoint"},Fi="Blocked by CSP",qi="The endpoint parameter is not a valid URL",zi="Failed to load the JS script of the agent",Vi="9319";function Ki(e,t){var n,o,i,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||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,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Fi||s===qi)n.exclude(),r=0;else if(s===Vi)n.exclude();else if(s===zi){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+o()-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,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(i)}))}))};return u(c).then((function(e){return[e,a]}))}var Hi="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Ji=Hi;function Bi(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:Hi,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(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 Ki(e,Xi)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Vi?new Error(zi):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function Xi(e){return function(e,t,n){var o,i=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,a())};i.addEventListener(r,s);var a=function(){return i.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(),o)return n(o);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(qi);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(zi))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(Fi)})).then(Gi)}function Gi(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Vi);return n}const Yi="3.2.0",Zi="undefined"!=typeof window,Qi=Math.pow(2,31)-1,er=`https://descopecdn.com/npm/oidc-client-ts@${Yi}/dist/browser/oidc-client-ts.min.js`,tr=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Yi}/dist/browser/oidc-client-ts.min.js`,nr=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let or;const ir=e=>{try{return Cn(e).exp}catch(e){return null}},rr=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ir(n)},sr=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?ir(o):void 0)},ar=e=>{const{access_token:n,id_token:o,refresh_token:i,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:o,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||sr(e),cookieExpiration:e.cookieExpiration||rr(e)},s)},lr=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},cr=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 ar(n)},dr=()=>Zi&&!!window.descopeBridge,ur=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return nr.includes(n)},hr=void 0!==or||Zi&&void 0!==window.localStorage,pr=(e,t)=>{var n,o;return null===(o=null===(n=or||Zi&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},fr=e=>{var t,n;return null===(n=null===(t=or||Zi&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},gr=e=>{var t,n;return null===(n=null===(t=or||Zi&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},vr=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==or?void 0:or.key)||void 0===t?void 0:t.call(or,e))&&void 0!==n?n:Zi&&(null===(i=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===i?void 0:i.call(o,e)))&&void 0!==r?r:null},mr=(...e)=>{console.debug(...e)},br=(...e)=>{console.warn(...e)},wr="DS",yr="DSR",kr="DSI",Ir="DSRCN";function Sr(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Cr(o);Wi.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}function Cr(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const Or=e=>(null==e?void 0:e.cookieName)||wr,xr=e=>(null==e?void 0:e.cookieName)||yr;function Ar(e="",t){return Wi.get(xr(t))||fr(`${e}${yr}`)||""}function jr(e="",t){return Wi.get(Or(t))||fr(`${e}${wr}`)||""}function Er(e=""){return fr(`${e}${kr}`)||""}function Rr(e="",t,n,o){gr(`${e}${yr}`),gr(`${e}${wr}`),gr(`${e}${kr}`),gr(`${e}${Ir}`);const i=Or(t);Wi.remove(i,null==o?void 0:o.session);const r=xr(n);Wi.remove(r,null==o?void 0:o.refresh)}const Tr=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||Ar(e,t)});if(!n){const t=function(e=""){return fr(`${e}${Ir}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return fr(`${e}DTD`)||""}(e);return r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r})),i},Ur=Zi&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",_r="vsid",$r="vrid",Pr="fp",Lr=(e=!1)=>{const t=fr(Pr);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Mr=async(e,t=Ur)=>{try{if(Lr())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Bi({apiKey:e,endpoint:[o.toString(),Di],scriptUrlPattern:[r,Ji]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[_r]:e,[$r]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};pr(Pr,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Nr=e=>{const t=Lr(!0);return t&&e.body&&(e.body.fpData=t),e},Wr="descopeFlowNonce",Dr="X-Descope-Flow-Nonce",Fr="/v1/flow/start",qr="/v1/flow/next",zr=(e,t=Wr)=>`${t}${e}`,Vr=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Kr=e=>{var t;return e.path===qr&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Vr(e.body.executionId):null},Hr="dls_last_user_login_id",Jr="dls_last_user_display_name",Br=e=>pr(Hr,e),Xr=()=>fr(Hr),Gr=()=>fr(Jr),Yr=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=Xr(),r=Gr();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},Zr="DSLI",Qr=e=>async(...t)=>{const n=await e(...t);return gr(Zr),n};function es(){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 ts(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=as(n.publicKey.challenge),n.publicKey.user.id=as(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=as(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:ls(n.rawId),type:n.type,response:{attestationObject:ls(n.response.attestationObject),clientDataJSON:ls(n.response.clientDataJSON)}});var n}async function ns(e){const t=rs(e);return ss(await navigator.credentials.get(t))}async function os(e,t){const n=rs(e);return n.signal=t.signal,n.mediation="conditional",ss(await navigator.credentials.get(n))}async function is(e=!1){var t,n;if(!Zi)return Promise.resolve(!1);if(dr()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function rs(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=as(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=as(e.id)})),n}function ss(e){return JSON.stringify({id:e.id,rawId:ls(e.rawId),type:e.type,response:{authenticatorData:ls(e.response.authenticatorData),clientDataJSON:ls(e.response.clientDataJSON),signature:ls(e.response.signature),userHandle:e.response.userHandle?ls(e.response.userHandle):void 0}})}function as(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ls(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var cs,ds=(cs=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ts(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await ns(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await ts(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await ns(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ts(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:ts,get:ns,isSupported:is,conditional:os}}),(...e)=>{const t=cs(...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 us="/fedcm/config",hs=()=>{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 ps(e,t){var n;try{await fs(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function fs(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=hs(),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(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var gs=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await is(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let vs;const ms=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);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",(()=>{ms(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),bs=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{vs||(vs=(async()=>{try{return require("oidc-client-ts")}catch(e){return ms([er,tr],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await vs;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new i({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}})(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.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)))),pr(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var i;const{client:r}=await o(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=fr(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 i.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:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||Er(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return gr(i),t||window.location.replace(s),r}}},ws=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,or=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Zi?(o&&i&&Mr(o).catch((()=>null)),e(lr(r,{beforeRequest:Nr}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.50.1"},t.baseHeaders)}))),(e=>t=>{const n=es(),o=es(),i=es(),r=es(),s=e(lr(t,{afterRequest:async(e,t)=>{if(ur(e,t))mr("Session invalidated, notifying subscribers with empty values"),o.pub(null),i.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await cr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&i.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await cr(t);s&&o.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Oo(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return o.pub(null),i.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:o.sub,onUserChange:i.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var o;const{enableFlowNonce:i=!0,nonceStoragePrefix:r=Wr}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(s);((e=Wr)=>{try{if(!hr)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==or?void 0:or.length)&&void 0!==t?t:Zi&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=vr(i);if(t&&t.startsWith(e)){const n=fr(t);if(n)try{JSON.parse(n).expiry<Date.now()&&gr(t)}catch(e){gr(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=e(lr(s,{afterRequest:async(e,t)=>{if(e.path!==Fr&&e.path!==qr)return;const{nonce:n,executionId:o}=await(async(e,t)=>{try{const n=t.headers.get(Dr);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Kr(e)),{nonce:n,executionId:Vr(o)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&o&&((e,t,n,o=Wr)=>{try{const i=zr(e,o),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};pr(i,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(o,n,e.path===Fr,r)},beforeRequest:e=>{if(e.path===qr){const t=Kr(e);if(t){const n=((e,t=Wr)=>{try{const n=zr(e,t),o=fr(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(((e,t=Wr)=>{try{const n=zr(e,t);gr(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):i.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,r);n&&(e.headers=e.headers||{},e.headers[Dr]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let i;e=new Promise((e=>{i=e})),await o;try{return await t(...n)}finally{i()}}}return a}),(e=>t=>{const n=e(lr(t,{afterRequest:async(e,t)=>{if(ur(e,t))return void gr(Zr);const n=await cr(t);(null==n?void 0:n.sessionExpiration)&&pr(Zr,String(n.sessionExpiration))}}));return Oo(n,["logout","logoutAll","oidc.logout"],Qr)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);const r=!!o,s="object"==typeof o&&(null==o?void 0:o.customActivityTracking);if(!r||dr())return Object.assign(e(i),{markUserActive:()=>{br("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(mr("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Zi&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(mr("Expiration time passed, refreshing session"),f.refresh(Ar()||d))}));const f=e(lr(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i,nextRefreshSeconds:r}=await cr(t);if(ur(e,t))mr("Session invalidated, canceling all timers"),a();else if(n||i){if(c=((e,t)=>{if(t)return new Date(1e3*t);mr("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,i),!c)return void mr("Could not extract expiration time from session token");d=o,h=r>0;const e=((e,t)=>{let n;var o;return t>0?(n=1e3*t,mr(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>Qi&&(mr(`Timeout is too large (${n}ms), setting it to ${Qi}ms`),n=Qi),n})(c,r);if(a(),e<=2e4)return void mr("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});mr(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Zi&&"hidden"===document.visibilityState)mr("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return mr("Skipping refresh due to timer - user is idle"),void(p=!0);mr("Refreshing session due to timer"),f.refresh(Ar()||o)}}),e)}}}));return Object.assign(Oo(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return mr("Clearing all timers"),a(),n})),{markUserActive:u?()=>{mr("markUserActive() called"),h||mr("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(mr("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Ar()||d))}:()=>{br("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:Xr,getLastUserDisplayName:Gr});const s=e(lr(r,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:i}=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=ar((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==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;r?(Br(r),(e=>{pr(Jr,e)})(s)):(null==i?void 0:i.loginId)&&Br(i.loginId)}}));let a=Oo(s,["flow.start"],Yr);return a=Oo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(gr(Hr),gr(Jr)),o})(i)),Object.assign(a,{getLastUserLoginId:Xr,getLastUserDisplayName:Gr})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!Zi)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(lr(Object.assign({refreshCookieName:a},l),{beforeRequest:Tr(s,r,a),afterRequest:async(e,t)=>{if(ur(e,t))mr("Session invalidated, clearing persisted tokens"),Rr(s,i,r,c);else{const e=await cr(t);e.cookieName?pr(`${s||""}${Ir}`,e.cookieName):e.refreshJwt&&gr(`${s||""}${Ir}`);const n=((e={},t=!1,n="",o=!1)=>{var i,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(o){gr(`${n}${yr}`);const t=o.sameSite||"Strict",s=null===(i=o.secure)||void 0===i||i,a=null!==(r=o.domain)&&void 0!==r?r:e.cookieDomain,l=xr(o);s&&"https:"!==window.location.protocol&&br("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Sr(l,c,d);const h=Cr(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=xr(o);Wi.remove(e),pr(`${n}${yr}`,c)}if(l)if(t){const n=t.sameSite||"Strict",o=null===(s=t.secure)||void 0===s||s,i=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=Or(t);o&&"https:"!==window.location.protocol&&br("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});Sr(r,l,c);const d=Cr(i);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?i:void 0}})}else pr(`${n}${wr}`,l);return e.idToken&&pr(`${n}${kr}`,e.idToken),d&&pr(`${n}DTD`,d),u})(e,i,s,r);n&&(c=n)}}})),u=Oo(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return Rr(e,t,n,null==o?void 0:o()),s})(s,i,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Ar(s,r),getSessionToken:()=>jr(s,i),getIdToken:()=>Er(s)})}))((e=>{const t=Mi(e),n=bs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(dr())return mr(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(i&&!fr(Zr)&&!fr(Hr)&&!fr("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=jr(),a=Ar();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){mr("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},l,i)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:gs(t),webauthn:ds(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){ps(o,e)},requestAuthentication(e){ps(o,e)}},async oneTap(e,t,n,i,r){await fs(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:i,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(i+us),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>Zi&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+us);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var o,i})),ys={allOutboundApps:"/v1/mgmt/outbound/apps",connectedOutboundApps:"/v1/mgmt/outbound/apps-with-user-token"},ks={me:"/v1/auth/me"},Is=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)})),Ss=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))})),Cs=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))})),Os=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))})),xs=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>n(void 0,void 0,void 0,(function*(){if(t)return Ss();const n=yield e.get(ys.allOutboundApps);return yield Is(n),n.json()})),getConnectedOutboundApps:o=>n(void 0,[o],void 0,(function*({userId:n,tenantId:o}){if(t)return Cs();const i=yield e.get(ys.connectedOutboundApps,{queryParams:o?{userId:n,tenantId:o}:{userId:n}});return yield Is(i),i.json()}))}),As=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return Os();const n=yield e.get(ks.me);return yield Is(n),n.json()}))}),js=a((e=>{var t,s,a,l;const c=r(O,S,v,dn,x)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||oe}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(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"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,n)=>{const o=ws(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.3.2"}}));return{outboundApps:xs({httpClient:o.httpClient,mock:t}),user:Object.assign({},As({httpClient:o.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),Es=Qt("users/me",((e,{extra:{api:t}})=>t.user.me())),Rs={action:Es,reducer:pn(Es)({onFulfilled:(e,t)=>{e.me.data=t.payload}},fn((e=>e.me)))},Ts=a((e=>{const t=r(ln({name:"widget",initialState:kn,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{Rs.reducer(e),yn.reducer(e),mn.reducer(e)},asyncActions:{getMe:Rs.action,getOutboundApps:mn.action,getConnectedOutboundApps:yn.action}}),I,v,js)(e);return class extends t{constructor(...e){super(...e),this.state=kn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Us="widget-flow",_s=a((e=>{var t,i,s;return s=class extends(r(I,te,Ts,dn,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=hn(Us);r&&(!function(e){if(window.history.replaceState&&hn(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())}}(Us),o(this,t,"m",i).call(this,r))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(un({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));new G((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),$s=kt((e=>e.outboundAppsList.data),(e=>e.connectedOutboundAppsIds.data),(e=>e.allowedAppsIds.data),((e,t,n)=>e.filter((e=>void 0===n||n.includes(e.id))).map((e=>{const n=(null==t?void 0:t.includes(e.id))||!1;return Object.assign(Object.assign({},e),{appId:e.id,isConnected:n})})).sort(((e,t)=>e.name.localeCompare(t.name))))),Ps=kt((e=>e.me.data),(e=>e.userId)),Ls=a((e=>{const t=r(E,C({"widget-id":C.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(`outbound-applications-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Ms=a((e=>{var t,i,a,l,c;return c=class extends(r(v,I,D,H,Ls,Ts)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,n,i){"allowed-outbound-apps-ids"===e&&n!==i&&this.actions.setAllowedAppsIds(o(this,t,"a",l))}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(o(this,t,"a",l)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:Ps(this.state),tenantId:this.tenantId})]);const r=yield o(this,t,"m",i).call(this);o(this,t,"m",a).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},a=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},l=function(){var e;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const t=null===(e=this.getAttribute("allowed-outbound-apps-ids"))||void 0===e?void 0:e.trim();return t?t.split(",").map((e=>e.trim())).filter(Boolean):[]},c})),Ns=a((e=>class extends(r(se,S)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Ws=a((e=>{var t,s,a,l,c,d,u,h,p,f,g,m,b,w,y,k,I;return I=class extends(r(Ns,Ts,v,Ms,te)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),u.set(this,null),h.set(this,null),k.set(this,(e=>{let t,n;return(...o)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,o)||(t=o,n=e(...o)),n)})((e=>{o(this,s,"f").data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",y).call(this,$s(this.state)),o(this,t,"m",p).call(this),o(this,t,"m",m).call(this),this.subscribe(o(this,k,"f").bind(this),$s)}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,k=new WeakMap,t=new WeakSet,p=function(){o(this,s,"f").connectFlowId&&(i(this,a,this.createModal({"data-id":"outbound-apps-connect"}),"f"),o(this,a,"f").afterClose=()=>{var e;if(o(this,u,"f")){const t=null===(e=o(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",o(this,u,"f")),i(this,u,null,"f")}},i(this,c,new G((()=>{var e;return null===(e=o(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(o(this,c,"f")))},f=function(e,t,n){e.open(),t.removeEventListener("page-updated",n)},g=function(e,n){var i;const r=null===(i=e.ele)||void 0===i?void 0:i.querySelector("descope-wc"),s=()=>o(this,t,"m",f).call(this,e,r,s);n=s,null==r||r.addEventListener("page-updated",n)},m=function(){i(this,l,this.createModal({"data-id":"outbound-apps-disconnect"}),"f"),i(this,d,new G((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=()=>{var e;if(o(this,h,"f")){const t=null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",o(this,h,"f")),i(this,h,null,"f")}},this.syncFlowTheme(o(this,d,"f"))},b=function(e){o(this,a,"f").setContent(un({projectId:this.projectId,flowId:o(this,s,"f").connectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:e})),o(this,t,"m",g).call(this,o(this,a,"f"),o(this,u,"f")),o(this,c,"f").onSuccess((()=>{o(this,a,"f").close(),this.actions.getConnectedOutboundApps({userId:Ps(this.state),tenantId:this.tenantId})}))},w=function(e){o(this,l,"f").setContent(un({projectId:this.projectId,flowId:o(this,s,"f").disconnectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:e})),o(this,t,"m",g).call(this,o(this,l,"f"),o(this,h,"f")),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getConnectedOutboundApps({userId:Ps(this.state)})}))},y=function(e){i(this,s,new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),o(this,s,"f").onConnectClick((({id:e})=>{o(this,t,"m",b).call(this,e)})),o(this,s,"f").onDisconnectClick((({id:e})=>{o(this,t,"m",w).call(this,e)})),o(this,s,"f").data=e},I})),Ds=a((e=>class extends(r(U,se,_s,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)}))}})),Fs=r((e=>class extends(Ds(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 Vc})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.3.2"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",Fs);const qs=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var zs,Vs,Ks,Hs,Js,Bs,Xs,Gs,Ys,Zs;const Qs=document.createElement("template");Qs.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 ea=r(z)(HTMLElement);class ta extends ea{constructor(){var e;super(),zs.add(this),Vs.set(this,new p({messages:[]})),Ks.set(this,void 0),Hs.set(this,void 0),Js.set(this,void 0),Bs.set(this,{resize:o(this,zs,"m",Zs).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Qs.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'),i(this,Ks,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Hs,o(this,Ks,"f").querySelector(".content"),"f"),i(this,Js,o(this,Ks,"f").querySelector(".header"),"f")}updateData(e){o(this,Vs,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=qs(e,e.offsetLeft-o,e.offsetTop-i,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})(o(this,Ks,"f"),o(this,Js,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Bs,"f").resize),(e=o(this,Ks,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,Ks,"f").onresize=o(this,zs,"m",Ys).bind(this),o(this,Vs,"f").subscribe(o(this,zs,"m",Xs).bind(this))}disconnectedCallback(){o(this,Vs,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Bs,"f").resize)}}Vs=new WeakMap,Ks=new WeakMap,Hs=new WeakMap,Js=new WeakMap,Bs=new WeakMap,zs=new WeakSet,Xs=function(e){o(this,zs,"m",Gs).call(this,e),o(this,zs,"m",Ys).call(this)},Gs=function(e){o(this,Hs,"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("")},Ys=function(){o(this,Hs,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Zs=function(){const[e,t]=qs(o(this,Ks,"f"),Number.parseInt(o(this,Ks,"f").style.left,10),Number.parseInt(o(this,Ks,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Ks,"f").style.top=`${t}px`,o(this,Ks,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ta);var na=Object.freeze({__proto__:null,default:ta});const oa="undefined"!=typeof localStorage,ia="J151000",ra="E103205",sa=oa&&localStorage.getItem("base.content.url")||"",aa="base.ui.components.url";oa&&localStorage.getItem(aa),oa&&localStorage.getItem(aa);const la="descope-login-flow",ca="code",da="redirect_mode",ua="err",ha="data-exclude-field",pa="data-exclude-next",fa="dls_last_auth",ga="state_id",va="saml_idp_state_id",ma="wsfed_idp_state_id",ba="saml_idp_username",wa="descope_idp_initiated",ya="sso_app_id",ka="custom_app_id",Ia="third_party_app_id",Sa="third_party_app_state_id",Ca="oidc_login_hint",Oa="oidc_prompt",xa="oidc_resource",Aa="oidc_error_redirect_uri",ja="application_scopes",Ea="data-type",Ra="redirect",Ta="poll",Ua="webauthnCreate",_a="webauthnGet",$a="nativeBridge",Pa="loadForm",La="submit",Ma="polling",Na=["descope-multi-select-combo-box","descope-text-area"],Wa="dls_last_auth_in_flight",Da=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Fa;!function(e){e.backward="backward",e.forward="forward"}(Fa||(Fa={}));const qa=["descope-enriched-text"];function za(e){return new URLSearchParams(window.location.search).get(e)}function Va(e){if(window.history.replaceState&&za(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 Ka(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Fa.forward:n<o?Fa.backward:void 0}const Ha=e=>{let[t="",n=""]=(za(la)||"").split("_");const o=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||o&&o!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:o}};function Ja(){Va(la)}const Ba=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Xa=(e,t)=>{const{executionId:n,stepId:o,executionFlowId:i}=Ha(e);if(i&&e!==i)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&Ja();const r=za("t")||void 0;r&&Va("t");const s=za(ca)||void 0;s&&Va(ca);const a="popup"===za(da);a&&Va(da);const l=za(ua)||void 0;l&&Va(ua);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:za("ra-challenge"),redirectAuthCallbackUrl:za("ra-callback"),redirectAuthBackupCallbackUri:za("ra-backup-callback"),redirectAuthInitiator:za("ra-initiator")},p=za(ga);p&&Va(ga);const f=za(va);f&&Va(va);const g=za(ma);g&&Va(ma);const v=za(ba);f&&Va(ba);const m=za(wa);m&&Va(wa);const b=za(ya);b&&Va(ya);const w=za(ka);w&&Va(ka);const y=za(Ia);y&&Va(Ia);const k=za(Sa);k&&Va(Sa);const I=za(ja);I&&Va(ja);const S=za(Ca);S&&Va(Ca);const C=za(Oa);C&&Va(Oa);const O=za(Aa);O&&Va(Aa);const x=za(xa);return x&&Va(xa),{executionId:n,stepId:o,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:b,customAppId:w,oidcLoginHint:S,oidcPrompt:C,oidcErrorRedirectUri:O,oidcResource:x,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:I}}},Ga=e=>{let t,n;return Object.assign(((...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}),{reset:()=>{t=void 0,n=void 0}})},Ya=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function Za(e,t,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),o(e))})).catch((e=>{r||(clearTimeout(s),i(e))}))}))}const Qa=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:o,samlIdpUsername:i,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||o||i||r||s||a||l||c||d||u||h||p),el=e=>null==e?void 0:e.submit(),tl=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},nl=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function ol(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 il=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function rl(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var sl,al,ll,cl;function dl(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!dl(r,s))return!1}else if(r!==s)return!1}return!0}let ul=class{constructor(e={},{forceUpdate:t=!1}={}){sl.set(this,void 0),al.set(this,{}),ll.set(this,0),cl.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,sl,"f")):e,n=Object.assign(Object.assign({},o(this,sl,"f")),t),r=o(this,sl,"f");i(this,sl,n,"f"),Object.freeze(o(this,sl,"f")),setTimeout((()=>{Object.values(o(this,al,"f")).forEach((({cb:e,selector:t,forceUpdate:i})=>{const s=t(r),a=t(n);(o(this,cl,"f")||i||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!dl(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},i(this,sl,e,"f"),i(this,cl,t,"f")}get current(){return Object.assign({},o(this,sl,"f"))}set forceUpdate(e){i(this,cl,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return i(this,ll,o(this,ll,"f")+1,"f"),o(this,al,"f")[o(this,ll,"f")]={cb:e,selector:t,forceUpdate:n},o(this,ll,"f").toString()}unsubscribe(e){const t=!!o(this,al,"f")[e];return t&&delete o(this,al,"f")[e],t}unsubscribeAll(){return i(this,al,{},"f"),!0}};sl=new WeakMap,al=new WeakMap,ll=new WeakMap,cl=new WeakMap;const hl=["*","#","/","(",")","[","]","_","<",">","`"],pl=e=>"string"!=typeof e?e:e.replace((e=>{const t=hl.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),fl=["disabled"],gl=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ha}])`)).forEach((e=>{e.value=n}))}))},vl=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),ml=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,o)=>n?pl(vl(t,o)):vl(t,o))),bl=(e,t,n)=>{e.querySelectorAll(`[${Ea}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},wl=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},yl=(e,n,o,i)=>{var r,s;bl(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),bl(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>qa.includes(e))(e.localName);e.textContent=ml(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",ml(o,t))}))})(e,n),((e,n,o)=>{if(!n)return;const{componentsDynamicAttrs:i}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});i&&Object.keys(i).forEach((e=>{const t=i[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 i=n[t];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(e){o.error(`Could not stringify value "${i}" for "${t}"`,e.message),i=""}e.setAttribute(t,i)}))}))}))})(e,null==n?void 0:n.componentsConfig,i),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=ml(e.value,t)}))}))})(e,n),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{fl.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o),((e,t={},n)=>{Object.entries(t).forEach((([t,o])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(o){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;default:null==n||n.error(`Unknown component state "${o}" for component with id "${t}"`,'Valid states are "disable" and "hide"')}}))}))})(e,null==n?void 0:n.componentsState,i)},kl=Ga((()=>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)))),o=(()=>{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 Za(100,n,o)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let Il;const Sl=(e,t)=>{Il?Il.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Cl=e=>Il?Il.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Ol="dls_ab_testing_id",xl={"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,o]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=o?o:0)},"not-in-range":(e,t)=>{const[n,o]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==o&&!Number.isNaN(n)&&!Number.isNaN(o))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>o},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function Al(e,t){const n={};try{Object.assign(n,JSON.parse(Cl(fa)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function jl(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Sl(fa,JSON.stringify(e)))}function El(){try{return JSON.parse(Cl(Wa)||"{}")}catch(e){return{}}}function Rl(e){try{(e=>{Il?Il.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(Wa)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const Tl=(e,t="")=>Object.keys(e).reduce(((n,o)=>{var i;if(Array.isArray(e[o]))return Object.assign(Object.assign({},n),{[o]:{value:e[o].map((e=>"object"==typeof e&&null!==e?Tl(e):e))}});if("object"==typeof e[o]&&null!==e[o]&&!(null===(i=e[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),Tl(e[o],`${t+o}.`));const r="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},n),{[t+o]:r,[`form.${t}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Ul=a((e=>{var t,n,i,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;o(this,t,"m",n).call(this)&&o(this,t,"m",i).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)},i=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 _l,$l,Pl,Ll,Ml,Nl,Wl,Dl,Fl,ql,zl,Vl,Kl,Hl,Jl,Bl,Xl,Gl,Yl,Zl,Ql,ec;const tc=r(se,E,Ul,z)(HTMLElement);class nc extends tc{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(),_l.add(this),Pl.set(this,!1),Ll.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,_l,"m",ec).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)}},Ml.set(this,new ul),Nl.set(this,new ul),Wl.set(this,{}),this.getComponentsContext=()=>o(this,Wl,"f"),this.nextRequestStatus=new ul({isLoading:!1}),Dl.set(this,void 0),Fl.set(this,{popstate:o(this,_l,"m",Hl).bind(this),componentsContext:o(this,_l,"m",Yl).bind(this)}),ql.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,ql,e,"f"),o(this,_l,"m",Vl).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 Tl(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 o(this,Ll,"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");i(this,Ll,e,"f"),(e=>{Il=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(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Na.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),o(this,Nl,"f").subscribe(o(this,_l,"m",Ql).bind(this)),o(this,Nl,"f").update({isDebug:this.debug}),o(this,_l,"m",Kl).call(this),yield o(this,_l,"m",Xl).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=Xa(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,Fl,"f").popstate),window.addEventListener("components-context",o(this,Fl,"f").componentsContext),o(this,Ml,"f").subscribe(o(this,_l,"m",Bl).bind(this)),o(this,Ml,"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)),i(this,Pl,!0,"f")}))}disconnectedCallback(){o(this,Ml,"f").unsubscribeAll(),o(this,Nl,"f").unsubscribeAll(),o(this,_l,"m",Zl).call(this),window.removeEventListener("popstate",o(this,Fl,"f").popstate),window.removeEventListener("components-context",o(this,Fl,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,Pl,"f")&&t!==n&&$l.observedAttributes.includes(e)){o(this,_l,"m",Kl).call(this);const i=null===t;o(this,Ml,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,Ja()),{[Ba(e)]:n,stepId:r,executionId:s}})),o(this,Nl,"f").update({isDebug:this.debug})}}}var oc,ic,rc,sc,ac,lc,cc,dc,uc,hc,pc,fc,gc,vc,mc,bc,wc,yc,kc,Ic,Sc,Cc,Oc,xc,Ac,jc,Ec,Rc,Tc,Uc,_c,$c,Pc,Lc,Mc,Nc,Wc,Dc,Fc,qc;$l=nc,Pl=new WeakMap,Ll=new WeakMap,Ml=new WeakMap,Nl=new WeakMap,Wl=new WeakMap,Dl=new WeakMap,Fl=new WeakMap,ql=new WeakMap,_l=new WeakSet,zl=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 ")},Vl=function(){o(this,_l,"m",zl).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Kl=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];$l.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Ba(t)])throw Error(`${t} cannot be empty`)}))},Hl=function(){const{stepId:e,executionId:t}=Ha(this.flowId);o(this,Ml,"f").update({stepId:e,executionId:t})},Jl=function(e,t){ws&&"function"==typeof ws||this.logger.error("SDK was not loaded properly",ws,JSON.stringify(ws));const i=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},$l.sdkConfigOverrides),{projectId:e,baseUrl:t});o(this,Ll,"f")&&(i.customStorage=o(this,Ll,"f")),this.sdk=ws(i),["start","next"].forEach((e=>{const t=function(e,t,o){return(...i)=>n(this,void 0,void 0,(function*(){let n;const r=o+1;for(let s=0;s<r;s++)try{return yield e(...i)}catch(e){n=e,s<o&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...o)=>n(this,void 0,void 0,(function*(){try{return yield t(...o)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:ia,errorDescription:t.toString()}}}}))}))},Bl=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,_l,"m",Jl).call(this,t,n)}o(this,ql,"f").call(this,e)}))},Xl=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield o(this,_l,"m",Gl).call(this))}))},Gl=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(sa||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.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}}))},Yl=function(e){i(this,Wl,Object.assign(Object.assign({},o(this,Wl,"f")),e.detail),"f")},Zl=function(){var e;null===(e=o(this,Dl,"f"))||void 0===e||e.remove(),i(this,Dl,null,"f")},Ql=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,Dl,document.createElement("descope-debugger"),"f"),Object.assign(o(this,Dl,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return ad})),document.body.appendChild(o(this,Dl,"f"))):o(this,_l,"m",Zl).call(this)}))},ec=function(e,t){var n;e&&this.debug&&(null===(n=o(this,Dl,"f"))||void 0===n||n.updateData({title:e,description:t}))},nc.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.64.3"}};class zc extends nc{static set sdkConfigOverrides(e){nc.sdkConfigOverrides=e}static get sdkConfigOverrides(){return nc.sdkConfigOverrides}constructor(){const e=new ul({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),oc.add(this),this.stepState=new ul({}),ic.set(this,void 0),rc.set(this,null),sc.set(this,null),ac.set(this,{visibilitychange:o(this,oc,"m",lc).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},vc.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},bc.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()?o(this,oc,"m",wc).call(this,t):t()})),yc.set(this,((e,t,r,s,a=!1)=>{const l=[ra,"E103202"];if(this.flowState.current.action===Ta){if(o(this,Ic,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;i(this,ic,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,i;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 Za(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,yc,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===ia)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,yc,"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===(i=null==p?void 0:p.error)||void 0===i?void 0:i.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):o(this,yc,"f").call(this,e,t,r,s),o(this,Sc,"f").call(this,p)}))),d),"f")}})),kc.set(this,(()=>{clearTimeout(o(this,ic,"f")),i(this,ic,null,"f")})),Ic.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),Sc.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 i=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}`;o(this,oc,"m",Fc).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:i}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||i,(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!==ra||!this.isRestartOnError||o(this,oc,"m",gc).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:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,o):this.loggerWrapper.info(n,o)}));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!==Ta&&o(this,kc,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&jl(Object.assign(Object.assign({},w),{lastUsedPerScreen:El()})),Rl(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void o(this,oc,"m",Fc).call(this,"success",t)}this.storeLastAuthenticatedUser&&jl(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:O,redirect:x,webauthn:A,error:j,samlIdpResponse:E,wsFedIdpResponse:R,nativeResponse:T}=e.data,U=Date.now();y!==Ta?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:O,status:m,stepId:S,stepName:C,action:y,error:j}),(null===(g=O.state)||void 0===g?void 0:g.clientScripts)&&i(this,sc,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==A?void 0:A.transactionId,webauthnOptions:null==A?void 0:A.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,wsFedIdpResponseUrl:null==R?void 0:R.url,wsFedIdpResponseWresult:null==R?void 0:R.wresult,wsFedIdpResponseWctx:null==R?void 0:R.wctx,nativeResponseType:null==T?void 0:T.type,nativePayload:null==T?void 0:T.payload,reqTimestamp:U})):this.flowState.update({action:y,reqTimestamp:U})})),Cc.set(this,Ga((()=>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)}}))))),Rc.set(this,null),Pc.set(this,nl(((e,t,i)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||o(this,oc,"m",jc).call(this)){const r=null==e?void 0:e.getAttribute("id");o(this,oc,"m",Nc).call(this,e,r,i),o(this,oc,"m",Tc).call(this,e);const s=yield o(this,oc,"m",Ec).call(this),a=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const l=Object.assign(Object.assign(Object.assign({},a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,l),this.nextRequestStatus.update({isLoading:!1}),o(this,oc,"m",Uc).call(this,s)}}))))),this.flowState=e}nativeResume(e,t){var n,i,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const o=new URL(c.url);t=null===(n=o.searchParams)||void 0===n?void 0:n.get(ca),e=(null===(i=o.searchParams)||void 0===i?void 0:i.get(ua))||void 0}null===(s=(r=this.nativeCallbacks).complete)||void 0===s||s.call(r,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(c.url),t=e.searchParams.get("t"),n=e.searchParams.get(la).split("_").pop();o(this,kc,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=c;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=c,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(l=(a=this.nativeCallbacks).complete)||void 0===l||l.call(a,c)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[rl(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 o=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,o,i;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(o=globalThis.descope)||void 0===o?void 0:o[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.16",`dist/${e.id}.js`));const s=null===(i=globalThis.descope)||void 0===i?void 0:i[e.id];return new Promise(((n,o)=>{try{const o=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(o){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=o,this.shadowRoot.appendChild(t);const n=this.nextRequestStatus.subscribe((()=>{var i;this.loggerWrapper.debug("Stopping script",e.id),(null===(i=o.stop)||void 0===i?void 0:i.call(o))&&(this.nextRequestStatus.unsubscribe(n),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){o(e)}}))}))))),i=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([o,i])}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)),o(this,oc,"m",pc).call(this),window.addEventListener("visibilitychange",o(this,ac,"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(),o(this,kc,"f").call(this),null===(e=o(this,rc,"f"))||void 0===e||e.abort(),i(this,rc,null,"f"),window.removeEventListener("visibilitychange",o(this,ac,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=ol(e),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${t}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${t}-${o.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:I,exchangeError:S,webauthnTransactionId:C,webauthnOptions:O,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:A,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:E,locale:R,samlIdpResponseUrl:T,samlIdpResponseSamlResponse:U,samlIdpResponseRelayState:_,wsFedIdpResponseUrl:$,wsFedIdpResponseWresult:P,wsFedIdpResponseWctx:L,nativeResponseType:M,nativePayload:N,reqTimestamp:W}=e,D=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let F,q,z;const V=(()=>{const e=Cl(Ol);if(!e){const e=Math.floor(100*Math.random()+1);return Sl(Ol,e.toString()),e}return Number(e)})(),{outboundAppId:K}=this,{outboundAppScopes:H}=this,J=this.sdk.getLastUserLoginId(),B=yield this.getFlowConfig(),X=yield this.getProjectConfig(),G=Object.entries(X.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Y=A&&x?{callbackUrl:A,codeChallenge:x,backupCallbackUri:j}:void 0,Z=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let Q={};if(!p){Rl(this.loggerWrapper);const e=[...B.clientScripts||[],...B.sdkScripts||[]];if(B.conditions){let t=[];({startScreenId:F,conditionInteractionId:z,startScreenName:q,clientScripts:t,componentsConfig:Q}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=xl[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:J,code:k,token:y,abTestingKey:V,lastAuth:Al(J,this.loggerWrapper)},B.conditions)),e.push(...t||[])}else B.condition?({startScreenId:F,conditionInteractionId:z}=((e,t)=>{var n;const o=null===(n=xl[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,startScreenName:null==i?void 0:i.screenName,conditionInteractionId:null==i?void 0:i.interactionId}})(B.condition,{loginId:J,code:k,token:y,abTestingKey:V,lastAuth:Al(J,this.loggerWrapper)})):(q=B.startScreenName,F=B.startScreenId);if(i(this,sc,this.loadSdkScripts(e),"f"),B.fingerprintEnabled&&B.fingerprintKey?yield Mr(B.fingerprintKey,this.baseUrl):gr(Pr),!Qa(F,D)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},D),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:Al(J,this.loggerWrapper),abTestingKey:V,locale:ol(R).locale,nativeOptions:Z,outboundAppId:K,outboundAppScopes:H}),z,"",X.componentsVersion,G,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),D.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),D.oidcLoginHint?{externalId:D.oidcLoginHint}:{}));return o(this,Sc,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:I,code:k,exchangeError:S,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&k||s("exchangeError")&&S))return void o(this,oc,"m",qc).call(this,p,k,S);if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&S)){const e=yield this.sdk.flow.next(p,h,La,B.version,X.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return o(this,Sc,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Pa&&T&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.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(i),o(i)})(T,U,_||"",el)}if(f===Pa&&$&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!P)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e;const r=(e,t)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n};i.appendChild(r("wa","wsignin1.0")),i.appendChild(r("wresult",t)),i.appendChild(r("wctx",n));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",i.appendChild(s),document.body.appendChild(i),o(i)})($,P,L||"",el)}if(f===Ra&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,o)=>{const i=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+i,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-o)/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=${o},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:o,data:i}=e.data||{};"code"===o&&this.flowState.update({code:i.code,exchangeError:i.exchangeError})};let i;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),o(this,oc,"m",Fc).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==i||i())}),1e3);if(t)window.addEventListener("message",n),i=()=>{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,i=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),o(this,oc,"m",Fc).call(this,"popupclosed",{});return}if(f===Ua||f===_a){if(!C||!O)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=o(this,rc,"f"))||void 0===l||l.abort(),i(this,rc,null,"f");try{e=f===Ua?yield this.sdk.webauthn.helpers.create(O):yield this.sdk.webauthn.helpers.get(O)}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,La,B.version,X.componentsVersion,{transactionId:C,response:e,failure:t});o(this,Sc,"f").call(this,n)}if(f===$a)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,La,B.version,X.componentsVersion,e);o(this,Sc,"f").call(this,t)})),o(this,oc,"m",uc).call(this,M,N),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&o(this,yc,"f").call(this,p,h,B.version,X.componentsVersion),!g&&!F)return void this.loggerWrapper.warn("No screen was found to show");const ee=F||g,te=yield this.getHtmlFilenameWithLocale(R,ee),{oidcLoginHint:ne,oidcPrompt:oe,oidcErrorRedirectUri:ie,oidcResource:re,samlIdpUsername:se}=D,ae={direction:Ka(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:J,name:this.sdk.getLastUserDisplayName()||J},componentsConfig:Object.assign(Object.assign(Object.assign({},B.componentsConfig),Q),null==v?void 0:v.componentsConfig)}),htmlFilename:`${ee}.html`,htmlLocaleFilename:te,screenId:ee,stepName:e.stepName||q,samlIdpUsername:se,oidcLoginHint:ne,oidcPrompt:oe,oidcErrorRedirectUri:ie,oidcResource:re,action:f,locale:ol(R).locale},le=Al(J,this.loggerWrapper);Qa(F,D)?ae.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==B?void 0:B.clientScripts)||[];yield o(this,oc,"m",Lc).call(this,n);const i=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},D),{lastAuth:le,preview:this.preview,abTestingKey:V,client:this.client}),w&&{redirectUrl:w}),{locale:ol(R).locale,nativeOptions:Z,outboundAppId:K,outboundAppScopes:H}),z,e,X.componentsVersion,G,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),il(t)),k&&{exchangeCode:k,idpInitiated:!0}),D.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}),ae.next.isCustomScreen);return o(this,Sc,"f").call(this,i),i})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ae.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==v?void 0:v.clientScripts)||[];yield o(this,oc,"m",Lc).call(this,n);const i=yield this.sdk.flow.next(p,h,e,B.version,X.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),il(t)),ae.next.isCustomScreen);return o(this,Sc,"f").call(this,i),i}))),this.loggerWrapper.debug("Got a screen with id",ae.screenId),yield o(this,oc,"m",mc).call(this,ae),this.stepState.update(ae)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen");const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const f=p.content.cloneNode(!0),g=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield o(this,oc,"m",xc).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${Ea}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(i=u.form)||void 0===i?void 0:i.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),yl(f,u,this.formConfig,this.loggerWrapper);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,o])=>{Array.from(e.querySelectorAll(`[${n}="${o}"]`)).forEach((e=>{e.setAttribute(n,t||o)}))}))})(f,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,o])=>{Array.from(e.querySelectorAll(`[${t}="${o}"]`)).forEach((e=>{e.setAttribute(t,n||o)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,i;yield g;const r=this.contentRootElement;((e,t)=>{wl(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{wl(e,"descope-notp-image",t)})(r,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),((e,t,n,o)=>{n&&Object.keys(n).forEach((i=>{if(!t.querySelector(i))return void o.debug(`Skipping css vars for component "${i}"`,`Got css vars for component ${i} but Could not find it on next page`);const r=customElements.get(i);r?Object.keys(n[i]).forEach((t=>{var s;const a=n[i],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void o.info(`Could not find css variable name for ${t} in ${i}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):o.debug(`Could not find component class for ${i}`,"Check if the component is registered")}))})(r,f,u.cssVars,this.loggerWrapper),r.replaceChildren(f);const s=!t.htmlFilename;setTimeout((()=>{o(this,oc,"m",_c).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const o=()=>{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 o();const i={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(i.timer),i.timer=void 0)};i.timer=setTimeout((()=>{e.removeEventListener("click",r),o(),i.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{gl(e,null==t?void 0:t.inputs),gl(e,null==t?void 0:t.form)})(r,u),o(this,oc,"m",Ac).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),Ya(r,this.autoFocus,s),o(this,oc,"m",Wc).call(this,h)})),o(this,oc,"m",Dc).call(this,d,h),r.querySelector(`[${Ea}="polling"]`)&&d(Ma,{})}));c?o(this,oc,"m",wc).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${ha}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}ic=new WeakMap,rc=new WeakMap,sc=new WeakMap,ac=new WeakMap,vc=new WeakMap,bc=new WeakMap,yc=new WeakMap,kc=new WeakMap,Ic=new WeakMap,Sc=new WeakMap,Cc=new WeakMap,Rc=new WeakMap,Pc=new WeakMap,oc=new WeakSet,lc=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},cc=function(e,t,i){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=i,this.nativeCallbacks.screenResolve=n,o(this,oc,"m",uc).call(this,"beforeScreen",{screen:e,context:t})}))}))},dc=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&o(this,oc,"m",uc).call(this,"afterScreen",{screen:e})},uc=function(e,t){o(this,oc,"m",Fc).call(this,"bridge",{type:e,payload:t})},hc=function({errorText:e,errorType:t}){const n=()=>{var n;let o=e;try{o=(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(`[${Ea}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",o)};this.addEventListener("screen-updated",n,{once:!0}),n()},pc=function(){var e,n,i;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,o=t(void 0===n?{}:n,["errorText","errorType"]),i=t(e,["screenState"]);return Object.assign(Object.assign({},i),{screenState:o})})),null===(n=this.stepState)||void 0===n||n.subscribe(o(this,oc,"m",hc).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===(i=this.stepState)||void 0===i||i.subscribe(o(this,oc,"m",fc).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0})},fc=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Ya(this.contentRootElement,this.autoFocus,!1))},gc=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")}))},mc=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,o;const i=(r=e.screenState,s=(e,t)=>Da.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)&&(i.error={text:a,type:l}),e.action&&(i.action=e.action),(null===(o=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===o?void 0:o.data)&&(i.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),i})(t(r,["next","stepName"]));let c=yield o(this,oc,"m",cc).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(o(this,bc,"f").call(this,c),s&&(s.isCustomScreen=c),o(this,vc,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),i(this,vc,c,"f"),c?this.stepState.unsubscribeAll():o(this,oc,"m",pc).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),o(this,oc,"m",Ac).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},wc=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")},Oc=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)}))}},xc=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,rc,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield kl())){const{options:e,transactionId:r}=(yield o(this,Cc,"f").call(this))||{};e&&r&&(o(this,oc,"m",Oc).call(this,s),i(this,rc,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,o(this,rc,"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)})))}}))},Ac=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&o(this,oc,"m",Fc).call(this,"ready",{}),t||o(this,oc,"m",dc).call(this,n),o(this,oc,"m",Fc).call(this,"page-updated",{screenName:n}),o(this,oc,"m",Fc).call(this,"screen-updated",{screenName:n})},jc=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"===t.localName||t.classList.contains("hidden")||(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},Ec=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})),{})}))},Tc=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(),o=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(o)})),s=()=>{var e;window.removeEventListener("pageshow",o(this,Rc,"f")),i(this,Rc,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),r())}),"f"),window.addEventListener("pageshow",o(this,Rc,"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())}))},Uc=function(e={}){var t,n;const o=tl(e,["externalId","email","phone"]),i=tl(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});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)}},_c=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>o(this,oc,"m",$c).call(this,e)))},$c=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),o=`input-${e.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),e.appendChild(i),t.setAttribute("slot",o),this.appendChild(t)}))},Lc=function(e){return n(this,void 0,void 0,(function*(){if(o(this,sc,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield o(this,sc,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const i=[];for(const e of t)"function"==typeof e.refresh&&i.push(e.refresh());if(i.length>0)try{yield Za(5e3,Promise.all(i),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Mc=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var i;(null===(i=n.checkValidity)||void 0===i?void 0:i.call(n))&&o(this,Pc,"f").call(this,n,e,t)}))}))},Nc=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=El();n[e]=t,Sl(Wa,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Wc=function(e){var t;const n=null===(t=Al(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const o=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),i=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);o&&i&&(i.replaceWith(o),o.appendChild(i))},Dc=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${pa}]), [data-type="button"]:not([${pa}]`).forEach((n=>{n.onclick=()=>{o(this,Pc,"f").call(this,n,e,t)}})),o(this,oc,"m",Mc).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${ha}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Fc=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},qc=function(e,t,n){var o;const[i,r]=(null===(o=window.name)||void 0===o?void 0:o.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===i&&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",zc);var Vc=Object.freeze({__proto__:null,default:zc});const Kc=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},Hc=(e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Kc(e,e.offsetLeft-o,e.offsetTop-i,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 Jc,Bc,Xc,Gc,Yc,Zc,Qc,ed,td,nd,od;const id=document.createElement("template");id.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 rd=r(z)(HTMLElement);class sd extends rd{constructor(){super(),Jc.add(this),Bc.set(this,new ul({messages:[]})),Xc.set(this,void 0),Gc.set(this,void 0),Yc.set(this,void 0),Zc.set(this,{resize:o(this,Jc,"m",od).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(id.content.cloneNode(!0)),i(this,Xc,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Gc,o(this,Xc,"f").querySelector(".content"),"f"),i(this,Yc,o(this,Xc,"f").querySelector(".header"),"f"),o(this,Jc,"m",Qc).call(this)}updateData(e){o(this,Bc,"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),Hc(o(this,Xc,"f"),o(this,Yc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Zc,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(o(this,Xc,"f")),o(this,Xc,"f").onresize=o(this,Jc,"m",nd).bind(this),o(this,Bc,"f").subscribe(o(this,Jc,"m",ed).bind(this))}))}disconnectedCallback(){o(this,Bc,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Zc,"f").resize)}}Bc=new WeakMap,Xc=new WeakMap,Gc=new WeakMap,Yc=new WeakMap,Zc=new WeakMap,Jc=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'),o(this,Xc,"f").style.top="32px",o(this,Xc,"f").style.left=window.innerWidth-300-32+"px"},ed=function(e){o(this,Jc,"m",td).call(this,e),o(this,Jc,"m",nd).call(this)},td=function(e){o(this,Gc,"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("")},nd=function(){o(this,Gc,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},od=function(){const[e,t]=Kc(o(this,Xc,"f"),Number.parseInt(o(this,Xc,"f").style.left,10),Number.parseInt(o(this,Xc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Xc,"f").style.top=`${t}px`,o(this,Xc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",sd);var ad=Object.freeze({__proto__:null,default:sd});return Fs}();
5
+ this["descope-outbound-applications-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.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=>{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 o=e(n);return o[t]=!0,o}};var l,c,d,u;function h(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!h(r,s))return!1}else if(r!==s)return!1}return!0}let p=class{constructor(e={},{forceUpdate:t=!1}={}){l.set(this,void 0),c.set(this,{}),d.set(this,0),u.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,l,"f")):e,n=Object.assign(Object.assign({},o(this,l,"f")),t);if(o(this,u,"f")||!h(o(this,l,"f"),n)){const e=o(this,l,"f");i(this,l,n,"f"),Object.freeze(o(this,l,"f")),setTimeout((()=>{Object.values(o(this,c,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,l,e,"f"),i(this,u,t,"f")}get current(){return Object.assign({},o(this,l,"f"))}subscribe(e){return i(this,d,o(this,d,"f")+1,"f"),o(this,c,"f")[o(this,d,"f")]=e,o(this,d,"f").toString()}unsubscribe(e){const t=!!o(this,c,"f")[e];return t&&delete o(this,c,"f")[e],t}unsubscribeAll(){return i(this,c,{},"f"),!0}};l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap;const f=["error","warn","info","debug"],g={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},v=a((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,g))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||g),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return f.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),m="undefined"!=typeof localStorage,b="https://static.descope.com/pages",w="https://static2.descope.com/pages",y=m&&localStorage.getItem("base.content.url")||"",k=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,I=a((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)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),S=a((e=>{var t,n;const i=r(v,I)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,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})),C=e=>t=>{var n,i,s;const a=r(v,I,S)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",i).bind(this))}async init(){var e;l.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};C.missingAttrValidator=k;const O=a((e=>{const t=r(C({"project-id":k}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),x=a((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),A="Trying the next fallback URL...",j=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(o){return null==n||n.debug(`Network error fetching URL ${e} [${o.message}], retrying...`),fetch(e,t)}};const E=a((e=>{var t,n,s,a,l,c,d;const u=r(v,O,x)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=o(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];i(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;o(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;e++){const r=i[e],s=e===i.length-1;try{const i=await j(r.toString(),t,{logger:n});if(i.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${r}`),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${A}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${A}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=y||this.baseStaticUrl;if(r)return o(this,t,"m",c).call(this,e,r);o(this,n,"f")!==this.baseUrl&&(i(this,n,this.baseUrl,"f"),i(this,s,void 0,"f"),o(this,a,"f").clear());const l=[];if(o(this,s,"f"))l.push(o(this,t,"m",c).call(this,e,o(this,s,"f"))),o(this,s,"f")===b&&l.push(o(this,t,"m",c).call(this,e,w));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&l.push(o(this,t,"m",c).call(this,e,n)),o(this,a,"f").has(b)||l.push(o(this,t,"m",c).call(this,e,b)),l.push(o(this,t,"m",c).call(this,e,w))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=b}){const i=new URL(o);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=o,i}({projectId:this.projectId,filename:e,baseUrl:t})},d})),R=a((e=>{var t,n;const i=r(C({"project-id":k}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),T=a((e=>{var t,n,s,a,l;const c=r(E,R,I)(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",o(this,t,"m",n).bind(this))}get config(){return o(this,s,"f")||i(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){i(this,s,void 0,"f")},l})),U=a((e=>{var t,n,s,a,l,c,d;return d=class extends(r(I,v)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(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)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return ra})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),_=["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,n)=>new Promise(((o,i)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),i(e)},r.onload=()=>{r.setAttribute("status","loaded"),o(r)},r.src=t.toString(),document.body.appendChild(r)})),L=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},M=a((e=>{const t=r(v)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[],i){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${i?" with SRI integrity check":""}`),(async(e,t)=>{for(const o of e){const{id:e,url:i,integrity:r}=o,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await L(s,r),o}catch(e){t(o,!0)}else try{return await P(e,i,r),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="",i)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${o}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${$(a)}`};return i&&(l.integrity=i),[...e,l]}),[]))([...o,this.baseCdnUrl,..._],e,t,n,i),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),N="base.ui.components.url",W=m&&localStorage.getItem(N),D=a((e=>{var t,n,s,a,l,c,d;const u=r(v,T,M)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return o(this,a,"f")||i(this,a,o(this,t,"m",c).call(this),"f"),o(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await o(this,t,"m",n).call(this),i=await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[W],i),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),F=a((e=>{var t,n,i;const s=r(I,S)(e);return i=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",o(this,t,"m",n).bind(this)),o(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},i}));class q{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 z=a((e=>{const t=r(F)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new q(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const o=[...e.adoptedStyleSheets||[]];o[t?"unshift":"push"](n),e.adoptedStyleSheets=o}}return n}}})),V="content-root",K="root",H=a((e=>{const t=r(z)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${V}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${V} {\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(V),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),J="descope-modal";var B;let X=class{constructor(e,t){B.set(this,void 0),this.nodeName="",i(this,B,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,B,"f"))}get ele(){var e,t;const n="function"==typeof o(this,B,"f")?o(this,B,"f").call(this):o(this,B,"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}};B=new WeakMap;let G=class extends X{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}};var Y;let Z=class extends X{constructor(){super(...arguments),Y.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=""),o(this,Y,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,Y,"f").content.cloneNode(!0)))}setContent(e){i(this,Y,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};Y=new WeakMap;let Q=class extends X{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},ee=class extends X{constructor(){super(...arguments),this.nodeName="descope-outbound-apps"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get connectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("connect-flow-id"))||""}get disconnectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("disconnect-flow-id"))||""}onConnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("connect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("connect-clicked",n)}}onDisconnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("disconnect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("disconnect-clicked",n)}}};const te=a((e=>{var t,n;const i=r(I,H,D)(e);return n=class extends i{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(J);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([J]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ne="descope-notification";a((e=>{var t,n;const i=r(I,H,D)(e);return n=class extends i{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(ne);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(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([ne])}},t=new WeakMap,n}));const oe="theme",ie=(e,t,n="")=>Object.entries(e).reduce(((e,[o,i])=>{if(!/^[a-zA-Z0-9-]+$/.test(o))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${o}`:o;if("object"==typeof i&&null!==i)return e+ie(i,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(i);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),"");function re(e,t){const n=Object.assign({},e);for(const[e,o]of Object.entries(t||{}))if(null!=o)if("object"==typeof o){if(0===Object.keys(o).length)continue;n[e]=re(n[e]||{},o)}else n[e]="string"==typeof o?(n[e]||"")+o:o;return n}const se=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",ae=a((e=>{const t=r(C({tenant:se}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),le=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ce=a((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,b,w,y,k,O,x,A,j;const R=r(C({theme:le}),ae,E,I,D,T,H,S,z)(e);return j=class extends R{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),O.set(this,(()=>{o(this,t,"m",x).call(this),o(this,A,"f").call(this,"os"===this.getAttribute("theme"))})),A.set(this,(e=>{var n,i,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(this,t,"m",x).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}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,O,"f").call(this),await Promise.all([o(this,t,"m",p).call(this),o(this,t,"m",v).call(this),o(this,t,"m",b).call(this)]),o(this,t,"m",m).call(this),this.observeAttributes(["theme"],o(this,O,"f")),this.observeAttributes(["theme-override"],(()=>o(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{i(this,d,null,"f"),o(this,t,"m",v).call(this),o(this,t,"m",b).call(this)})),this.observeAttributes(["style-id"],(()=>{i(this,c,null,"f"),o(this,t,"m",y).call(this),o(this,t,"m",p).call(this),o(this,t,"m",b).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,O=new WeakMap,A=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,i,r,s,a;const l=null===(i=null===(o=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===o?void 0:o.colors)||void 0===i?void 0:i.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${ie({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},u=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(N))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(N),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},h=function(){return o(this,c,"f")||(i(this,c,o(this,t,"m",u).call(this),"f"),o(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,c,"f")},p=async function(){var e,r;const s=await o(this,t,"a",h);if(!s)return;const a=((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)||"");o(this,n,"f")?o(this,n,"f").replaceSync(a):i(this,n,this.injectStyle(a,{prepend:!0}),"f")},f=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.error("Cannot fetch tenant theme file","make sure that your tenantId, projectId & flowId are correct")}},g=function(){return o(this,d,"f")||i(this,d,o(this,t,"m",f).call(this),"f"),o(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=o(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await o(this,t,"a",g);if(!l)return void(null===(n=o(this,s,"f"))||void 0===n||n.replaceSync(""));const c=((null===(r=l.light)||void 0===r?void 0:r.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");o(this,s,"f")?o(this,s,"f").replaceSync(c):i(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=o(this,a,"f"))||void 0===e||e.replaceSync(""));const n=o(this,t,"m",l).call(this);o(this,a,"f")?o(this,a,"f").replaceSync(n):i(this,a,this.injectStyle(n),"f")},b=async function(){var e,n,i,r;const s=await o(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await o(this,t,"a",g);a.componentsThemeManager.themes={light:re((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==l?void 0:l.light)||void 0===n?void 0:n.components)||{}),dark:re((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await o(this,t,"m",w).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")},k=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)},x=function(){o(this,t,"m",y).call(this),o(this,t,"m",k).call(this)},j}));var de=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ue=()=>Math.random().toString(36).substring(7).split("").join("."),he={INIT:`@@redux/INIT${ue()}`,REPLACE:`@@redux/REPLACE${ue()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ue()}`};function pe(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 fe(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 ge(e){let t=typeof e;return t=fe(e),t}function ve(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${ge(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: '${ge(n)}'`);return n(ve)(e,t)}let o=e,i=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 i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${ge(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(!pe(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${ge(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: '${ge(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=o(i,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:he.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: '${ge(e)}`);o=e,h({type:he.REPLACE})},[de]: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: '${ge(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[de](){return this}}}}}function me(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function be(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&me(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:he.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:he.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 '${he.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 o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===he.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!pe(e))return`The ${r} has unexpected type of "${ge(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===he.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: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&me(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],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||o.length!==Object.keys(e).length,s?a:e}}function we(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function ye(e){return pe(e)&&"type"in e&&"string"==typeof e.type}var ke=Symbol.for("immer-nothing"),Ie=Symbol.for("immer-draftable"),Se=Symbol.for("immer-state"),Ce=[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 Oe(e,...t){{const n=Ce[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var xe=Object.getPrototypeOf;function Ae(e){return!!e&&!!e[Se]}function je(e){return!!e&&(Re(e)||Array.isArray(e)||!!e[Ie]||!!e.constructor?.[Ie]||Pe(e)||Le(e))}var Ee=Object.prototype.constructor.toString();function Re(e){if(!e||"object"!=typeof e)return!1;const t=xe(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)===Ee}function Te(e,t){0===Ue(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Ue(e){const t=e[Se];return t?t.type_:Array.isArray(e)?1:Pe(e)?2:Le(e)?3:0}function _e(e,t){return 2===Ue(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function $e(e,t,n){const o=Ue(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function Pe(e){return e instanceof Map}function Le(e){return e instanceof Set}function Me(e){return e.copy_||e.base_}function Ne(e,t){if(Pe(e))return new Map(e);if(Le(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Re(e)){if(!xe(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Se];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(xe(e),n)}function We(e,t=!1){return Fe(e)||Ae(e)||!je(e)||(Ue(e)>1&&(e.set=e.add=e.clear=e.delete=De),Object.freeze(e),t&&Te(e,((e,t)=>We(t,!0)))),e}function De(){Oe(2)}function Fe(e){return Object.isFrozen(e)}var qe,ze={};function Ve(e){const t=ze[e];return t||Oe(0,e),t}function Ke(){return qe}function He(e,t){t&&(Ve("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Je(e){Be(e),e.drafts_.forEach(Ge),e.drafts_=null}function Be(e){e===qe&&(qe=e.parent_)}function Xe(e){return qe={drafts_:[],parent_:qe,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ge(e){const t=e[Se];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Ye(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Se].modified_&&(Je(t),Oe(4)),je(e)&&(e=Ze(t,e),t.parent_||et(t,e)),t.patches_&&Ve("Patches").generateReplacementPatches_(n[Se].base_,e,t.patches_,t.inversePatches_)):e=Ze(t,n,[]),Je(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ke?e:void 0}function Ze(e,t,n){if(Fe(t))return t;const o=t[Se];if(!o)return Te(t,((i,r)=>Qe(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return et(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),Te(i,((i,s)=>Qe(e,o,t,i,s,n,r))),et(e,t,!1),n&&e.patches_&&Ve("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Qe(e,t,n,o,i,r,s){if(i===n&&Oe(5),Ae(i)){const s=Ze(e,i,r&&t&&3!==t.type_&&!_e(t.assigned_,o)?r.concat(o):void 0);if($e(n,o,s),!Ae(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(je(i)&&!Fe(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ze(e,i),t&&t.scope_.parent_||et(e,i)}}function et(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&We(t,n)}var tt={get(e,t){if(t===Se)return e;const n=Me(e);if(!_e(n,t))return function(e,t,n){const o=it(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!je(o)?o:o===ot(e.base_,t)?(st(e),e.copy_[t]=at(o,e)):o},has:(e,t)=>t in Me(e),ownKeys:e=>Reflect.ownKeys(Me(e)),set(e,t,n){const o=it(Me(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=ot(Me(e),t),i=o?.[Se];if(i&&i.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,o)&&(void 0!==n||_e(e.base_,t)))return!0;st(e),rt(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!==ot(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,st(e),rt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Me(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Oe(11)},getPrototypeOf:e=>xe(e.base_),setPrototypeOf(){Oe(12)}},nt={};function ot(e,t){const n=e[Se];return(n?Me(n):e)[t]}function it(e,t){if(!(t in e))return;let n=xe(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=xe(n)}}function rt(e){e.modified_||(e.modified_=!0,e.parent_&&rt(e.parent_))}function st(e){e.copy_||(e.copy_=Ne(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Te(tt,((e,t)=>{nt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),nt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Oe(13),nt.set.call(this,e,t,void 0)},nt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Oe(14),tt.set.call(this,e[0],t,n,e[0])};function at(e,t){const n=Pe(e)?Ve("MapSet").proxyMap_(e,t):Le(e)?Ve("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Ke(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=tt;n&&(i=[o],r=nt);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Ke()).drafts_.push(n),n}function lt(e){return Ae(e)||Oe(10,e),ct(e)}function ct(e){if(!je(e)||Fe(e))return e;const t=e[Se];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Ne(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Ne(e,!0);return Te(n,((e,t)=>{$e(n,e,ct(t))})),t&&(t.finalized_=!1),n}var dt=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 o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&Oe(6),void 0!==n&&"function"!=typeof n&&Oe(7),je(e)){const i=Xe(this),r=at(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?Je(i):Be(i)}return He(i,n),Ye(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===ke&&(o=void 0),this.autoFreeze_&&We(o,!0),n){const t=[],i=[];Ve("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Oe(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){je(e)||Oe(8),Ae(e)&&(e=lt(e));const t=Xe(this),n=at(e,void 0);return n[Se].isManual_=!0,Be(t),n}finishDraft(e,t){const n=e&&e[Se];n&&n.isManual_||Oe(9);const{scope_:o}=n;return He(o,t),Ye(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Ve("Patches").applyPatches_;return Ae(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},ut=dt.produce;dt.produceWithPatches.bind(dt),dt.setAutoFreeze.bind(dt),dt.setUseStrictShallowCopy.bind(dt),dt.applyPatches.bind(dt),dt.createDraft.bind(dt),dt.finishDraft.bind(dt);var ht=(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})}}},pt=(e,t,n)=>{const{memoize:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);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})}},ft={inputStabilityCheck:"once",identityFunctionCheck:"once"};var gt=e=>Array.isArray(e)?e:[e];function vt(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 mt(e,t){const n=[],{length:o}=e;for(let i=0;i<o;i++)n.push(e[i].apply(null,t));return n}var bt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},wt=0,yt=1;function kt(){return{s:wt,v:void 0,o:null,p:null}}function It(e,t={}){let n=kt();const{resultEqualityCheck:o}=t;let i,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 o=e.get(n);void 0===o?(t=kt(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=kt(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===yt)l=t.v;else if(l=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,l)&&(l=e,0!==r&&r--);i="object"==typeof l&&null!==l||"function"==typeof l?new bt(l):l}return a.s=yt,a.v=l,l}return s.clearCache=()=>{n=kt(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function St(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,i=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=It,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=gt(c),f=gt(u),g=vt(e),v=l((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){i++;const e=mt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...ft,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ht},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:pt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=mt(g,arguments);o.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:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Ct=St(It),Ot=Object.assign(((e,t=Ct)=>{!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),o=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})));return o}),{withTypes:()=>Ot});function xt(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var At=xt(),jt=xt;((...e)=>{const t=St(...e)})(It);var Et="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?we:we.apply(null,arguments)},Rt=e=>e&&"function"==typeof e.match;function Tt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>ye(t)&&t.type===e,n}function Ut(e){return"function"==typeof e&&"type"in e&&Rt(e)}function _t(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 $t=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 Pt(e){return je(e)?ut(e,(()=>{})):e}function Lt(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Mt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Nt(e,t,n){const o=Wt(e,t,n);return{detectMutations:()=>Dt(e,t,o,n)}}function Wt(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=Wt(e,t,n[i],s))}}return r}function Dt(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let i in l){const s=r?r+"."+i:i;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Dt(e,t,n.children[i],o[i],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Ft(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||pe(e)}function qt(e,t="",n=Ft,o,i=[],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!=o?o(e):Object.entries(e),l=i.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=qt(c,a,n,o,i,r),s))return s}return r&&zt(e)&&r.add(e),!1}function zt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!zt(t))return!1;return!0}function Vt(e){return"boolean"==typeof e}var Kt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new $t;if(t&&(Vt(t)?r.push(At):r.push(jt(t.extraArgument))),n){let e={};Vt(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=Mt,ignoredPaths:i,warnAfter:r=32}=e;const s=Nt.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>l=>{const c=_t(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),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(o=e(),n=i.detectMutations(),i=s(o),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(o){let e={};Vt(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=Ft,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["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(!ye(u))return c(u);const h=c(u),p=_t(s,"SerializableStateInvariantMiddleware");return l||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=qt(u,"",t,n,i,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 o=qt(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;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(i){let e={};Vt(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Ut}=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},Ht=e=>t=>{setTimeout(t,e)},Jt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Ht(10),Bt=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new $t(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let i=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?Jt:"callback"===e.type?e.queueNotification:Ht(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,l(c))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function Xt(e){const t=Kt(),{reducer:n,middleware:o,devTools:i=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!pe(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=be(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(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=we;i&&(c=Et({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);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:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=we(...a)(i.dispatch),{...i,dispatch:r}}}(...l),u=Bt(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 ve(a,r,c(...h))}function Gt(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)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,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function Yt(...e){return t=>e.some((e=>((e,t)=>Rt(e)?e.match(t):e(t))(e,t)))}var Zt=["name","message","stack","code"],Qt=class{constructor(e,t){this.payload=e,this.meta=t}_type},en=class{constructor(e,t){this.payload=e,this.meta=t}_type},tn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Zt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},nn=(()=>{function e(e,t,n){const o=Tt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Tt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Tt(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||tn)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,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(i(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 Qt(e,t),fulfillWithValue:(e,t)=>new en(e,t)})).then((t=>{if(t instanceof Qt)throw t;return t instanceof en?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof Qt?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(on)})}}),{pending:i,rejected:r,fulfilled:o,settled:Yt(r,o),typePrefix:e})}return e.withTypes=()=>e,e})();function on(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var rn=Symbol.for("rtk-slice-createasyncthunk");function sn(e,t){return`${e}/${t}`}function an(e,t,n,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var ln=function({creators:e}={}){const t=e?.asyncThunk?.[rn];return function(e){const{name:n,reducerPath:o=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 i=("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(i),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=[],o]="function"==typeof e.extraReducers?Gt(e.extraReducers):[e.extraReducers],i={...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,[o,i,r]=Gt(t);if(function(e){return"function"==typeof e}(e))n=()=>Pt(e());else{const t=Pt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...i.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(Ae(e)){const o=n(e,t);return void 0===o?e:o}if(je(e))return ut(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:sn(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Tt(e,s):Tt(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)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=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.exposeCaseReducer(t,{fulfilled:s||cn,pending:a||cn,rejected:l||cn,settled:c||cn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,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=Lt(d,this,{insert:()=>new WeakMap});return Lt(n,t,{insert:()=>{const n={};for(const[o,i]of Object.entries(e.selectors??{}))n[o]=an(this,i,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 o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function cn(){}var dn="listenerMiddleware";Tt(`${dn}/add`),Tt(`${dn}/removeAll`),Tt(`${dn}/remove`);const un=e=>a((t=>{const n=ln(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(v)(t)){constructor(...e){super(...e);const t=Xt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{on(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));a((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 hn=a((e=>{const t=r(C({"widget-id":k}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}}));a((e=>{const t=r(T,hn)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}}));const pn=a((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),fn=(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 gn(e){return new URLSearchParams(window.location.search).get(e)}const vn=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)}))}))},mn=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}}),bn=nn("outboundApps/load",((e,{extra:{api:t}})=>t.outboundApps.getAllOutboundApps())),wn=vn(bn)({onFulfilled:(e,t)=>{var n;e.outboundAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},mn((e=>e.outboundAppsList))),yn={action:bn,reducer:wn},kn=nn("outboundApps/getConnectedOutboundApps",((e,{extra:{api:t}})=>t.outboundApps.getConnectedOutboundApps(e))),In=vn(kn)({onFulfilled:(e,t)=>{var n;e.connectedOutboundAppsIds.data=null===(n=t.payload)||void 0===n?void 0:n.appIds}},mn((e=>e.connectedOutboundAppsIds))),Sn={action:kn,reducer:In},Cn={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}};class On extends Error{}function xn(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 An(e,t){if("string"!=typeof e)throw new On("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,o=e.split(".")[n];if("string"!=typeof o)throw new On(`Invalid token specified: missing part #${n+1}`);let i;try{i=xn(o)}catch(e){throw new On(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new On(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}On.prototype.name="InvalidTokenError";var jn={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>",Rn=`https://api.${En}descope.com`,Tn=6e5,Un="dct",_n=()=>{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")}},$n=[503,521,522,524,530],Pn=[100,5e3,5e3],Ln=e=>new Promise((t=>setTimeout(t,e))),Mn=e=>async(...t)=>{let n=await e(...t),o=0;for(;$n.includes(n.status)&&o<Pn.length;)await Ln(Pn[o]),n=await e(...t),o++;o>0&&(n.retries=o);const i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n};let Nn;const Wn=()=>{if(Nn)return Nn;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 Nn=`${t}-${n}`,Nn};var Dn;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(Dn||(Dn={}));const Fn=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(En,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return r},qn=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),zn={"Content-Type":"application/json"},Vn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Kn=(e,t)=>{const n={"x-descope-sdk-session-id":Wn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.62.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Hn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var Jn=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||Rn,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=>_n().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await Mn(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return _n().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:Mn(n)})(i,a),d=async e=>{var i;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:qn(Vn(t,g),Kn(t,o),(null==n?void 0:n.baseHeaders)||{},Hn(v)?zn:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const b=await c(Fn({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==b?void 0:b.clone()),null==r?void 0:r.transformResponse){const e=await b.json(),t=(w=(null===(i=b.headers)||void 0===i?void 0:i.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function o(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function i(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;o();)if(","===e.charAt(n)){for(s=n,n+=1,o(),a=n;n<e.length&&i();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},b),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}var w;return b};return{get:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Dn.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Dn.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Dn.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Dn.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Dn.delete,token:o}),hooks:r,buildUrl:(e,n)=>Fn({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.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}}))},Bn=429;function Xn(e,t,n){var o;let i=Gn(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[Un])===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function Gn(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return An(e)}function Yn(e){const{exp:t}=Gn(e);return(new Date).getTime()/1e3>t}function Zn(e){let t=Gn(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Qn(e,t){return Xn(e,t,"permissions")}function eo(e,t){return Xn(e,t,"roles")}const to=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function no(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=r:(i.error=r,o.status===Bn&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function oo(e){var t;return(null===(t=Gn(e))||void 0===t?void 0:t[Un])||""}const io=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),ro=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},so=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ao=e=>t=>e.test(t),lo=ao(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),co=ao(/^\+[1-9]{1}[0-9]{3,14}$/),uo=io(lo,'"{val}" is not a valid email'),ho=io(co,'"{val}" is not a valid phone number'),po=io((e=>e.length>=1),"Minimum length is 1");const fo=io((e=>"string"==typeof e),"Input is not a string"),go=io((e=>Array.isArray(e)),"Input is not an array"),vo=io((e=>"boolean"==typeof e),"Input is not a boolean"),mo=io((e=>void 0===e),"Input is defined"),bo=ro([fo(),mo()],"Input is not a string or undefined"),wo=ro([go(),vo()],"Input is not an array or boolean"),yo=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>so(...e).validate(n[t]))),t(...n)),ko=e=>[fo(`"${e}" must be a string`)],Io=e=>[bo(`"${e}" must be string or undefined`)],So=e=>[fo(`"${e}" must be a string`),po(`"${e}" must not be empty`)],Co=e=>[fo(`"${e}" must be a string`),uo()],Oo=e=>[fo(`"${e}" must be a string`),ho()],xo=yo(So("accessKey")),Ao=e=>({exchange:xo(((t,n)=>no(e.post(jn.accessKey.exchange,{loginOptions:n},{token:t}))))}),jo=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),Eo=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Tn,Tn)});var Ro,To;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Ro||(Ro={})),function(e){e.email="email"}(To||(To={}));const Uo=Object.assign(Object.assign({},Ro),To);var _o;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(_o||(_o={}));const $o=So("loginId"),Po=yo(So("token")),Lo=yo($o),Mo=yo(So("pendingRef")),No=yo($o,Co("email")),Wo=e=>({verify:Po((t=>no(e.post(jn.enchantedLink.verify,{token:t})))),signIn:Lo(((n,o,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return no(e.post(to(jn.enchantedLink.signIn,Uo.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:Lo(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return no(e.post(to(jn.enchantedLink.signUpOrIn,Uo.email),{loginId:n,URI:o,loginOptions:s,providerId:r}))})),signUp:Lo(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return no(e.post(to(jn.enchantedLink.signUp,Uo.email),{loginId:n,URI:o,user:i,loginOptions:a,providerId:s}))})),waitForSession:Mo(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Eo(n);let s;const a=setInterval((async()=>{const n=await e.post(jn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(no(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:No(((t,n,o,i,r)=>no(e.post(jn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),Do=yo(So("flowId")),Fo=yo(So("executionId"),So("stepId"),So("interactionId")),qo=e=>({start:Do(((t,n,o,i,r,s,a,l=!1)=>no(e.post(jn.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:Fo(((t,n,o,i,r,s,a=!1)=>no(e.post(jn.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a}))))}),zo=So("loginId"),Vo=yo(So("token")),Ko=yo(zo),Ho=yo(zo,Oo("phone")),Jo=yo(zo,Co("email")),Bo=Object.keys(Uo).filter((e=>e!==Ro.voice&&e!==Ro.im)),Xo=e=>({verify:Vo((t=>no(e.post(jn.magicLink.verify,{token:t})))),signIn:Bo.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ko(((n,i,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return no(e.post(to(jn.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:Bo.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ko(((n,i,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return no(e.post(to(jn.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:Bo.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ko(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return no(e.post(to(jn.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:Jo(((t,n,o,i,r)=>no(e.post(jn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Ro).filter((e=>e!==Ro.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ho(((t,o,i,r,s)=>no(e.post(to(jn.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var Go;!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"}(Go||(Go={}));const Yo=yo(So("code")),Zo=e=>({start:Object.assign(((t,n,o,i,r)=>no(e.post(jn.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(Go).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>no(e.post(jn.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:Yo((t=>no(e.post(jn.oauth.exchange,{code:t})))),startNative:(t,n,o)=>no(e.post(jn.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>no(e.post(jn.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>no(e.get(jn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>no(e.post(jn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>no(e.post(jn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Qo=So("appId"),ei=yo(Qo),ti=e=>({connect:ei(((t,n,o)=>{const i=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,no(e.post(jn.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),ni=So("loginId"),oi=yo(ni,So("code")),ii=yo(ni),ri=yo(ni,Oo("phone")),si=yo(ni,Co("email")),ai=e=>({verify:Object.keys(Uo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oi(((t,o)=>no(e.post(to(jn.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Uo).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ii(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return no(e.post(to(jn.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Uo).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ii(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return no(e.post(to(jn.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Uo).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:ii(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return no(e.post(to(jn.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:si(((t,n,o,i)=>no(e.post(jn.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Ro).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ri(((t,o,i,r)=>no(e.post(to(jn.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),li=yo(So("tenant")),ci=yo(So("code")),di=e=>({start:li(((t,n,o,i,r,s,a,l)=>no(e.post(jn.saml.start,o||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},i&&{token:i}))))),exchange:ci((t=>no(e.post(jn.saml.exchange,{code:t}))))}),ui=So("loginId"),hi=yo(ui,So("code")),pi=yo(ui),fi=yo(ui),gi=e=>({signUp:pi(((t,n)=>no(e.post(jn.totp.signUp,{loginId:t,user:n})))),verify:hi(((t,n,o,i)=>no(e.post(jn.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:fi(((t,n)=>no(e.post(jn.totp.update,{loginId:t},{token:n}))))}),vi=So("loginId"),mi=So("newPassword"),bi=yo(vi,So("password")),wi=yo(vi),yi=yo(vi,mi),ki=yo(vi,So("oldPassword"),mi),Ii=e=>({signUp:bi(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return no(e.post(jn.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:bi(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return no(e.post(jn.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:wi(((t,n,o)=>no(e.post(jn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:yi(((t,n,o)=>no(e.post(jn.password.update,{loginId:t,newPassword:n},{token:o})))),replace:ki(((t,n,o)=>no(e.post(jn.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>no(e.get(jn.password.policy))}),Si=ko("loginId"),Ci=So("loginId"),Oi=So("origin"),xi=yo(Ci,Oi,So("name")),Ai=yo(Ci,Oi),ji=yo(Si,Oi),Ei=yo(Ci,Oi,Io("token")),Ri=yo(So("transactionId"),So("response")),Ti=e=>({signUp:{start:xi(((t,n,o,i,r)=>no(e.post(jn.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:r,passkeyOptions:i})))),finish:Ri(((t,n)=>no(e.post(jn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:ji(((t,n,o,i,r)=>no(e.post(jn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:Ri(((t,n)=>no(e.post(jn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ai(((t,n,o,i)=>no(e.post(jn.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:o}))))},update:{start:Ei(((t,n,o,i)=>no(e.post(jn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i},{token:o})))),finish:Ri(((t,n)=>no(e.post(jn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Ui=ko("loginId"),_i=yo(Ui),$i=yo(So("pendingRef")),Pi=e=>({signUpOrIn:_i(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return no(e.post(jn.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:_i(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return no(e.post(jn.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:_i(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return no(e.post(jn.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:$i(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Eo(n);let s;const a=setInterval((async()=>{const n=await e.post(jn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(no(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Li=yo(So("token")),Mi=yo(Io("token"));var Ni,Wi=yo([(Ni=So("projectId"),io(((e,t)=>n=>so(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",Ni))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=Jn({baseUrl:o,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:i,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:Ao(l),otp:ai(l),magicLink:Xo(l),enchantedLink:Wo(l),oauth:Zo(l),outbound:ti(l),saml:di(l),totp:gi(l),notp:Pi(l),webauthn:Ti(l),password:Ii(l),flow:qo(l),refresh:Mi(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?jn.tryRefresh:jn.refresh;return no(l.post(r,i,{token:e,queryParams:t}))})),selectTenant:yo([fo("tenantId")],[bo('"token" must be string or undefined')])(((e,t)=>no(l.post(jn.selectTenant,{tenant:e},{token:t})))),logout:Mi((e=>no(l.post(jn.logout,{},{token:e})))),logoutAll:Mi((e=>no(l.post(jn.logoutAll,{},{token:e})))),me:Mi((e=>no(l.get(jn.me,{token:e})))),myTenants:yo([wo('"tenants" must a string array or a boolean')],[bo('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,no(l.post(jn.myTenants,n,{token:t}))})),history:Mi((e=>no(l.get(jn.history,{token:e})))),isJwtExpired:Li(Yn),getTenants:Li(Zn),getJwtPermissions:Li(Qn),getJwtRoles:Li(eo),getCurrentTenant:Li(oo),httpClient:l};var l})),Di=Object.assign(Wi,{DeliveryMethods:Uo});
6
+ /*! js-cookie v3.0.5 | MIT */function Fi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var qi=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=Fi({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",Fi({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Fi({},this.attributes,t))},withConverter:function(t){return e(Fi({},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 zi={default:"endpoint"},Vi="Blocked by CSP",Ki="The endpoint parameter is not a valid URL",Hi="Failed to load the JS script of the agent",Ji="9319";function Bi(e,t){var n,o,i,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||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,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Vi||s===Ki)n.exclude(),r=0;else if(s===Ji)n.exclude();else if(s===Hi){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+o()-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,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(i)}))}))};return u(c).then((function(e){return[e,a]}))}var Xi="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Gi=Xi;function Yi(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:Xi,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(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 Bi(e,Zi)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Ji?new Error(Hi):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function Zi(e){return function(e,t,n){var o,i=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,a())};i.addEventListener(r,s);var a=function(){return i.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(),o)return n(o);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(Ki);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(Hi))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(Vi)})).then(Qi)}function Qi(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Ji);return n}const er="3.2.0",tr="undefined"!=typeof window,nr=Math.pow(2,31)-1,or=`https://descopecdn.com/npm/oidc-client-ts@${er}/dist/browser/oidc-client-ts.min.js`,ir=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${er}/dist/browser/oidc-client-ts.min.js`,rr=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let sr;const ar=e=>{try{return An(e).exp}catch(e){return null}},lr=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ar(n)},cr=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?ar(o):void 0)},dr=e=>{const{access_token:n,id_token:o,refresh_token:i,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:o,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||cr(e),cookieExpiration:e.cookieExpiration||lr(e)},s)},ur=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},hr=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 dr(n)},pr=()=>tr&&!!window.descopeBridge,fr=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return rr.includes(n)},gr=void 0!==sr||tr&&void 0!==window.localStorage,vr=(e,t)=>{var n,o;return null===(o=null===(n=sr||tr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},mr=e=>{var t,n;return null===(n=null===(t=sr||tr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},br=e=>{var t,n;return null===(n=null===(t=sr||tr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},wr=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==sr?void 0:sr.key)||void 0===t?void 0:t.call(sr,e))&&void 0!==n?n:tr&&(null===(i=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===i?void 0:i.call(o,e)))&&void 0!==r?r:null},yr=(...e)=>{console.debug(...e)},kr=(...e)=>{console.warn(...e)},Ir="DS",Sr="DSR",Cr="DSI",Or="DSRCN";function xr(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Ar(o);qi.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}function Ar(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const jr=e=>(null==e?void 0:e.cookieName)||Ir,Er=e=>(null==e?void 0:e.cookieName)||Sr;function Rr(e="",t){return qi.get(Er(t))||mr(`${e}${Sr}`)||""}function Tr(e="",t){return qi.get(jr(t))||mr(`${e}${Ir}`)||""}function Ur(e=""){return mr(`${e}${Cr}`)||""}function _r(e="",t,n,o){br(`${e}${Sr}`),br(`${e}${Ir}`),br(`${e}${Cr}`),br(`${e}${Or}`);const i=jr(t);qi.remove(i,null==o?void 0:o.session);const r=Er(n);qi.remove(r,null==o?void 0:o.refresh)}const $r=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||Rr(e,t)});if(!n){const t=function(e=""){return mr(`${e}${Or}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return mr(`${e}DTD`)||""}(e);return r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r})),i},Pr=tr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Lr="vsid",Mr="vrid",Nr="fp",Wr=(e=!1)=>{const t=mr(Nr);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Dr=async(e,t=Pr)=>{try{if(Wr())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Yi({apiKey:e,endpoint:[o.toString(),zi],scriptUrlPattern:[r,Gi]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Lr]:e,[Mr]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};vr(Nr,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Fr=e=>{const t=Wr(!0);return t&&e.body&&(e.body.fpData=t),e},qr="descopeFlowNonce",zr="X-Descope-Flow-Nonce",Vr="/v1/flow/start",Kr="/v1/flow/next",Hr=(e,t=qr)=>`${t}${e}`,Jr=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Br=e=>{var t;return e.path===Kr&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Jr(e.body.executionId):null},Xr="dls_last_user_login_id",Gr="dls_last_user_display_name",Yr=e=>vr(Xr,e),Zr=()=>mr(Xr),Qr=()=>mr(Gr),es=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=Zr(),r=Qr();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},ts="DSLI",ns=e=>async(...t)=>{const n=await e(...t);return br(ts),n};function os(){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 is(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ds(n.publicKey.challenge),n.publicKey.user.id=ds(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=ds(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:us(n.rawId),type:n.type,response:{attestationObject:us(n.response.attestationObject),clientDataJSON:us(n.response.clientDataJSON)}});var n}async function rs(e){const t=ls(e);return cs(await navigator.credentials.get(t))}async function ss(e,t){const n=ls(e);return n.signal=t.signal,n.mediation="conditional",cs(await navigator.credentials.get(n))}async function as(e=!1){var t,n;if(!tr)return Promise.resolve(!1);if(pr()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function ls(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ds(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=ds(e.id)})),n}function cs(e){return JSON.stringify({id:e.id,rawId:us(e.rawId),type:e.type,response:{authenticatorData:us(e.response.authenticatorData),clientDataJSON:us(e.response.clientDataJSON),signature:us(e.response.signature),userHandle:e.response.userHandle?us(e.response.userHandle):void 0}})}function ds(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function us(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var hs,ps=(hs=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await is(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await rs(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await is(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await rs(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await is(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:is,get:rs,isSupported:as,conditional:ss}}),(...e)=>{const t=hs(...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 fs="/fedcm/config",gs=()=>{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 vs(e,t){var n;try{await ms(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function ms(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=gs(),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(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var bs=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await as(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let ws;const ys=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);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",(()=>{ys(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),ks=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{ws||(ws=(async()=>{try{return require("oidc-client-ts")}catch(e){return ys([or,ir],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await ws;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new i({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}})(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.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)))),vr(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var i;const{client:r}=await o(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=mr(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 i.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:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||Ur(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return br(i),t||window.location.replace(s),r}}},Is=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,sr=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return tr?(o&&i&&Dr(o).catch((()=>null)),e(ur(r,{beforeRequest:Fr}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.50.1"},t.baseHeaders)}))),(e=>t=>{const n=os(),o=os(),i=os(),r=os(),s=e(ur(t,{afterRequest:async(e,t)=>{if(fr(e,t))yr("Session invalidated, notifying subscribers with empty values"),o.pub(null),i.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await hr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&i.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await hr(t);s&&o.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=jo(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return o.pub(null),i.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:o.sub,onUserChange:i.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var o;const{enableFlowNonce:i=!0,nonceStoragePrefix:r=qr}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(s);((e=qr)=>{try{if(!gr)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==sr?void 0:sr.length)&&void 0!==t?t:tr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=wr(i);if(t&&t.startsWith(e)){const n=mr(t);if(n)try{JSON.parse(n).expiry<Date.now()&&br(t)}catch(e){br(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=e(ur(s,{afterRequest:async(e,t)=>{if(e.path!==Vr&&e.path!==Kr)return;const{nonce:n,executionId:o}=await(async(e,t)=>{try{const n=t.headers.get(zr);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Br(e)),{nonce:n,executionId:Jr(o)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&o&&((e,t,n,o=qr)=>{try{const i=Hr(e,o),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};vr(i,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(o,n,e.path===Vr,r)},beforeRequest:e=>{if(e.path===Kr){const t=Br(e);if(t){const n=((e,t=qr)=>{try{const n=Hr(e,t),o=mr(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(((e,t=qr)=>{try{const n=Hr(e,t);br(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):i.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,r);n&&(e.headers=e.headers||{},e.headers[zr]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let i;e=new Promise((e=>{i=e})),await o;try{return await t(...n)}finally{i()}}}return a}),(e=>t=>{const n=e(ur(t,{afterRequest:async(e,t)=>{if(fr(e,t))return void br(ts);const n=await hr(t);(null==n?void 0:n.sessionExpiration)&&vr(ts,String(n.sessionExpiration))}}));return jo(n,["logout","logoutAll","oidc.logout"],ns)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);const r=!!o,s="object"==typeof o&&(null==o?void 0:o.customActivityTracking);if(!r||pr())return Object.assign(e(i),{markUserActive:()=>{kr("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(yr("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),tr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(yr("Expiration time passed, refreshing session"),f.refresh(Rr()||d))}));const f=e(ur(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i,nextRefreshSeconds:r}=await hr(t);if(fr(e,t))yr("Session invalidated, canceling all timers"),a();else if(n||i){if(c=((e,t)=>{if(t)return new Date(1e3*t);yr("Could not extract expiration time from session token, trying to decode the token");try{const t=An(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!c)return void yr("Could not extract expiration time from session token");d=o,h=r>0;const e=((e,t)=>{let n;var o;return t>0?(n=1e3*t,yr(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>nr&&(yr(`Timeout is too large (${n}ms), setting it to ${nr}ms`),n=nr),n})(c,r);if(a(),e<=2e4)return void yr("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});yr(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(tr&&"hidden"===document.visibilityState)yr("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return yr("Skipping refresh due to timer - user is idle"),void(p=!0);yr("Refreshing session due to timer"),f.refresh(Rr()||o)}}),e)}}}));return Object.assign(jo(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return yr("Clearing all timers"),a(),n})),{markUserActive:u?()=>{yr("markUserActive() called"),h||yr("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(yr("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Rr()||d))}:()=>{kr("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:Zr,getLastUserDisplayName:Qr});const s=e(ur(r,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:i}=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=dr((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==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;r?(Yr(r),(e=>{vr(Gr,e)})(s)):(null==i?void 0:i.loginId)&&Yr(i.loginId)}}));let a=jo(s,["flow.start"],es);return a=jo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(br(Xr),br(Gr)),o})(i)),Object.assign(a,{getLastUserLoginId:Zr,getLastUserDisplayName:Qr})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!tr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(ur(Object.assign({refreshCookieName:a},l),{beforeRequest:$r(s,r,a),afterRequest:async(e,t)=>{if(fr(e,t))yr("Session invalidated, clearing persisted tokens"),_r(s,i,r,c);else{const e=await hr(t);e.cookieName?vr(`${s||""}${Or}`,e.cookieName):e.refreshJwt&&br(`${s||""}${Or}`);const n=((e={},t=!1,n="",o=!1)=>{var i,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(o){br(`${n}${Sr}`);const t=o.sameSite||"Strict",s=null===(i=o.secure)||void 0===i||i,a=null!==(r=o.domain)&&void 0!==r?r:e.cookieDomain,l=Er(o);s&&"https:"!==window.location.protocol&&kr("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});xr(l,c,d);const h=Ar(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=Er(o);qi.remove(e),vr(`${n}${Sr}`,c)}if(l)if(t){const n=t.sameSite||"Strict",o=null===(s=t.secure)||void 0===s||s,i=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=jr(t);o&&"https:"!==window.location.protocol&&kr("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});xr(r,l,c);const d=Ar(i);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?i:void 0}})}else vr(`${n}${Ir}`,l);return e.idToken&&vr(`${n}${Cr}`,e.idToken),d&&vr(`${n}DTD`,d),u})(e,i,s,r);n&&(c=n)}}})),u=jo(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return _r(e,t,n,null==o?void 0:o()),s})(s,i,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Rr(s,r),getSessionToken:()=>Tr(s,i),getIdToken:()=>Ur(s)})}))((e=>{const t=Di(e),n=ks(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(pr())return yr(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(i&&!mr(ts)&&!mr(Xr)&&!mr("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Tr(),a=Rr();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){yr("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},l,i)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:bs(t),webauthn:ps(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){vs(o,e)},requestAuthentication(e){vs(o,e)}},async oneTap(e,t,n,i,r){await ms(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:i,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(i+fs),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>tr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+fs);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var o,i})),Ss={allOutboundApps:"/v1/mgmt/outbound/apps",connectedOutboundApps:"/v1/mgmt/outbound/apps-with-user-token"},Cs={me:"/v1/auth/me"},Os=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)})),xs=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))})),As=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))})),js=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))})),Es=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>n(void 0,void 0,void 0,(function*(){if(t)return xs();const n=yield e.get(Ss.allOutboundApps);return yield Os(n),n.json()})),getConnectedOutboundApps:o=>n(void 0,[o],void 0,(function*({userId:n,tenantId:o}){if(t)return As();const i=yield e.get(Ss.connectedOutboundApps,{queryParams:o?{userId:n,tenantId:o}:{userId:n}});return yield Os(i),i.json()}))}),Rs=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return js();const n=yield e.get(Cs.me);return yield Os(n),n.json()}))}),Ts=a((e=>{var t,s,a,l;const c=r(O,S,v,pn,x)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||oe}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(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"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,n)=>{const o=Is(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.3.4"}}));return{outboundApps:Es({httpClient:o.httpClient,mock:t}),user:Object.assign({},Rs({httpClient:o.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),Us=nn("users/me",((e,{extra:{api:t}})=>t.user.me())),_s={action:Us,reducer:vn(Us)({onFulfilled:(e,t)=>{e.me.data=t.payload}},mn((e=>e.me)))},$s=a((e=>{const t=r(un({name:"widget",initialState:Cn,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{_s.reducer(e),Sn.reducer(e),yn.reducer(e)},asyncActions:{getMe:_s.action,getOutboundApps:yn.action,getConnectedOutboundApps:Sn.action}}),I,v,Ts)(e);return class extends t{constructor(...e){super(...e),this.state=Cn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ps="widget-flow",Ls=a((e=>{var t,i,s;return s=class extends(r(I,te,$s,pn,v,ce)(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=gn(Ps);r&&(!function(e){if(window.history.replaceState&&gn(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())}}(Ps),o(this,t,"m",i).call(this,r))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(fn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));new G((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),Ms=Ct((e=>e.outboundAppsList.data),(e=>e.connectedOutboundAppsIds.data),(e=>e.allowedAppsIds.data),((e,t,n)=>e.filter((e=>void 0===n||n.includes(e.id))).map((e=>{const n=(null==t?void 0:t.includes(e.id))||!1;return Object.assign(Object.assign({},e),{appId:e.id,isConnected:n})})).sort(((e,t)=>e.name.localeCompare(t.name))))),Ns=Ct((e=>e.me.data),(e=>e.userId)),Ws=a((e=>{const t=r(E,C({"widget-id":C.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(`outbound-applications-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Ds=a((e=>{var t,i,a,l,c;return c=class extends(r(v,I,D,H,Ws,$s)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,n,i){"allowed-outbound-apps-ids"===e&&n!==i&&this.actions.setAllowedAppsIds(o(this,t,"a",l))}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(o(this,t,"a",l)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:Ns(this.state),tenantId:this.tenantId})]);const r=yield o(this,t,"m",i).call(this);o(this,t,"m",a).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},a=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},l=function(){var e;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const t=null===(e=this.getAttribute("allowed-outbound-apps-ids"))||void 0===e?void 0:e.trim();return t?t.split(",").map((e=>e.trim())).filter(Boolean):[]},c})),Fs=a((e=>class extends(r(ce,S)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),qs=a((e=>{var t,s,a,l,c,d,u,h,p,f,g,m,b,w,y,k,I;return I=class extends(r(Fs,$s,v,Ds,te)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),u.set(this,null),h.set(this,null),k.set(this,(e=>{let t,n;return(...o)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,o)||(t=o,n=e(...o)),n)})((e=>{o(this,s,"f").data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",y).call(this,Ms(this.state)),o(this,t,"m",p).call(this),o(this,t,"m",m).call(this),this.subscribe(o(this,k,"f").bind(this),Ms)}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,k=new WeakMap,t=new WeakSet,p=function(){o(this,s,"f").connectFlowId&&(i(this,a,this.createModal({"data-id":"outbound-apps-connect"}),"f"),o(this,a,"f").afterClose=()=>{var e;if(o(this,u,"f")){const t=null===(e=o(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",o(this,u,"f")),i(this,u,null,"f")}},i(this,c,new G((()=>{var e;return null===(e=o(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(o(this,c,"f")))},f=function(e,t,n){e.open(),t.removeEventListener("page-updated",n)},g=function(e,n){var i;const r=null===(i=e.ele)||void 0===i?void 0:i.querySelector("descope-wc"),s=()=>o(this,t,"m",f).call(this,e,r,s);n=s,null==r||r.addEventListener("page-updated",n)},m=function(){i(this,l,this.createModal({"data-id":"outbound-apps-disconnect"}),"f"),i(this,d,new G((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=()=>{var e;if(o(this,h,"f")){const t=null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",o(this,h,"f")),i(this,h,null,"f")}},this.syncFlowTheme(o(this,d,"f"))},b=function(e){o(this,a,"f").setContent(fn({projectId:this.projectId,flowId:o(this,s,"f").connectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:e})),o(this,t,"m",g).call(this,o(this,a,"f"),o(this,u,"f")),o(this,c,"f").onSuccess((()=>{o(this,a,"f").close(),this.actions.getConnectedOutboundApps({userId:Ns(this.state),tenantId:this.tenantId})}))},w=function(e){o(this,l,"f").setContent(fn({projectId:this.projectId,flowId:o(this,s,"f").disconnectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:e})),o(this,t,"m",g).call(this,o(this,l,"f"),o(this,h,"f")),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getConnectedOutboundApps({userId:Ns(this.state)})}))},y=function(e){i(this,s,new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),o(this,s,"f").onConnectClick((({id:e})=>{o(this,t,"m",b).call(this,e)})),o(this,s,"f").onDisconnectClick((({id:e})=>{o(this,t,"m",w).call(this,e)})),o(this,s,"f").data=e},I})),zs=a((e=>class extends(r(U,ce,Ls,qs)(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)}))}})),Vs=r((e=>class extends(zs(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 Jc})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.3.4"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",Vs);const Ks=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Hs,Js,Bs,Xs,Gs,Ys,Zs,Qs,ea,ta;const na=document.createElement("template");na.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 oa=r(z)(HTMLElement);class ia extends oa{constructor(){var e;super(),Hs.add(this),Js.set(this,new p({messages:[]})),Bs.set(this,void 0),Xs.set(this,void 0),Gs.set(this,void 0),Ys.set(this,{resize:o(this,Hs,"m",ta).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(na.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'),i(this,Bs,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Xs,o(this,Bs,"f").querySelector(".content"),"f"),i(this,Gs,o(this,Bs,"f").querySelector(".header"),"f")}updateData(e){o(this,Js,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Ks(e,e.offsetLeft-o,e.offsetTop-i,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})(o(this,Bs,"f"),o(this,Gs,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Ys,"f").resize),(e=o(this,Bs,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,Bs,"f").onresize=o(this,Hs,"m",ea).bind(this),o(this,Js,"f").subscribe(o(this,Hs,"m",Zs).bind(this))}disconnectedCallback(){o(this,Js,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Ys,"f").resize)}}Js=new WeakMap,Bs=new WeakMap,Xs=new WeakMap,Gs=new WeakMap,Ys=new WeakMap,Hs=new WeakSet,Zs=function(e){o(this,Hs,"m",Qs).call(this,e),o(this,Hs,"m",ea).call(this)},Qs=function(e){o(this,Xs,"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("")},ea=function(){o(this,Xs,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},ta=function(){const[e,t]=Ks(o(this,Bs,"f"),Number.parseInt(o(this,Bs,"f").style.left,10),Number.parseInt(o(this,Bs,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Bs,"f").style.top=`${t}px`,o(this,Bs,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ia);var ra=Object.freeze({__proto__:null,default:ia});const sa="undefined"!=typeof localStorage,aa="J151000",la="E103205",ca=sa&&localStorage.getItem("base.content.url")||"",da="base.ui.components.url";sa&&localStorage.getItem(da),sa&&localStorage.getItem(da);const ua="descope-login-flow",ha="code",pa="redirect_mode",fa="err",ga="data-exclude-field",va="data-exclude-next",ma="dls_last_auth",ba="state_id",wa="saml_idp_state_id",ya="wsfed_idp_state_id",ka="saml_idp_username",Ia="descope_idp_initiated",Sa="sso_app_id",Ca="custom_app_id",Oa="third_party_app_id",xa="third_party_app_state_id",Aa="oidc_login_hint",ja="oidc_prompt",Ea="oidc_resource",Ra="oidc_error_redirect_uri",Ta="application_scopes",Ua="data-type",_a="redirect",$a="poll",Pa="webauthnCreate",La="webauthnGet",Ma="nativeBridge",Na="loadForm",Wa="submit",Da="polling",Fa=["descope-multi-select-combo-box","descope-text-area"],qa="dls_last_auth_in_flight",za=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Va;!function(e){e.backward="backward",e.forward="forward"}(Va||(Va={}));const Ka=["descope-enriched-text"];function Ha(e){return new URLSearchParams(window.location.search).get(e)}function Ja(e){if(window.history.replaceState&&Ha(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 Ba(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Va.forward:n<o?Va.backward:void 0}const Xa=e=>{let[t="",n=""]=(Ha(ua)||"").split("_");const o=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||o&&o!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:o}};function Ga(){Ja(ua)}const Ya=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Za=(e,t)=>{const{executionId:n,stepId:o,executionFlowId:i}=Xa(e);if(i&&e!==i)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&Ga();const r=Ha("t")||void 0;r&&Ja("t");const s=Ha(ha)||void 0;s&&Ja(ha);const a="popup"===Ha(pa);a&&Ja(pa);const l=Ha(fa)||void 0;l&&Ja(fa);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:Ha("ra-challenge"),redirectAuthCallbackUrl:Ha("ra-callback"),redirectAuthBackupCallbackUri:Ha("ra-backup-callback"),redirectAuthInitiator:Ha("ra-initiator")},p=Ha(ba);p&&Ja(ba);const f=Ha(wa);f&&Ja(wa);const g=Ha(ya);g&&Ja(ya);const v=Ha(ka);f&&Ja(ka);const m=Ha(Ia);m&&Ja(Ia);const b=Ha(Sa);b&&Ja(Sa);const w=Ha(Ca);w&&Ja(Ca);const y=Ha(Oa);y&&Ja(Oa);const k=Ha(xa);k&&Ja(xa);const I=Ha(Ta);I&&Ja(Ta);const S=Ha(Aa);S&&Ja(Aa);const C=Ha(ja);C&&Ja(ja);const O=Ha(Ra);O&&Ja(Ra);const x=Ha(Ea);return x&&Ja(Ea),{executionId:n,stepId:o,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:b,customAppId:w,oidcLoginHint:S,oidcPrompt:C,oidcErrorRedirectUri:O,oidcResource:x,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:I}}},Qa=e=>{let t,n;return Object.assign(((...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}),{reset:()=>{t=void 0,n=void 0}})},el=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function tl(e,t,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),o(e))})).catch((e=>{r||(clearTimeout(s),i(e))}))}))}const nl=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:o,samlIdpUsername:i,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||o||i||r||s||a||l||c||d||u||h||p),ol=e=>null==e?void 0:e.submit(),il=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},rl=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function sl(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 al=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function ll(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var cl,dl,ul,hl;function pl(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!pl(r,s))return!1}else if(r!==s)return!1}return!0}let fl=class{constructor(e={},{forceUpdate:t=!1}={}){cl.set(this,void 0),dl.set(this,{}),ul.set(this,0),hl.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,cl,"f")):e,n=Object.assign(Object.assign({},o(this,cl,"f")),t),r=o(this,cl,"f");i(this,cl,n,"f"),Object.freeze(o(this,cl,"f")),setTimeout((()=>{Object.values(o(this,dl,"f")).forEach((({cb:e,selector:t,forceUpdate:i})=>{const s=t(r),a=t(n);(o(this,hl,"f")||i||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!pl(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},i(this,cl,e,"f"),i(this,hl,t,"f")}get current(){return Object.assign({},o(this,cl,"f"))}set forceUpdate(e){i(this,hl,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return i(this,ul,o(this,ul,"f")+1,"f"),o(this,dl,"f")[o(this,ul,"f")]={cb:e,selector:t,forceUpdate:n},o(this,ul,"f").toString()}unsubscribe(e){const t=!!o(this,dl,"f")[e];return t&&delete o(this,dl,"f")[e],t}unsubscribeAll(){return i(this,dl,{},"f"),!0}};cl=new WeakMap,dl=new WeakMap,ul=new WeakMap,hl=new WeakMap;const gl=["*","#","/","(",")","[","]","_","<",">","`"],vl=e=>"string"!=typeof e?e:e.replace((e=>{const t=gl.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),ml=["disabled"],bl=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ga}])`)).forEach((e=>{e.value=n}))}))},wl=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),yl=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,o)=>n?vl(wl(t,o)):wl(t,o))),kl=(e,t,n)=>{e.querySelectorAll(`[${Ua}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Il=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},Sl=(e,n,o,i)=>{var r,s;kl(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),kl(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>Ka.includes(e))(e.localName);e.textContent=yl(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",yl(o,t))}))})(e,n),((e,n,o)=>{if(!n)return;const{componentsDynamicAttrs:i}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});i&&Object.keys(i).forEach((e=>{const t=i[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 i=n[t];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(e){o.error(`Could not stringify value "${i}" for "${t}"`,e.message),i=""}e.setAttribute(t,i)}))}))}))})(e,null==n?void 0:n.componentsConfig,i),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=yl(e.value,t)}))}))})(e,n),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{ml.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o),((e,t={},n)=>{Object.entries(t).forEach((([t,o])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(o){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;case"read-only":e.setAttribute("readonly","true");break;default:null==n||n.error(`Unknown component state "${o}" for component with id "${t}"`,'Valid states are "disable", "hide", and "read-only"')}}))}))})(e,null==n?void 0:n.componentsState,i)},Cl=Qa((()=>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)))),o=(()=>{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 tl(100,n,o)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let Ol;const xl=(e,t)=>{Ol?Ol.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Al=e=>Ol?Ol.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,jl="dls_ab_testing_id",El={"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,o]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=o?o:0)},"not-in-range":(e,t)=>{const[n,o]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==o&&!Number.isNaN(n)&&!Number.isNaN(o))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>o},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function Rl(e,t){const n={};try{Object.assign(n,JSON.parse(Al(ma)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function Tl(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||xl(ma,JSON.stringify(e)))}function Ul(){try{return JSON.parse(Al(qa)||"{}")}catch(e){return{}}}function _l(e){try{(e=>{Ol?Ol.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(qa)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const $l=(e,t="")=>Object.keys(e).reduce(((n,o)=>{var i;if(Array.isArray(e[o]))return Object.assign(Object.assign({},n),{[o]:{value:e[o].map((e=>"object"==typeof e&&null!==e?$l(e):e))}});if("object"==typeof e[o]&&null!==e[o]&&!(null===(i=e[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),$l(e[o],`${t+o}.`));const r="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},n),{[t+o]:r,[`form.${t}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Pl=a((e=>{var t,n,i,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;o(this,t,"m",n).call(this)&&o(this,t,"m",i).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)},i=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 Ll,Ml,Nl,Wl,Dl,Fl,ql,zl,Vl,Kl,Hl,Jl,Bl,Xl,Gl,Yl,Zl,Ql,ec,tc,nc,oc;const ic=r(ce,E,Pl,z)(HTMLElement);class rc extends ic{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(),Ll.add(this),Nl.set(this,!1),Wl.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,Ll,"m",oc).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},Dl.set(this,new fl),Fl.set(this,new fl),ql.set(this,{}),this.getComponentsContext=()=>o(this,ql,"f"),this.nextRequestStatus=new fl({isLoading:!1}),zl.set(this,void 0),Vl.set(this,{popstate:o(this,Ll,"m",Xl).bind(this),componentsContext:o(this,Ll,"m",ec).bind(this)}),Kl.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,Kl,e,"f"),o(this,Ll,"m",Jl).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}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 $l(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 o(this,Wl,"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");i(this,Wl,e,"f"),(e=>{Ol=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(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Fa.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),o(this,Fl,"f").subscribe(o(this,Ll,"m",nc).bind(this)),o(this,Fl,"f").update({isDebug:this.debug}),o(this,Ll,"m",Bl).call(this),yield o(this,Ll,"m",Zl).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=Za(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,Vl,"f").popstate),window.addEventListener("components-context",o(this,Vl,"f").componentsContext),o(this,Dl,"f").subscribe(o(this,Ll,"m",Yl).bind(this)),o(this,Dl,"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)),i(this,Nl,!0,"f")}))}disconnectedCallback(){o(this,Dl,"f").unsubscribeAll(),o(this,Fl,"f").unsubscribeAll(),o(this,Ll,"m",tc).call(this),window.removeEventListener("popstate",o(this,Vl,"f").popstate),window.removeEventListener("components-context",o(this,Vl,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,Nl,"f")&&t!==n&&Ml.observedAttributes.includes(e)){o(this,Ll,"m",Bl).call(this);const i=null===t;o(this,Dl,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,Ga()),{[Ya(e)]:n,stepId:r,executionId:s}})),o(this,Fl,"f").update({isDebug:this.debug})}}}var sc,ac,lc,cc,dc,uc,hc,pc,fc,gc,vc,mc,bc,wc,yc,kc,Ic,Sc,Cc,Oc,xc,Ac,jc,Ec,Rc,Tc,Uc,_c,$c,Pc,Lc,Mc,Nc,Wc,Dc,Fc,qc,zc,Vc,Kc;Ml=rc,Nl=new WeakMap,Wl=new WeakMap,Dl=new WeakMap,Fl=new WeakMap,ql=new WeakMap,zl=new WeakMap,Vl=new WeakMap,Kl=new WeakMap,Ll=new WeakSet,Hl=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 ")},Jl=function(){o(this,Ll,"m",Hl).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Bl=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];Ml.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Ya(t)])throw Error(`${t} cannot be empty`)}))},Xl=function(){const{stepId:e,executionId:t}=Xa(this.flowId);o(this,Dl,"f").update({stepId:e,executionId:t})},Gl=function(e,t){Is&&"function"==typeof Is||this.logger.error("SDK was not loaded properly",Is,JSON.stringify(Is));const i=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Ml.sdkConfigOverrides),{projectId:e,baseUrl:t});o(this,Wl,"f")&&(i.customStorage=o(this,Wl,"f")),this.sdk=Is(i),["start","next"].forEach((e=>{const t=function(e,t,o){return(...i)=>n(this,void 0,void 0,(function*(){let n;const r=o+1;for(let s=0;s<r;s++)try{return yield e(...i)}catch(e){n=e,s<o&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...o)=>n(this,void 0,void 0,(function*(){try{return yield t(...o)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:aa,errorDescription:t.toString()}}}}))}))},Yl=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,Ll,"m",Gl).call(this,t,n)}o(this,Kl,"f").call(this,e)}))},Zl=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield o(this,Ll,"m",Ql).call(this))}))},Ql=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(ca||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.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}}))},ec=function(e){i(this,ql,Object.assign(Object.assign({},o(this,ql,"f")),e.detail),"f")},tc=function(){var e;null===(e=o(this,zl,"f"))||void 0===e||e.remove(),i(this,zl,null,"f")},nc=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,zl,document.createElement("descope-debugger"),"f"),Object.assign(o(this,zl,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return dd})),document.body.appendChild(o(this,zl,"f"))):o(this,Ll,"m",tc).call(this)}))},oc=function(e,t){var n;e&&this.debug&&(null===(n=o(this,zl,"f"))||void 0===n||n.updateData({title:e,description:t}))},rc.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.66.0"}};class Hc extends rc{static set sdkConfigOverrides(e){rc.sdkConfigOverrides=e}static get sdkConfigOverrides(){return rc.sdkConfigOverrides}constructor(){const e=new fl({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),sc.add(this),this.stepState=new fl({}),ac.set(this,void 0),lc.set(this,null),cc.set(this,null),dc.set(this,{visibilitychange:o(this,sc,"m",uc).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},wc.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},kc.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()?o(this,sc,"m",Ic).call(this,t):t()})),Sc.set(this,((e,t,r,s,a=!1)=>{const l=[la,"E103202"];if(this.flowState.current.action===$a){if(o(this,Oc,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;i(this,ac,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,i;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,Da,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 tl(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,Sc,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===aa)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,Sc,"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===(i=null==p?void 0:p.error)||void 0===i?void 0:i.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):o(this,Sc,"f").call(this,e,t,r,s),o(this,xc,"f").call(this,p)}))),d),"f")}})),Cc.set(this,(()=>{clearTimeout(o(this,ac,"f")),i(this,ac,null,"f")})),Oc.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),xc.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,f,g;if(!(null==e?void 0:e.ok)){const i=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}`;o(this,sc,"m",Vc).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:i}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||i,(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!==la||!this.isRestartOnError||o(this,sc,"m",bc).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:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,o):this.loggerWrapper.info(n,o)}));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!==$a&&o(this,Cc,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Tl(Object.assign(Object.assign({},w),{lastUsedPerScreen:Ul()})),_l(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void o(this,sc,"m",Vc).call(this,"success",t)}this.storeLastAuthenticatedUser&&Tl(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:O,redirect:x,webauthn:A,error:j,samlIdpResponse:E,wsFedIdpResponse:R,nativeResponse:T}=e.data,U=Date.now();y!==$a?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:O,status:m,stepId:S,stepName:C,action:y,error:j}),(null===(g=O.state)||void 0===g?void 0:g.clientScripts)&&i(this,cc,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==A?void 0:A.transactionId,webauthnOptions:null==A?void 0:A.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,wsFedIdpResponseUrl:null==R?void 0:R.url,wsFedIdpResponseWresult:null==R?void 0:R.wresult,wsFedIdpResponseWctx:null==R?void 0:R.wctx,nativeResponseType:null==T?void 0:T.type,nativePayload:null==T?void 0:T.payload,reqTimestamp:U})):this.flowState.update({action:y,reqTimestamp:U})})),Ac.set(this,Qa((()=>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)}}))))),_c.set(this,null),Nc.set(this,rl(((e,t,i)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||o(this,sc,"m",Tc).call(this)){const r=null==e?void 0:e.getAttribute("id");o(this,sc,"m",Fc).call(this,e,r,i),o(this,sc,"m",$c).call(this,e);const s=yield o(this,sc,"m",Uc).call(this),a=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const l=Object.assign(Object.assign(Object.assign({},a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,l),this.nextRequestStatus.update({isLoading:!1}),o(this,sc,"m",Pc).call(this,s)}}))))),this.flowState=e}nativeResume(e,t){var n,i,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const o=new URL(c.url);t=null===(n=o.searchParams)||void 0===n?void 0:n.get(ha),e=(null===(i=o.searchParams)||void 0===i?void 0:i.get(fa))||void 0}null===(s=(r=this.nativeCallbacks).complete)||void 0===s||s.call(r,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(c.url),t=e.searchParams.get("t"),n=e.searchParams.get(ua).split("_").pop();o(this,Cc,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=c;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=c,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(l=(a=this.nativeCallbacks).complete)||void 0===l||l.call(a,c)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[ll(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 o=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,o,i;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(o=globalThis.descope)||void 0===o?void 0:o[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.16",`dist/${e.id}.js`));const s=null===(i=globalThis.descope)||void 0===i?void 0:i[e.id];return new Promise(((n,o)=>{try{const o=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(o){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=o,this.shadowRoot.appendChild(t);const n=this.nextRequestStatus.subscribe((()=>{var i;this.loggerWrapper.debug("Stopping script",e.id),(null===(i=o.stop)||void 0===i?void 0:i.call(o))&&(this.nextRequestStatus.unsubscribe(n),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){o(e)}}))}))))),i=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([o,i])}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)),o(this,sc,"m",vc).call(this),window.addEventListener("visibilitychange",o(this,dc,"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(),o(this,Cc,"f").call(this),null===(e=o(this,lc,"f"))||void 0===e||e.abort(),i(this,lc,null,"f"),window.removeEventListener("visibilitychange",o(this,dc,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=sl(e),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${t}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${t}-${o.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:I,exchangeError:S,webauthnTransactionId:C,webauthnOptions:O,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:A,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:E,locale:R,samlIdpResponseUrl:T,samlIdpResponseSamlResponse:U,samlIdpResponseRelayState:_,wsFedIdpResponseUrl:$,wsFedIdpResponseWresult:P,wsFedIdpResponseWctx:L,nativeResponseType:M,nativePayload:N,reqTimestamp:W}=e,D=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let F,q,z;const V=(()=>{const e=Al(jl);if(!e){const e=Math.floor(100*Math.random()+1);return xl(jl,e.toString()),e}return Number(e)})(),{outboundAppId:K}=this,{outboundAppScopes:H}=this,J=this.sdk.getLastUserLoginId(),B=yield this.getFlowConfig(),X=yield this.getProjectConfig(),G=Object.entries(X.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Y=A&&x?{callbackUrl:A,codeChallenge:x,backupCallbackUri:j}:void 0,Z=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let Q={};if(!p){_l(this.loggerWrapper);const e=[...B.clientScripts||[],...B.sdkScripts||[]];if(B.conditions){let t=[];({startScreenId:F,conditionInteractionId:z,startScreenName:q,clientScripts:t,componentsConfig:Q}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=El[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:J,code:k,token:y,abTestingKey:V,lastAuth:Rl(J,this.loggerWrapper)},B.conditions)),e.push(...t||[])}else B.condition?({startScreenId:F,conditionInteractionId:z}=((e,t)=>{var n;const o=null===(n=El[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,startScreenName:null==i?void 0:i.screenName,conditionInteractionId:null==i?void 0:i.interactionId}})(B.condition,{loginId:J,code:k,token:y,abTestingKey:V,lastAuth:Rl(J,this.loggerWrapper)})):(q=B.startScreenName,F=B.startScreenId);if(i(this,cc,this.loadSdkScripts(e),"f"),B.fingerprintEnabled&&B.fingerprintKey?yield Dr(B.fingerprintKey,this.baseUrl):br(Nr),!nl(F,D)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},D),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:Rl(J,this.loggerWrapper),abTestingKey:V,locale:sl(R).locale,nativeOptions:Z,outboundAppId:K,outboundAppScopes:H}),z,"",X.componentsVersion,G,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),D.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),D.oidcLoginHint?{externalId:D.oidcLoginHint}:{}));return o(this,xc,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:I,code:k,exchangeError:S,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&k||s("exchangeError")&&S))return void o(this,sc,"m",Kc).call(this,p,k,S);if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&S)){const e=yield this.sdk.flow.next(p,h,Wa,B.version,X.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return o(this,xc,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Na&&T&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.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(i),o(i)})(T,U,_||"",ol)}if(f===Na&&$&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!P)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e;const r=(e,t)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n};i.appendChild(r("wa","wsignin1.0")),i.appendChild(r("wresult",t)),i.appendChild(r("wctx",n));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",i.appendChild(s),document.body.appendChild(i),o(i)})($,P,L||"",ol)}if(f===_a&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,o)=>{const i=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+i,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-o)/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=${o},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:o,data:i}=e.data||{};"code"===o&&this.flowState.update({code:i.code,exchangeError:i.exchangeError})};let i;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),o(this,sc,"m",Vc).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==i||i())}),1e3);if(t)window.addEventListener("message",n),i=()=>{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,i=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),o(this,sc,"m",Vc).call(this,"popupclosed",{});return}if(f===Pa||f===La){if(!C||!O)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=o(this,lc,"f"))||void 0===l||l.abort(),i(this,lc,null,"f");try{e=f===Pa?yield this.sdk.webauthn.helpers.create(O):yield this.sdk.webauthn.helpers.get(O)}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,Wa,B.version,X.componentsVersion,{transactionId:C,response:e,failure:t});o(this,xc,"f").call(this,n)}if(f===Ma)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Wa,B.version,X.componentsVersion,e);o(this,xc,"f").call(this,t)})),o(this,sc,"m",fc).call(this,M,N),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&o(this,Sc,"f").call(this,p,h,B.version,X.componentsVersion),!g&&!F)return void this.loggerWrapper.warn("No screen was found to show");const ee=F||g,te=yield this.getHtmlFilenameWithLocale(R,ee),{oidcLoginHint:ne,oidcPrompt:oe,oidcErrorRedirectUri:ie,oidcResource:re,samlIdpUsername:se}=D,ae={direction:Ba(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:J,name:this.sdk.getLastUserDisplayName()||J},componentsConfig:Object.assign(Object.assign(Object.assign({},B.componentsConfig),Q),null==v?void 0:v.componentsConfig)}),htmlFilename:`${ee}.html`,htmlLocaleFilename:te,screenId:ee,stepName:e.stepName||q,samlIdpUsername:se,oidcLoginHint:ne,oidcPrompt:oe,oidcErrorRedirectUri:ie,oidcResource:re,action:f,locale:sl(R).locale},le=Rl(J,this.loggerWrapper);nl(F,D)?ae.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==B?void 0:B.clientScripts)||[];yield o(this,sc,"m",Wc).call(this,n);const i=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},D),{lastAuth:le,preview:this.preview,abTestingKey:V,client:this.client}),w&&{redirectUrl:w}),{locale:sl(R).locale,nativeOptions:Z,outboundAppId:K,outboundAppScopes:H}),z,e,X.componentsVersion,G,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),al(t)),k&&{exchangeCode:k,idpInitiated:!0}),D.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}),ae.next.isCustomScreen);return o(this,xc,"f").call(this,i),i})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ae.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==v?void 0:v.clientScripts)||[];yield o(this,sc,"m",Wc).call(this,n);const i=yield this.sdk.flow.next(p,h,e,B.version,X.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),al(t)),ae.next.isCustomScreen);return o(this,xc,"f").call(this,i),i}))),this.loggerWrapper.debug("Got a screen with id",ae.screenId),yield o(this,sc,"m",yc).call(this,ae),this.stepState.update(ae)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen");const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const f=p.content.cloneNode(!0),g=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield o(this,sc,"m",Ec).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${Ua}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(i=u.form)||void 0===i?void 0:i.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),Sl(f,u,this.formConfig,this.loggerWrapper);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,o])=>{Array.from(e.querySelectorAll(`[${n}="${o}"]`)).forEach((e=>{e.setAttribute(n,t||o)}))}))})(f,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,o])=>{Array.from(e.querySelectorAll(`[${t}="${o}"]`)).forEach((e=>{e.setAttribute(t,n||o)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,i;yield g;const r=this.contentRootElement;((e,t)=>{Il(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{Il(e,"descope-notp-image",t)})(r,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),((e,t,n,o)=>{n&&Object.keys(n).forEach((i=>{if(!t.querySelector(i))return void o.debug(`Skipping css vars for component "${i}"`,`Got css vars for component ${i} but Could not find it on next page`);const r=customElements.get(i);r?Object.keys(n[i]).forEach((t=>{var s;const a=n[i],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void o.info(`Could not find css variable name for ${t} in ${i}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):o.debug(`Could not find component class for ${i}`,"Check if the component is registered")}))})(r,f,u.cssVars,this.loggerWrapper),r.replaceChildren(f);const s=!t.htmlFilename;setTimeout((()=>{o(this,sc,"m",Lc).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const o=()=>{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 o();const i={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(i.timer),i.timer=void 0)};i.timer=setTimeout((()=>{e.removeEventListener("click",r),o(),i.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{bl(e,null==t?void 0:t.inputs),bl(e,null==t?void 0:t.form)})(r,u),o(this,sc,"m",Rc).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),el(r,this.autoFocus,s),o(this,sc,"m",qc).call(this,h)})),o(this,sc,"m",zc).call(this,d,h),r.querySelector(`[${Ua}="polling"]`)&&d(Da,{})}));c?o(this,sc,"m",Ic).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${ga}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}ac=new WeakMap,lc=new WeakMap,cc=new WeakMap,dc=new WeakMap,wc=new WeakMap,kc=new WeakMap,Sc=new WeakMap,Cc=new WeakMap,Oc=new WeakMap,xc=new WeakMap,Ac=new WeakMap,_c=new WeakMap,Nc=new WeakMap,sc=new WeakSet,uc=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},hc=function(e,t,i){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=i,this.nativeCallbacks.screenResolve=n,o(this,sc,"m",fc).call(this,"beforeScreen",{screen:e,context:t})}))}))},pc=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&o(this,sc,"m",fc).call(this,"afterScreen",{screen:e})},fc=function(e,t){o(this,sc,"m",Vc).call(this,"bridge",{type:e,payload:t})},gc=function({errorText:e,errorType:t}){const n=()=>{var n;let o=e;try{o=(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(`[${Ua}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",o)};this.addEventListener("screen-updated",n,{once:!0}),n()},vc=function(){var e,n,i;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,o=t(void 0===n?{}:n,["errorText","errorType"]),i=t(e,["screenState"]);return Object.assign(Object.assign({},i),{screenState:o})})),null===(n=this.stepState)||void 0===n||n.subscribe(o(this,sc,"m",gc).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===(i=this.stepState)||void 0===i||i.subscribe(o(this,sc,"m",mc).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})},mc=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=""}))})),el(this.contentRootElement,this.autoFocus,!1))},bc=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},yc=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=(e=>{var t,n,o;const i=(r=e.screenState,s=(e,t)=>za.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)&&(i.error={text:a,type:l}),e.action&&(i.action=e.action),(null===(o=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===o?void 0:o.data)&&(i.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),i})(t(r,["next","stepName"]));let c=yield o(this,sc,"m",hc).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(o(this,kc,"f").call(this,c),s&&(s.isCustomScreen=c),o(this,wc,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),i(this,wc,c,"f"),c?this.stepState.unsubscribeAll():o(this,sc,"m",vc).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),o(this,sc,"m",Rc).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},Ic=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")},jc=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)}))}},Ec=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,lc,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Cl())){const{options:e,transactionId:r}=(yield o(this,Ac,"f").call(this))||{};e&&r&&(o(this,sc,"m",jc).call(this,s),i(this,lc,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,o(this,lc,"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&&o(this,sc,"m",Vc).call(this,"ready",{}),t||o(this,sc,"m",pc).call(this,n),o(this,sc,"m",Vc).call(this,"page-updated",{screenName:n}),o(this,sc,"m",Vc).call(this,"screen-updated",{screenName:n})},Tc=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"===t.localName||t.classList.contains("hidden")||(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},Uc=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})),{})}))},$c=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(),o=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(o)})),s=()=>{var e;window.removeEventListener("pageshow",o(this,_c,"f")),i(this,_c,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),r())}),"f"),window.addEventListener("pageshow",o(this,_c,"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())}))},Pc=function(e={}){var t,n;const o=il(e,["externalId","email","phone"]),i=il(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});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)}},Lc=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>o(this,sc,"m",Mc).call(this,e)))},Mc=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),o=`input-${e.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),e.appendChild(i),t.setAttribute("slot",o),this.appendChild(t)}))},Wc=function(e){return n(this,void 0,void 0,(function*(){if(o(this,cc,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield o(this,cc,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const i=[];for(const e of t)"function"==typeof e.refresh&&i.push(e.refresh());if(i.length>0)try{yield tl(5e3,Promise.all(i),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Dc=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var i;(null===(i=n.checkValidity)||void 0===i?void 0:i.call(n))&&o(this,Nc,"f").call(this,n,e,t)}))}))},Fc=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=Ul();n[e]=t,xl(qa,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},qc=function(e){var t;const n=null===(t=Rl(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const o=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),i=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);o&&i&&(i.replaceWith(o),o.appendChild(i))},zc=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${va}]), [data-type="button"]:not([${va}]`).forEach((n=>{n.onclick=()=>{o(this,Nc,"f").call(this,n,e,t)}})),o(this,sc,"m",Dc).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${ga}])`).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}))},Kc=function(e,t,n){var o;const[i,r]=(null===(o=window.name)||void 0===o?void 0:o.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===i&&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",Hc);var Jc=Object.freeze({__proto__:null,default:Hc});const Bc=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},Xc=(e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Bc(e,e.offsetLeft-o,e.offsetTop-i,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 Gc,Yc,Zc,Qc,ed,td,nd,od,id,rd,sd;const ad=document.createElement("template");ad.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 ld=r(z)(HTMLElement);class cd extends ld{constructor(){super(),Gc.add(this),Yc.set(this,new fl({messages:[]})),Zc.set(this,void 0),Qc.set(this,void 0),ed.set(this,void 0),td.set(this,{resize:o(this,Gc,"m",sd).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ad.content.cloneNode(!0)),i(this,Zc,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Qc,o(this,Zc,"f").querySelector(".content"),"f"),i(this,ed,o(this,Zc,"f").querySelector(".header"),"f"),o(this,Gc,"m",nd).call(this)}updateData(e){o(this,Yc,"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),Xc(o(this,Zc,"f"),o(this,ed,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,td,"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}})(o(this,Zc,"f")),o(this,Zc,"f").onresize=o(this,Gc,"m",rd).bind(this),o(this,Yc,"f").subscribe(o(this,Gc,"m",od).bind(this))}))}disconnectedCallback(){o(this,Yc,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,td,"f").resize)}}Yc=new WeakMap,Zc=new WeakMap,Qc=new WeakMap,ed=new WeakMap,td=new WeakMap,Gc=new WeakSet,nd=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'),o(this,Zc,"f").style.top="32px",o(this,Zc,"f").style.left=window.innerWidth-300-32+"px"},od=function(e){o(this,Gc,"m",id).call(this,e),o(this,Gc,"m",rd).call(this)},id=function(e){o(this,Qc,"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("")},rd=function(){o(this,Qc,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},sd=function(){const[e,t]=Bc(o(this,Zc,"f"),Number.parseInt(o(this,Zc,"f").style.left,10),Number.parseInt(o(this,Zc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Zc,"f").style.top=`${t}px`,o(this,Zc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",cd);var dd=Object.freeze({__proto__:null,default:cd});return Vs}();
7
7
  //# sourceMappingURL=index.js.map