@descope/outbound-applications-widget 0.7.22 → 0.7.23

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.7.22
3
+ * @descope/outbound-applications-widget v0.7.23
4
4
  */
5
5
  this["descope-outbound-applications-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e={})=>{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),(e=>"string"==typeof e?e:"boolean"==typeof e?String(e):(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},l=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}let f=class{constructor(e={},{forceUpdate:t=!1}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,c,"f")):e,n=Object.assign(Object.assign({},i(this,c,"f")),t);if(i(this,h,"f")||!p(i(this,c,"f"),n)){const e=i(this,c,"f");o(this,c,n,"f"),Object.freeze(i(this,c,"f")),setTimeout((()=>{Object.values(i(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,c,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,c,"f"))}subscribe(e){return o(this,u,i(this,u,"f")+1,"f"),i(this,d,"f")[i(this,u,"f")]=e,i(this,u,"f").toString()}unsubscribe(e){const t=!!i(this,d,"f")[e];return t&&delete i(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const g=e=>String(null!=e?e:"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");function v(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 m=["error","warn","info","debug"],b={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},w=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,b))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||b),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return m.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},s})),y="undefined"!=typeof localStorage,k="https://static.descope.com/pages",S="https://static2.descope.com/pages",I=y&&localStorage.getItem("base.content.url")||"",C=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,O=l((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),E=l((e=>{var t,n;const o=r(w,O)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&e.oldValue!==n.getAttribute(e.attributeName)&&o(e.attributeName)}))})).observe(n,{attributes:!0,attributeOldValue:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),A=e=>t=>{var n,o,s;const a=r(w,O,E)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},s};A.missingAttrValidator=C;const x=l((e=>{const t=r(A({"project-id":C}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),j=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),R="Trying the next fallback URL...",T=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const _=l((e=>{var t,n,s,a,l,c,d;const u=r(w,x,j)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=i(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;i(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await T(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${R}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${R}`)}}})(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=I||this.baseStaticUrl;if(r)return i(this,t,"m",c).call(this,e,r);i(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),i(this,a,"f").clear());const l=[];if(i(this,s,"f"))l.push(i(this,t,"m",c).call(this,e,i(this,s,"f"))),i(this,s,"f")===k&&l.push(i(this,t,"m",c).call(this,e,S));else{const n=this.baseUrl+"/pages";this.baseUrl&&!i(this,a,"f").has(n)&&l.push(i(this,t,"m",c).call(this,e,n)),i(this,a,"f").has(k)||l.push(i(this,t,"m",c).call(this,e,k)),l.push(i(this,t,"m",c).call(this,e,S))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=k}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},d})),$=l((e=>{var t,n;const o=r(A({"project-id":C}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),P=l((e=>{var t,n,s,a,l;const c=r(_,$,O)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,s,"f")||o(this,s,i(this,a,"f").call(this),"f"),i(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},l})),U=l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(O,w)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),"debug"===e&&i(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Ta})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),L=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],M=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()}`},W=(e,t,n)=>new Promise(((i,o)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),i(r)},r.src=t.toString(),document.body.appendChild(r)})),N=(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)}))}))},D=l((e=>{const t=r(w)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:r}=i,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await N(s,r),i}catch(e){t(i,!0)}else try{return await W(e,o,r),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${M(a)}`};return o&&(l.integrity=o),[...e,l]}),[]))([...i,this.baseCdnUrl,...L],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),q="base.ui.components.url",F=y&&localStorage.getItem(q),z=l((e=>{var t,n,s,a,l,c,d;const u=r(w,P,D)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return i(this,a,"f")||o(this,a,i(this,t,"m",c).call(this),"f"),i(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await i(this,t,"m",n).call(this),o=F?void 0:await i(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[F],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),V=l((e=>{var t,n,o;const s=r(O,E)(e);return o=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class J{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 H=l((e=>{const t=r(V)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new J(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),K="content-root",B="root",Y=l((e=>{const t=r(H)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${B}">\n <div id="${K}"></div>\n </div>\n `,this.injectStyle(`\n #${B}, #${K} {\n height: 100%;\n }\n #${B} {\n position: relative;\n height: fit-content;\n }\n #${B}:has(> #${K} > #ROOT[st-host-height="100%"]) {\n height: 100%;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(K),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(B)}}})),G="descope-modal";var X;let Z=class{constructor(e,t){X.set(this,void 0),this.nodeName="",o(this,X,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(i(this,X,"f"))}get ele(){var e,t;const n="function"==typeof i(this,X,"f")?i(this,X,"f").call(this):i(this,X,"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}};X=new WeakMap;let Q=class extends Z{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")}start(){var e,t;null===(t=null===(e=this.ele)||void 0===e?void 0:e.start)||void 0===t||t.call(e)}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 ee,te,ne,ie;let oe=class extends Z{constructor(...e){super(...e),ee.add(this),te.set(this,void 0),ne.set(this,void 0),this.nodeName="descope-modal",i(this,ee,"m",ie).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),i(this,ee,"m",ie).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,te,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,te,"f").content.cloneNode(!0)))}setContent(e){o(this,te,e,"f"),this.reset()}remove(){var e,t;null===(e=i(this,ne,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};te=new WeakMap,ne=new WeakMap,ee=new WeakSet,ie=function(){if(i(this,ne,"f"))return;const e=this.ele;e&&(o(this,ne,new MutationObserver((t=>{t.forEach(((n,i)=>{var o;const r="true"===n.oldValue,s=t[i+1]?t[i+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),i(this,ne,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let re=class extends Z{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()}},se=class extends Z{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 ae=l((e=>{var t,n;const o=r(O,Y,z)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends oe{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return i(this,t,"f")}createModal(e,n=i(this,t,"f")){const o=((e={})=>{const t=document.createElement(G);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(o),new n(o,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([G]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),le=l((e=>class extends(ae(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,n;await super.open(),null===(n=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===n||n.call(t)}})}})),ce="descope-notification";l((e=>{var t,n;const o=r(O,Y,z)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends re{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ce);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([ce])}},t=new WeakMap,n}));const de="theme",ue=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+ue(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),""),he=e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)};function pe(e,t){const n=Object.assign({},e);for(const[e,i]of Object.entries(t||{}))if(null!=i)if("object"==typeof i){if(0===Object.keys(i).length)continue;n[e]=pe(n[e]||{},i)}else n[e]="string"==typeof i?(n[e]||"")+i:i;return n}const fe=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",ge=l((e=>{const t=r(A({tenant:fe}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),ve=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',me=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,b,w,y,k,S,I,C,x,j;const R=r(A({theme:ve}),ge,_,O,z,P,Y,E,H)(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),I.set(this,(()=>{i(this,t,"m",C).call(this),i(this,x,"f").call(this,"os"===this.getAttribute("theme"))})),x.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",C).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")||de}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,I,"f").call(this),await Promise.all([i(this,t,"m",p).call(this),i(this,t,"m",v).call(this),i(this,t,"m",b).call(this)]),i(this,t,"m",m).call(this),this.observeAttributes(["theme"],i(this,I,"f")),this.observeAttributes(["theme-override"],(()=>i(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{o(this,d,null,"f"),i(this,t,"m",v).call(this),i(this,t,"m",b).call(this),i(this,t,"m",k).call(this)})),this.observeAttributes(["style-id"],(()=>{o(this,c,null,"f"),i(this,t,"m",y).call(this),i(this,t,"m",p).call(this),i(this,t,"m",b).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,I=new WeakMap,x=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,r,s,a;const l=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${ue({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(q))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(q),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 i(this,c,"f")||(o(this,c,i(this,t,"m",u).call(this),"f"),i(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,c,"f")},p=async function(){var e,r;const s=await i(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)||"");i(this,n,"f")?i(this,n,"f").replaceSync(a):o(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.warn("No tenant style exists, using project default theme.")}},g=function(){return i(this,d,"f")||o(this,d,i(this,t,"m",f).call(this),"f"),i(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=i(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await i(this,t,"a",g);if(!l)return void(null===(n=i(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)||"");i(this,s,"f")?i(this,s,"f").replaceSync(c):o(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=i(this,a,"f"))||void 0===e||e.replaceSync(""));const n=i(this,t,"m",l).call(this);i(this,a,"f")?i(this,a,"f").replaceSync(n):o(this,a,this.injectStyle(n),"f")},b=async function(){var e,n,o,r;const s=await i(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await i(this,t,"a",g);a.componentsThemeManager.themes={light:pe((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:pe((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.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||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await i(this,t,"m",w).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),he(e.url))})):this.logger.debug("No fonts to load"),i(this,t,"m",k).call(this)},k=async function(){var e;if(!this.tenantId)return;const n=await i(this,t,"a",g),o=null===(e=null==n?void 0:n[this.theme])||void 0===e?void 0:e.fonts;Object.values(o||{}).forEach((e=>{(null==e?void 0:e.url)&&(this.logger.debug(`Loading tenant font from URL "${e.url}"`),he(e.url))}))},S=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)},C=function(){i(this,t,"m",y).call(this),i(this,t,"m",S).call(this)},j}));var be=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),we=()=>Math.random().toString(36).substring(7).split("").join("."),ye={INIT:`@@redux/INIT${we()}`,REPLACE:`@@redux/REPLACE${we()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${we()}`};function ke(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 Se(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function Ie(e){let t=typeof e;return t=Se(e),t}function Ce(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Ie(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${Ie(n)}'`);return n(Ce)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Ie(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return 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(!ke(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Ie(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${Ie(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=i(o,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:ye.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${Ie(e)}`);i=e,h({type:ye.REPLACE})},[be]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${Ie(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[be](){return this}}}}}function Oe(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Ee(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&Oe(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const i=Object.keys(n);let o,r;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:ye.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:ye.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 '${ye.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const i=function(e,t,n,i){const o=Object.keys(t),r=n&&n.type===ye.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!ke(e))return`The ${r} has unexpected type of "${Ie(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!i[e]));return s.forEach((e=>{i[e]=!0})),n&&n.type===ye.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);i&&Oe(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||i.length!==Object.keys(e).length,s?a:e}}function Ae(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function xe(e){return ke(e)&&"type"in e&&"string"==typeof e.type}var je=Symbol.for("immer-nothing"),Re=Symbol.for("immer-draftable"),Te=Symbol.for("immer-state"),_e=[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 $e(e,...t){{const n=_e[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var Pe=Object.getPrototypeOf;function Ue(e){return!!e&&!!e[Te]}function Le(e){return!!e&&(We(e)||Array.isArray(e)||!!e[Re]||!!e.constructor?.[Re]||ze(e)||Ve(e))}var Me=Object.prototype.constructor.toString();function We(e){if(!e||"object"!=typeof e)return!1;const t=Pe(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)===Me}function Ne(e,t){0===De(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function De(e){const t=e[Te];return t?t.type_:Array.isArray(e)?1:ze(e)?2:Ve(e)?3:0}function qe(e,t){return 2===De(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Fe(e,t,n){const i=De(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function ze(e){return e instanceof Map}function Ve(e){return e instanceof Set}function Je(e){return e.copy_||e.base_}function He(e,t){if(ze(e))return new Map(e);if(Ve(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&We(e)){if(!Pe(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Te];let i=Reflect.ownKeys(n);for(let t=0;t<i.length;t++){const o=i[t],r=n[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(Pe(e),n)}function Ke(e,t=!1){return Ye(e)||Ue(e)||!Le(e)||(De(e)>1&&(e.set=e.add=e.clear=e.delete=Be),Object.freeze(e),t&&Ne(e,((e,t)=>Ke(t,!0)))),e}function Be(){$e(2)}function Ye(e){return Object.isFrozen(e)}var Ge,Xe={};function Ze(e){const t=Xe[e];return t||$e(0,e),t}function Qe(){return Ge}function et(e,t){t&&(Ze("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function tt(e){nt(e),e.drafts_.forEach(ot),e.drafts_=null}function nt(e){e===Ge&&(Ge=e.parent_)}function it(e){return Ge={drafts_:[],parent_:Ge,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ot(e){const t=e[Te];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function rt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Te].modified_&&(tt(t),$e(4)),Le(e)&&(e=st(t,e),t.parent_||lt(t,e)),t.patches_&&Ze("Patches").generateReplacementPatches_(n[Te].base_,e,t.patches_,t.inversePatches_)):e=st(t,n,[]),tt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==je?e:void 0}function st(e,t,n){if(Ye(t))return t;const i=t[Te];if(!i)return Ne(t,((o,r)=>at(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return lt(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const t=i.copy_;let o=t,r=!1;3===i.type_&&(o=new Set(t),t.clear(),r=!0),Ne(o,((o,s)=>at(e,i,t,o,s,n,r))),lt(e,t,!1),n&&e.patches_&&Ze("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function at(e,t,n,i,o,r,s){if(o===n&&$e(5),Ue(o)){const s=st(e,o,r&&t&&3!==t.type_&&!qe(t.assigned_,i)?r.concat(i):void 0);if(Fe(n,i,s),!Ue(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(Le(o)&&!Ye(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;st(e,o),t&&t.scope_.parent_||lt(e,o)}}function lt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ke(t,n)}var ct={get(e,t){if(t===Te)return e;const n=Je(e);if(!qe(n,t))return function(e,t,n){const i=ht(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}(e,n,t);const i=n[t];return e.finalized_||!Le(i)?i:i===ut(e.base_,t)?(ft(e),e.copy_[t]=gt(i,e)):i},has:(e,t)=>t in Je(e),ownKeys:e=>Reflect.ownKeys(Je(e)),set(e,t,n){const i=ht(Je(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=ut(Je(e),t),o=i?.[Te];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||qe(e.base_,t)))return!0;ft(e),pt(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!==ut(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,ft(e),pt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Je(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){$e(11)},getPrototypeOf:e=>Pe(e.base_),setPrototypeOf(){$e(12)}},dt={};function ut(e,t){const n=e[Te];return(n?Je(n):e)[t]}function ht(e,t){if(!(t in e))return;let n=Pe(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Pe(n)}}function pt(e){e.modified_||(e.modified_=!0,e.parent_&&pt(e.parent_))}function ft(e){e.copy_||(e.copy_=He(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ne(ct,((e,t)=>{dt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),dt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&$e(13),dt.set.call(this,e,t,void 0)},dt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&$e(14),ct.set.call(this,e[0],t,n,e[0])};function gt(e,t){const n=ze(e)?Ze("MapSet").proxyMap_(e,t):Ve(e)?Ze("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Qe(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=ct;n&&(o=[i],r=dt);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:Qe()).drafts_.push(n),n}function vt(e){return Ue(e)||$e(10,e),mt(e)}function mt(e){if(!Le(e)||Ye(e))return e;const t=e[Te];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=He(e,t.scope_.immer_.useStrictShallowCopy_)}else n=He(e,!0);return Ne(n,((e,t)=>{Fe(n,e,mt(t))})),t&&(t.finalized_=!1),n}var bt=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const i=this;return function(e=n,...o){return i.produce(e,(e=>t.call(this,e,...o)))}}let i;if("function"!=typeof t&&$e(6),void 0!==n&&"function"!=typeof n&&$e(7),Le(e)){const o=it(this),r=gt(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?tt(o):nt(o)}return et(o,n),rt(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===je&&(i=void 0),this.autoFreeze_&&Ke(i,!0),n){const t=[],o=[];Ze("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}$e(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,i;const o=this.produce(e,t,((e,t)=>{n=e,i=t}));return[o,n,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Le(e)||$e(8),Ue(e)&&(e=vt(e));const t=it(this),n=gt(e,void 0);return n[Te].isManual_=!0,nt(t),n}finishDraft(e,t){const n=e&&e[Te];n&&n.isManual_||$e(9);const{scope_:i}=n;return et(i,t),rt(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const i=Ze("Patches").applyPatches_;return Ue(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},wt=bt.produce;bt.produceWithPatches.bind(bt),bt.setAutoFreeze.bind(bt),bt.setUseStrictShallowCopy.bind(bt),bt.applyPatches.bind(bt),bt.createDraft.bind(bt),bt.finishDraft.bind(bt);var yt=(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})}}},kt=(e,t,n)=>{const{memoize:i,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=i((()=>({})),...o);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},St={inputStabilityCheck:"once",identityFunctionCheck:"once"};var It=e=>Array.isArray(e)?e:[e];function Ct(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 Ot(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var Et="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},At=0,xt=1;function jt(){return{s:At,v:void 0,o:null,p:null}}function Rt(e,t={}){let n=jt();const{resultEqualityCheck:i}=t;let o,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const i=e.get(n);void 0===i?(t=jt(),e.set(n,t)):t=i}else{let e=t.p;null===e&&(t.p=e=new Map);const i=e.get(n);void 0===i?(t=jt(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===xt)l=t.v;else if(l=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,l)&&(l=e,0!==r&&r--);o="object"==typeof l&&null!==l||"function"==typeof l?new Et(l):l}return a.s=xt,a.v=l,l}return s.clearCache=()=>{n=jt(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Tt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=Rt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=It(c),f=It(u),g=Ct(e),v=l((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){o++;const e=Ot(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...St,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:yt},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:kt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=Ot(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:l,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var _t=Tt(Rt),$t=Object.assign(((e,t=_t)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e),i=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,i)=>(e[n[i]]=t,e)),{})));return i}),{withTypes:()=>$t});function Pt(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var Ut=Pt(),Lt=Pt;((...e)=>{const t=Tt(...e)})(Rt);var Mt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ae:Ae.apply(null,arguments)},Wt=e=>e&&"function"==typeof e.match;function Nt(e,t){function n(...n){if(t){let i=t(...n);if(!i)throw new Error("prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>xe(t)&&t.type===e,n}function Dt(e){return"function"==typeof e&&"type"in e&&Wt(e)}function qt(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Ft=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function zt(e){return Le(e)?wt(e,(()=>{})):e}function Vt(e,t,n){if(e.has(t)){let i=e.get(t);return n.update&&(i=n.update(i,t,e),e.set(t,i)),i}if(!n.insert)throw new Error("No insert provided for key not already in map");const i=n.insert(t,e);return e.set(t,i),i}function Jt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Ht(e,t,n){const i=Kt(e,t,n);return{detectMutations:()=>Bt(e,t,i,n)}}function Kt(e,t=[],n,i="",o=new Set){const r={value:n};if(!e(n)&&!o.has(n)){o.add(n),r.children={};for(const o in n){const s=i?i+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=Kt(e,t,n[o],s))}}return r}function Bt(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in i)l[e]=!0;const c=t.length>0;for(let o in l){const s=r?r+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Bt(e,t,n.children[o],i[o],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Yt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||ke(e)}function Gt(e,t="",n=Yt,i,o=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),l=o.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Gt(c,a,n,i,o,r),s))return s}return r&&Xt(e)&&r.add(e),!1}function Xt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Xt(t))return!1;return!0}function Zt(e){return"boolean"==typeof e}var Qt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Ft;if(t&&(Zt(t)?r.push(Ut):r.push(Lt(t.extraArgument))),n){let e={};Zt(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,i,o){return JSON.stringify(e,n(t,o),i)},n=function(e,t){let n=[],i=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?i.splice(s,1/0,o):i.push(o),~n.indexOf(r)&&(r=t.call(this,o,r))}else n.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:i=Jt,ignoredPaths:o,warnAfter:r=32}=e;const s=Ht.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>l=>{const c=qt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(i){let e={};Zt(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=Yt,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!xe(u))return c(u);const h=c(u),p=qt(s,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Gt(u,"",t,n,o,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const i=Gt(e.getState(),"",t,n,r,d);if(i){const{keyPath:e,value:t}=i;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};Zt(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=Dt}=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},en=e=>t=>{setTimeout(t,e)},tn="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:en(10),nn=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Ft(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?tn:"callback"===e.type?e.queueNotification:en(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,l(c))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function on(e){const t=Qt(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!ke(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=Ee(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(l=i(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=Ae;o&&(c=Mt({trace:!0,..."object"==typeof o&&o}));const d=function(...e){return t=>(n,i)=>{const o=t(n,i);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Ae(...a)(o.dispatch),{...o,dispatch:r}}}(...l),u=nn(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 Ce(a,r,c(...h))}function rn(e){const t={},n=[];let i;const o={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if(i)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(i)throw new Error("`builder.addDefaultCase` can only be called once");return i=e,o}};return e(o),[t,n,i]}function sn(...e){return t=>e.some((e=>((e,t)=>Wt(e)?e.match(t):e(t))(e,t)))}var an=["name","message","stack","code"],ln=class{constructor(e,t){this.payload=e,this.meta=t}_type},cn=class{constructor(e,t){this.payload=e,this.meta=t}_type},dn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of an)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},un=(()=>{function e(e,t,n){const i=Nt(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Nt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Nt(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||dn)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new ln(e,t),fulfillWithValue:(e,t)=>new cn(e,t)})).then((t=>{if(t instanceof ln)throw t;return t instanceof cn?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof ln?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(hn)})}}),{pending:o,rejected:r,fulfilled:i,settled:sn(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function hn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var pn=Symbol.for("rtk-slice-createasyncthunk");function fn(e,t){return`${e}/${t}`}function gn(e,t,n,i){function o(o,...r){let s=n.call(e,o);if(void 0===s){if(!i)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return o.unwrapped=t,o}var vn=function({creators:e}={}){const t=e?.asyncThunk?.[pn];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?rn(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[i,o,r]=rn(t);if(function(e){return"function"==typeof e}(e))n=()=>zt(e());else{const t=zt(e);n=()=>t}function s(e=n(),t){let s=[i[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(Ue(e)){const i=n(e,t);return void 0===i?e:i}if(Le(e))return wt(e,(e=>n(e,t)));{const i=n(e,t);if(void 0===i){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return i}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);i&&e.addDefaultCase(i)}))}r.forEach((i=>{const r=o[i],s={reducerName:i,type:fn(n,i),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},i,o){let r,s;if("reducer"in i){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(i))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=i.reducer,s=i.prepare}else r=i;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Nt(e,s):Nt(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);l&&i.addCase(u.rejected,l);c&&i.addMatcher(u.settled,c);i.exposeCaseReducer(t,{fulfilled:s||mn,pending:a||mn,rejected:l||mn,settled:c||mn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=Vt(d,this,{insert:()=>new WeakMap});return Vt(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=gn(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const i=t??this.reducerPath;return e.inject({reducerPath:i,reducer:this.reducer},n),{...this,reducerPath:i}}};return h}}();function mn(){}var bn="listenerMiddleware";Nt(`${bn}/add`),Nt(`${bn}/removeAll`),Nt(`${bn}/remove`);const wn=e=>l((t=>{const n=vn(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(w)(t)){constructor(...e){super(...e);const t=on({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const i=await t.dispatch(e(...n));try{hn(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(w(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 yn=l((e=>{const t=r(A({"widget-id":C}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),kn=l((e=>{const t=r(P,yn)(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]}async getHostedPageBaseUrl(){var e;const t=await this.config;return null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.hostedPageBaseUrl}}})),Sn=l((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=v(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),In=e=>l((t=>{var n,o,s;const a=r(_,yn,kn,Sn)(t);return s=class extends a{constructor(){super(...arguments),n.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const r=await i(this,n,"m",o).call(this,t);if(void 0!==r)return r;const s=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==s?void 0:s.body}},n=new WeakSet,o=async function(t){var n;const i=await this.getWidgetConfig(),o=this.firstAvailableLocale(null!==(n=null==i?void 0:i.targetLocales)&&void 0!==n?n:[]);if(!o)return;const r=".html",s=t.endsWith(r)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${o}${r}`,"text");return null==t?void 0:t.body}catch(e){return}},s})),Cn=l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),On=y&&localStorage.getItem("base.debug.logs.url"),En=l((e=>{const t=r(A({"flow-id":C}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function An(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const i=Math.floor(n/60);return i<24?`${i} hours`:`${Math.floor(i/24)} days`}const xn=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g;const v=r(D,w,O,P,x,En)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),s.set(this,!1),a.set(this,null),f.set(this,null)}get telemetryManager(){return i(this,n,"f")}updateTelemetryContext(e){if(i(this,n,"f"))try{i(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";o(this,f,i(this,t,"m",h).call(this).then((e=>i(this,t,"m",l).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=i(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",d).call(this)}},n=new WeakMap,s=new WeakMap,a=new WeakMap,f=new WeakMap,t=new WeakSet,l=async function(e,r){if(null==e?void 0:e.enabled)if(i(this,s,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const a=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",a,"dist/index.js",[On]);const l=window.DescopeDebugLogs;if(!l)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(o(this,n,new l({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:r.projectId,flowId:r.flowId,version:r.sdkVersion||"1.0.0"},this.logger),"f"),!i(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void o(this,n,null,"f");o(this,s,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&i(this,t,"m",c).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),o(this,s,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},c=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void i(this,t,"m",d).call(this);const r=864e5,s=Math.min(n,r);n>r&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${An(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${An(s)})`),o(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),i(this,t,"m",d).call(this)}),s),"f")},d=function(){if(i(this,a,"f")&&(clearTimeout(i(this,a,"f")),o(this,a,null,"f")),i(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),i(this,n,"f").shutdown(),o(this,n,null,"f"),o(this,s,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},u=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},h=async function(){var e;const n=await this.config,o=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let r;try{const e=Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);r={enabled:"true"===(process.env.DESCOPE_TELEMETRY_ENABLED||"").toLowerCase(),rumConfig:Object.assign({applicationId:process.env.DESCOPE_TELEMETRY_APPLICATION_ID||"",identityPoolId:process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID||"",region:process.env.DESCOPE_TELEMETRY_REGION||"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})}}catch(e){r={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const s=Object.assign(Object.assign(Object.assign({},r),o),{rumConfig:Object.assign(Object.assign({},r.rumConfig),null==o?void 0:o.rumConfig),capture:i(this,t,"m",p).call(this,null==o?void 0:o.capture)});return s.enabled&&!i(this,t,"m",u).call(this,s.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),s.enabled=!1),o||(s.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),s},p=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},g})),jn=l((e=>{var n,o,r;return r=class extends(me(e)){constructor(){super(...arguments),n.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:r,client:s,form:l}=e,c=t(e,["flowId","client","form"]);return a(Object.assign({projectId:this.getAttribute("project-id"),flowId:r,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:i(this,n,"m",o).call(this,l),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,o=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r})),Rn=/(["\\])/g;function Tn(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(Rn,"\\$1")}"]`));var n}function _n(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{Tn(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}const $n=l((e=>{var t,n,s,a,l,c;const d=r(w,Y)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,{})}async init(){var e,r;if("true"===this.getAttribute("mock"))return o(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=i(this,t,"m",a).call(this);o(this,n,i(this,t,"m",l).call(this,s),"f"),await(null===(r=super.init)||void 0===r?void 0:r.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),o(this,s,null!==(t=await i(this,n,"f"))&&void 0!==t?t:{},"f"),_n(this.contentRootElement,i(this,s,"f"))}async reevaluateComponentsState(){const e=i(this,t,"m",a).call(this);var n,r;n=this.contentRootElement,r=i(this,s,"f"),n&&r&&Object.entries(r).forEach((([e,t])=>{Tn(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),o(this,s,await i(this,t,"m",l).call(this,e),"f"),_n(this.contentRootElement,i(this,s,"f"))}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},l=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const i=await n.json();return null!==(t=null==i?void 0:i.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},c}));function Pn(e){return new URLSearchParams(window.location.search).get(e)}const Un=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Ln=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}}),Mn=un("outboundApps/load",((e,{extra:{api:t}})=>t.outboundApps.getAllOutboundApps())),Wn=Un(Mn)({onFulfilled:(e,t)=>{var n;e.outboundAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},Ln((e=>e.outboundAppsList))),Nn={action:Mn,reducer:Wn},Dn=un("outboundApps/getConnectedOutboundApps",((e,{extra:{api:t}})=>t.outboundApps.getConnectedOutboundApps(e))),qn=Un(Dn)({onFulfilled:(e,t)=>{var n;e.connectedOutboundAppsIds.data=null===(n=t.payload)||void 0===n?void 0:n.appIds}},Ln((e=>e.connectedOutboundAppsIds))),Fn={action:Dn,reducer:qn},zn={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}};class Vn extends Error{}function Jn(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 Hn(e,t){if("string"!=typeof e)throw new Vn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new Vn(`Invalid token specified: missing part #${n+1}`);let o;try{o=Jn(i)}catch(e){throw new Vn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new Vn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Vn.prototype.name="InvalidTokenError";var Kn={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",phone:"/v1/auth/enchantedlink/update/phone"},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"},sso:{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"},emailVerification:{start:"/v1/auth/emailverification/start"},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",event:"/v1/flow/event"}};const Bn="<region>",Yn=`https://api.${Bn}descope.com`,Gn=6e5,Xn=()=>{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")}},Zn=[503,520,521,522,524,530],Qn=[100,5e3,5e3],ei=e=>new Promise((t=>setTimeout(t,e))),ti=e=>async function(...t){let n=await e(...t);const i=!!(null==(o=t[1])?void 0:o.disableRetry);var o;let r=0;for(;!i&&Zn.includes(n.status)&&r<Qn.length;)await ei(Qn[r]),n=await e(...t),r++;r>0&&(n.retries=r);const s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n};let ni;const ii=()=>{if(ni)return ni;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 ni=`${t}-${n}`,ni};var oi;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(oi||(oi={}));const ri=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(Bn,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},si=(...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)),{})),ai={"Content-Type":"application/json"},li=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},ci=(e,t)=>{const n={"x-descope-sdk-session-id":ii(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.78.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},di=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var ui=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||Yn,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 function(...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=>Xn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await ti(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return Xn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:ti(n)})(o,a),d=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g,keepalive:v,disableRetry:m}=a,b=(e=>void 0===e?void 0:JSON.stringify(e))(u),w=Object.assign(Object.assign({headers:si(li(t,g),ci(t,i),(null==n?void 0:n.baseHeaders)||{},di(b)?ai:{},h),method:f,body:b},v?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(w.credentials=s||"include");const y=await c(ri({path:d,baseUrl:l,queryParams:p,projectId:t}),w);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==y?void 0:y.clone()),null==r?void 0:r.transformResponse){const e=await y.json(),t=(k=(null===(o=y.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;i();)if(","===e.charAt(n)){for(s=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(k).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.create(null),{json:()=>Promise.resolve(e),cookies:t}),i=new Proxy(y,{get:(e,t)=>{if(t in n)return n[t];const i=e[t];return"function"==typeof i?i.bind(e):i},set:(e,t,i)=>(n[t]=i,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>i,r.transformResponse(i)}var k;return y};return{get:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:oi.get,token:i,keepalive:o,disableRetry:r}),post:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:oi.post,token:o,keepalive:r,disableRetry:s}),patch:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:oi.patch,token:o,keepalive:r,disableRetry:s}),put:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:oi.put,token:o,keepalive:r,disableRetry:s}),delete:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:oi.delete,token:i,keepalive:o,disableRetry:r}),hooks:r,buildUrl:(e,n)=>ri({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},hi=429;function pi(e,t,n){var i;let o=fi(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o.dct)===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function fi(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Hn(e)}function gi(e){const{exp:t}=fi(e);return(new Date).getTime()/1e3>t}function vi(e){let t=fi(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function mi(e,t){return pi(e,t,"permissions")}function bi(e,t){return pi(e,t,"roles")}const wi=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function yi(e,t){var n,i;const o=await e,r={code:o.status,ok:o.ok,response:o},s=await o.clone().json();if(o.ok)r.data=s;else{r.error=s,o.status===hi&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0});const e=null===(i=o.headers)||void 0===i?void 0:i.get("cf-ray");e&&r.error&&Object.assign(r.error,{traceId:e})}return r}function ki(e){var t;return(null===(t=fi(e))||void 0===t?void 0:t.dct)||""}const Si=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Ii=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},Ci=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Oi=e=>t=>e.test(t),Ei=Oi(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ai=Oi(/^\+[1-9]{1}[0-9]{3,14}$/),xi=Si(Ei,'"{val}" is not a valid email'),ji=Si(Ai,'"{val}" is not a valid phone number'),Ri=Si((e=>e.length>=1),"Minimum length is 1");const Ti=Si((e=>"string"==typeof e),"Input is not a string"),_i=Si((e=>Array.isArray(e)),"Input is not an array"),$i=Si((e=>"boolean"==typeof e),"Input is not a boolean"),Pi=Si((e=>void 0===e),"Input is defined"),Ui=Ii([Ti(),Pi()],"Input is not a string or undefined"),Li=Ii([_i(),$i()],"Input is not an array or boolean"),Mi=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Ci(...e).validate(n[t]))),t(...n)),Wi=e=>[Ti(`"${e}" must be a string`)],Ni=e=>[Ui(`"${e}" must be string or undefined`)],Di=e=>[Ti(`"${e}" must be a string`),Ri(`"${e}" must not be empty`)],qi=e=>[Ti(`"${e}" must be a string`),xi()],Fi=e=>[Ti(`"${e}" must be a string`),ji()],zi=Mi(Di("accessKey")),Vi=e=>({exchange:zi(((t,n)=>yi(e.post(Kn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Ji=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),Hi=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Gn,Gn)});var Ki,Bi;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Ki||(Ki={})),function(e){e.email="email"}(Bi||(Bi={}));const Yi=Object.assign(Object.assign({},Ki),Bi);var Gi;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Gi||(Gi={}));const Xi=Di("loginId"),Zi=Mi(Di("token")),Qi=Mi(Xi),eo=Mi(Di("pendingRef")),to=Mi(Xi,Fi("phone")),no=Mi(Xi,qi("email")),io=e=>{const n=n=>(i,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return yi(e.post(wi(Kn.enchantedLink.signIn,n),{loginId:i,URI:o,loginOptions:l,providerId:a},{token:s}))},i=n=>(i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return yi(e.post(wi(Kn.enchantedLink.signUpOrIn,n),{loginId:i,URI:o,loginOptions:a,providerId:s}))},o=n=>(i,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return yi(e.post(wi(Kn.enchantedLink.signUp,n),{loginId:i,URI:o,user:r,loginOptions:l,providerId:a}))};return{verify:Zi((t=>yi(e.post(Kn.enchantedLink.verify,{token:t})))),signIn:Qi(n(Yi.email)),signInWithPhone:Qi(n(Ki.sms)),signUpOrIn:Qi(i(Yi.email)),signUpOrInWithPhone:Qi(i(Ki.sms)),signUp:Qi(o(Yi.email)),signUpWithPhone:Qi(o(Ki.sms)),waitForSession:eo(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Hi(n);let s;const a=setInterval((async()=>{const n=await e.post(Kn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(yi(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:no(((t,n,i,o,r)=>yi(e.post(Kn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:{sms:to(((t,n,i,o,r)=>yi(e.post(wi(Kn.enchantedLink.update.phone,Ki.sms),Object.assign({loginId:t,phone:n,URI:i},r),{token:o}))))}}}},oo=Mi(Di("flowId")),ro=Mi(Di("executionId"),Di("stepId"),Di("interactionId")),so=Mi(Di("executionId")),ao=e=>({start:oo(((t,n,i,o,r,s,a,l=!1)=>yi(e.post(Kn.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:ro(((t,n,i,o,r,s,a=!1,l)=>yi(e.post(Kn.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a,options:l})))),event:so(((t,n,i)=>yi(e.post(Kn.flow.event,{executionId:t,events:n},{keepalive:i,disableRetry:!0}))))}),lo=Di("loginId"),co=Mi(Di("token")),uo=Mi(lo);Mi(Di("pendingRef"));const ho=Mi(lo,Fi("phone")),po=Mi(lo,qi("email")),fo=Object.keys(Yi).filter((e=>e!==Ki.voice&&e!==Ki.im)),go=e=>({verify:co((t=>yi(e.post(Kn.magicLink.verify,{token:t})))),signIn:fo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:uo(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return yi(e.post(wi(Kn.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:fo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:uo(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return yi(e.post(wi(Kn.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:fo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:uo(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return yi(e.post(wi(Kn.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:po(((t,n,i,o,r)=>yi(e.post(Kn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(Ki).filter((e=>e!==Ki.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ho(((t,i,o,r,s)=>yi(e.post(wi(Kn.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var vo;!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"}(vo||(vo={}));const mo=Mi(Di("code")),bo=e=>({start:Object.assign(((t,n,i,o,r)=>yi(e.post(Kn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(vo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>yi(e.post(Kn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:mo((t=>yi(e.post(Kn.oauth.exchange,{code:t})))),startNative:(t,n,i)=>yi(e.post(Kn.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>yi(e.post(Kn.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>yi(e.get(Kn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>yi(e.post(Kn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>yi(e.post(Kn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),wo=Di("appId"),yo=Mi(wo),ko=e=>({connect:yo(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,yi(e.post(Kn.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),So=Di("loginId"),Io=Mi(So,Di("code")),Co=Mi(So),Oo=Mi(So,Fi("phone")),Eo=Mi(So,qi("email")),Ao=e=>({verify:Object.keys(Yi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Io(((t,i)=>yi(e.post(wi(Kn.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Yi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Co(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return yi(e.post(wi(Kn.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Yi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Co(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return yi(e.post(wi(Kn.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Yi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Co(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return yi(e.post(wi(Kn.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Eo(((t,n,i,o)=>yi(e.post(Kn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(Ki).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Oo(((t,i,o,r)=>yi(e.post(wi(Kn.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),xo=Mi(Di("tenant")),jo=Mi(Di("code")),Ro=e=>({start:xo(((t,n,i,o,r,s,a,l)=>yi(e.post(Kn.sso.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},o&&{token:o}))))),exchange:jo((t=>yi(e.post(Kn.sso.exchange,{code:t}))))}),To=Di("loginId"),_o=Mi(To,Di("code")),$o=Mi(To),Po=Mi(To),Uo=e=>({signUp:$o(((t,n)=>yi(e.post(Kn.totp.signUp,{loginId:t,user:n})))),verify:_o(((t,n,i,o)=>yi(e.post(Kn.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:Po(((t,n)=>yi(e.post(Kn.totp.update,{loginId:t},{token:n}))))}),Lo=e=>({start:()=>yi(e.post(Kn.emailVerification.start,{}))}),Mo=Di("loginId"),Wo=Di("newPassword"),No=Mi(Mo,Di("password")),Do=Mi(Mo),qo=Mi(Mo,Wo),Fo=Mi(Mo,Di("oldPassword"),Wo),zo=e=>({signUp:No(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return yi(e.post(Kn.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:No(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return yi(e.post(Kn.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:Do(((t,n,i)=>yi(e.post(Kn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:qo(((t,n,i)=>yi(e.post(Kn.password.update,{loginId:t,newPassword:n},{token:i})))),replace:Fo(((t,n,i)=>yi(e.post(Kn.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>yi(e.get(Kn.password.policy))}),Vo=Wi("loginId"),Jo=Di("loginId"),Ho=Wi("origin"),Ko=Mi(Jo,Ho,Di("name")),Bo=Mi(Jo,Ho),Yo=Mi(Vo,Ho),Go=Mi(Jo,Ho,Ni("token")),Xo=Mi(Di("transactionId"),Di("response")),Zo=e=>({signUp:{start:Ko(((t,n,i,o,r)=>yi(e.post(Kn.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:Xo(((t,n)=>yi(e.post(Kn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Yo(((t,n,i,o,r)=>yi(e.post(Kn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:Xo(((t,n)=>yi(e.post(Kn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Bo(((t,n,i,o)=>yi(e.post(Kn.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:Go(((t,n,i,o,r)=>yi(e.post(Kn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:r},{token:i})))),finish:Xo(((t,n)=>yi(e.post(Kn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Qo=Wi("loginId"),er=Mi(Qo),tr=Mi(Di("pendingRef")),nr=e=>({signUpOrIn:er(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return yi(e.post(Kn.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:er(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return yi(e.post(Kn.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:er(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return yi(e.post(Kn.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:tr(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Hi(n);let s;const a=setInterval((async()=>{const n=await e.post(Kn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(yi(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),ir=Mi(Di("token")),or=Mi(Ni("token"));var rr,sr=Mi([(rr=Di("projectId"),Si(((e,t)=>n=>Ci(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",rr))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=ui({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:Vi(l),otp:Ao(l),magicLink:go(l),enchantedLink:io(l),oauth:bo(l),outbound:ko(l),sso:Ro(l),saml:Ro(l),totp:Uo(l),notp:nr(l),webauthn:Zo(l),password:zo(l),flow:ao(l),emailVerification:Lo(l),refresh:or(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?Kn.tryRefresh:Kn.refresh;return yi(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:Mi([Ti("tenantId")],[Ui('"token" must be string or undefined')])(((e,t)=>yi(l.post(Kn.selectTenant,{tenant:e},{token:t})))),logout:or((e=>yi(l.post(Kn.logout,{},{token:e})))),logoutAll:or((e=>yi(l.post(Kn.logoutAll,{},{token:e})))),me:or((e=>yi(l.get(Kn.me,{token:e})))),myTenants:Mi([Li('"tenants" must a string array or a boolean')],[Ui('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,yi(l.post(Kn.myTenants,n,{token:t}))})),history:or((e=>yi(l.get(Kn.history,{token:e})))),isJwtExpired:ir(gi),getTenants:ir(vi),getJwtPermissions:ir(mi),getJwtRoles:ir(bi),getCurrentTenant:ir(ki),httpClient:l};var l})),ar=Object.assign(sr,{DeliveryMethods:Yi});
6
- /*! js-cookie v3.0.8 | MIT */function lr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)"__proto__"!==i&&(e[i]=n[i])}return e}var cr=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=lr({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in i||(i[a]=t.read(s,a)),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",lr({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,lr({},this.attributes,t))},withConverter:function(t){return e(lr({},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 dr={default:"endpoint"},ur="Blocked by CSP",hr="The endpoint parameter is not a valid URL",pr="Failed to load the JS script of the agent",fr="9319";function gr(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===ur||s===hr)n.exclude(),r=0;else if(s===fr)n.exclude();else if(s===pr){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var vr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",mr=vr;function br(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:vr,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return gr(e,wr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===fr?new Error(pr):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function wr(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(hr);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(pr))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(ur)})).then(yr)}function yr(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(fr);return n}const kr="3.2.0",Sr="undefined"!=typeof window,Ir=Math.pow(2,31)-1,Cr=2e4,Or=`https://descopecdn.com/npm/oidc-client-ts@${kr}/dist/browser/oidc-client-ts.min.js`,Er=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${kr}/dist/browser/oidc-client-ts.min.js`,Ar=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let xr;const jr=e=>{try{return Hn(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:jr(n)},Tr=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?jr(i):void 0)},_r=e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||Tr(e),cookieExpiration:e.cookieExpiration||Rr(e)},s)},$r=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Pr=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 _r(n)},Ur=()=>Sr&&!!window.descopeBridge,Lr=(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 Ar.includes(n)},Mr=void 0!==xr||Sr&&void 0!==window.localStorage,Wr=(e,t)=>{var n,i;return null===(i=null===(n=xr||Sr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},Nr=e=>{var t,n;return null===(n=null===(t=xr||Sr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Dr=e=>{var t,n;return null===(n=null===(t=xr||Sr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},qr=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==xr?void 0:xr.key)||void 0===t?void 0:t.call(xr,e))&&void 0!==n?n:Sr&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},Fr=e=>{var t,n;return Sr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},zr=e=>{var t,n;try{Sr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},Vr=(...e)=>{console.debug(...e)},Jr=(...e)=>{console.warn(...e)},Hr=e=>e?e.getTime()-(new Date).getTime():0,Kr="DS",Br="DSR",Yr="DSI",Gr="DSRCN";function Xr(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Zr(i);cr.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}function Zr(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 Qr=e=>(null==e?void 0:e.cookieName)||Kr,es=e=>(null==e?void 0:e.cookieName)||Br;function ts(e="",t){return cr.get(es(t))||Nr(`${e}${Br}`)||""}function ns(e="",t){return cr.get(Qr(t))||Nr(`${e}${Kr}`)||""}function is(e=""){return Nr(`${e}${Yr}`)||""}function os(e="",t,n,i){Dr(`${e}${Br}`),Dr(`${e}${Kr}`),Dr(`${e}${Yr}`),Dr(`${e}${Gr}`);const o=Qr(t);cr.remove(o,null==i?void 0:i.session);const r=es(n);cr.remove(r,null==i?void 0:i.refresh)}const rs=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||ts(e,t)});if(!n){const t=function(e=""){return Nr(`${e}${Gr}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return Nr(`${e}DTD`)||""}(e);r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return Nr(`${e}DKD`)||""}(e);return s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-known-device-token":s})),o},ss=Sr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",as="vsid",ls="vrid",cs="fp",ds=(e=!1)=>{const t=Nr(cs);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},us=async(e,t=ss)=>{try{if(ds())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=br({apiKey:e,endpoint:[i.toString(),dr],scriptUrlPattern:[r,mr]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[as]:e,[ls]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Wr(cs,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},hs=e=>{const t=ds(!0);return t&&e.body&&(e.body.fpData=t),e},ps="descopeFlowNonce",fs="X-Descope-Flow-Nonce",gs="/v1/flow/start",vs="/v1/flow/next",ms=(e,t=ps)=>`${t}${e}`,bs=(e,t=ps)=>{try{const n=ms(e,t),i=Nr(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(ws(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},ws=(e,t=ps)=>{try{const n=ms(e,t);Dr(n)}catch(e){console.error("Error removing flow nonce:",e)}},ys=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},ks=e=>{var t;return e.path===vs&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ys(e.body.executionId):null},Ss="dls_last_user_login_id",Is="dls_last_user_display_name",Cs=e=>Wr(Ss,e),Os=()=>Nr(Ss),Es=()=>Nr(Is),As=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Os(),r=Es();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},xs="DSLI",js=e=>async(...t)=>{const n=await e(...t);return zr(xs),n};function Rs(){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,t){const n=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Ws(n.publicKey.challenge),n.publicKey.user.id=Ws(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Ws(e.id)})),n}(e);t&&(n.signal=t.signal);try{return i=await navigator.credentials.create(n),JSON.stringify({id:i.id,rawId:Ns(i.rawId),type:i.type,response:{attestationObject:Ns(i.response.attestationObject),clientDataJSON:Ns(i.response.clientDataJSON)}})}catch(e){throw await Ps(e,n,!0)}var i}async function _s(e,t){const n=Ls(e);t&&(n.signal=t.signal);try{return Ms(await navigator.credentials.get(n))}catch(e){throw await Ps(e,n,!1)}}async function $s(e,t){const n=Ls(e);n.signal=t.signal,n.mediation="conditional";try{return Ms(await navigator.credentials.get(n))}catch(e){throw await Ps(e,n,!1)}}async function Ps(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var i,o;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await Us())return"webauthn_unsupported";const s="platform"===(null===(o=null===(i=null==t?void 0:t.publicKey)||void 0===i?void 0:i.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await Us(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function Us(e=!1){var t,n;if(!Sr)return Promise.resolve(!1);if(Ur()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function Ls(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Ws(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Ws(e.id)})),n}function Ms(e){return JSON.stringify({id:e.id,rawId:Ns(e.rawId),type:e.type,response:{authenticatorData:Ns(e.response.authenticatorData),clientDataJSON:Ns(e.response.clientDataJSON),signature:Ns(e.response.signature),userHandle:e.response.userHandle?Ns(e.response.userHandle):void 0}})}function Ws(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ns(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ds,qs=(Ds=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await Ts(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await _s(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await Ts(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await _s(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await Ts(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Ts,get:_s,isSupported:Us,conditional:$s}}),(...e)=>{const t=Ds(...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";async function zs(e,t){var n;try{await Vs(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Vs(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var Js=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Us(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let Hs;const Ks=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Ks(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Bs=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{Hs||(Hs=(async()=>{try{return require("oidc-client-ts")}catch(e){return Ks([Or,Er],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await Hs;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),Wr(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=Nr(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||is(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return Dr(o),t||window.location.replace(s),r}}},Ys=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,xr=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Sr?(i&&o&&us(i).catch((()=>null)),e($r(r,{beforeRequest:hs}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.54.6"},t.baseHeaders)}))),(e=>t=>{const n=Rs(),i=Rs(),o=Rs(),r=Rs(),s=e($r(t,{afterRequest:async(e,t)=>{if(Lr(e,t))Vr("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await Pr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await Pr(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Ji(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var i;const{enableFlowNonce:o=!0,nonceStoragePrefix:r=ps}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=ps)=>{try{if(!Mr)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==xr?void 0:xr.length)&&void 0!==t?t:Sr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=qr(o);if(t&&t.startsWith(e)){const n=Nr(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Dr(t)}catch(e){Dr(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(r);const a=e($r(s,{afterRequest:async(e,t)=>{var n;if(e.path!==gs&&e.path!==vs)return;const{nonce:i,seq:o,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(fs),i=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const i=Number(n);return Number.isSafeInteger(i)?i:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=ks(e)),{nonce:n,seq:i,executionId:ys(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!i||!s)return;const a=e.path===gs,l=null===(n=bs(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==o&&void 0!==l&&o<=l||((e,t,n,i=ps,o)=>{try{const r=ms(e,i),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};Wr(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,i,a,r,null!=o?o:a?void 0:l)},beforeRequest:e=>{if(e.path===vs){const t=ks(e);if(t){const n=((e,t=ps)=>{var n,i;return null!==(i=null===(n=bs(e,t))||void 0===n?void 0:n.value)&&void 0!==i?i:null})(t,r);n&&(e.headers=e.headers||{},e.headers[fs]=n)}}return e}}));if(null===(i=a.flow)||void 0===i?void 0:i.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const i=e;let o;e=new Promise((e=>{o=e})),await i;try{return await t(...n)}finally{o()}}}return a}),(e=>t=>{const n=e($r(t,{afterRequest:async(e,t)=>{if(Lr(e,t))return void zr(xs);const n=await Pr(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,i;try{Sr&&(null===(i=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i||i.call(n,e,t))}catch(e){}})(xs,String(n.sessionExpiration))}}));return Ji(n,["logout","logoutAll","oidc.logout"],js)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);const r=!!i,s="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!r||Ur())return Object.assign(e(o),{markUserActive:()=>{Jr("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(Vr("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Sr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(Vr("Expiration time passed, refreshing session"),g())}));const f=e($r(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await Pr(t);if(Lr(e,t))Vr("Session invalidated, canceling all timers"),a(),c=void 0;else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);Vr("Could not extract expiration time from session token, trying to decode the token");try{const t=Hn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void Vr("Could not extract expiration time from session token");d=i,h=r>0;let e=((e,t)=>{let n;return t>0?(n=1e3*t,Vr(`Using provided nextRefreshSeconds: ${t}s`)):n=Hr(e)-Cr,n>Ir&&(Vr(`Timeout is too large (${n}ms), setting it to ${Ir}ms`),n=Ir),n})(c,r);a(),e<=Cr&&(e=Math.max(Hr(c),Cr));const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Vr(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Sr&&"hidden"===document.visibilityState)Vr("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return Vr("Skipping refresh due to timer - user is idle"),void(p=!0);Vr("Refreshing session due to timer"),g()}}),e)}}})),g=()=>f.refresh(ts()||d).catch((e=>{Jr("Automatic session refresh failed",e)}));return Object.assign(Ji(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Vr("Clearing all timers"),a(),n})),{markUserActive:u?()=>{Vr("markUserActive() called"),h||Vr("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(Vr("User became active after skipped refresh, triggering refresh"),p=!1,a(),g())}:()=>{Jr("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:Os,getLastUserDisplayName:Es});const s=e($r(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=_r((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(Cs(r),(e=>{Wr(Is,e)})(s)):(null==o?void 0:o.loginId)&&Cs(o.loginId)}}));let a=Ji(s,["flow.start"],As);return a=Ji(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Dr(Ss),Dr(Is)),i})(o)),Object.assign(a,{getLastUserLoginId:Os,getLastUserDisplayName:Es})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!Sr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e($r(Object.assign({refreshCookieName:a},l),{beforeRequest:rs(s,r,a),afterRequest:async(e,t)=>{if(Lr(e,t))Vr("Session invalidated, clearing persisted tokens"),os(s,o,r,c);else{const e=await Pr(t);e.cookieName?Wr(`${s||""}${Gr}`,e.cookieName):e.refreshJwt&&Dr(`${s||""}${Gr}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d,knownDeviceJwt:u}=e;let h;if(c)if(i){Dr(`${n}${Br}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,l=es(i);s&&"https:"!==window.location.protocol&&Jr("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Xr(l,c,d);const u=Zr(a);h=Object.assign(Object.assign({},h),{refresh:{path:d.cookiePath,domain:u?a:void 0}})}else{const e=es(i);cr.remove(e),Wr(`${n}${Br}`,c)}if(l)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=Qr(t);i&&"https:"!==window.location.protocol&&Jr("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});Xr(r,l,c);const d=Zr(o);h=Object.assign(Object.assign({},h),{session:{path:c.cookiePath,domain:d?o:void 0}})}else Wr(`${n}${Kr}`,l);return e.idToken&&Wr(`${n}${Yr}`,e.idToken),d&&Wr(`${n}DTD`,d),u&&Wr(`${n}DKD`,u),h})(e,o,s,r);n&&(c=n)}}})),u=Ji(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return os(e,t,n,null==i?void 0:i()),s})(s,o,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>ts(s,r),getSessionToken:()=>ns(s,o),getIdToken:()=>is(s)})}))((e=>{const t=ar(e),n=Bs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(Ur())return Vr(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&Sr&&void 0!==window.localStorage&&!Fr(xs)&&!Nr(Ss)&&!Fr("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=ns(),a=ts();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){Vr("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:Js(t),webauthn:qs(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){zs(i,e)},requestAuthentication(e){zs(i,e)}},async oneTap(e,t,n,o,r){await Vs(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+Fs),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Sr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+Fs);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),Gs={allOutboundApps:"/v1/mgmt/outbound/apps",connectedOutboundApps:"/v1/mgmt/outbound/apps-with-user-token"},Xs={me:"/v1/auth/me"},Zs=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)})),Qs=()=>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"}]})}))})),ea=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))})),ta=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))})),na=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>n(void 0,void 0,void 0,(function*(){if(t)return Qs();const n=yield e.get(Gs.allOutboundApps);return yield Zs(n),n.json()})),getConnectedOutboundApps:i=>n(void 0,[i],void 0,(function*({userId:n,tenantId:i}){if(t)return ea();const o=yield e.get(Gs.connectedOutboundApps,{queryParams:i?{userId:n,tenantId:i}:{userId:n}});return yield Zs(o),o.json()}))}),ia=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return ta();const n=yield e.get(Xs.me);return yield Zs(n),n.json()}))}),oa=l((e=>{var t,s,a,l;const c=r(x,E,w,Cn,j)(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")||de}get api(){return i(this,s,"f")||i(this,t,"m",a).call(this),i(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{i(this,s,"f")&&i(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,n)=>{const i=Ys(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.7.22"}}));return{outboundApps:na({httpClient:i.httpClient,mock:t}),user:Object.assign({},ia({httpClient:i.httpClient,mock:t})),httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),ra=un("users/me",((e,{extra:{api:t}})=>t.user.me())),sa={action:ra,reducer:Un(ra)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Ln((e=>e.me)))},aa=l((e=>{const t=r(wn({name:"widget",initialState:zn,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{sa.reducer(e),Fn.reducer(e),Nn.reducer(e)},asyncActions:{getMe:sa.action,getOutboundApps:Nn.action,getConnectedOutboundApps:Fn.action}}),O,w,oa)(e);return class extends t{constructor(...e){super(...e),this.state=zn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),la="widget-flow",ca=l((e=>{var t,o,s;return s=class extends(r(Sn,O,le,aa,Cn,w,me,jn)(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=Pn(la);r&&(!function(e){if(window.history.replaceState&&Pn(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())}}(la),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new Q((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),da=_t((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))))),ua=_t((e=>e.me.data),(e=>e.userId)),ha=l((e=>{var t,o,a,l,c;return c=class extends(r(w,O,z,Y,In("outbound-applications-widget"),aa)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,n,o){"allowed-outbound-apps-ids"===e&&n!==o&&this.actions.setAllowedAppsIds(i(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(i(this,t,"a",l)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:ua(this.state),tenantId:this.tenantId})]);const r=yield i(this,t,"m",o).call(this);i(this,t,"m",a).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));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})),pa=l((e=>class extends(r(me,E)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),fa=l((e=>{var t,s,a,l,c,d,u,h,p,f,g,v,m,b,y,k,S;return S=class extends(r(Sn,pa,aa,w,ha,le,jn)(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(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)})((e=>{i(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),i(this,t,"m",y).call(this,da(this.state)),i(this,t,"m",p).call(this),i(this,t,"m",v).call(this),this.subscribe(i(this,k,"f").bind(this),da)}))}},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(){i(this,s,"f").connectFlowId&&(o(this,a,this.createFlowModal({"data-id":"outbound-apps-connect"}),"f"),i(this,a,"f").afterClose=()=>{var e;if(i(this,u,"f")){const t=null===(e=i(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",i(this,u,"f")),o(this,u,null,"f")}},o(this,c,new Q((()=>{var e;return null===(e=i(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(i(this,c,"f")))},f=function(e,t,n){e.open(),t.removeEventListener("page-updated",n)},g=function(e,n){var o;const r=null===(o=e.ele)||void 0===o?void 0:o.querySelector("descope-wc"),s=()=>i(this,t,"m",f).call(this,e,r,s);n=s,null==r||r.addEventListener("page-updated",n)},v=function(){o(this,l,this.createFlowModal({"data-id":"outbound-apps-disconnect"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,l,"f").afterClose=()=>{var e;if(i(this,h,"f")){const t=null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",i(this,h,"f")),o(this,h,null,"f")}},this.syncFlowTheme(i(this,d,"f"))},m=function(e){i(this,a,"f").setContent(this.createFlowTemplate({flowId:i(this,s,"f").connectFlowId,lazyStart:!1,outboundAppId:e})),i(this,t,"m",g).call(this,i(this,a,"f"),i(this,u,"f")),i(this,c,"f").onSuccess((()=>{i(this,a,"f").close(),this.actions.getConnectedOutboundApps({userId:ua(this.state),tenantId:this.tenantId})}))},b=function(e){i(this,l,"f").setContent(this.createFlowTemplate({flowId:i(this,s,"f").disconnectFlowId,lazyStart:!1,outboundAppId:e})),i(this,t,"m",g).call(this,i(this,l,"f"),i(this,h,"f")),i(this,d,"f").onSuccess((()=>{i(this,l,"f").close(),this.actions.getConnectedOutboundApps({userId:ua(this.state)})}))},y=function(e){o(this,s,new se((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),i(this,s,"f").onConnectClick((({id:e})=>{i(this,t,"m",m).call(this,e)})),i(this,s,"f").onDisconnectClick((({id:e})=>{i(this,t,"m",b).call(this,e)})),i(this,s,"f").data=e},S})),ga=l((e=>class extends(r(U,me,ca,fa,$n)(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)}))}})),va=r((e=>class extends(ga(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 Pu})).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.7.22"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",va);const ma=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var ba,wa,ya,ka,Sa,Ia,Ca,Oa,Ea,Aa;const xa=document.createElement("template");xa.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 ja=r(H)(HTMLElement);class Ra extends ja{constructor(){var e;super(),ba.add(this),wa.set(this,new f({messages:[]})),ya.set(this,void 0),ka.set(this,void 0),Sa.set(this,void 0),Ia.set(this,{resize:i(this,ba,"m",Aa).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(xa.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,ya,this.shadowRoot.querySelector(".debugger"),"f"),i(this,ya,"f").style.top="32px",i(this,ya,"f").style.left=window.innerWidth-300-32+"px",o(this,ka,i(this,ya,"f").querySelector(".content"),"f"),o(this,Sa,i(this,ya,"f").querySelector(".header"),"f")}updateData(e){i(this,wa,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=ma(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,ya,"f"),i(this,Sa,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Ia,"f").resize),(e=i(this,ya,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},i(this,ya,"f").onresize=i(this,ba,"m",Ea).bind(this),i(this,wa,"f").subscribe(i(this,ba,"m",Ca).bind(this))}disconnectedCallback(){i(this,wa,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Ia,"f").resize)}}wa=new WeakMap,ya=new WeakMap,ka=new WeakMap,Sa=new WeakMap,Ia=new WeakMap,ba=new WeakSet,Ca=function(e){i(this,ba,"m",Oa).call(this,e),i(this,ba,"m",Ea).call(this)},Oa=function(e){i(this,ka,"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 ${g(e.title)}\n </div>\n <div class="msg_desc">\n ${g(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Ea=function(){i(this,ka,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Aa=function(){const[e,t]=ma(i(this,ya,"f"),Number.parseInt(i(this,ya,"f").style.left,10),Number.parseInt(i(this,ya,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,ya,"f").style.top=`${t}px`,i(this,ya,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Ra);var Ta=Object.freeze({__proto__:null});const _a="undefined"!=typeof localStorage,$a="J151000",Pa="E103205",Ua="E108201",La=_a&&localStorage.getItem("base.content.url")||"",Ma="base.ui.components.url";_a&&localStorage.getItem(Ma),_a&&localStorage.getItem(Ma);const Wa="descope-login-flow",Na="code",Da="redirect_mode",qa="err",Fa="data-exclude-field",za="data-exclude-next",Va="dls_last_auth",Ja="dls_last_submitted_login_id",Ha="state_id",Ka="saml_idp_state_id",Ba="wsfed_idp_state_id",Ya="saml_idp_username",Ga="descope_idp_initiated",Xa="sso_app_id",Za="custom_app_id",Qa="third_party_app_id",el="third_party_app_state_id",tl="oidc_login_hint",nl="oidc_prompt",il="oidc_resource",ol="oidc_error_redirect_uri",rl="application_scopes",sl="data-type",al="redirect",ll="poll",cl="webauthnCreate",dl="webauthnGet",ul="nativeBridge",hl="loadForm",pl="submit",fl="polling",gl=["descope-multi-select-combo-box","descope-text-area"],vl="dls_last_auth_in_flight",ml=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"],bl=["hide","disable","read-only"],wl="hidden";function yl(e,t){const n=e.closest(`.${wl}`);return!!n&&n!==t}const kl=/(["\\])/g;function Sl(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(kl,"\\$1")}function Il(e,t){return Array.from(e.querySelectorAll(`[id="${Sl(t)}"]`))}function Cl(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&Il(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove(wl);break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(n).forEach((i=>{const o=n[i],r=t[i];o!==r&&Il(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add(wl);break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}var Ol;!function(e){e.backward="backward",e.forward="forward"}(Ol||(Ol={}));const El=new Set,Al=(e,t)=>({origin:window.location.origin,pathname:window.location.pathname,hash:window.location.hash,projectId:e,flowId:t}),xl=(e,t)=>`dls_sso_query_params_${e}_${t}`,jl=e=>Object.values(null!=e?e:{}).some(Boolean),Rl=()=>{var e,t,n;try{const[i]=null!==(n=null===(t=null===(e=window.performance)||void 0===e?void 0:e.getEntriesByType)||void 0===t?void 0:t.call(e,"navigation"))&&void 0!==n?n:[],o=i;if("reload"!==(null==o?void 0:o.type)||!o.name)return!1;const r=new URL(o.name,window.location.href);return r.origin===window.location.origin&&r.pathname===window.location.pathname&&r.hash===window.location.hash}catch(e){return!1}},Tl=(e,t)=>(null==e?void 0:e.origin)===t.origin&&(null==e?void 0:e.pathname)===t.pathname&&(null==e?void 0:e.hash)===t.hash&&(null==e?void 0:e.projectId)===t.projectId&&(null==e?void 0:e.flowId)===t.flowId,_l=(e,t)=>{var n,i;try{const o=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(xl(e,t));if(!o)return;const r=JSON.parse(o);Tl(null==r?void 0:r.scope,Al(e,t))&&(null===(i=window.sessionStorage)||void 0===i||i.removeItem(xl(e,t)))}catch(e){}},$l=["descope-enriched-text"];function Pl(e){return new URLSearchParams(window.location.search).get(e)}function Ul(e){if(window.history.replaceState&&Pl(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 Ll(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Ol.forward:n<i?Ol.backward:void 0}const Ml=e=>{let[t="",n=""]=(Pl(Wa)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Wl(){Ul(Wa)}function Nl(e){try{const{origin:t}=new URL(e);return"null"===t?void 0:t}catch(e){return}}function Dl(){return Pl(Ba)}function ql(){Ul(Ba)}function Fl(){return Pl(rl)}function zl(){Ul(rl)}const Vl=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Jl=(e,t,n)=>{const{executionId:i,stepId:o,executionFlowId:r}=Ml(e);if(r&&e!==r)return n.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(i||o)&&Wl();const s=Pl("t")||void 0;s&&Ul("t");const a=Pl(Na)||void 0;a&&Ul(Na);const l="popup"===Pl(Da);l&&Ul(Da);const c=Pl(qa)||void 0;c&&Ul(qa);const{redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p}={redirectAuthCodeChallenge:Pl("ra-challenge"),redirectAuthCallbackUrl:Pl("ra-callback"),redirectAuthBackupCallbackUri:Pl("ra-backup-callback"),redirectAuthInitiator:Pl("ra-initiator")},f=Pl(Ha);f&&Ul(Ha);const g=Pl(Ka);g&&Ul(Ka);const v=Dl();v&&ql();const m=Pl(Ya);g&&Ul(Ya);const b=Pl(Ga);b&&Ul(Ga);const w=Pl(Xa);w&&Ul(Xa);const y=Pl(Za);y&&Ul(Za);const k=Pl(Qa);k&&Ul(Qa);const S=Pl(el);S&&Ul(el);const I=Fl();I&&zl();const C=Pl(tl);C&&Ul(tl);const O=Pl(nl);O&&Ul(nl);const E=Pl(ol);E&&Ul(ol);const A=Pl(il);A&&Ul(il);const x={oidcIdpStateId:f,samlIdpStateId:g,wsfedIdpStateId:v,samlIdpUsername:m,descopeIdpInitiated:"true"===b,ssoAppId:w,customAppId:y,oidcLoginHint:C,oidcPrompt:O,oidcErrorRedirectUri:E,oidcResource:A,thirdPartyAppId:k,thirdPartyAppStateId:S,applicationScopes:I},j=((e,t)=>{const n=[(i=Al(e,t)).origin,i.pathname,i.hash,i.projectId,i.flowId].join("|");var i;return!El.has(n)&&(El.add(n),!0)})(t,e);let R=x;if(jl(x))((e,t,n)=>{var i;if(jl(e))try{const o={params:e,scope:Al(t,n),ts:Date.now()};null===(i=window.sessionStorage)||void 0===i||i.setItem(xl(t,n),JSON.stringify(o))}catch(e){}})(x,t,e);else if(!r){const i=j?((e,t)=>{var n;if(!Rl())return null;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(xl(e,t));if(!i)return null;const o=JSON.parse(i);return Tl(null==o?void 0:o.scope,Al(e,t))?Date.now()-o.ts>=6e5?null:o.params:null}catch(e){return null}})(t,e):null;i?(n.debug("Restored SSO query params after a page reload"),R=i):((e,t)=>{Rl()||_l(e,t)})(t,e)}return{executionId:i,stepId:o,token:s,code:a,isPopup:l,exchangeError:c,redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p,ssoQueryParams:R}},Hl=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},Kl=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=Array.from(e.querySelectorAll('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])')).find((t=>!yl(t,e)));setTimeout((()=>{null==t||t.focus()}))}};function Bl(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const Yl=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||i||o||r||s||a||l||c||d||u||h||p),Gl=(e,t,n)=>{const i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,n&&i.setAttribute("role",n),i},Xl=e=>null==e?void 0:e.submit(),Zl=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Ql=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},ec={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",reuse:"data-password-policy-value-reuse",activePolicies:"active-policies",availablePolicies:"available-policies"},tc=(e,t)=>{var n;const i=null==e?void 0:e.componentsDynamicAttrs;if(!i)return;const o=Object.entries(i).find((([e])=>(e=>{var t;return null===(t=e.match(/\[data-name=["']([^"']+)["']\]/))||void 0===t?void 0:t[1]})(e)===t));return null===(n=null==o?void 0:o[1])||void 0===n?void 0:n.attributes},nc=[{key:"totp",from:e=>e.totp},{key:"notp",from:e=>e.notp},{key:"sentTo",from:e=>e.sentTo},{key:"sso",from:e=>e.sso},{key:"selfProvisionDomains",from:e=>e.selfProvisionDomains},{key:"inboundAppApproveScopes",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data}},{key:"securityQuestionsSetup",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqSetup}},{key:"securityQuestionsVerify",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqVerify}},{key:"userTenants",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userSelectedTenant)||void 0===n?void 0:n.data}},{key:"userRoles",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userRoles)||void 0===n?void 0:n.data}},{key:"ssoApplications",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoApplications)||void 0===n?void 0:n.data}},{key:"ssoConfigurations",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoConfigurations)||void 0===n?void 0:n.data}},{key:"samlAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlMappings)||void 0===n?void 0:n.options}},{key:"oidcAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.oidcMappings)||void 0===n?void 0:n.options}},{key:"samlGroupMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlGroupMappings)||void 0===n?void 0:n.options}},{key:"passwordPolicy",from:e=>{var t;return(e=>{if(!e)return;const t=Object.fromEntries(Object.entries(ec).map((([t,n])=>[t,e[n]])).filter((([,e])=>void 0!==e)));return Object.keys(t).length?t:void 0})(null===(t=e.componentsConfig)||void 0===t?void 0:t.newPassword)}},{key:"recoveryCodes",from:e=>(e=>{const t=tc(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=tc(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],ic=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function oc(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var rc,sc,ac,lc;function cc(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!cc(r,s))return!1}else if(r!==s)return!1}return!0}let dc=class{constructor(e={},{forceUpdate:t=!1}={}){rc.set(this,void 0),sc.set(this,{}),ac.set(this,0),lc.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,rc,"f")):e,n=Object.assign(Object.assign({},i(this,rc,"f")),t),r=i(this,rc,"f");o(this,rc,n,"f"),Object.freeze(i(this,rc,"f")),setTimeout((()=>{Object.values(i(this,sc,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,lc,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!cc(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,rc,e,"f"),o(this,lc,t,"f")}get current(){return Object.assign({},i(this,rc,"f"))}set forceUpdate(e){o(this,lc,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,ac,i(this,ac,"f")+1,"f"),i(this,sc,"f")[i(this,ac,"f")]={cb:e,selector:t,forceUpdate:n},i(this,ac,"f").toString()}unsubscribe(e){const t=!!i(this,sc,"f")[e];return t&&delete i(this,sc,"f")[e],t}unsubscribeAll(){return o(this,sc,{},"f"),!0}};rc=new WeakMap,sc=new WeakMap,ac=new WeakMap,lc=new WeakMap;const uc=["*","#","/","(",")","[","]","_","<",">","`"],hc=e=>"string"!=typeof e?e:e.replace((e=>{const t=uc.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),pc=["disabled"],fc=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Fa}])`)).forEach((e=>{e.value=n}))}))},gc=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),vc=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?hc(gc(t,i)):gc(t,i))),mc=(e,t,n)=>{e.querySelectorAll(`[${sl}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},bc=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},wc=(e,n,i,o)=>{var r,s;mc(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),mc(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=>$l.includes(e))(e.localName);e.textContent=vc(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",vc(i,t))}))})(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==n?void 0:n.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=vc(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])=>{pc.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},yc=Hl((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield Bl(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let kc;const Sc=(e,t)=>{kc?kc.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Ic=e=>kc?kc.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Cc="dls_ab_testing_id",Oc={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function Ec(e,t){const n={};try{Object.assign(n,JSON.parse(Ic(Va)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function Ac(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Sc(Va,JSON.stringify(e)))}function xc(){try{return JSON.parse(Ic(vl)||"{}")}catch(e){return{}}}function jc(e){try{(e=>{kc?kc.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(vl)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const Rc=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?Rc(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),Rc(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Tc=l((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r})),_c=["input","change"];function $c(e){if("number"==typeof e&&Number.isFinite(e))return{value:e,ok:!0};if("boolean"==typeof e)return{value:e?1:0,ok:!0};if("string"==typeof e){if(""===e.trim())return{value:0,ok:!1};const t=Number(e);if(Number.isFinite(t))return{value:t,ok:!0}}return{value:0,ok:!1}}function Pc(e){return null==e?"":"string"==typeof e?e:"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isFinite(e)?String(e):"":String(e)}function Uc(e){if("boolean"==typeof e)return{value:e,ok:!0};if("string"==typeof e){if("true"===e)return{value:!0,ok:!0};if("false"===e)return{value:!1,ok:!0}}return"number"==typeof e?{value:0!==e,ok:!0}:{value:!1,ok:!1}}function Lc(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function Mc(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Wc=new Map,Nc={equal:(e,t)=>e===t||Pc(e)===Pc(t),"not-equal":(e,t)=>e!==t&&Pc(e)!==Pc(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(Pc(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(Pc(t)),"greater-than":(e,t)=>{const n=$c(e),i=$c(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=$c(e),i=$c(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=$c(e),i=$c(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=$c(e),i=$c(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>Mc(e),"not-empty":e=>!Mc(e),"is-true":e=>{const t=Uc(e);return t.ok&&t.value},"is-false":e=>{const t=Uc(e);return t.ok&&!t.value},in:(e,t)=>{const n=Lc(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=Lc(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(Wc.has(e))return null!==(t=Wc.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return Wc.set(e,n),n}(Pc(t));return null!==n&&n.test(e)}};function Dc(e,t){var n;if(e)return"form"===e.kind&&e.form?t[e.form]:"list"===e.kind?(null!==(n=e.items)&&void 0!==n?n:[]).map((e=>Dc(e,t))):e.value}function qc(e,t){const n=Nc[e.operator];return!!n&&n(Dc(e.target,t),Dc(e.predicate,t))}function Fc(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var i;(function(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const i=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!i.length&&(e.logicalOr?i.some((e=>qc(e,t))):i.every((e=>qc(e,t))))}(e,t)))})(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const zc="component-conditions:";function Vc(e){return e instanceof HTMLInputElement?"checkbox"===e.type?e.checked:e.value:"checked"in e?e.checked:"value"in e?e.value:void 0}function Jc(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function Hc(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function Kc(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const Bc=l((e=>{var t,n,s,a,l,c;const d=r(w)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,Hc())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{bl.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${bl.map((e=>`"${e}"`)).join(", ")}`)})),Cl(e,{},t))}initRealtimeConditions(e,r){var a,c,d,u;i(this,t,"m",l).call(this);const h=null!==(a=null==r?void 0:r.realtimeComponentsConditions)&&void 0!==a?a:[];if(!h.length)return void this.logger.debug(`${zc} no real-time rules to apply on this screen`);this.logger.info(`${zc} found ${h.length} real-time rule(s) for this screen`);const p={};Object.entries(null!==(c=null==r?void 0:r.form)&&void 0!==c?c:{}).forEach((([e,t])=>{p[`form.${e}`]=t})),function(e){const t=new Set,n=e=>{var i;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(i=e.items)&&void 0!==i?i:[]).forEach(n))};return(null!=e?e:[]).forEach((e=>{var t;return(null!==(t=e.rules)&&void 0!==t?t:[]).forEach((e=>{var t;return(null!==(t=e.atomicConditions)&&void 0!==t?t:[]).forEach((e=>{n(e.target),n(e.predicate)}))}))})),t}(h).forEach((t=>{const n=function(e,t){const n=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${Sl(t)}"]`)||e.querySelector(`[name="${Sl(n)}"]`)}(e,t);if(!n)return;const i=Vc(n);void 0!==i&&(p[t]=i)}));const f=function(e){const t=new Set;return(null!=e?e:[]).forEach((e=>{var n;(null!==(n=e.componentIds)&&void 0!==n?n:[]).forEach((e=>t.add(e)))})),t}(h),g={},v={};Object.entries(null!==(d=null==r?void 0:r.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{f.has(e)&&(v[e]=t)})),Object.entries(null!==(u=null==r?void 0:r.serverOnlyComponentsState)&&void 0!==u?u:{}).forEach((([e,t])=>{f.has(e)&&(g[e]=t)}));const m={conditions:h,touchedIds:f,snapshot:p,applied:v,serverBaseline:g,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},b=Kc(Fc(h,p),g,f);Jc(v,b)||(m.applied=Cl(e,v,b)),m.inputHandler=e=>i(this,t,"m",s).call(this,e),_c.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${zc} listening for "${_c.join('" and "')}" events on form fields; ${Object.keys(v).length} component(s) start hidden / disabled / read-only by these rules`);const w=this.nextRequestStatus;if(null==w?void 0:w.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=w.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=w.unsubscribe)||void 0===e||e.call(w,t))}}o(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(e){var o,r;const s=i(this,n,"f");if(!s.root||s.paused)return;const l=e.target;if(!l)return;if(null===(o=l.hasAttribute)||void 0===o?void 0:o.call(l,Fa))return;const c=null===(r=l.getAttribute)||void 0===r?void 0:r.call(l,"name");if(!c)return;const d=function(e){return e.startsWith("form.")?e:`form.${e}`}(c);s.snapshot[d]=Vc(l),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,i(this,t,"m",a).call(this)}),50)},a=function(){const e=i(this,n,"f");if(!e.root)return;let t;try{t=Kc(Fc(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${zc} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const o=e.applied;Jc(o,t)||(this.logger.debug(`${zc} form changed — updating components: was ${JSON.stringify(o)}, now ${JSON.stringify(t)}`),e.applied=Cl(e.root,o,t))},l=function(){const e=i(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&_c.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)})),o(this,n,Hc(),"f")},c})),Yc="project-id",Gc="flow-id",Xc=e=>{const t=(e=>{const t=e.getAttribute(Yc),n=e.getAttribute(Gc);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(Yc)===t&&e.getAttribute(Gc)===n)):[]})(e);return t.length>1&&t[0]!==e},Zc=l((e=>{var t,n,s,a;const l=r(w)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}connectedCallback(){var e;null===(e=super.connectedCallback)||void 0===e||e.call(this),i(this,t,"m",s).call(this)}attributeChangedCallback(e,n,o){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),n===o||e!==Yc&&e!==Gc||i(this,t,"m",s).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(Yc),t=this.getAttribute(Gc),r=`${e}|${t}`;i(this,n,"f")!==r&&Xc(this)&&(o(this,n,r,"f"),this.logger.warn("Multiple Descope flow components detected on the same page",`The same flow ("${t}") and project ("${e}") are running more than once on this page. This is not supported and may cause the flow to behave unexpectedly.`))}))},a})),Qc=["externalId","email","phone"],ed=["newPassword","password"],td="data-username-anchor",nd=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(Ja);if(!n)return"";const i=JSON.parse(n);return i.executionId===e&&i.loginId||""}catch(e){return""}},id=l((e=>{var t,n,s,a,l;const c=r(w)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,l,c;o(this,n,{email:null==e?void 0:e.email,loginIds:(null===(r=null==e?void 0:e.loginIds)||void 0===r?void 0:r.length)?e.loginIds:[nd(i(this,t,"a",a))||(null===(c=null===(l=i(this,t,"a",s).sdk)||void 0===l?void 0:l.getLastUserLoginId)||void 0===c?void 0:c.call(l))].filter(Boolean)},"f")}updateUsernameAnchor(){document.querySelectorAll(`[${td}="true"]`).forEach((e=>e.remove())),((e,t,n,i)=>{var o;const r=(null==n?void 0:n.email)||(null===(o=null==n?void 0:n.loginIds)||void 0===o?void 0:o[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...Qc.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?i.debug("Username anchor: screen already has an identifier field"):(i.debug("Username anchor: injecting hidden username input"),e.appendChild((e=>{const t=document.createElement("input");return t.setAttribute("autocomplete","username"),t.setAttribute("name","username"),t.setAttribute("type","email"),t.setAttribute("readonly","true"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.setAttribute(Fa,"true"),t.setAttribute(td,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):i.debug("Username anchor: no user identifier available"):i.debug("Username anchor: no password component on screen")})(this,i(this,t,"a",s).contentRootElement,i(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const o=Zl(e,Qc);o&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem(Ja,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(o,n||i(this,t,"a",a))}storeCredentials(e={}){var t,o,r,s,a,l;const c=Zl(e,Qc)||(null===(t=i(this,n,"f"))||void 0===t?void 0:t.email)||(null===(r=null===(o=i(this,n,"f"))||void 0===o?void 0:o.loginIds)||void 0===r?void 0:r[0]),d=Zl(e,ed);if(c&&d)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:c,password:d});null===(l=null===(a=null===(s=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===s?void 0:s.store)||void 0===a?void 0:a.call(s,e))||void 0===l||l.catch((e=>{this.logger.debug("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.warn("Could not store credentials",e.message)}}},n=new WeakMap,t=new WeakSet,s=function(){return this},a=function(){var e,n;return(null===(n=null===(e=i(this,t,"a",s).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},l})),od="data-evp-token",rd='descope-email-field[email-verification="true"]',sd=e=>{e.querySelectorAll(`[${od}]`).forEach((e=>e.remove()))},ad=l((e=>{var t,s,a,l,c,d,u;const h=r(w)(e);return u=class extends h{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,!1),l.set(this,0),c.set(this,(e=>{(e=>e.composedPath().some((e=>e instanceof Element&&e.matches(rd))))(e)&&(o(this,a,"focusin"===e.type,"f"),"focusout"===e.type&&o(this,l,Date.now(),"f"))}))}clearEmailVerification(){o(this,s,void 0,"f"),o(this,a,!1,"f"),o(this,l,0,"f"),sd(this)}startEmailVerification(e){var n,r,a;const l=null===(n=i(this,t,"a",d).sdk)||void 0===n?void 0:n.emailVerification;if(!(l&&(()=>{var e,t;return!!(null===(t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands)||void 0===t?void 0:t.some((({brand:e})=>"Google Chrome"===e)))})()&&(u=e,u.querySelector(rd))&&this.closest("form")))return;var u;null===(r=this.shadowRoot)||void 0===r||r.addEventListener("focusin",i(this,c,"f")),null===(a=this.shadowRoot)||void 0===a||a.addEventListener("focusout",i(this,c,"f"));const h=l.start().then((e=>{var t,n;e.ok&&(null===(t=e.data)||void 0===t?void 0:t.nonce)?i(this,s,"f")===h&&((e,t)=>{const n=document.createElement("input");n.type="hidden",n.setAttribute("autocomplete","email-verification-token"),n.setAttribute(Fa,"true"),n.setAttribute(od,"true"),n.nonce=t,n.setAttribute("nonce",t),e.appendChild(n)})(this,e.data.nonce):this.logger.warn("Email verification start failed",null===(n=e.error)||void 0===n?void 0:n.errorDescription)})).catch((e=>{this.logger.warn("Email verification start failed",null==e?void 0:e.message)}));o(this,s,h,"f")}emailVerificationToken(e){return n(this,void 0,void 0,(function*(){var t,n;if("true"===e.getAttribute("formnovalidate")||!this.querySelector(`[${od}]`)||!(null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(rd))||void 0===n?void 0:n.value))return"";i(this,a,"f")&&(()=>{var e;let t=document.activeElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.activeElement;)t=t.shadowRoot.activeElement;t instanceof HTMLElement&&t.blur()})();const o=i(this,l,"f")+900-Date.now();o>0&&(yield new Promise((e=>{setTimeout(e,o)})));const r=(e=>{const t=e.querySelector(`[${od}]`),n=e.closest("form");if(!t||!n)return"";let i="";const o=e=>{e.target===n&&(e.preventDefault(),e.stopImmediatePropagation(),i=t.value,t.value="")};window.addEventListener("submit",o,!0);const{noValidate:r}=n;n.noValidate=!0;try{n.requestSubmit()}finally{n.noValidate=r,window.removeEventListener("submit",o,!0)}return i})(this);return r&&sd(this),r}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(){return this},u})),ld=e=>`${e.screenId}|${e.field}|${e.rule}`,cd=()=>{try{return crypto.randomUUID()}catch(e){return`${Date.now()}-${Math.round(1e9*Math.random())}`}},dd=(e,t)=>e?e.badInput?"bad-input":e.valueMissing?"required":e.typeMismatch?"email"===t||"url"===t?t:"type-mismatch":e.patternMismatch?"pattern":e.tooShort?"too-short":e.tooLong?"too-long":e.rangeUnderflow||e.rangeOverflow||e.stepMismatch?"range":e.customError?"custom":"unknown":"unknown",ud=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,b,y,k,S,I,C;const O=r(w)(e);return C=class extends O{constructor(){super(...arguments),t.add(this),n.set(this,[]),s.set(this,void 0),a.set(this,void 0),l.set(this,new Set),c.set(this,!1),d.set(this,0),u.set(this,void 0),h.set(this,!1),p.set(this,(()=>i(this,t,"m",y).call(this,!1))),f.set(this,(()=>{"hidden"===document.visibilityState&&i(this,t,"m",y).call(this,!0)})),g.set(this,(()=>i(this,t,"m",y).call(this,!0)))}setValidationTrackingEnabled(e){i(this,h,"f")!==e&&(o(this,h,e,"f"),e||i(this,t,"m",b).call(this))}setValidationTrackingSender(e){o(this,u,e,"f")}setValidationTrackingExecution(e){i(this,h,"f")&&e&&i(this,n,"f").length&&(o(this,s,e,"f"),i(this,t,"m",y).call(this,!1))}trackValidationErrors(e,n){var o,r;try{i(this,t,"m",v).call(this,e,n)}catch(e){null===(r=null===(o=this.logger)||void 0===o?void 0:o.debug)||void 0===r||r.call(o,"Failed to track validation errors",String(e))}}teardownValidationTracking(){i(this,t,"m",y).call(this,!1),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),i(this,c,"f")&&(o(this,c,!1,"f"),this.removeEventListener("screen-updated",i(this,p,"f")),this.removeEventListener("success",i(this,p,"f")),this.removeEventListener("error",i(this,p,"f")),document.removeEventListener("visibilitychange",i(this,f,"f")),window.removeEventListener("pagehide",i(this,g,"f")))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap,t=new WeakSet,v=function(e,r){if(!i(this,h,"f")||!(null==e?void 0:e.length))return;const a=r||{};i(this,t,"m",I).call(this),e.forEach((e=>{if(i(this,n,"f").length>=20)return;const r=((e,t)=>{var n;const i=null===(n=null==e?void 0:e.getAttribute)||void 0===n?void 0:n.call(e,"name");return i?{id:cd(),field:i,rule:dd(e.validity,e.type),message:e.validationMessage||"",screenId:t.screenId||"",screenName:t.screenName||"",ts:Date.now()}:null})(e,a);if(!r)return;const l=ld(r);i(this,n,"f").some((e=>ld(e)===l))||(i(this,n,"f").push(r),o(this,s,a.executionId||i(this,s,"f"),"f"),i(this,n,"f").length>=20&&i(this,t,"m",y).call(this,!1))})),i(this,n,"f").length>=20?i(this,t,"m",y).call(this,!1):i(this,t,"m",m).call(this)},m=function(){clearTimeout(i(this,a,"f")),o(this,a,setTimeout((()=>i(this,t,"m",y).call(this,!1)),2e3),"f")},b=function(){clearTimeout(i(this,a,"f")),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),o(this,n,[],"f"),o(this,s,void 0,"f")},y=function(e){var r,l;if(clearTimeout(i(this,a,"f")),!i(this,n,"f").length)return void o(this,s,void 0,"f");if(!i(this,s,"f"))return;if(!i(this,u,"f"))return;const c=i(this,n,"f"),h=i(this,s,"f");o(this,n,[],"f"),o(this,s,void 0,"f");try{const n={executionId:h,events:c};e?i(this,u,"f").call(this,n,{keepalive:!0}).catch((()=>{})):i(this,t,"m",k).call(this,n,2,i(this,d,"f"))}catch(e){null===(l=null===(r=this.logger)||void 0===r?void 0:r.debug)||void 0===l||l.call(r,"Failed to send validation events",String(e))}},k=function(e,n,o){i(this,u,"f").call(this,e,{keepalive:!1}).then((r=>{!r.ok&&r.retryable&&n>0&&i(this,t,"m",S).call(this,e,n,o)})).catch((()=>{n>0&&i(this,t,"m",S).call(this,e,n,o)}))},S=function(e,n,o){if(o!==i(this,d,"f"))return;const r=setTimeout((()=>{i(this,l,"f").delete(r),o===i(this,d,"f")&&i(this,t,"m",k).call(this,e,n-1,o)}),800*(2-n+1));i(this,l,"f").add(r)},I=function(){i(this,c,"f")||(o(this,c,!0,"f"),this.addEventListener("screen-updated",i(this,p,"f")),this.addEventListener("success",i(this,p,"f")),this.addEventListener("error",i(this,p,"f")),document.addEventListener("visibilitychange",i(this,f,"f")),window.addEventListener("pagehide",i(this,g,"f")))},C}));var hd,pd,fd,gd,vd,md,bd,wd,yd,kd,Sd,Id,Cd,Od,Ed,Ad,xd,jd,Rd,Td,_d,$d,Pd,Ud,Ld,Md;const Wd=r(me,_,Tc,Bc,Zc,id,ad,H,xn,ud)(HTMLElement);class Nd extends Wd{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","send-session-token","style-id"]}constructor(e){super(),hd.add(this),this.sdkVersion="4.7.1",fd.set(this,!1),gd.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,hd,"m",Md).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)}},vd.set(this,new dc),md.set(this,new dc),bd.set(this,{}),this.getComponentsContext=()=>i(this,bd,"f"),this.nextRequestStatus=new dc({isLoading:!1}),wd.set(this,void 0),yd.set(this,{popstate:i(this,hd,"m",Od).bind(this),componentsContext:i(this,hd,"m",Td).bind(this)}),kd.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),_d.set(this,void 0),$d.set(this,void 0),o(this,kd,e,"f"),i(this,hd,"m",Id).call(this)}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 sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return Rc(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,gd,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,gd,e,"f"),(e=>{kc=e})(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=i(this,$d,"f"))||void 0===e||e.call(this),o(this,_d,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=gl.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,md,"f").subscribe(i(this,hd,"m",Ld).bind(this)),i(this,md,"f").update({isDebug:this.debug}),i(this,hd,"m",Cd).call(this),yield i(this,hd,"m",jd).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}=Jl(this.flowId,this.projectId,this.loggerWrapper);window.addEventListener("popstate",i(this,yd,"f").popstate),window.addEventListener("components-context",i(this,yd,"f").componentsContext),i(this,vd,"f").subscribe(i(this,hd,"m",xd).bind(this)),i(this,vd,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},g)),o(this,fd,!0,"f")}))}disconnectedCallback(){var e;i(this,vd,"f").unsubscribeAll(),i(this,md,"f").unsubscribeAll(),i(this,hd,"m",Ud).call(this),window.removeEventListener("popstate",i(this,yd,"f").popstate),window.removeEventListener("components-context",i(this,yd,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var o;if(null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,t,n),this.shadowRoot.isConnected&&i(this,fd,"f")&&t!==n&&pd.observedAttributes.includes(e)){i(this,hd,"m",Cd).call(this);const o=null===t;i(this,vd,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Wl()),{[Vl(e)]:n,stepId:r,executionId:s}})),i(this,md,"f").update({isDebug:this.debug})}}}var Dd,qd,Fd,zd,Vd,Jd,Hd,Kd,Bd,Yd,Gd,Xd,Zd,Qd,eu,tu,nu,iu,ou,ru,su,au,lu,cu,du,uu,hu,pu,fu,gu,vu,mu,bu,wu,yu,ku,Su,Iu,Cu,Ou,Eu,Au,xu,ju,Ru,Tu;pd=Nd,fd=new WeakMap,gd=new WeakMap,vd=new WeakMap,md=new WeakMap,bd=new WeakMap,wd=new WeakMap,yd=new WeakMap,kd=new WeakMap,_d=new WeakMap,$d=new WeakMap,hd=new WeakSet,Sd=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 ")},Id=function(){i(this,hd,"m",Sd).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Cd=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","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];pd.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Vl(t)])throw Error(`${t} cannot be empty`)}))},Od=function(){const{stepId:e,executionId:t}=Ml(this.flowId);t&&i(this,vd,"f").update({stepId:e,executionId:t})},Ed=function(e,t){Ys&&"function"==typeof Ys||this.logger.error("SDK was not loaded properly",Ys,JSON.stringify(Ys));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},pd.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,gd,"f")&&(o.customStorage=i(this,gd,"f")),this.sdk=Ys(o);const r={start:1,next:7};["start","next"].forEach((e=>{const t=function(e,t,i){return(...o)=>n(this,void 0,void 0,(function*(){let n;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...o)}catch(e){n=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...o)=>n(this,void 0,void 0,(function*(){const n=[...o],s=r[e],a=i(this,hd,"m",Ad).call(this,n[s]);void 0!==a&&(n[s]=a);try{return yield t(...n)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:$a,errorDescription:t.toString()}}}}))}));const s=this.sdk.flow.start;this.sdk.flow.start=(...e)=>n(this,void 0,void 0,(function*(){return yield i(this,hd,"m",Pd).call(this),s.apply(this.sdk.flow,e)}))},Ad=function(e){if(!this.sendSessionToken)return e;const t=null==ns?void 0:ns(this.storagePrefix);return t?Object.assign(Object.assign({},null!=e?e:{}),{sessionJwt:t}):e},xd=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,hd,"m",Ed).call(this,t,n)}i(this,kd,"f").call(this,e)}))},jd=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,hd,"m",Rd).call(this))}))},Rd=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(La||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Td=function(e){o(this,bd,Object.assign(Object.assign({},i(this,bd,"f")),e.detail),"f")},Pd=function(){return this.lazyStart?(i(this,_d,"f")||o(this,_d,new Promise((e=>{o(this,$d,e,"f")})),"f"),i(this,_d,"f")):Promise.resolve()},Ud=function(){var e;null===(e=i(this,wd,"f"))||void 0===e||e.remove(),o(this,wd,null,"f")},Ld=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,wd,document.createElement("descope-debugger"),"f"),Object.assign(i(this,wd,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Xu})),document.body.appendChild(i(this,wd,"f"))):i(this,hd,"m",Ud).call(this)}))},Md=function(e,t){var n;e&&this.debug&&(null===(n=i(this,wd,"f"))||void 0===n||n.updateData({title:e,description:t}))},Nd.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.7.1"}};const _u="__descope_webauthn_timed_out__";class $u extends Nd{static set sdkConfigOverrides(e){Nd.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Nd.sdkConfigOverrides}constructor(){const e=new dc({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Dd.add(this),this.stepState=new dc({}),qd.set(this,void 0),Fd.set(this,null),zd.set(this,null),Vd.set(this,{visibilitychange:i(this,Dd,"m",Jd).bind(this)}),this.bridgeVersion=$u.bridgeVersion,Hd.set(this,void 0),this.nativeCallbacks={},eu.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},iu.set(this,(e=>{e&&this.clearEmailVerification();const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,Dd,"m",ou).call(this,t):t()})),ru.set(this,((e,t,r,s,a=!1)=>{const l=[Pa,"E103202",Ua];if(this.flowState.current.action===ll){if(i(this,au,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,qd,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,fl,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 Bl(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,ru,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===$a)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,ru,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,ru,"f").call(this,e,t,r,s),i(this,lu,"f").call(this,p)}))),d),"f")}})),su.set(this,(()=>{clearTimeout(i(this,qd,"f")),o(this,qd,null,"f")})),au.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),lu.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,f,g;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,Dd,"m",Ru).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==Pa&&d!==Ua||!this.isRestartOnError||i(this,Dd,"m",Qd).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(f=e.data)||void 0===f?void 0:f.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==ll&&i(this,su,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Ac(Object.assign(Object.assign({},w),{lastUsedPerScreen:xc()})),jc(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),this.setValidationTrackingExecution(e.data.executionId),((e,t)=>{_l(e,t)})(this.projectId,this.flowId),void i(this,Dd,"m",Ru).call(this,"success",t)}this.storeLastAuthenticatedUser&&Ac(w,!0),k&&window.open(k,"_blank");const{executionId:S,stepId:I,stepName:C,screen:O,redirect:E,webauthn:A,error:x,samlIdpResponse:j,wsFedIdpResponse:R,nativeResponse:T}=e.data,_=Date.now();y!==ll?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${m}`,"",{screen:O,status:m,stepId:I,stepName:C,action:y,error:x}),(null===(g=O.state)||void 0===g?void 0:g.clientScripts)&&o(this,zd,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:I,stepName:C,executionId:S,action:y,redirectTo:null==E?void 0:E.url,redirectIsPopup:null==E?void 0:E.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==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.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:_})):this.flowState.update({action:y,reqTimestamp:_})})),cu.set(this,Hl((()=>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)}}))))),pu.set(this,void 0),fu.set(this,void 0),yu.set(this,null),Cu.set(this,Ql(((e,t,o)=>n(this,void 0,void 0,(function*(){var n;if("true"!==e.getAttribute("loading")&&"true"!==e.getAttribute("disabled")){if("true"===e.getAttribute("formnovalidate")||i(this,Dd,"m",bu).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,Dd,"m",Au).call(this,e,r,o);const s=i(this,Dd,"m",ku).call(this,e);try{const o=yield i(this,Dd,"m",wu).call(this),s=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const a=yield this.emailVerificationToken(e),l=Object.assign(Object.assign(Object.assign(Object.assign({},s),o),{origin:i(this,Dd,"a",mu)}),a&&{evpToken:a}),c=yield t(r,l);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(o,null===(n=null==c?void 0:c.data)||void 0===n?void 0:n.executionId),this.storeCredentials(o)}catch(e){throw s(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=e,this.setValidationTrackingSender(((e,t)=>n(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:n}){const i=yield this.sdk.flow.event(e,t,n);return{ok:i.ok,retryable:i.code>=500||429===i.code}}))))}nativeResume(e,t){var n,o,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const i=new URL(c.url);t=null===(n=i.searchParams)||void 0===n?void 0:n.get(Na),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get(qa))||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(Wa).split("_").pop();i(this,su,"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:{[oc(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(i=globalThis.descope)||void 0===i?void 0:i[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.21",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,i)=>{try{const i=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t);const o=this.nextRequestStatus.subscribe((()=>{var n;this.loggerWrapper.debug("Stopping script",e.id),(null===(n=i.stop)||void 0===n?void 0:n.call(i))&&(this.nextRequestStatus.unsubscribe(o),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}));"function"==typeof i.present&&n(e.id)}}catch(e){i(e)}}))})))));let o;const r=new Promise((e=>{o=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,r]).finally((()=>clearTimeout(o)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,o(this,Hd,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,Dd,"m",Xd).call(this),window.addEventListener("visibilitychange",i(this,Vd,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e,t,n;super.disconnectedCallback(),this.teardownValidationTracking(),i(this,Hd,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,i(this,Hd,"f")),o(this,Hd,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,su,"f").call(this),null===(n=i(this,Fd,"f"))||void 0===n||n.abort(),o(this,Fd,null,"f"),this.clearEmailVerification(),window.removeEventListener("visibilitychange",i(this,Vd,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=v(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:m,redirectTo:b,redirectIsPopup:w,redirectUrl:y,token:k,code:S,isPopup:I,exchangeError:C,webauthnTransactionId:O,webauthnOptions:E,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:R,locale:T,samlIdpResponseUrl:_,samlIdpResponseSamlResponse:$,samlIdpResponseRelayState:P,wsFedIdpResponseUrl:U,wsFedIdpResponseWresult:L,wsFedIdpResponseWctx:M,nativeResponseType:W,nativePayload:N,reqTimestamp:D}=e,q=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,z,V;const J=(()=>{const e=Ic(Cc);if(!e){const e=Math.floor(100*Math.random()+1);return Sc(Cc,e.toString()),e}return Number(e)})(),{outboundAppId:H,outboundAppScopes:K}=this,B=this.sdk.getLastUserLoginId();s("flowId")&&this.setValidationTrackingEnabled(!1);const Y=yield this.getFlowConfig();i(this,Dd,"m",gu).call(this,Y,p,s);const G=yield this.getProjectConfig(),X=Object.entries(G.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Z=x&&A?{callbackUrl:x,codeChallenge:A,backupCallbackUri:j}:void 0,Q=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 ee={};if(!p){jc(this.loggerWrapper);const e=[...Y.clientScripts||[],...Y.sdkScripts||[]];if(Y.conditions){let t=[];({startScreenId:F,conditionInteractionId:V,startScreenName:z,clientScripts:t,componentsConfig:ee}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=Oc[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:B,code:S,token:k,abTestingKey:J,lastAuth:Ec(B,this.loggerWrapper)},Y.conditions)),e.push(...t||[])}else Y.condition?({startScreenId:F,startScreenName:z,conditionInteractionId:V}=((e,t)=>{var n;const i=null===(n=Oc[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(Y.condition,{loginId:B,code:S,token:k,abTestingKey:J,lastAuth:Ec(B,this.loggerWrapper)})):(z=Y.startScreenName,F=Y.startScreenId);if(o(this,pu,F,"f"),o(this,fu,z,"f"),o(this,zd,this.loadSdkScripts(e),"f"),Y.fingerprintEnabled&&Y.fingerprintKey?yield us(Y.fingerprintKey,this.baseUrl):Dr(cs),!Yl(F,q)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Z},q),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:Ec(B,this.loggerWrapper),abTestingKey:J,locale:v(T).locale,nativeOptions:Q,outboundAppId:H,outboundAppScopes:K}),V,"",G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:i(this,Dd,"a",mu)},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return i(this,lu,"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:S,exchangeError:C,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&S||s("exchangeError")&&C))return void i(this,Dd,"m",Tu).call(this,p,S,C);if(p&&(s("token")&&k||s("code")&&S||s("exchangeError")&&C)){const e=yield this.sdk.flow.next(p,h,pl,Y.version,G.componentsVersion,{token:k,exchangeCode:S,exchangeError:C,origin:i(this,Dd,"a",mu)});return i(this,lu,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===hl&&_&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!$)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(Gl("SAMLResponse",t,"saml-response")),o.appendChild(Gl("RelayState",n,"saml-relay-state")),document.body.appendChild(o),i(o)})(_,$,P||"",Xl)}if(f===hl&&U&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!L)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(Gl("wa","wsignin1.0")),o.appendChild(Gl("wresult",t)),o.appendChild(Gl("wctx",n)),document.body.appendChild(o),i(o)})(U,L,M||"",Xl)}if(f===al&&(s("redirectTo")||s("deferredRedirect"))){if(!b)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===b)return;if("android"===R&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(b,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));let n=!1;const o=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:o,data:r}=e.data||{};"code"===o&&(n=!0,this.flowState.update({code:r.code,exchangeError:r.exchangeError}))};let r;this.loggerWrapper.debug("Starting popup closed detection");const s=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(s),i(this,Dd,"m",Ru).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(t)window.addEventListener("message",o),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",o)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=o,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(b),this.flowState.update({redirectTo:"no-op"}),i(this,Dd,"m",Ru).call(this,"popupclosed",{});return}if(f===cl||f===dl){if(!O||!E)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(l=i(this,Fd,"f"))||void 0===l||l.abort(),o(this,Fd,null,"f");const e=yield i(this,Dd,"m",nu).call(this,f,E),t=yield this.sdk.flow.next(p,h,pl,Y.version,G.componentsVersion,Object.assign({transactionId:O},e));i(this,lu,"f").call(this,t)}if(f===ul)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,pl,Y.version,G.componentsVersion,e);i(this,lu,"f").call(this,t)})),i(this,Dd,"m",Yd).call(this,W,N),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&i(this,ru,"f").call(this,p,h,Y.version,G.componentsVersion),!g&&!F)return void this.loggerWrapper.warn("No screen was found to show");const te=F||g,ne=yield this.getHtmlFilenameWithLocale(T,te),{oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=q,le={direction:Ll(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:B,name:this.sdk.getLastUserDisplayName()||B},componentsConfig:Object.assign(Object.assign(Object.assign({},Y.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||z,samlIdpUsername:ae,oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,action:f,locale:v(T).locale},ce=Ec(B,this.loggerWrapper);Yl(F,q)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==Y?void 0:Y.clientScripts)||[];yield i(this,Dd,"m",Ou).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Z},q),{lastAuth:ce,preview:this.preview,abTestingKey:J,client:this.client}),y&&{redirectUrl:y}),{locale:v(T).locale,nativeOptions:Q,outboundAppId:H,outboundAppScopes:K}),V,e,G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:i(this,Dd,"a",mu)},this.formConfigValues),this.getComponentsContext()),ic(t)),S&&{exchangeCode:S,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return i(this,lu,"f").call(this,o),o})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==m?void 0:m.clientScripts)||[];yield i(this,Dd,"m",Ou).call(this,n);const o=yield this.sdk.flow.next(p,h,e,Y.version,G.componentsVersion,Object.assign(Object.assign({origin:i(this,Dd,"a",mu)},this.getComponentsContext()),ic(t)),le.next.isCustomScreen);return i(this,lu,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield i(this,Dd,"m",tu).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen"),this.clearEmailVerification(),this.updateScreenUser(null==u?void 0:u.user);const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const f=p.content.cloneNode(!0),g=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield i(this,Dd,"m",uu).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${sl}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),wc(f,u,this.formConfig,this.loggerWrapper),this.applyComponentsState(f,null==u?void 0:u.componentsState),this.startEmailVerification(f);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(f,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield g;const r=this.contentRootElement;((e,t)=>{bc(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{bc(e,"descope-notp-image",t)})(r,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,f,u.cssVars,this.loggerWrapper),r.replaceChildren(f);const s=!t.htmlFilename;setTimeout((()=>{i(this,Dd,"m",Su).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&((e,t)=>{e.querySelectorAll("*[name]").forEach((n=>{n.addEventListener("blur",(()=>{var i;if(yl(n,e))return;const o=()=>{var e;const i=n.focus;n.focus=()=>{};const o=null===(e=n.reportValidity)||void 0===e?void 0:e.call(n);t&&!1===o&&t(n),setTimeout((()=>{n.focus=i}))};if("true"===n.getAttribute("invalid")||(null===(i=n.value)||void 0===i?void 0:i.length))return void o();const r={timer:void 0},s=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(r.timer),r.timer=void 0)};r.timer=setTimeout((()=>{e.removeEventListener("click",s),o(),r.timer=void 0}),150),e.addEventListener("click",s,{once:!0})}))}))})(r,(e=>this.trackValidationErrors([e],i(this,Dd,"a",vu)))),((e,t)=>{fc(e,null==t?void 0:t.inputs),fc(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),i(this,Dd,"m",hu).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),Kl(r,this.autoFocus,s),i(this,Dd,"m",xu).call(this,h)})),i(this,Dd,"m",ju).call(this,d,h),r.querySelector(`[${sl}="polling"]`)&&d(fl,{})}));c?i(this,Dd,"m",ou).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Fa}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}qd=new WeakMap,Fd=new WeakMap,zd=new WeakMap,Vd=new WeakMap,Hd=new WeakMap,eu=new WeakMap,iu=new WeakMap,ru=new WeakMap,su=new WeakMap,au=new WeakMap,lu=new WeakMap,cu=new WeakMap,pu=new WeakMap,fu=new WeakMap,yu=new WeakMap,Cu=new WeakMap,Dd=new WeakSet,Jd=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},Kd=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,Dd,"m",Yd).call(this,"beforeScreen",{screen:e,context:t})}))}))},Bd=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,Dd,"m",Yd).call(this,"afterScreen",{screen:e})},Yd=function(e,t){i(this,Dd,"m",Ru).call(this,"bridge",{type:e,payload:t})},Gd=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${sl}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},Xd=function(){var e,n,o,r;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=void 0===n?{}:n,{errorText:o,errorType:r}=i,s=t(i,["errorText","errorType"]),a=t(e,["screenState"]);return Object.assign(Object.assign({},a),{screenState:s})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,Dd,"m",Gd).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,Dd,"m",Zd).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===(r=this.flowState)||void 0===r||r.subscribe((({screenId:e,executionId:t})=>{var n;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(n=this.logger)||void 0===n||n.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},Zd=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=""}))})),Kl(this.contentRootElement,this.autoFocus,!1))},Qd=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")}))},tu=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=>{const t=(n=e.screenState,i=(e,t)=>ml.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(0,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;(o||r)&&(t.error={text:o,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return nc.forEach((({key:n,from:i})=>{const o=i(e);void 0!==o&&(t[n]=o)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t})(t(r,["next","stepName"]));let c=yield i(this,Dd,"m",Kd).call(this,a,l,s);c||(c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,l,s,this)));const d=!this.stepState.current.htmlFilename;if(i(this,iu,"f").call(this,c),s&&(s.isCustomScreen=c),i(this,eu,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,eu,c,"f"),c?this.stepState.unsubscribeAll():i(this,Dd,"m",Xd).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),i(this,Dd,"m",hu).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},nu=function(e,t){return n(this,void 0,void 0,(function*(){const n=new AbortController;try{const i=e===cl?this.sdk.webauthn.helpers.create(t,n):this.sdk.webauthn.helpers.get(t,n),o=yield Bl(9e4,i,_u);return o!==_u?{response:o}:(n.abort(),this.loggerWrapper.warn("WebAuthn operation timed out after 90000ms"),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},ou=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")},du=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)}))}},uu=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,Fd,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield yc())){const{options:e,transactionId:r}=(yield i(this,cu,"f").call(this))||{};e&&r&&(i(this,Dd,"m",du).call(this,s),o(this,Fd,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,Fd,"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)})))}}))},hu=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,Dd,"m",Ru).call(this,"ready",{}),t||i(this,Dd,"m",Bd).call(this,n),i(this,Dd,"m",Ru).call(this,"page-updated",{screenName:n}),i(this,Dd,"m",Ru).call(this,"screen-updated",{screenName:n})},gu=function(e,t,n){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&n("executionId")&&this.setValidationTrackingExecution(t)},vu=function(){var e,t,n,o,r,s,a;const l=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==l?void 0:l.executionId)?{executionId:l.executionId,screenId:l.screenId,screenName:(null===(a=null===(s=this.stepState)||void 0===s?void 0:s.current)||void 0===a?void 0:a.stepName)||l.stepName}:{executionId:void 0,screenId:null!==(t=i(this,pu,"f"))&&void 0!==t?t:null==l?void 0:l.screenId,screenName:null!==(n=i(this,fu,"f"))&&void 0!==n?n:(null===(r=null===(o=this.stepState)||void 0===o?void 0:o.current)||void 0===r?void 0:r.stepName)||(null==l?void 0:l.stepName)}},mu=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},bu=function(){let e=!0;const t=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((n=>{var i,o,r;"slot"===n.localName||yl(n,this.contentRootElement)||(null===(i=n.reportValidity)||void 0===i||i.call(n),n.validity&&!n.validity.valid&&t.push(n),e&&(e=null===(r=null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))||void 0===r||r))})),t.length&&this.trackValidationErrors(t,i(this,Dd,"a",vu)),e},wu=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})),{})}))},ku=function(e){var t,r;const s=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),a=(null===(r=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===r?void 0:r.clientScripts)||[];e.setAttribute("loading","true"),s.forEach((e=>e.setAttribute("disabled","true")));const l=()=>{e.removeAttribute("loading"),s.forEach((e=>{e.removeAttribute("disabled")}))},c=e=>n(this,void 0,void 0,(function*(){var t;if(this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",c),!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&a.length)return o(this,zd,(()=>n(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(a)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void l();l();const i=yield this.getFlowConfig(),r=[...i.clientScripts||[],...i.sdkScripts||[]];this.loadSdkScripts(r)})),d=()=>{var e;window.removeEventListener("pageshow",i(this,yu,"f")),o(this,yu,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",i(this,yu,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&c(),this.removeEventListener("popupclosed",c),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},u=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",c,{once:!0}):(this.nextRequestStatus.unsubscribe(u),"success"===this.flowStatus?(this.removeEventListener("popupclosed",c),l()):d())}));return l},Su=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,Dd,"m",Iu).call(this,e)))},Iu=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},Ou=function(e){return n(this,void 0,void 0,(function*(){if(i(this,zd,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,zd,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const o=[];for(const e of t)"function"==typeof e.refresh&&o.push(e.refresh());if(o.length>0)try{yield Bl(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Eu=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var o;(null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))&&i(this,Cu,"f").call(this,n,e,t)}))}))},Au=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=xc();n[e]=t,Sc(vl,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},xu=function(e){var t;const n=null===(t=Ec(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},ju=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${za}]), [data-type="button"]:not([${za}]`).forEach((n=>{n.onclick=()=>{i(this,Cu,"f").call(this,n,e,t)}})),i(this,Dd,"m",Eu).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Fa}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Ru=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Tu=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s="descope-wc"===o&&!!r,a=s?function(e){const t=Nl(e);if(t)return t===window.location.origin||Nl(function(){const e=new URLSearchParams(window.location.search).getAll("popup_opener_origin");return 1===e.length?e[0]:void 0}())===t?t:void 0}(r):void 0;s&&!a&&this.loggerWrapper.warn("Popup opener origin is not approved for this project, add it to the approved domains to send the OAuth result to it",r);const l={data:{code:t,exchangeError:n},action:"code"};if(a){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",a);try{window.opener.postMessage(l,a)}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(l),t.close()}try{window.close()}catch(e){}},$u.bridgeVersion=3,customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",$u);var Pu=Object.freeze({__proto__:null,default:$u});const Uu=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},Lu=(e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Uu(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c};var Mu,Wu,Nu,Du,qu,Fu,zu,Vu,Ju,Hu,Ku;const Bu=document.createElement("template");Bu.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 Yu=r(H)(HTMLElement);class Gu extends Yu{constructor(){super(),Mu.add(this),Wu.set(this,new dc({messages:[]})),Nu.set(this,void 0),Du.set(this,void 0),qu.set(this,void 0),Fu.set(this,{resize:i(this,Mu,"m",Ku).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Bu.content.cloneNode(!0)),o(this,Nu,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Du,i(this,Nu,"f").querySelector(".content"),"f"),o(this,qu,i(this,Nu,"f").querySelector(".header"),"f"),i(this,Mu,"m",zu).call(this)}updateData(e){i(this,Wu,"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),Lu(i(this,Nu,"f"),i(this,qu,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Fu,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(i(this,Nu,"f")),i(this,Nu,"f").onresize=i(this,Mu,"m",Hu).bind(this),i(this,Wu,"f").subscribe(i(this,Mu,"m",Vu).bind(this))}))}disconnectedCallback(){i(this,Wu,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Fu,"f").resize)}}Wu=new WeakMap,Nu=new WeakMap,Du=new WeakMap,qu=new WeakMap,Fu=new WeakMap,Mu=new WeakSet,zu=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,Nu,"f").style.top="32px",i(this,Nu,"f").style.left=window.innerWidth-300-32+"px"},Vu=function(e){i(this,Mu,"m",Ju).call(this,e),i(this,Mu,"m",Hu).call(this)},Ju=function(e){i(this,Du,"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 ${g(e.title)}\n </div>\n <div class="msg_desc">\n ${g(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Hu=function(){i(this,Du,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Ku=function(){const[e,t]=Uu(i(this,Nu,"f"),Number.parseInt(i(this,Nu,"f").style.left,10),Number.parseInt(i(this,Nu,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Nu,"f").style.top=`${t}px`,i(this,Nu,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Gu);var Xu=Object.freeze({__proto__:null,default:Gu});return va}();
6
+ /*! js-cookie v3.0.8 | MIT */function lr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)"__proto__"!==i&&(e[i]=n[i])}return e}var cr=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=lr({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in i||(i[a]=t.read(s,a)),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",lr({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,lr({},this.attributes,t))},withConverter:function(t){return e(lr({},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 dr={default:"endpoint"},ur="Blocked by CSP",hr="The endpoint parameter is not a valid URL",pr="Failed to load the JS script of the agent",fr="9319";function gr(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===ur||s===hr)n.exclude(),r=0;else if(s===fr)n.exclude();else if(s===pr){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var vr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",mr=vr;function br(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:vr,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return gr(e,wr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===fr?new Error(pr):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function wr(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(hr);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(pr))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(ur)})).then(yr)}function yr(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(fr);return n}const kr="3.2.0",Sr="undefined"!=typeof window,Ir=Math.pow(2,31)-1,Cr=2e4,Or=`https://descopecdn.com/npm/oidc-client-ts@${kr}/dist/browser/oidc-client-ts.min.js`,Er=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${kr}/dist/browser/oidc-client-ts.min.js`,Ar=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let xr;const jr=e=>{try{return Hn(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:jr(n)},Tr=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?jr(i):void 0)},_r=e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||Tr(e),cookieExpiration:e.cookieExpiration||Rr(e)},s)},$r=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Pr=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 _r(n)},Ur=()=>Sr&&!!window.descopeBridge,Lr=(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 Ar.includes(n)},Mr=void 0!==xr||Sr&&void 0!==window.localStorage,Wr=(e,t)=>{var n,i;return null===(i=null===(n=xr||Sr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},Nr=e=>{var t,n;return null===(n=null===(t=xr||Sr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Dr=e=>{var t,n;return null===(n=null===(t=xr||Sr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},qr=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==xr?void 0:xr.key)||void 0===t?void 0:t.call(xr,e))&&void 0!==n?n:Sr&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},Fr=e=>{var t,n;return Sr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},zr=e=>{var t,n;try{Sr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},Vr=(...e)=>{console.debug(...e)},Jr=(...e)=>{console.warn(...e)},Hr=e=>e?e.getTime()-(new Date).getTime():0,Kr="DS",Br="DSR",Yr="DSI",Gr="DSRCN";function Xr(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Zr(i);cr.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}function Zr(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 Qr=e=>(null==e?void 0:e.cookieName)||Kr,es=e=>(null==e?void 0:e.cookieName)||Br;function ts(e="",t){return cr.get(es(t))||Nr(`${e}${Br}`)||""}function ns(e="",t){return cr.get(Qr(t))||Nr(`${e}${Kr}`)||""}function is(e=""){return Nr(`${e}${Yr}`)||""}function os(e="",t,n,i){Dr(`${e}${Br}`),Dr(`${e}${Kr}`),Dr(`${e}${Yr}`),Dr(`${e}${Gr}`);const o=Qr(t);cr.remove(o,null==i?void 0:i.session);const r=es(n);cr.remove(r,null==i?void 0:i.refresh)}const rs=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||ts(e,t)});if(!n){const t=function(e=""){return Nr(`${e}${Gr}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return Nr(`${e}DTD`)||""}(e);r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return Nr(`${e}DKD`)||""}(e);return s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-known-device-token":s})),o},ss=Sr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",as="vsid",ls="vrid",cs="fp",ds=(e=!1)=>{const t=Nr(cs);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},us=async(e,t=ss)=>{try{if(ds())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=br({apiKey:e,endpoint:[i.toString(),dr],scriptUrlPattern:[r,mr]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[as]:e,[ls]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Wr(cs,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},hs=e=>{const t=ds(!0);return t&&e.body&&(e.body.fpData=t),e},ps="descopeFlowNonce",fs="X-Descope-Flow-Nonce",gs="/v1/flow/start",vs="/v1/flow/next",ms=(e,t=ps)=>`${t}${e}`,bs=(e,t=ps)=>{try{const n=ms(e,t),i=Nr(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(ws(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},ws=(e,t=ps)=>{try{const n=ms(e,t);Dr(n)}catch(e){console.error("Error removing flow nonce:",e)}},ys=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},ks=e=>{var t;return e.path===vs&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ys(e.body.executionId):null},Ss="dls_last_user_login_id",Is="dls_last_user_display_name",Cs=e=>Wr(Ss,e),Os=()=>Nr(Ss),Es=()=>Nr(Is),As=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Os(),r=Es();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},xs="DSLI",js=e=>async(...t)=>{const n=await e(...t);return zr(xs),n};function Rs(){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,t){const n=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Ws(n.publicKey.challenge),n.publicKey.user.id=Ws(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Ws(e.id)})),n}(e);t&&(n.signal=t.signal);try{return i=await navigator.credentials.create(n),JSON.stringify({id:i.id,rawId:Ns(i.rawId),type:i.type,response:{attestationObject:Ns(i.response.attestationObject),clientDataJSON:Ns(i.response.clientDataJSON)}})}catch(e){throw await Ps(e,n,!0)}var i}async function _s(e,t){const n=Ls(e);t&&(n.signal=t.signal);try{return Ms(await navigator.credentials.get(n))}catch(e){throw await Ps(e,n,!1)}}async function $s(e,t){const n=Ls(e);n.signal=t.signal,n.mediation="conditional";try{return Ms(await navigator.credentials.get(n))}catch(e){throw await Ps(e,n,!1)}}async function Ps(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var i,o;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await Us())return"webauthn_unsupported";const s="platform"===(null===(o=null===(i=null==t?void 0:t.publicKey)||void 0===i?void 0:i.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await Us(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function Us(e=!1){var t,n;if(!Sr)return Promise.resolve(!1);if(Ur()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function Ls(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Ws(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Ws(e.id)})),n}function Ms(e){return JSON.stringify({id:e.id,rawId:Ns(e.rawId),type:e.type,response:{authenticatorData:Ns(e.response.authenticatorData),clientDataJSON:Ns(e.response.clientDataJSON),signature:Ns(e.response.signature),userHandle:e.response.userHandle?Ns(e.response.userHandle):void 0}})}function Ws(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ns(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ds,qs=(Ds=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await Ts(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await _s(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await Ts(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await _s(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await Ts(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Ts,get:_s,isSupported:Us,conditional:$s}}),(...e)=>{const t=Ds(...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";async function zs(e,t){var n;try{await Vs(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Vs(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var Js=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Us(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let Hs;const Ks=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Ks(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Bs=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{Hs||(Hs=(async()=>{try{return require("oidc-client-ts")}catch(e){return Ks([Or,Er],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await Hs;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),Wr(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=Nr(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||is(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return Dr(o),t||window.location.replace(s),r}}},Ys=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,xr=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Sr?(i&&o&&us(i).catch((()=>null)),e($r(r,{beforeRequest:hs}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.54.6"},t.baseHeaders)}))),(e=>t=>{const n=Rs(),i=Rs(),o=Rs(),r=Rs(),s=e($r(t,{afterRequest:async(e,t)=>{if(Lr(e,t))Vr("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await Pr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await Pr(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Ji(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var i;const{enableFlowNonce:o=!0,nonceStoragePrefix:r=ps}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=ps)=>{try{if(!Mr)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==xr?void 0:xr.length)&&void 0!==t?t:Sr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=qr(o);if(t&&t.startsWith(e)){const n=Nr(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Dr(t)}catch(e){Dr(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(r);const a=e($r(s,{afterRequest:async(e,t)=>{var n;if(e.path!==gs&&e.path!==vs)return;const{nonce:i,seq:o,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(fs),i=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const i=Number(n);return Number.isSafeInteger(i)?i:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=ks(e)),{nonce:n,seq:i,executionId:ys(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!i||!s)return;const a=e.path===gs,l=null===(n=bs(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==o&&void 0!==l&&o<=l||((e,t,n,i=ps,o)=>{try{const r=ms(e,i),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};Wr(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,i,a,r,null!=o?o:a?void 0:l)},beforeRequest:e=>{if(e.path===vs){const t=ks(e);if(t){const n=((e,t=ps)=>{var n,i;return null!==(i=null===(n=bs(e,t))||void 0===n?void 0:n.value)&&void 0!==i?i:null})(t,r);n&&(e.headers=e.headers||{},e.headers[fs]=n)}}return e}}));if(null===(i=a.flow)||void 0===i?void 0:i.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const i=e;let o;e=new Promise((e=>{o=e})),await i;try{return await t(...n)}finally{o()}}}return a}),(e=>t=>{const n=e($r(t,{afterRequest:async(e,t)=>{if(Lr(e,t))return void zr(xs);const n=await Pr(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,i;try{Sr&&(null===(i=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i||i.call(n,e,t))}catch(e){}})(xs,String(n.sessionExpiration))}}));return Ji(n,["logout","logoutAll","oidc.logout"],js)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);const r=!!i,s="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!r||Ur())return Object.assign(e(o),{markUserActive:()=>{Jr("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(Vr("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Sr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(Vr("Expiration time passed, refreshing session"),g())}));const f=e($r(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await Pr(t);if(Lr(e,t))Vr("Session invalidated, canceling all timers"),a(),c=void 0;else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);Vr("Could not extract expiration time from session token, trying to decode the token");try{const t=Hn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void Vr("Could not extract expiration time from session token");d=i,h=r>0;let e=((e,t)=>{let n;return t>0?(n=1e3*t,Vr(`Using provided nextRefreshSeconds: ${t}s`)):n=Hr(e)-Cr,n>Ir&&(Vr(`Timeout is too large (${n}ms), setting it to ${Ir}ms`),n=Ir),n})(c,r);a(),e<=Cr&&(e=Math.max(Hr(c),Cr));const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Vr(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Sr&&"hidden"===document.visibilityState)Vr("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return Vr("Skipping refresh due to timer - user is idle"),void(p=!0);Vr("Refreshing session due to timer"),g()}}),e)}}})),g=()=>f.refresh(ts()||d).catch((e=>{Jr("Automatic session refresh failed",e)}));return Object.assign(Ji(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Vr("Clearing all timers"),a(),n})),{markUserActive:u?()=>{Vr("markUserActive() called"),h||Vr("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(Vr("User became active after skipped refresh, triggering refresh"),p=!1,a(),g())}:()=>{Jr("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:Os,getLastUserDisplayName:Es});const s=e($r(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=_r((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(Cs(r),(e=>{Wr(Is,e)})(s)):(null==o?void 0:o.loginId)&&Cs(o.loginId)}}));let a=Ji(s,["flow.start"],As);return a=Ji(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Dr(Ss),Dr(Is)),i})(o)),Object.assign(a,{getLastUserLoginId:Os,getLastUserDisplayName:Es})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!Sr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e($r(Object.assign({refreshCookieName:a},l),{beforeRequest:rs(s,r,a),afterRequest:async(e,t)=>{if(Lr(e,t))Vr("Session invalidated, clearing persisted tokens"),os(s,o,r,c);else{const e=await Pr(t);e.cookieName?Wr(`${s||""}${Gr}`,e.cookieName):e.refreshJwt&&Dr(`${s||""}${Gr}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d,knownDeviceJwt:u}=e;let h;if(c)if(i){Dr(`${n}${Br}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,l=es(i);s&&"https:"!==window.location.protocol&&Jr("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Xr(l,c,d);const u=Zr(a);h=Object.assign(Object.assign({},h),{refresh:{path:d.cookiePath,domain:u?a:void 0}})}else{const e=es(i);cr.remove(e),Wr(`${n}${Br}`,c)}if(l)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=Qr(t);i&&"https:"!==window.location.protocol&&Jr("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});Xr(r,l,c);const d=Zr(o);h=Object.assign(Object.assign({},h),{session:{path:c.cookiePath,domain:d?o:void 0}})}else Wr(`${n}${Kr}`,l);return e.idToken&&Wr(`${n}${Yr}`,e.idToken),d&&Wr(`${n}DTD`,d),u&&Wr(`${n}DKD`,u),h})(e,o,s,r);n&&(c=n)}}})),u=Ji(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return os(e,t,n,null==i?void 0:i()),s})(s,o,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>ts(s,r),getSessionToken:()=>ns(s,o),getIdToken:()=>is(s)})}))((e=>{const t=ar(e),n=Bs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(Ur())return Vr(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&Sr&&void 0!==window.localStorage&&!Fr(xs)&&!Nr(Ss)&&!Fr("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=ns(),a=ts();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){Vr("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:Js(t),webauthn:qs(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){zs(i,e)},requestAuthentication(e){zs(i,e)}},async oneTap(e,t,n,o,r){await Vs(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+Fs),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Sr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+Fs);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),Gs={allOutboundApps:"/v1/mgmt/outbound/apps",connectedOutboundApps:"/v1/mgmt/outbound/apps-with-user-token"},Xs={me:"/v1/auth/me"},Zs=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)})),Qs=()=>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"}]})}))})),ea=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))})),ta=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))})),na=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>n(void 0,void 0,void 0,(function*(){if(t)return Qs();const n=yield e.get(Gs.allOutboundApps);return yield Zs(n),n.json()})),getConnectedOutboundApps:i=>n(void 0,[i],void 0,(function*({userId:n,tenantId:i}){if(t)return ea();const o=yield e.get(Gs.connectedOutboundApps,{queryParams:i?{userId:n,tenantId:i}:{userId:n}});return yield Zs(o),o.json()}))}),ia=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return ta();const n=yield e.get(Xs.me);return yield Zs(n),n.json()}))}),oa=l((e=>{var t,s,a,l;const c=r(x,E,w,Cn,j)(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")||de}get api(){return i(this,s,"f")||i(this,t,"m",a).call(this),i(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{i(this,s,"f")&&i(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,n)=>{const i=Ys(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.7.23"}}));return{outboundApps:na({httpClient:i.httpClient,mock:t}),user:Object.assign({},ia({httpClient:i.httpClient,mock:t})),httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),ra=un("users/me",((e,{extra:{api:t}})=>t.user.me())),sa={action:ra,reducer:Un(ra)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Ln((e=>e.me)))},aa=l((e=>{const t=r(wn({name:"widget",initialState:zn,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{sa.reducer(e),Fn.reducer(e),Nn.reducer(e)},asyncActions:{getMe:sa.action,getOutboundApps:Nn.action,getConnectedOutboundApps:Fn.action}}),O,w,oa)(e);return class extends t{constructor(...e){super(...e),this.state=zn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),la="widget-flow",ca=l((e=>{var t,o,s;return s=class extends(r(Sn,O,le,aa,Cn,w,me,jn)(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=Pn(la);r&&(!function(e){if(window.history.replaceState&&Pn(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())}}(la),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new Q((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),da=_t((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))))),ua=_t((e=>e.me.data),(e=>e.userId)),ha=l((e=>{var t,o,a,l,c;return c=class extends(r(w,O,z,Y,In("outbound-applications-widget"),aa)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,n,o){"allowed-outbound-apps-ids"===e&&n!==o&&this.actions.setAllowedAppsIds(i(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(i(this,t,"a",l)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:ua(this.state),tenantId:this.tenantId})]);const r=yield i(this,t,"m",o).call(this);i(this,t,"m",a).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));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})),pa=l((e=>class extends(r(me,E)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),fa=l((e=>{var t,s,a,l,c,d,u,h,p,f,g,v,m,b,y,k,S;return S=class extends(r(Sn,pa,aa,w,ha,le,jn)(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(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)})((e=>{i(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),i(this,t,"m",y).call(this,da(this.state)),i(this,t,"m",p).call(this),i(this,t,"m",v).call(this),this.subscribe(i(this,k,"f").bind(this),da)}))}},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(){i(this,s,"f").connectFlowId&&(o(this,a,this.createFlowModal({"data-id":"outbound-apps-connect"}),"f"),i(this,a,"f").afterClose=()=>{var e;if(i(this,u,"f")){const t=null===(e=i(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",i(this,u,"f")),o(this,u,null,"f")}},o(this,c,new Q((()=>{var e;return null===(e=i(this,a,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(i(this,c,"f")))},f=function(e,t,n){e.open(),t.removeEventListener("page-updated",n)},g=function(e,n){var o;const r=null===(o=e.ele)||void 0===o?void 0:o.querySelector("descope-wc"),s=()=>i(this,t,"m",f).call(this,e,r,s);n=s,null==r||r.addEventListener("page-updated",n)},v=function(){o(this,l,this.createFlowModal({"data-id":"outbound-apps-disconnect"}),"f"),o(this,d,new Q((()=>{var e;return null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,l,"f").afterClose=()=>{var e;if(i(this,h,"f")){const t=null===(e=i(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",i(this,h,"f")),o(this,h,null,"f")}},this.syncFlowTheme(i(this,d,"f"))},m=function(e){i(this,a,"f").setContent(this.createFlowTemplate({flowId:i(this,s,"f").connectFlowId,lazyStart:!1,outboundAppId:e})),i(this,t,"m",g).call(this,i(this,a,"f"),i(this,u,"f")),i(this,c,"f").onSuccess((()=>{i(this,a,"f").close(),this.actions.getConnectedOutboundApps({userId:ua(this.state),tenantId:this.tenantId})}))},b=function(e){i(this,l,"f").setContent(this.createFlowTemplate({flowId:i(this,s,"f").disconnectFlowId,lazyStart:!1,outboundAppId:e})),i(this,t,"m",g).call(this,i(this,l,"f"),i(this,h,"f")),i(this,d,"f").onSuccess((()=>{i(this,l,"f").close(),this.actions.getConnectedOutboundApps({userId:ua(this.state)})}))},y=function(e){o(this,s,new se((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),i(this,s,"f").onConnectClick((({id:e})=>{i(this,t,"m",m).call(this,e)})),i(this,s,"f").onDisconnectClick((({id:e})=>{i(this,t,"m",b).call(this,e)})),i(this,s,"f").data=e},S})),ga=l((e=>class extends(r(U,me,ca,fa,$n)(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)}))}})),va=r((e=>class extends(ga(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 Pu})).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.7.23"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",va);const ma=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var ba,wa,ya,ka,Sa,Ia,Ca,Oa,Ea,Aa;const xa=document.createElement("template");xa.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 ja=r(H)(HTMLElement);class Ra extends ja{constructor(){var e;super(),ba.add(this),wa.set(this,new f({messages:[]})),ya.set(this,void 0),ka.set(this,void 0),Sa.set(this,void 0),Ia.set(this,{resize:i(this,ba,"m",Aa).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(xa.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,ya,this.shadowRoot.querySelector(".debugger"),"f"),i(this,ya,"f").style.top="32px",i(this,ya,"f").style.left=window.innerWidth-300-32+"px",o(this,ka,i(this,ya,"f").querySelector(".content"),"f"),o(this,Sa,i(this,ya,"f").querySelector(".header"),"f")}updateData(e){i(this,wa,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=ma(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,ya,"f"),i(this,Sa,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Ia,"f").resize),(e=i(this,ya,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},i(this,ya,"f").onresize=i(this,ba,"m",Ea).bind(this),i(this,wa,"f").subscribe(i(this,ba,"m",Ca).bind(this))}disconnectedCallback(){i(this,wa,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Ia,"f").resize)}}wa=new WeakMap,ya=new WeakMap,ka=new WeakMap,Sa=new WeakMap,Ia=new WeakMap,ba=new WeakSet,Ca=function(e){i(this,ba,"m",Oa).call(this,e),i(this,ba,"m",Ea).call(this)},Oa=function(e){i(this,ka,"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 ${g(e.title)}\n </div>\n <div class="msg_desc">\n ${g(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Ea=function(){i(this,ka,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Aa=function(){const[e,t]=ma(i(this,ya,"f"),Number.parseInt(i(this,ya,"f").style.left,10),Number.parseInt(i(this,ya,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,ya,"f").style.top=`${t}px`,i(this,ya,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Ra);var Ta=Object.freeze({__proto__:null});const _a="undefined"!=typeof localStorage,$a="J151000",Pa="E103205",Ua="E108201",La=_a&&localStorage.getItem("base.content.url")||"",Ma="base.ui.components.url";_a&&localStorage.getItem(Ma),_a&&localStorage.getItem(Ma);const Wa="descope-login-flow",Na="code",Da="redirect_mode",qa="err",Fa="data-exclude-field",za="data-exclude-next",Va="dls_last_auth",Ja="dls_last_submitted_login_id",Ha="state_id",Ka="saml_idp_state_id",Ba="wsfed_idp_state_id",Ya="saml_idp_username",Ga="descope_idp_initiated",Xa="sso_app_id",Za="custom_app_id",Qa="third_party_app_id",el="third_party_app_state_id",tl="oidc_login_hint",nl="oidc_prompt",il="oidc_resource",ol="oidc_error_redirect_uri",rl="application_scopes",sl="data-type",al="redirect",ll="poll",cl="webauthnCreate",dl="webauthnGet",ul="nativeBridge",hl="loadForm",pl="submit",fl="polling",gl=["descope-multi-select-combo-box","descope-text-area"],vl="dls_last_auth_in_flight",ml=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"],bl=["hide","disable","read-only"],wl="hidden";function yl(e,t){const n=e.closest(`.${wl}`);return!!n&&n!==t}const kl=/(["\\])/g;function Sl(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(kl,"\\$1")}function Il(e,t){return Array.from(e.querySelectorAll(`[id="${Sl(t)}"]`))}function Cl(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&Il(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove(wl);break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(n).forEach((i=>{const o=n[i],r=t[i];o!==r&&Il(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add(wl);break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}var Ol;!function(e){e.backward="backward",e.forward="forward"}(Ol||(Ol={}));const El=new Set,Al=(e,t)=>({origin:window.location.origin,pathname:window.location.pathname,hash:window.location.hash,projectId:e,flowId:t}),xl=(e,t)=>`dls_sso_query_params_${e}_${t}`,jl=e=>Object.values(null!=e?e:{}).some(Boolean),Rl=()=>{var e,t,n;try{const[i]=null!==(n=null===(t=null===(e=window.performance)||void 0===e?void 0:e.getEntriesByType)||void 0===t?void 0:t.call(e,"navigation"))&&void 0!==n?n:[],o=i;if("reload"!==(null==o?void 0:o.type)||!o.name)return!1;const r=new URL(o.name,window.location.href);return r.origin===window.location.origin&&r.pathname===window.location.pathname&&r.hash===window.location.hash}catch(e){return!1}},Tl=(e,t)=>(null==e?void 0:e.origin)===t.origin&&(null==e?void 0:e.pathname)===t.pathname&&(null==e?void 0:e.hash)===t.hash&&(null==e?void 0:e.projectId)===t.projectId&&(null==e?void 0:e.flowId)===t.flowId,_l=(e,t)=>{var n,i;try{const o=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(xl(e,t));if(!o)return;const r=JSON.parse(o);Tl(null==r?void 0:r.scope,Al(e,t))&&(null===(i=window.sessionStorage)||void 0===i||i.removeItem(xl(e,t)))}catch(e){}},$l=["descope-enriched-text"];function Pl(e){return new URLSearchParams(window.location.search).get(e)}function Ul(e){if(window.history.replaceState&&Pl(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 Ll(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Ol.forward:n<i?Ol.backward:void 0}const Ml=e=>{let[t="",n=""]=(Pl(Wa)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Wl(){Ul(Wa)}function Nl(e){try{const{origin:t}=new URL(e);return"null"===t?void 0:t}catch(e){return}}function Dl(){return Pl(Ba)}function ql(){Ul(Ba)}function Fl(){return Pl(rl)}function zl(){Ul(rl)}const Vl=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Jl=(e,t,n)=>{const{executionId:i,stepId:o,executionFlowId:r}=Ml(e);if(r&&e!==r)return n.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(i||o)&&Wl();const s=Pl("t")||void 0;s&&Ul("t");const a=Pl(Na)||void 0;a&&Ul(Na);const l="popup"===Pl(Da);l&&Ul(Da);const c=Pl(qa)||void 0;c&&Ul(qa);const{redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p}={redirectAuthCodeChallenge:Pl("ra-challenge"),redirectAuthCallbackUrl:Pl("ra-callback"),redirectAuthBackupCallbackUri:Pl("ra-backup-callback"),redirectAuthInitiator:Pl("ra-initiator")},f=Pl(Ha);f&&Ul(Ha);const g=Pl(Ka);g&&Ul(Ka);const v=Dl();v&&ql();const m=Pl(Ya);g&&Ul(Ya);const b=Pl(Ga);b&&Ul(Ga);const w=Pl(Xa);w&&Ul(Xa);const y=Pl(Za);y&&Ul(Za);const k=Pl(Qa);k&&Ul(Qa);const S=Pl(el);S&&Ul(el);const I=Fl();I&&zl();const C=Pl(tl);C&&Ul(tl);const O=Pl(nl);O&&Ul(nl);const E=Pl(ol);E&&Ul(ol);const A=Pl(il);A&&Ul(il);const x={oidcIdpStateId:f,samlIdpStateId:g,wsfedIdpStateId:v,samlIdpUsername:m,descopeIdpInitiated:"true"===b,ssoAppId:w,customAppId:y,oidcLoginHint:C,oidcPrompt:O,oidcErrorRedirectUri:E,oidcResource:A,thirdPartyAppId:k,thirdPartyAppStateId:S,applicationScopes:I},j=((e,t)=>{const n=[(i=Al(e,t)).origin,i.pathname,i.hash,i.projectId,i.flowId].join("|");var i;return!El.has(n)&&(El.add(n),!0)})(t,e);let R=x;if(jl(x))((e,t,n)=>{var i;if(jl(e))try{const o={params:e,scope:Al(t,n),ts:Date.now()};null===(i=window.sessionStorage)||void 0===i||i.setItem(xl(t,n),JSON.stringify(o))}catch(e){}})(x,t,e);else if(!r){const i=j?((e,t)=>{var n;if(!Rl())return null;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(xl(e,t));if(!i)return null;const o=JSON.parse(i);return Tl(null==o?void 0:o.scope,Al(e,t))?Date.now()-o.ts>=6e5?null:o.params:null}catch(e){return null}})(t,e):null;i?(n.debug("Restored SSO query params after a page reload"),R=i):((e,t)=>{Rl()||_l(e,t)})(t,e)}return{executionId:i,stepId:o,token:s,code:a,isPopup:l,exchangeError:c,redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p,ssoQueryParams:R}},Hl=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},Kl=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=Array.from(e.querySelectorAll('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])')).find((t=>!yl(t,e)));setTimeout((()=>{null==t||t.focus()}))}};function Bl(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const Yl=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||i||o||r||s||a||l||c||d||u||h||p),Gl=(e,t,n)=>{const i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,n&&i.setAttribute("role",n),i},Xl=e=>null==e?void 0:e.submit(),Zl=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Ql=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},ec={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",reuse:"data-password-policy-value-reuse",activePolicies:"active-policies",availablePolicies:"available-policies"},tc=(e,t)=>{var n;const i=null==e?void 0:e.componentsDynamicAttrs;if(!i)return;const o=Object.entries(i).find((([e])=>(e=>{var t;return null===(t=e.match(/\[data-name=["']([^"']+)["']\]/))||void 0===t?void 0:t[1]})(e)===t));return null===(n=null==o?void 0:o[1])||void 0===n?void 0:n.attributes},nc=[{key:"totp",from:e=>e.totp},{key:"notp",from:e=>e.notp},{key:"sentTo",from:e=>e.sentTo},{key:"sso",from:e=>e.sso},{key:"selfProvisionDomains",from:e=>e.selfProvisionDomains},{key:"inboundAppApproveScopes",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data}},{key:"securityQuestionsSetup",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqSetup}},{key:"securityQuestionsVerify",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqVerify}},{key:"userTenants",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userSelectedTenant)||void 0===n?void 0:n.data}},{key:"userRoles",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userRoles)||void 0===n?void 0:n.data}},{key:"ssoApplications",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoApplications)||void 0===n?void 0:n.data}},{key:"ssoConfigurations",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoConfigurations)||void 0===n?void 0:n.data}},{key:"samlAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlMappings)||void 0===n?void 0:n.options}},{key:"oidcAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.oidcMappings)||void 0===n?void 0:n.options}},{key:"samlGroupMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlGroupMappings)||void 0===n?void 0:n.options}},{key:"passwordPolicy",from:e=>{var t;return(e=>{if(!e)return;const t=Object.fromEntries(Object.entries(ec).map((([t,n])=>[t,e[n]])).filter((([,e])=>void 0!==e)));return Object.keys(t).length?t:void 0})(null===(t=e.componentsConfig)||void 0===t?void 0:t.newPassword)}},{key:"recoveryCodes",from:e=>(e=>{const t=tc(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=tc(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],ic=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function oc(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var rc,sc,ac,lc;function cc(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!cc(r,s))return!1}else if(r!==s)return!1}return!0}let dc=class{constructor(e={},{forceUpdate:t=!1}={}){rc.set(this,void 0),sc.set(this,{}),ac.set(this,0),lc.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,rc,"f")):e,n=Object.assign(Object.assign({},i(this,rc,"f")),t),r=i(this,rc,"f");o(this,rc,n,"f"),Object.freeze(i(this,rc,"f")),setTimeout((()=>{Object.values(i(this,sc,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,lc,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!cc(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,rc,e,"f"),o(this,lc,t,"f")}get current(){return Object.assign({},i(this,rc,"f"))}set forceUpdate(e){o(this,lc,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,ac,i(this,ac,"f")+1,"f"),i(this,sc,"f")[i(this,ac,"f")]={cb:e,selector:t,forceUpdate:n},i(this,ac,"f").toString()}unsubscribe(e){const t=!!i(this,sc,"f")[e];return t&&delete i(this,sc,"f")[e],t}unsubscribeAll(){return o(this,sc,{},"f"),!0}};rc=new WeakMap,sc=new WeakMap,ac=new WeakMap,lc=new WeakMap;const uc=["*","#","/","(",")","[","]","_","<",">","`"],hc=e=>"string"!=typeof e?e:e.replace((e=>{const t=uc.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),pc=["disabled"],fc=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Fa}])`)).forEach((e=>{e.value=n}))}))},gc=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),vc=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?hc(gc(t,i)):gc(t,i))),mc=(e,t,n)=>{e.querySelectorAll(`[${sl}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},bc=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},wc=(e,n,i,o)=>{var r,s;mc(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),mc(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=>$l.includes(e))(e.localName);e.textContent=vc(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",vc(i,t))}))})(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==n?void 0:n.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=vc(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])=>{pc.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},yc=Hl((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield Bl(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let kc;const Sc=(e,t)=>{kc?kc.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Ic=e=>kc?kc.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Cc="dls_ab_testing_id",Oc={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function Ec(e,t){const n={};try{Object.assign(n,JSON.parse(Ic(Va)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function Ac(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Sc(Va,JSON.stringify(e)))}function xc(){try{return JSON.parse(Ic(vl)||"{}")}catch(e){return{}}}function jc(e){try{(e=>{kc?kc.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(vl)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const Rc=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?Rc(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),Rc(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Tc=l((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r})),_c=["input","change"];function $c(e){if("number"==typeof e&&Number.isFinite(e))return{value:e,ok:!0};if("boolean"==typeof e)return{value:e?1:0,ok:!0};if("string"==typeof e){if(""===e.trim())return{value:0,ok:!1};const t=Number(e);if(Number.isFinite(t))return{value:t,ok:!0}}return{value:0,ok:!1}}function Pc(e){return null==e?"":"string"==typeof e?e:"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isFinite(e)?String(e):"":String(e)}function Uc(e){if("boolean"==typeof e)return{value:e,ok:!0};if("string"==typeof e){if("true"===e)return{value:!0,ok:!0};if("false"===e)return{value:!1,ok:!0}}return"number"==typeof e?{value:0!==e,ok:!0}:{value:!1,ok:!1}}function Lc(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function Mc(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Wc=new Map,Nc={equal:(e,t)=>e===t||Pc(e)===Pc(t),"not-equal":(e,t)=>e!==t&&Pc(e)!==Pc(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(Pc(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(Pc(t)),"greater-than":(e,t)=>{const n=$c(e),i=$c(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=$c(e),i=$c(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=$c(e),i=$c(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=$c(e),i=$c(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>Mc(e),"not-empty":e=>!Mc(e),"is-true":e=>{const t=Uc(e);return t.ok&&t.value},"is-false":e=>{const t=Uc(e);return t.ok&&!t.value},in:(e,t)=>{const n=Lc(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=Lc(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(Wc.has(e))return null!==(t=Wc.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return Wc.set(e,n),n}(Pc(t));return null!==n&&n.test(e)}};function Dc(e,t){var n;if(e)return"form"===e.kind&&e.form?t[e.form]:"list"===e.kind?(null!==(n=e.items)&&void 0!==n?n:[]).map((e=>Dc(e,t))):e.value}function qc(e,t){const n=Nc[e.operator];return!!n&&n(Dc(e.target,t),Dc(e.predicate,t))}function Fc(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var i;(function(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const i=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!i.length&&(e.logicalOr?i.some((e=>qc(e,t))):i.every((e=>qc(e,t))))}(e,t)))})(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const zc="component-conditions:";function Vc(e){return e instanceof HTMLInputElement?"checkbox"===e.type?e.checked:e.value:"checked"in e?e.checked:"value"in e?e.value:void 0}function Jc(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function Hc(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function Kc(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const Bc=l((e=>{var t,n,s,a,l,c;const d=r(w)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,Hc())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{bl.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${bl.map((e=>`"${e}"`)).join(", ")}`)})),Cl(e,{},t))}initRealtimeConditions(e,r){var a,c,d,u;i(this,t,"m",l).call(this);const h=null!==(a=null==r?void 0:r.realtimeComponentsConditions)&&void 0!==a?a:[];if(!h.length)return void this.logger.debug(`${zc} no real-time rules to apply on this screen`);this.logger.info(`${zc} found ${h.length} real-time rule(s) for this screen`);const p={};Object.entries(null!==(c=null==r?void 0:r.form)&&void 0!==c?c:{}).forEach((([e,t])=>{p[`form.${e}`]=t})),function(e){const t=new Set,n=e=>{var i;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(i=e.items)&&void 0!==i?i:[]).forEach(n))};return(null!=e?e:[]).forEach((e=>{var t;return(null!==(t=e.rules)&&void 0!==t?t:[]).forEach((e=>{var t;return(null!==(t=e.atomicConditions)&&void 0!==t?t:[]).forEach((e=>{n(e.target),n(e.predicate)}))}))})),t}(h).forEach((t=>{const n=function(e,t){const n=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${Sl(t)}"]`)||e.querySelector(`[name="${Sl(n)}"]`)}(e,t);if(!n)return;const i=Vc(n);void 0!==i&&(p[t]=i)}));const f=function(e){const t=new Set;return(null!=e?e:[]).forEach((e=>{var n;(null!==(n=e.componentIds)&&void 0!==n?n:[]).forEach((e=>t.add(e)))})),t}(h),g={},v={};Object.entries(null!==(d=null==r?void 0:r.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{f.has(e)&&(v[e]=t)})),Object.entries(null!==(u=null==r?void 0:r.serverOnlyComponentsState)&&void 0!==u?u:{}).forEach((([e,t])=>{f.has(e)&&(g[e]=t)}));const m={conditions:h,touchedIds:f,snapshot:p,applied:v,serverBaseline:g,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},b=Kc(Fc(h,p),g,f);Jc(v,b)||(m.applied=Cl(e,v,b)),m.inputHandler=e=>i(this,t,"m",s).call(this,e),_c.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${zc} listening for "${_c.join('" and "')}" events on form fields; ${Object.keys(v).length} component(s) start hidden / disabled / read-only by these rules`);const w=this.nextRequestStatus;if(null==w?void 0:w.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=w.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=w.unsubscribe)||void 0===e||e.call(w,t))}}o(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(e){var o,r;const s=i(this,n,"f");if(!s.root||s.paused)return;const l=e.target;if(!l)return;if(null===(o=l.hasAttribute)||void 0===o?void 0:o.call(l,Fa))return;const c=null===(r=l.getAttribute)||void 0===r?void 0:r.call(l,"name");if(!c)return;const d=function(e){return e.startsWith("form.")?e:`form.${e}`}(c);s.snapshot[d]=Vc(l),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,i(this,t,"m",a).call(this)}),50)},a=function(){const e=i(this,n,"f");if(!e.root)return;let t;try{t=Kc(Fc(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${zc} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const o=e.applied;Jc(o,t)||(this.logger.debug(`${zc} form changed — updating components: was ${JSON.stringify(o)}, now ${JSON.stringify(t)}`),e.applied=Cl(e.root,o,t))},l=function(){const e=i(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&_c.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)})),o(this,n,Hc(),"f")},c})),Yc="project-id",Gc="flow-id",Xc=e=>{const t=(e=>{const t=e.getAttribute(Yc),n=e.getAttribute(Gc);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(Yc)===t&&e.getAttribute(Gc)===n)):[]})(e);return t.length>1&&t[0]!==e},Zc=l((e=>{var t,n,s,a;const l=r(w)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}connectedCallback(){var e;null===(e=super.connectedCallback)||void 0===e||e.call(this),i(this,t,"m",s).call(this)}attributeChangedCallback(e,n,o){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),n===o||e!==Yc&&e!==Gc||i(this,t,"m",s).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(Yc),t=this.getAttribute(Gc),r=`${e}|${t}`;i(this,n,"f")!==r&&Xc(this)&&(o(this,n,r,"f"),this.logger.warn("Multiple Descope flow components detected on the same page",`The same flow ("${t}") and project ("${e}") are running more than once on this page. This is not supported and may cause the flow to behave unexpectedly.`))}))},a})),Qc=["externalId","email","phone"],ed=["newPassword","password"],td="data-username-anchor",nd=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(Ja);if(!n)return"";const i=JSON.parse(n);return i.executionId===e&&i.loginId||""}catch(e){return""}},id=l((e=>{var t,n,s,a,l;const c=r(w)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,l,c;o(this,n,{email:null==e?void 0:e.email,loginIds:(null===(r=null==e?void 0:e.loginIds)||void 0===r?void 0:r.length)?e.loginIds:[nd(i(this,t,"a",a))||(null===(c=null===(l=i(this,t,"a",s).sdk)||void 0===l?void 0:l.getLastUserLoginId)||void 0===c?void 0:c.call(l))].filter(Boolean)},"f")}updateUsernameAnchor(){document.querySelectorAll(`[${td}="true"]`).forEach((e=>e.remove())),((e,t,n,i)=>{var o;const r=(null==n?void 0:n.email)||(null===(o=null==n?void 0:n.loginIds)||void 0===o?void 0:o[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...Qc.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?i.debug("Username anchor: screen already has an identifier field"):(i.debug("Username anchor: injecting hidden username input"),e.appendChild((e=>{const t=document.createElement("input");return t.setAttribute("autocomplete","username"),t.setAttribute("name","username"),t.setAttribute("type","email"),t.setAttribute("readonly","true"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.setAttribute(Fa,"true"),t.setAttribute(td,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):i.debug("Username anchor: no user identifier available"):i.debug("Username anchor: no password component on screen")})(this,i(this,t,"a",s).contentRootElement,i(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const o=Zl(e,Qc);o&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem(Ja,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(o,n||i(this,t,"a",a))}storeCredentials(e={}){var t,o,r,s,a,l;const c=Zl(e,Qc)||(null===(t=i(this,n,"f"))||void 0===t?void 0:t.email)||(null===(r=null===(o=i(this,n,"f"))||void 0===o?void 0:o.loginIds)||void 0===r?void 0:r[0]),d=Zl(e,ed);if(c&&d)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:c,password:d});null===(l=null===(a=null===(s=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===s?void 0:s.store)||void 0===a?void 0:a.call(s,e))||void 0===l||l.catch((e=>{this.logger.debug("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.warn("Could not store credentials",e.message)}}},n=new WeakMap,t=new WeakSet,s=function(){return this},a=function(){var e,n;return(null===(n=null===(e=i(this,t,"a",s).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},l})),od="data-evp-token",rd='descope-email-field[email-verification="true"]',sd=e=>{e.querySelectorAll(`[${od}]`).forEach((e=>e.remove()))},ad=l((e=>{var t,s,a,l,c,d,u;const h=r(w)(e);return u=class extends h{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,!1),l.set(this,0),c.set(this,(e=>{(e=>e.composedPath().some((e=>e instanceof Element&&e.matches(rd))))(e)&&(o(this,a,"focusin"===e.type,"f"),"focusout"===e.type&&o(this,l,Date.now(),"f"))}))}clearEmailVerification(){o(this,s,void 0,"f"),o(this,a,!1,"f"),o(this,l,0,"f"),sd(this)}startEmailVerification(e){var n,r,a;const l=null===(n=i(this,t,"a",d).sdk)||void 0===n?void 0:n.emailVerification;if(!(l&&(()=>{var e,t;return!!(null===(t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands)||void 0===t?void 0:t.some((({brand:e})=>"Google Chrome"===e)))})()&&(u=e,u.querySelector(rd))&&this.closest("form")))return;var u;null===(r=this.shadowRoot)||void 0===r||r.addEventListener("focusin",i(this,c,"f")),null===(a=this.shadowRoot)||void 0===a||a.addEventListener("focusout",i(this,c,"f"));const h=l.start().then((e=>{var t,n;e.ok&&(null===(t=e.data)||void 0===t?void 0:t.nonce)?i(this,s,"f")===h&&((e,t)=>{const n=document.createElement("input");n.type="hidden",n.setAttribute("autocomplete","email-verification-token"),n.setAttribute(Fa,"true"),n.setAttribute(od,"true"),n.nonce=t,n.setAttribute("nonce",t),e.appendChild(n)})(this,e.data.nonce):this.logger.warn("Email verification start failed",null===(n=e.error)||void 0===n?void 0:n.errorDescription)})).catch((e=>{this.logger.warn("Email verification start failed",null==e?void 0:e.message)}));o(this,s,h,"f")}emailVerificationToken(e){return n(this,void 0,void 0,(function*(){var t,n;if("true"===e.getAttribute("formnovalidate")||!this.querySelector(`[${od}]`)||!(null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(rd))||void 0===n?void 0:n.value))return"";i(this,a,"f")&&(()=>{var e;let t=document.activeElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.activeElement;)t=t.shadowRoot.activeElement;t instanceof HTMLElement&&t.blur()})();const o=i(this,l,"f")+900-Date.now();o>0&&(yield new Promise((e=>{setTimeout(e,o)})));const r=(e=>{const t=e.querySelector(`[${od}]`),n=e.closest("form");if(!t||!n)return"";let i="";const o=e=>{e.target===n&&(e.preventDefault(),e.stopImmediatePropagation(),i=t.value,t.value="")};window.addEventListener("submit",o,!0);const{noValidate:r}=n;n.noValidate=!0;try{n.requestSubmit()}finally{n.noValidate=r,window.removeEventListener("submit",o,!0)}return i})(this);return r&&sd(this),r}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(){return this},u})),ld=e=>`${e.screenId}|${e.field}|${e.rule}`,cd=()=>{try{return crypto.randomUUID()}catch(e){return`${Date.now()}-${Math.round(1e9*Math.random())}`}},dd=(e,t)=>e?e.badInput?"bad-input":e.valueMissing?"required":e.typeMismatch?"email"===t||"url"===t?t:"type-mismatch":e.patternMismatch?"pattern":e.tooShort?"too-short":e.tooLong?"too-long":e.rangeUnderflow||e.rangeOverflow||e.stepMismatch?"range":e.customError?"custom":"unknown":"unknown",ud=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,b,y,k,S,I,C;const O=r(w)(e);return C=class extends O{constructor(){super(...arguments),t.add(this),n.set(this,[]),s.set(this,void 0),a.set(this,void 0),l.set(this,new Set),c.set(this,!1),d.set(this,0),u.set(this,void 0),h.set(this,!1),p.set(this,(()=>i(this,t,"m",y).call(this,!1))),f.set(this,(()=>{"hidden"===document.visibilityState&&i(this,t,"m",y).call(this,!0)})),g.set(this,(()=>i(this,t,"m",y).call(this,!0)))}setValidationTrackingEnabled(e){i(this,h,"f")!==e&&(o(this,h,e,"f"),e||i(this,t,"m",b).call(this))}setValidationTrackingSender(e){o(this,u,e,"f")}setValidationTrackingExecution(e){i(this,h,"f")&&e&&i(this,n,"f").length&&(o(this,s,e,"f"),i(this,t,"m",y).call(this,!1))}trackValidationErrors(e,n){var o,r;try{i(this,t,"m",v).call(this,e,n)}catch(e){null===(r=null===(o=this.logger)||void 0===o?void 0:o.debug)||void 0===r||r.call(o,"Failed to track validation errors",String(e))}}teardownValidationTracking(){i(this,t,"m",y).call(this,!1),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),i(this,c,"f")&&(o(this,c,!1,"f"),this.removeEventListener("screen-updated",i(this,p,"f")),this.removeEventListener("success",i(this,p,"f")),this.removeEventListener("error",i(this,p,"f")),document.removeEventListener("visibilitychange",i(this,f,"f")),window.removeEventListener("pagehide",i(this,g,"f")))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap,t=new WeakSet,v=function(e,r){if(!i(this,h,"f")||!(null==e?void 0:e.length))return;const a=r||{};i(this,t,"m",I).call(this),e.forEach((e=>{if(i(this,n,"f").length>=20)return;const r=((e,t)=>{var n;const i=null===(n=null==e?void 0:e.getAttribute)||void 0===n?void 0:n.call(e,"name");return i?{id:cd(),field:i,rule:dd(e.validity,e.type),message:e.validationMessage||"",screenId:t.screenId||"",screenName:t.screenName||"",ts:Date.now()}:null})(e,a);if(!r)return;const l=ld(r);i(this,n,"f").some((e=>ld(e)===l))||(i(this,n,"f").push(r),o(this,s,a.executionId||i(this,s,"f"),"f"),i(this,n,"f").length>=20&&i(this,t,"m",y).call(this,!1))})),i(this,n,"f").length>=20?i(this,t,"m",y).call(this,!1):i(this,t,"m",m).call(this)},m=function(){clearTimeout(i(this,a,"f")),o(this,a,setTimeout((()=>i(this,t,"m",y).call(this,!1)),2e3),"f")},b=function(){clearTimeout(i(this,a,"f")),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),o(this,n,[],"f"),o(this,s,void 0,"f")},y=function(e){var r,l;if(clearTimeout(i(this,a,"f")),!i(this,n,"f").length)return void o(this,s,void 0,"f");if(!i(this,s,"f"))return;if(!i(this,u,"f"))return;const c=i(this,n,"f"),h=i(this,s,"f");o(this,n,[],"f"),o(this,s,void 0,"f");try{const n={executionId:h,events:c};e?i(this,u,"f").call(this,n,{keepalive:!0}).catch((()=>{})):i(this,t,"m",k).call(this,n,2,i(this,d,"f"))}catch(e){null===(l=null===(r=this.logger)||void 0===r?void 0:r.debug)||void 0===l||l.call(r,"Failed to send validation events",String(e))}},k=function(e,n,o){i(this,u,"f").call(this,e,{keepalive:!1}).then((r=>{!r.ok&&r.retryable&&n>0&&i(this,t,"m",S).call(this,e,n,o)})).catch((()=>{n>0&&i(this,t,"m",S).call(this,e,n,o)}))},S=function(e,n,o){if(o!==i(this,d,"f"))return;const r=setTimeout((()=>{i(this,l,"f").delete(r),o===i(this,d,"f")&&i(this,t,"m",k).call(this,e,n-1,o)}),800*(2-n+1));i(this,l,"f").add(r)},I=function(){i(this,c,"f")||(o(this,c,!0,"f"),this.addEventListener("screen-updated",i(this,p,"f")),this.addEventListener("success",i(this,p,"f")),this.addEventListener("error",i(this,p,"f")),document.addEventListener("visibilitychange",i(this,f,"f")),window.addEventListener("pagehide",i(this,g,"f")))},C}));var hd,pd,fd,gd,vd,md,bd,wd,yd,kd,Sd,Id,Cd,Od,Ed,Ad,xd,jd,Rd,Td,_d,$d,Pd,Ud,Ld,Md;const Wd=r(me,_,Tc,Bc,Zc,id,ad,H,xn,ud)(HTMLElement);class Nd extends Wd{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","send-session-token","style-id"]}constructor(e){super(),hd.add(this),this.sdkVersion="4.7.2",fd.set(this,!1),gd.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,hd,"m",Md).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)}},vd.set(this,new dc),md.set(this,new dc),bd.set(this,{}),this.getComponentsContext=()=>i(this,bd,"f"),this.nextRequestStatus=new dc({isLoading:!1}),wd.set(this,void 0),yd.set(this,{popstate:i(this,hd,"m",Od).bind(this),componentsContext:i(this,hd,"m",Td).bind(this)}),kd.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),_d.set(this,void 0),$d.set(this,void 0),o(this,kd,e,"f"),i(this,hd,"m",Id).call(this)}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 sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return Rc(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,gd,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,gd,e,"f"),(e=>{kc=e})(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=i(this,$d,"f"))||void 0===e||e.call(this),o(this,_d,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=gl.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,md,"f").subscribe(i(this,hd,"m",Ld).bind(this)),i(this,md,"f").update({isDebug:this.debug}),i(this,hd,"m",Cd).call(this),yield i(this,hd,"m",jd).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}=Jl(this.flowId,this.projectId,this.loggerWrapper);window.addEventListener("popstate",i(this,yd,"f").popstate),window.addEventListener("components-context",i(this,yd,"f").componentsContext),i(this,vd,"f").subscribe(i(this,hd,"m",xd).bind(this)),i(this,vd,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},g)),o(this,fd,!0,"f")}))}disconnectedCallback(){var e;i(this,vd,"f").unsubscribeAll(),i(this,md,"f").unsubscribeAll(),i(this,hd,"m",Ud).call(this),window.removeEventListener("popstate",i(this,yd,"f").popstate),window.removeEventListener("components-context",i(this,yd,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var o;if(null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,t,n),this.shadowRoot.isConnected&&i(this,fd,"f")&&t!==n&&pd.observedAttributes.includes(e)){i(this,hd,"m",Cd).call(this);const o=null===t;i(this,vd,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Wl()),{[Vl(e)]:n,stepId:r,executionId:s}})),i(this,md,"f").update({isDebug:this.debug})}}}var Dd,qd,Fd,zd,Vd,Jd,Hd,Kd,Bd,Yd,Gd,Xd,Zd,Qd,eu,tu,nu,iu,ou,ru,su,au,lu,cu,du,uu,hu,pu,fu,gu,vu,mu,bu,wu,yu,ku,Su,Iu,Cu,Ou,Eu,Au,xu,ju,Ru,Tu;pd=Nd,fd=new WeakMap,gd=new WeakMap,vd=new WeakMap,md=new WeakMap,bd=new WeakMap,wd=new WeakMap,yd=new WeakMap,kd=new WeakMap,_d=new WeakMap,$d=new WeakMap,hd=new WeakSet,Sd=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 ")},Id=function(){i(this,hd,"m",Sd).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Cd=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","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];pd.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Vl(t)])throw Error(`${t} cannot be empty`)}))},Od=function(){const{stepId:e,executionId:t}=Ml(this.flowId);t&&i(this,vd,"f").update({stepId:e,executionId:t})},Ed=function(e,t){Ys&&"function"==typeof Ys||this.logger.error("SDK was not loaded properly",Ys,JSON.stringify(Ys));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},pd.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,gd,"f")&&(o.customStorage=i(this,gd,"f")),this.sdk=Ys(o);const r={start:1,next:7};["start","next"].forEach((e=>{const t=function(e,t,i){return(...o)=>n(this,void 0,void 0,(function*(){let n;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...o)}catch(e){n=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...o)=>n(this,void 0,void 0,(function*(){const n=[...o],s=r[e],a=i(this,hd,"m",Ad).call(this,n[s]);void 0!==a&&(n[s]=a);try{return yield t(...n)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:$a,errorDescription:t.toString()}}}}))}));const s=this.sdk.flow.start;this.sdk.flow.start=(...e)=>n(this,void 0,void 0,(function*(){return yield i(this,hd,"m",Pd).call(this),s.apply(this.sdk.flow,e)}))},Ad=function(e){if(!this.sendSessionToken)return e;const t=null==ns?void 0:ns(this.storagePrefix);return t?Object.assign(Object.assign({},null!=e?e:{}),{sessionJwt:t}):e},xd=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,hd,"m",Ed).call(this,t,n)}i(this,kd,"f").call(this,e)}))},jd=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,hd,"m",Rd).call(this))}))},Rd=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(La||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Td=function(e){o(this,bd,Object.assign(Object.assign({},i(this,bd,"f")),e.detail),"f")},Pd=function(){return this.lazyStart?(i(this,_d,"f")||o(this,_d,new Promise((e=>{o(this,$d,e,"f")})),"f"),i(this,_d,"f")):Promise.resolve()},Ud=function(){var e;null===(e=i(this,wd,"f"))||void 0===e||e.remove(),o(this,wd,null,"f")},Ld=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,wd,document.createElement("descope-debugger"),"f"),Object.assign(i(this,wd,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Xu})),document.body.appendChild(i(this,wd,"f"))):i(this,hd,"m",Ud).call(this)}))},Md=function(e,t){var n;e&&this.debug&&(null===(n=i(this,wd,"f"))||void 0===n||n.updateData({title:e,description:t}))},Nd.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.7.2"}};const _u="__descope_webauthn_timed_out__";class $u extends Nd{static set sdkConfigOverrides(e){Nd.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Nd.sdkConfigOverrides}constructor(){const e=new dc({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Dd.add(this),this.stepState=new dc({}),qd.set(this,void 0),Fd.set(this,null),zd.set(this,null),Vd.set(this,{visibilitychange:i(this,Dd,"m",Jd).bind(this)}),this.bridgeVersion=$u.bridgeVersion,Hd.set(this,void 0),this.nativeCallbacks={},eu.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},iu.set(this,(e=>{e&&this.clearEmailVerification();const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,Dd,"m",ou).call(this,t):t()})),ru.set(this,((e,t,r,s,a=!1)=>{const l=[Pa,"E103202",Ua];if(this.flowState.current.action===ll){if(i(this,au,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,qd,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,fl,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 Bl(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,ru,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===$a)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,ru,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,ru,"f").call(this,e,t,r,s),i(this,lu,"f").call(this,p)}))),d),"f")}})),su.set(this,(()=>{clearTimeout(i(this,qd,"f")),o(this,qd,null,"f")})),au.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),lu.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,f,g;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,Dd,"m",Ru).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==Pa&&d!==Ua||!this.isRestartOnError||i(this,Dd,"m",Qd).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(f=e.data)||void 0===f?void 0:f.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==ll&&i(this,su,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Ac(Object.assign(Object.assign({},w),{lastUsedPerScreen:xc()})),jc(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),this.setValidationTrackingExecution(e.data.executionId),((e,t)=>{_l(e,t)})(this.projectId,this.flowId),void i(this,Dd,"m",Ru).call(this,"success",t)}this.storeLastAuthenticatedUser&&Ac(w,!0),k&&window.open(k,"_blank");const{executionId:S,stepId:I,stepName:C,screen:O,redirect:E,webauthn:A,error:x,samlIdpResponse:j,wsFedIdpResponse:R,nativeResponse:T}=e.data,_=Date.now();y!==ll?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${m}`,"",{screen:O,status:m,stepId:I,stepName:C,action:y,error:x}),(null===(g=O.state)||void 0===g?void 0:g.clientScripts)&&o(this,zd,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:I,stepName:C,executionId:S,action:y,redirectTo:null==E?void 0:E.url,redirectIsPopup:null==E?void 0:E.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==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.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:_})):this.flowState.update({action:y,reqTimestamp:_})})),cu.set(this,Hl((()=>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)}}))))),pu.set(this,void 0),fu.set(this,void 0),yu.set(this,null),Cu.set(this,Ql(((e,t,o)=>n(this,void 0,void 0,(function*(){var n;if("true"!==e.getAttribute("loading")&&"true"!==e.getAttribute("disabled")){if("true"===e.getAttribute("formnovalidate")||i(this,Dd,"m",bu).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,Dd,"m",Au).call(this,e,r,o);const s=i(this,Dd,"m",ku).call(this,e);try{const o=yield i(this,Dd,"m",wu).call(this),s=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const a=yield this.emailVerificationToken(e),l=Object.assign(Object.assign(Object.assign(Object.assign({},s),o),{origin:i(this,Dd,"a",mu)}),a&&{evpToken:a}),c=yield t(r,l);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(o,null===(n=null==c?void 0:c.data)||void 0===n?void 0:n.executionId),this.storeCredentials(o)}catch(e){throw s(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=e,this.setValidationTrackingSender(((e,t)=>n(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:n}){const i=yield this.sdk.flow.event(e,t,n);return{ok:i.ok,retryable:i.code>=500||429===i.code}}))))}nativeResume(e,t){var n,o,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const i=new URL(c.url);t=null===(n=i.searchParams)||void 0===n?void 0:n.get(Na),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get(qa))||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(Wa).split("_").pop();i(this,su,"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:{[oc(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=e=>n(this,void 0,void 0,(function*(){var n,i,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(i=globalThis.descope)||void 0===i?void 0:i[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.22",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,i)=>{try{const i=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t);const o=this.nextRequestStatus.subscribe((()=>{var n;this.loggerWrapper.debug("Stopping script",e.id),(null===(n=i.stop)||void 0===n?void 0:n.call(i))&&(this.nextRequestStatus.unsubscribe(o),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}));"function"==typeof i.present&&n(e.id)}}catch(e){i(e)}}))})),o=Promise.all((null!=e?e:[]).map((e=>i(e).catch((t=>(this.loggerWrapper.warn(`Sdk script ${e.id} failed to load, continuing without it`,null==t?void 0:t.message),null))))));let r;const s=new Promise((e=>{r=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([o,s]).finally((()=>clearTimeout(r))).catch((e=>(this.loggerWrapper.warn("Sdk scripts failed to load, continuing without them",null==e?void 0:e.message),null)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,o(this,Hd,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,Dd,"m",Xd).call(this),window.addEventListener("visibilitychange",i(this,Vd,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e,t,n;super.disconnectedCallback(),this.teardownValidationTracking(),i(this,Hd,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,i(this,Hd,"f")),o(this,Hd,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,su,"f").call(this),null===(n=i(this,Fd,"f"))||void 0===n||n.abort(),o(this,Fd,null,"f"),this.clearEmailVerification(),window.removeEventListener("visibilitychange",i(this,Vd,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=v(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:m,redirectTo:b,redirectIsPopup:w,redirectUrl:y,token:k,code:S,isPopup:I,exchangeError:C,webauthnTransactionId:O,webauthnOptions:E,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:R,locale:T,samlIdpResponseUrl:_,samlIdpResponseSamlResponse:$,samlIdpResponseRelayState:P,wsFedIdpResponseUrl:U,wsFedIdpResponseWresult:L,wsFedIdpResponseWctx:M,nativeResponseType:W,nativePayload:N,reqTimestamp:D}=e,q=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,z,V;const J=(()=>{const e=Ic(Cc);if(!e){const e=Math.floor(100*Math.random()+1);return Sc(Cc,e.toString()),e}return Number(e)})(),{outboundAppId:H,outboundAppScopes:K}=this,B=this.sdk.getLastUserLoginId();s("flowId")&&this.setValidationTrackingEnabled(!1);const Y=yield this.getFlowConfig();i(this,Dd,"m",gu).call(this,Y,p,s);const G=yield this.getProjectConfig(),X=Object.entries(G.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Z=x&&A?{callbackUrl:x,codeChallenge:A,backupCallbackUri:j}:void 0,Q=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 ee={};if(!p){jc(this.loggerWrapper);const e=[...Y.clientScripts||[],...Y.sdkScripts||[]];if(Y.conditions){let t=[];({startScreenId:F,conditionInteractionId:V,startScreenName:z,clientScripts:t,componentsConfig:ee}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=Oc[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:B,code:S,token:k,abTestingKey:J,lastAuth:Ec(B,this.loggerWrapper)},Y.conditions)),e.push(...t||[])}else Y.condition?({startScreenId:F,startScreenName:z,conditionInteractionId:V}=((e,t)=>{var n;const i=null===(n=Oc[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(Y.condition,{loginId:B,code:S,token:k,abTestingKey:J,lastAuth:Ec(B,this.loggerWrapper)})):(z=Y.startScreenName,F=Y.startScreenId);if(o(this,pu,F,"f"),o(this,fu,z,"f"),o(this,zd,this.loadSdkScripts(e),"f"),Y.fingerprintEnabled&&Y.fingerprintKey?yield us(Y.fingerprintKey,this.baseUrl):Dr(cs),!Yl(F,q)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Z},q),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:Ec(B,this.loggerWrapper),abTestingKey:J,locale:v(T).locale,nativeOptions:Q,outboundAppId:H,outboundAppScopes:K}),V,"",G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:i(this,Dd,"a",mu)},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return i(this,lu,"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:S,exchangeError:C,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&S||s("exchangeError")&&C))return void i(this,Dd,"m",Tu).call(this,p,S,C);if(p&&(s("token")&&k||s("code")&&S||s("exchangeError")&&C)){const e=yield this.sdk.flow.next(p,h,pl,Y.version,G.componentsVersion,{token:k,exchangeCode:S,exchangeError:C,origin:i(this,Dd,"a",mu)});return i(this,lu,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===hl&&_&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!$)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(Gl("SAMLResponse",t,"saml-response")),o.appendChild(Gl("RelayState",n,"saml-relay-state")),document.body.appendChild(o),i(o)})(_,$,P||"",Xl)}if(f===hl&&U&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!L)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(Gl("wa","wsignin1.0")),o.appendChild(Gl("wresult",t)),o.appendChild(Gl("wctx",n)),document.body.appendChild(o),i(o)})(U,L,M||"",Xl)}if(f===al&&(s("redirectTo")||s("deferredRedirect"))){if(!b)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===b)return;if("android"===R&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(b,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));let n=!1;const o=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:o,data:r}=e.data||{};"code"===o&&(n=!0,this.flowState.update({code:r.code,exchangeError:r.exchangeError}))};let r;this.loggerWrapper.debug("Starting popup closed detection");const s=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(s),i(this,Dd,"m",Ru).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(t)window.addEventListener("message",o),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",o)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=o,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(b),this.flowState.update({redirectTo:"no-op"}),i(this,Dd,"m",Ru).call(this,"popupclosed",{});return}if(f===cl||f===dl){if(!O||!E)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(l=i(this,Fd,"f"))||void 0===l||l.abort(),o(this,Fd,null,"f");const e=yield i(this,Dd,"m",nu).call(this,f,E),t=yield this.sdk.flow.next(p,h,pl,Y.version,G.componentsVersion,Object.assign({transactionId:O},e));i(this,lu,"f").call(this,t)}if(f===ul)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,pl,Y.version,G.componentsVersion,e);i(this,lu,"f").call(this,t)})),i(this,Dd,"m",Yd).call(this,W,N),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&i(this,ru,"f").call(this,p,h,Y.version,G.componentsVersion),!g&&!F)return void this.loggerWrapper.warn("No screen was found to show");const te=F||g,ne=yield this.getHtmlFilenameWithLocale(T,te),{oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=q,le={direction:Ll(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:B,name:this.sdk.getLastUserDisplayName()||B},componentsConfig:Object.assign(Object.assign(Object.assign({},Y.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||z,samlIdpUsername:ae,oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,action:f,locale:v(T).locale},ce=Ec(B,this.loggerWrapper);Yl(F,q)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==Y?void 0:Y.clientScripts)||[];yield i(this,Dd,"m",Ou).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Z},q),{lastAuth:ce,preview:this.preview,abTestingKey:J,client:this.client}),y&&{redirectUrl:y}),{locale:v(T).locale,nativeOptions:Q,outboundAppId:H,outboundAppScopes:K}),V,e,G.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:i(this,Dd,"a",mu)},this.formConfigValues),this.getComponentsContext()),ic(t)),S&&{exchangeCode:S,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return i(this,lu,"f").call(this,o),o})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==m?void 0:m.clientScripts)||[];yield i(this,Dd,"m",Ou).call(this,n);const o=yield this.sdk.flow.next(p,h,e,Y.version,G.componentsVersion,Object.assign(Object.assign({origin:i(this,Dd,"a",mu)},this.getComponentsContext()),ic(t)),le.next.isCustomScreen);return i(this,lu,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield i(this,Dd,"m",tu).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen"),this.clearEmailVerification(),this.updateScreenUser(null==u?void 0:u.user);const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const f=p.content.cloneNode(!0),g=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield i(this,Dd,"m",uu).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${sl}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),wc(f,u,this.formConfig,this.loggerWrapper),this.applyComponentsState(f,null==u?void 0:u.componentsState),this.startEmailVerification(f);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(f,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield g;const r=this.contentRootElement;((e,t)=>{bc(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{bc(e,"descope-notp-image",t)})(r,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,f,u.cssVars,this.loggerWrapper),r.replaceChildren(f);const s=!t.htmlFilename;setTimeout((()=>{i(this,Dd,"m",Su).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&((e,t)=>{e.querySelectorAll("*[name]").forEach((n=>{n.addEventListener("blur",(()=>{var i;if(yl(n,e))return;const o=()=>{var e;const i=n.focus;n.focus=()=>{};const o=null===(e=n.reportValidity)||void 0===e?void 0:e.call(n);t&&!1===o&&t(n),setTimeout((()=>{n.focus=i}))};if("true"===n.getAttribute("invalid")||(null===(i=n.value)||void 0===i?void 0:i.length))return void o();const r={timer:void 0},s=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(r.timer),r.timer=void 0)};r.timer=setTimeout((()=>{e.removeEventListener("click",s),o(),r.timer=void 0}),150),e.addEventListener("click",s,{once:!0})}))}))})(r,(e=>this.trackValidationErrors([e],i(this,Dd,"a",vu)))),((e,t)=>{fc(e,null==t?void 0:t.inputs),fc(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),i(this,Dd,"m",hu).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),Kl(r,this.autoFocus,s),i(this,Dd,"m",xu).call(this,h)})),i(this,Dd,"m",ju).call(this,d,h),r.querySelector(`[${sl}="polling"]`)&&d(fl,{})}));c?i(this,Dd,"m",ou).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Fa}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}qd=new WeakMap,Fd=new WeakMap,zd=new WeakMap,Vd=new WeakMap,Hd=new WeakMap,eu=new WeakMap,iu=new WeakMap,ru=new WeakMap,su=new WeakMap,au=new WeakMap,lu=new WeakMap,cu=new WeakMap,pu=new WeakMap,fu=new WeakMap,yu=new WeakMap,Cu=new WeakMap,Dd=new WeakSet,Jd=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},Kd=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,Dd,"m",Yd).call(this,"beforeScreen",{screen:e,context:t})}))}))},Bd=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,Dd,"m",Yd).call(this,"afterScreen",{screen:e})},Yd=function(e,t){i(this,Dd,"m",Ru).call(this,"bridge",{type:e,payload:t})},Gd=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${sl}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},Xd=function(){var e,n,o,r;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=void 0===n?{}:n,{errorText:o,errorType:r}=i,s=t(i,["errorText","errorType"]),a=t(e,["screenState"]);return Object.assign(Object.assign({},a),{screenState:s})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,Dd,"m",Gd).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,Dd,"m",Zd).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===(r=this.flowState)||void 0===r||r.subscribe((({screenId:e,executionId:t})=>{var n;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(n=this.logger)||void 0===n||n.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},Zd=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=""}))})),Kl(this.contentRootElement,this.autoFocus,!1))},Qd=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")}))},tu=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=>{const t=(n=e.screenState,i=(e,t)=>ml.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(0,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;(o||r)&&(t.error={text:o,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return nc.forEach((({key:n,from:i})=>{const o=i(e);void 0!==o&&(t[n]=o)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t})(t(r,["next","stepName"]));let c=yield i(this,Dd,"m",Kd).call(this,a,l,s);c||(c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,l,s,this)));const d=!this.stepState.current.htmlFilename;if(i(this,iu,"f").call(this,c),s&&(s.isCustomScreen=c),i(this,eu,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,eu,c,"f"),c?this.stepState.unsubscribeAll():i(this,Dd,"m",Xd).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),i(this,Dd,"m",hu).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},nu=function(e,t){return n(this,void 0,void 0,(function*(){const n=new AbortController;try{const i=e===cl?this.sdk.webauthn.helpers.create(t,n):this.sdk.webauthn.helpers.get(t,n),o=yield Bl(9e4,i,_u);return o!==_u?{response:o}:(n.abort(),this.loggerWrapper.warn("WebAuthn operation timed out after 90000ms"),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},ou=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")},du=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)}))}},uu=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,Fd,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield yc())){const{options:e,transactionId:r}=(yield i(this,cu,"f").call(this))||{};e&&r&&(i(this,Dd,"m",du).call(this,s),o(this,Fd,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,Fd,"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)})))}}))},hu=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,Dd,"m",Ru).call(this,"ready",{}),t||i(this,Dd,"m",Bd).call(this,n),i(this,Dd,"m",Ru).call(this,"page-updated",{screenName:n}),i(this,Dd,"m",Ru).call(this,"screen-updated",{screenName:n})},gu=function(e,t,n){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&n("executionId")&&this.setValidationTrackingExecution(t)},vu=function(){var e,t,n,o,r,s,a;const l=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==l?void 0:l.executionId)?{executionId:l.executionId,screenId:l.screenId,screenName:(null===(a=null===(s=this.stepState)||void 0===s?void 0:s.current)||void 0===a?void 0:a.stepName)||l.stepName}:{executionId:void 0,screenId:null!==(t=i(this,pu,"f"))&&void 0!==t?t:null==l?void 0:l.screenId,screenName:null!==(n=i(this,fu,"f"))&&void 0!==n?n:(null===(r=null===(o=this.stepState)||void 0===o?void 0:o.current)||void 0===r?void 0:r.stepName)||(null==l?void 0:l.stepName)}},mu=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},bu=function(){let e=!0;const t=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((n=>{var i,o,r;"slot"===n.localName||yl(n,this.contentRootElement)||(null===(i=n.reportValidity)||void 0===i||i.call(n),n.validity&&!n.validity.valid&&t.push(n),e&&(e=null===(r=null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))||void 0===r||r))})),t.length&&this.trackValidationErrors(t,i(this,Dd,"a",vu)),e},wu=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})),{})}))},ku=function(e){var t,r;const s=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),a=(null===(r=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===r?void 0:r.clientScripts)||[];e.setAttribute("loading","true"),s.forEach((e=>e.setAttribute("disabled","true")));const l=()=>{e.removeAttribute("loading"),s.forEach((e=>{e.removeAttribute("disabled")}))},c=e=>n(this,void 0,void 0,(function*(){var t;if(this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",c),!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&a.length)return o(this,zd,(()=>n(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(a)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void l();l();const i=yield this.getFlowConfig(),r=[...i.clientScripts||[],...i.sdkScripts||[]];this.loadSdkScripts(r)})),d=()=>{var e;window.removeEventListener("pageshow",i(this,yu,"f")),o(this,yu,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",i(this,yu,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&c(),this.removeEventListener("popupclosed",c),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},u=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",c,{once:!0}):(this.nextRequestStatus.unsubscribe(u),"success"===this.flowStatus?(this.removeEventListener("popupclosed",c),l()):d())}));return l},Su=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,Dd,"m",Iu).call(this,e)))},Iu=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},Ou=function(e){return n(this,void 0,void 0,(function*(){if(i(this,zd,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,zd,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const o=[];for(const e of t)"function"==typeof e.refresh&&o.push(e.refresh());if(o.length>0)try{yield Bl(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Eu=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var o;(null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))&&i(this,Cu,"f").call(this,n,e,t)}))}))},Au=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=xc();n[e]=t,Sc(vl,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},xu=function(e){var t;const n=null===(t=Ec(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},ju=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${za}]), [data-type="button"]:not([${za}]`).forEach((n=>{n.onclick=()=>{i(this,Cu,"f").call(this,n,e,t)}})),i(this,Dd,"m",Eu).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Fa}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Ru=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Tu=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s="descope-wc"===o&&!!r,a=s?function(e){const t=Nl(e);if(t)return t===window.location.origin||Nl(function(){const e=new URLSearchParams(window.location.search).getAll("popup_opener_origin");return 1===e.length?e[0]:void 0}())===t?t:void 0}(r):void 0;s&&!a&&this.loggerWrapper.warn("Popup opener origin is not approved for this project, add it to the approved domains to send the OAuth result to it",r);const l={data:{code:t,exchangeError:n},action:"code"};if(a){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",a);try{window.opener.postMessage(l,a)}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(l),t.close()}try{window.close()}catch(e){}},$u.bridgeVersion=3,customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",$u);var Pu=Object.freeze({__proto__:null,default:$u});const Uu=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},Lu=(e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Uu(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c};var Mu,Wu,Nu,Du,qu,Fu,zu,Vu,Ju,Hu,Ku;const Bu=document.createElement("template");Bu.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 Yu=r(H)(HTMLElement);class Gu extends Yu{constructor(){super(),Mu.add(this),Wu.set(this,new dc({messages:[]})),Nu.set(this,void 0),Du.set(this,void 0),qu.set(this,void 0),Fu.set(this,{resize:i(this,Mu,"m",Ku).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Bu.content.cloneNode(!0)),o(this,Nu,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Du,i(this,Nu,"f").querySelector(".content"),"f"),o(this,qu,i(this,Nu,"f").querySelector(".header"),"f"),i(this,Mu,"m",zu).call(this)}updateData(e){i(this,Wu,"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),Lu(i(this,Nu,"f"),i(this,qu,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Fu,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(i(this,Nu,"f")),i(this,Nu,"f").onresize=i(this,Mu,"m",Hu).bind(this),i(this,Wu,"f").subscribe(i(this,Mu,"m",Vu).bind(this))}))}disconnectedCallback(){i(this,Wu,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Fu,"f").resize)}}Wu=new WeakMap,Nu=new WeakMap,Du=new WeakMap,qu=new WeakMap,Fu=new WeakMap,Mu=new WeakSet,zu=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,Nu,"f").style.top="32px",i(this,Nu,"f").style.left=window.innerWidth-300-32+"px"},Vu=function(e){i(this,Mu,"m",Ju).call(this,e),i(this,Mu,"m",Hu).call(this)},Ju=function(e){i(this,Du,"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 ${g(e.title)}\n </div>\n <div class="msg_desc">\n ${g(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Hu=function(){i(this,Du,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Ku=function(){const[e,t]=Uu(i(this,Nu,"f"),Number.parseInt(i(this,Nu,"f").style.left,10),Number.parseInt(i(this,Nu,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Nu,"f").style.top=`${t}px`,i(this,Nu,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Gu);var Xu=Object.freeze({__proto__:null,default:Gu});return va}();
7
7
  //# sourceMappingURL=index.js.map