@descope/applications-portal-widget 0.2.6 → 0.2.7

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,8 +1,8 @@
1
1
 
2
2
  /**
3
- * @descope/applications-portal-widget v0.2.6
3
+ * @descope/applications-portal-widget v0.2.7
4
4
  */
5
- this["descope-applications-portal-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function r(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const o=e(n);return o[t]=!0,o}};var c,l,u,d;function p(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!p(i,s))return!1}else if(i!==s)return!1}return!0}let h=class{constructor(e={},{updateOnlyOnChange:t=!0}={}){c.set(this,void 0),l.set(this,{}),u.set(this,0),d.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,c,"f")):e,n=Object.assign(Object.assign({},o(this,c,"f")),t);if(!o(this,d,"f")||!p(o(this,c,"f"),n)){const e=o(this,c,"f");r(this,c,n,"f"),Object.freeze(o(this,c,"f")),setTimeout((()=>{Object.values(o(this,l,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},r(this,c,e,"f"),r(this,d,t,"f")}get current(){return Object.assign({},o(this,c,"f"))}subscribe(e){return r(this,u,o(this,u,"f")+1,"f"),o(this,l,"f")[o(this,u,"f")]=e,o(this,u,"f").toString()}unsubscribe(e){const t=!!o(this,l,"f")[e];return t&&delete o(this,l,"f")[e],t}unsubscribeAll(){return r(this,l,{},"f"),!0}};c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap;const f=["error","warn","info","debug"],g=a((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",i).call(this,console))}set logger(e){r(this,n,o(this,t,"m",i).call(this,e),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return f.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),m="undefined"!=typeof localStorage,y=m&&localStorage.getItem("base.content.url")||"",v=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,b=a((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(r(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),w=a((e=>{var t,n;const r=i(g,b)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,r;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,r=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>r(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&r(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const r=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(r,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})),k=e=>t=>{var n,r,s;const a=i(g,b,w)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,o(this,n,"m",r).bind(this))}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),c.forEach((e=>o(this,n,"m",r).call(this,e,this.getAttribute(e))))}},n=new WeakSet,r=function(t,n){const o=e[t],r="function"==typeof o?o(t,n):o;r&&this.logger.error(r)},s};k.missingAttrValidator=v;const j=a((e=>{const t=i(k({"project-id":v}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),I=a((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}}));const O=a((e=>{const t=i(g,j,I)(e);return class extends t{async fetchStaticResource(e,t){const n=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const r=new URL(y||o||"https://static.descope.com/pages");return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,n,t),r.toString()}({projectId:this.projectId,filename:e,baseUrl:this.baseStaticUrl}),o=await fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:await o[t](),headers:Object.fromEntries(o.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),S=a((e=>{var t,n,s;const a=i(O)(e);return s=class extends a{constructor(){super(...arguments),t.set(this,void 0),n.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")}}))}get config(){return o(this,t,"f")||r(this,t,o(this,n,"f").call(this),"f"),o(this,t,"f")}},t=new WeakMap,n=new WeakMap,s})),x=a((e=>{var t,n,s,a,c,l,u;return u=class extends(i(b,g)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,r)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,r),"debug"===e&&o(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var r;null===(r=super.onLogEvent)||void 0===r||r.call(this,e,n),"error"===e&&o(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),r(this,n,null,"f")},a=async function(){r(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Cs})),document.body.appendChild(o(this,n,"f"))},c=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},l=function(e,t){var r;e&&(null===(r=o(this,n,"f"))||void 0===r||r.updateData({title:e,description:t}))},u})),E="load-descope-ui",C="base.ui.components.url",_=m&&localStorage.getItem(C)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",A=m&&localStorage.getItem(C)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",T=m&&localStorage.getItem(C)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",R=e=>{const t=document.createElement("script");return t.id=e,t},P=(e,t)=>e.replace("<version>",t),U=a((e=>{var t,n,s,a,c,l,u,d,p,h,f,m;const y=i(g,S)(e);return m=class extends y{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),s.set(this,Symbol("loadCbs")),p.set(this,void 0)}get descopeUi(){return o(this,p,"f")||r(this,p,o(this,t,"m",f).call(this),"f"),o(this,p,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",h).call(this,e))))}},n=new WeakMap,s=new WeakMap,p=new WeakMap,t=new WeakSet,a=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},c=function(e){const t=o(this,n,"f"),r=o(this,s,"f");e[t]=[],e[r]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[r].push(t)}})},l=async function(e,n,r,i){this.logger.debug("Trying to load DescopeUI from a fallback URL");const s=R(r);document.body.append(s),s.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${s.src}"`)))})),s.addEventListener("load",(()=>{n.forEach((e=>e()))})),s.src=P(i,await o(this,t,"m",a).call(this))},u=function(e){e.addEventListener("error",(()=>{e[o(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),o(this,t,"m",l).call(this,[o(this,t,"m",l).bind(this,e[o(this,n,"f")],e[o(this,s,"f")],"load-descope-ui-fallback-script-2",T),...e[o(this,n,"f")]],e[o(this,s,"f")],"load-descope-ui-fallback-script",A)})),e.addEventListener("load",(()=>{e[o(this,s,"f")].forEach((e=>e()))}))},d=async function(){if(document.querySelector(`script#${E}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=R(E);document.body.append(e),o(this,t,"m",c).call(this,e),o(this,t,"m",u).call(this,e),e.src=P(_,await o(this,t,"m",a).call(this))}return document.getElementById(E)},h=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},f=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),o(this,t,"m",d).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},m})),$="content-root",M="root",D=a((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${M}, #${$} {\n height: 100%;\n }\n #${M} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${M}">\n <div id="${$}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById($),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(M)}})),L="descope-modal";var N;let z=class{constructor(e,t){N.set(this,void 0),this.nodeName="",r(this,N,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,N,"f"))}get ele(){var e,t;const n="function"==typeof o(this,N,"f")?o(this,N,"f").call(this):o(this,N,"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)}};var W;N=new WeakMap;let F=class extends z{constructor(){super(...arguments),W.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,W,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,W,"f").content.cloneNode(!0)))}setContent(e){r(this,W,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};W=new WeakMap;let q=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()}},H=class extends z{constructor(){super(...arguments),this.nodeName="descope-apps-list"}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}};a((e=>{var t,n;const r=i(b,D,U)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends F{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(L);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([L]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));const J="descope-notification";a((e=>{var t,n;const r=i(b,D,U)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends q{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(J);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([J])}},t=new WeakMap,n}));const K=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',V=a((e=>{var t,n,s,a,c,l,u,d,p,h,f,g,m,y;const v=i(k({theme:K}),O,b,U,S,D,w)(e);return y=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{o(this,t,"m",g).call(this),o(this,m,"f").call(this,"os"===this.getAttribute("theme"))})),m.set(this,(e=>{var n,r,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(r=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===r?void 0:r[s])||void 0===i||i.call(r,"change",(()=>o(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this),o(this,t,"m",u).call(this),o(this,f,"f").call(this),this.observeAttributes(["theme"],o(this,f,"f")),this.observeAttributes(["style-id"],(()=>{r(this,s,null,"f"),o(this,t,"m",p).call(this),o(this,t,"m",l).call(this),o(this,t,"m",u).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,m=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(C))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(C),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},c=function(){return o(this,s,"f")||(r(this,s,o(this,t,"m",a).call(this),"f"),o(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,s,"f")},l=async function(){var e,i;const s=await o(this,t,"a",c);s&&(o(this,n,"f")||(r(this,n,document.createElement("style"),"f"),o(this,n,"f").id="global-style",this.shadowRoot.appendChild(o(this,n,"f"))),o(this,n,"f").innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||""))},u=async function(){var e,n;const r=Object.assign({},await o(this,t,"a",c));if(!r)return;const i=await this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components,dark:null===(n=null==r?void 0:r.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],r=null==n?void 0:n.cssTemplate,i=o||r;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},p=async function(){const e=await o(this,t,"m",d).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},h=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){o(this,t,"m",p).call(this),o(this,t,"m",h).call(this)},y}));var B=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),Y=()=>Math.random().toString(36).substring(7).split("").join("."),X={INIT:`@@redux/INIT${Y()}`,REPLACE:`@@redux/REPLACE${Y()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Y()}`};function G(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 Z(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 Q(e){let t=typeof e;return t=Z(e),t}function ee(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Q(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: '${Q(n)}'`);return n(ee)(e,t)}let o=e,r=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function u(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function d(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Q(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function p(e){if(!G(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Q(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: '${Q(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,r=o(r,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}p({type:X.INIT});return{dispatch:p,subscribe:d,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${Q(e)}`);o=e,p({type:X.REPLACE})},[B]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${Q(t)}'`);function n(){const e=t;e.next&&e.next(u())}n();return{unsubscribe:e(n)}},[B](){return this}}}}}function te(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ne(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const r=t[o];void 0===e[r]&&te(`No reducer provided for key "${r}"`),"function"==typeof e[r]&&(n[r]=e[r])}const o=Object.keys(n);let r,i;r={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:X.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:X.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 '${X.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){i=e}return function(e={},t){if(i)throw i;{const o=function(e,t,n,o){const r=Object.keys(t),i=n&&n.type===X.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!G(e))return`The ${i} has unexpected type of "${Q(e)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===X.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${r.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,r);o&&te(o)}let s=!1;const a={};for(let r=0;r<o.length;r++){const i=o[r],c=n[i],l=e[i],u=c(l,t);if(void 0===u){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 "${i}" 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[i]=u,s=s||u!==l}return s=s||o.length!==Object.keys(e).length,s?a:e}}function oe(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function re(e){return G(e)&&"type"in e&&"string"==typeof e.type}var ie=Symbol.for("immer-nothing"),se=Symbol.for("immer-draftable"),ae=Symbol.for("immer-state"),ce=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function le(e,...t){{const n=ce[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var ue=Object.getPrototypeOf;function de(e){return!!e&&!!e[ae]}function pe(e){return!!e&&(fe(e)||Array.isArray(e)||!!e[se]||!!e.constructor?.[se]||be(e)||we(e))}var he=Object.prototype.constructor.toString();function fe(e){if(!e||"object"!=typeof e)return!1;const t=ue(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)===he}function ge(e,t){0===me(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function me(e){const t=e[ae];return t?t.type_:Array.isArray(e)?1:be(e)?2:we(e)?3:0}function ye(e,t){return 2===me(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ve(e,t,n){const o=me(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function be(e){return e instanceof Map}function we(e){return e instanceof Set}function ke(e){return e.copy_||e.base_}function je(e,t){if(be(e))return new Map(e);if(we(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&fe(e)){if(!ue(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[ae];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const r=o[t],i=n[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[r]})}return Object.create(ue(e),n)}function Ie(e,t=!1){return Se(e)||de(e)||!pe(e)||(me(e)>1&&(e.set=e.add=e.clear=e.delete=Oe),Object.freeze(e),t&&ge(e,((e,t)=>Ie(t,!0)))),e}function Oe(){le(2)}function Se(e){return Object.isFrozen(e)}var xe,Ee={};function Ce(e){const t=Ee[e];return t||le(0,e),t}function _e(){return xe}function Ae(e,t){t&&(Ce("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Te(e){Re(e),e.drafts_.forEach(Ue),e.drafts_=null}function Re(e){e===xe&&(xe=e.parent_)}function Pe(e){return xe={drafts_:[],parent_:xe,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ue(e){const t=e[ae];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function $e(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[ae].modified_&&(Te(t),le(4)),pe(e)&&(e=Me(t,e),t.parent_||Le(t,e)),t.patches_&&Ce("Patches").generateReplacementPatches_(n[ae].base_,e,t.patches_,t.inversePatches_)):e=Me(t,n,[]),Te(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ie?e:void 0}function Me(e,t,n){if(Se(t))return t;const o=t[ae];if(!o)return ge(t,((r,i)=>De(e,o,t,r,i,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return Le(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let r=t,i=!1;3===o.type_&&(r=new Set(t),t.clear(),i=!0),ge(r,((r,s)=>De(e,o,t,r,s,n,i))),Le(e,t,!1),n&&e.patches_&&Ce("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function De(e,t,n,o,r,i,s){if(r===n&&le(5),de(r)){const s=Me(e,r,i&&t&&3!==t.type_&&!ye(t.assigned_,o)?i.concat(o):void 0);if(ve(n,o,s),!de(s))return;e.canAutoFreeze_=!1}else s&&n.add(r);if(pe(r)&&!Se(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Me(e,r),t&&t.scope_.parent_||Le(e,r)}}function Le(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ie(t,n)}var Ne={get(e,t){if(t===ae)return e;const n=ke(e);if(!ye(n,t))return function(e,t,n){const o=Fe(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!pe(o)?o:o===We(e.base_,t)?(He(e),e.copy_[t]=Je(o,e)):o},has:(e,t)=>t in ke(e),ownKeys:e=>Reflect.ownKeys(ke(e)),set(e,t,n){const o=Fe(ke(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=We(ke(e),t),r=o?.[ae];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||ye(e.base_,t)))return!0;He(e),qe(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!==We(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,He(e),qe(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=ke(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){le(11)},getPrototypeOf:e=>ue(e.base_),setPrototypeOf(){le(12)}},ze={};function We(e,t){const n=e[ae];return(n?ke(n):e)[t]}function Fe(e,t){if(!(t in e))return;let n=ue(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=ue(n)}}function qe(e){e.modified_||(e.modified_=!0,e.parent_&&qe(e.parent_))}function He(e){e.copy_||(e.copy_=je(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ge(Ne,((e,t)=>{ze[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ze.deleteProperty=function(e,t){return isNaN(parseInt(t))&&le(13),ze.set.call(this,e,t,void 0)},ze.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&le(14),Ne.set.call(this,e[0],t,n,e[0])};function Je(e,t){const n=be(e)?Ce("MapSet").proxyMap_(e,t):we(e)?Ce("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:_e(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=Ne;n&&(r=[o],i=ze);const{revoke:s,proxy:a}=Proxy.revocable(r,i);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:_e()).drafts_.push(n),n}function Ke(e){return de(e)||le(10,e),Ve(e)}function Ve(e){if(!pe(e)||Se(e))return e;const t=e[ae];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=je(e,t.scope_.immer_.useStrictShallowCopy_)}else n=je(e,!0);return ge(n,((e,t)=>{ve(n,e,Ve(t))})),t&&(t.finalized_=!1),n}var Be=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...r){return o.produce(e,(e=>t.call(this,e,...r)))}}let o;if("function"!=typeof t&&le(6),void 0!==n&&"function"!=typeof n&&le(7),pe(e)){const r=Pe(this),i=Je(e,void 0);let s=!0;try{o=t(i),s=!1}finally{s?Te(r):Re(r)}return Ae(r,n),$e(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===ie&&(o=void 0),this.autoFreeze_&&Ie(o,!0),n){const t=[],r=[];Ce("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}le(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const r=this.produce(e,t,((e,t)=>{n=e,o=t}));return[r,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){pe(e)||le(8),de(e)&&(e=Ke(e));const t=Pe(this),n=Je(e,void 0);return n[ae].isManual_=!0,Re(t),n}finishDraft(e,t){const n=e&&e[ae];n&&n.isManual_||le(9);const{scope_:o}=n;return Ae(o,t),$e(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Ce("Patches").applyPatches_;return de(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},Ye=Be.produce;Be.produceWithPatches.bind(Be),Be.setAutoFreeze.bind(Be),Be.setUseStrictShallowCopy.bind(Be),Be.applyPatches.bind(Be),Be.createDraft.bind(Be),Be.finishDraft.bind(Be);var Xe=(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})}}},Ge=(e,t,n)=>{const{memoize:o,memoizeOptions:r}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...r);if(!(a.apply(null,i)===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:i,secondInputs:s,stack:e})}},Ze={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Qe=e=>Array.isArray(e)?e:[e];function et(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 tt(e,t){const n=[],{length:o}=e;for(let r=0;r<o;r++)n.push(e[r].apply(null,t));return n}var nt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},ot=0,rt=1;function it(){return{s:ot,v:void 0,o:null,p:null}}function st(e,t={}){let n=it();const{resultEqualityCheck:o}=t;let r,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=it(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=it(),e.set(n,t)):t=o}}const a=t;let c;if(t.s===rt)c=t.v;else if(c=e.apply(null,arguments),i++,o){const e=r?.deref?.()??r;null!=e&&o(e,c)&&(c=e,0!==i&&i--);r="object"==typeof c&&null!==c||"function"==typeof c?new nt(c):c}return a.s=rt,a.v=c,c}return s.clearCache=()=>{n=it(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function at(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,r=0,i={},s=e.pop();"object"==typeof s&&(i=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,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:u=st,argsMemoizeOptions:d=[],devModeChecks:p={}}=a,h=Qe(l),f=Qe(d),g=et(e),m=c((function(){return o++,s.apply(null,arguments)}),...h);let y=!0;const v=u((function(){r++;const e=tt(g,arguments);t=m.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Ze,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Xe},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:Ge}}})(y,p);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=tt(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:h},arguments)}y&&(y=!1)}return t}),...f);return Object.assign(v,{resultFunc:s,memoizedResultFunc:m,dependencies:g,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:c,argsMemoize:u})};return Object.assign(o,{withTypes:()=>o}),o}var ct=at(st),lt=Object.assign(((e,t=ct)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})))}),{withTypes:()=>lt});function ut(e){return({dispatch:t,getState:n})=>o=>r=>"function"==typeof r?r(t,n,e):o(r)}var dt=ut(),pt=ut;((...e)=>{const t=at(...e)})(st);var ht="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?oe:oe.apply(null,arguments)},ft=e=>e&&"function"==typeof e.match;function gt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>re(t)&&t.type===e,n}function mt(e){return"function"==typeof e&&"type"in e&&ft(e)}function yt(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 vt=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 bt(e){return pe(e)?Ye(e,(()=>{})):e}function wt(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function kt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function jt(e,t,n){const o=It(e,t,n);return{detectMutations:()=>Ot(e,t,o,n)}}function It(e,t=[],n,o="",r=new Set){const i={value:n};if(!e(n)&&!r.has(n)){r.add(n),i.children={};for(const r in n){const s=o?o+"."+r:r;t.length&&-1!==t.indexOf(s)||(i.children[r]=It(e,t,n[r],s))}}return i}function Ot(e,t=[],n,o,r=!1,i=""){const s=n?n.value:void 0,a=s===o;if(r&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:i};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let r in c){const s=i?i+"."+r:r;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Ot(e,t,n.children[r],o[r],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function St(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||G(e)}function xt(e,t="",n=St,o,r=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),c=r.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(r.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=xt(l,a,n,o,r,i),s))return s}return i&&Et(e)&&i.add(e),!1}function Et(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Et(t))return!1;return!0}function Ct(e){return"boolean"==typeof e}var _t=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:r=!0}=e??{};let i=new vt;if(t&&(Ct(t)?i.push(dt):i.push(pt(t.extraArgument))),n){let e={};Ct(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,o,r){return JSON.stringify(e,n(t,r),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(r,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,r):o.push(r),~n.indexOf(i)&&(i=t.call(this,r,i))}else n.push(i);return null==e?i:e.call(this,r,i)}},{isImmutable:o=kt,ignoredPaths:r,warnAfter:i=32}=e;const s=jt.bind(null,o,r);return({getState:e})=>{let n,o=e(),r=s(o);return a=>c=>{const l=yt(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const u=a(c);return l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),u}}}}(e))}if(o){let e={};Ct(o)||(e=o),i.push(function(e={}){{const{isSerializable:t=St,getEntries:n,ignoredActions:o=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,u=!l&&WeakSet?new WeakSet:void 0;return e=>l=>d=>{if(!re(d))return l(d);const p=l(d),h=yt(s,"SerializableStateInvariantMiddleware");return c||o.length&&-1!==o.indexOf(d.type)||h.measureTime((()=>{const e=xt(d,"",t,n,r,u);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: ",d,"\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||(h.measureTime((()=>{const o=xt(e.getState(),"",t,n,i,u);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${d.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),h.warnIfExceeded()),p}}}(e))}if(r){let e={};Ct(r)||(e=r),i.unshift(function(e={}){const{isActionCreator:t=mt}=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 i},At=e=>t=>{setTimeout(t,e)},Tt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:At(10),Rt=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new vt(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let r=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Tt:"callback"===e.type?e.queueNotification:At(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>r&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return r=!e?.meta?.RTK_autoBatch,i=!r,i&&(s||(s=!0,c(l))),o.dispatch(e)}finally{r=!0}}})})("object"==typeof n?n:void 0)),o};function Pt(e){const t=_t(),{reducer:n,middleware:o,devTools:r=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!G(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=ne(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(c=o(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=oe;r&&(l=ht({trace:!0,..."object"==typeof r&&r}));const u=function(...e){return t=>(n,o)=>{const r=t(n,o);let i=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:r.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=oe(...a)(r.dispatch),{...r,dispatch:i}}}(...c),d=Rt(u);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let p="function"==typeof s?s(d):d();if(!Array.isArray(p))throw new Error("`enhancers` callback must return an array");if(p.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!p.includes(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return ee(a,i,l(...p))}function Ut(e){const t={},n=[];let o;const r={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,r},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),r},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,r}};return e(r),[t,n,o]}function $t(...e){return t=>e.some((e=>((e,t)=>ft(e)?e.match(t):e(t))(e,t)))}var Mt=["name","message","stack","code"],Dt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Lt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Nt=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Mt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},zt=(()=>{function e(e,t,n){const o=gt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),r=gt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=gt(e+"/rejected",((e,t,o,r,i)=>({payload:r,error:(n&&n.serializeError||Nt)(e||"Rejected"),meta:{...i||{},arg:o,requestId:t,rejectedWithValue:!!r,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),u=new AbortController;let d;function p(e){d=e,u.abort()}const h=async function(){let h;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||u.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>u.signal.addEventListener("abort",(()=>t({name:"AbortError",message:d||"Aborted"})))));s(r(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),h=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:u.signal,abort:p,rejectWithValue:(e,t)=>new Dt(e,t),fulfillWithValue:(e,t)=>new Lt(e,t)})).then((t=>{if(t instanceof Dt)throw t;return t instanceof Lt?o(t.payload,l,e,t.meta):o(t,l,e)}))])}catch(t){h=t instanceof Dt?i(null,l,e,t.payload,t.meta):i(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(h)&&h.meta.condition||s(h),h}();return Object.assign(h,{abort:p,requestId:l,arg:e,unwrap:()=>h.then(Wt)})}}),{pending:r,rejected:i,fulfilled:o,settled:$t(i,o),typePrefix:e})}return e.withTypes=()=>e,e})();function Wt(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var Ft=Symbol.for("rtk-slice-createasyncthunk");function qt(e,t){return`${e}/${t}`}function Ht(e,t,n,o){function r(r,...i){let s=n.call(e,r);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return r.unwrapped=t,r}var Jt=function({creators:e}={}){const t=e?.asyncThunk?.[Ft];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const r=("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)||{},i=Object.keys(r),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?Ut(e.extraReducers):[e.extraReducers],r={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,r,i]=Ut(t);if(function(e){return"function"==typeof e}(e))n=()=>bt(e());else{const t=bt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...r.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(de(e)){const o=n(e,t);return void 0===o?e:o}if(pe(e))return Ye(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in r)e.addCase(t,r[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}i.forEach((o=>{const i=r[o],s={reducerName:o,type:qt(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,r){let i,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=o.reducer,s=o.prepare}else i=o;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?gt(e,s):gt(e))}(s,i,a):function({type:e,reducerName:t},n,o,r){if(!r)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:i,fulfilled:s,pending:a,rejected:c,settled:l,options:u}=n,d=r(e,i,u);o.exposeAction(t,d),s&&o.addCase(d.fulfilled,s);a&&o.addCase(d.pending,a);c&&o.addCase(d.rejected,c);l&&o.addMatcher(d.settled,l);o.exposeCaseReducer(t,{fulfilled:s||Kt,pending:a||Kt,rejected:c||Kt,settled:l||Kt})}(s,i,a,t)}));const l=e=>e,u=new WeakMap;let d;const p={name:n,reducerPath:o,reducer:(e,t)=>(d||(d=c()),d(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(d||(d=c()),d.getInitialState()),getSelectors(t=l){const n=wt(u,this,{insert:()=>new WeakMap});return wt(n,t,{insert:()=>{const n={};for(const[o,r]of Object.entries(e.selectors??{}))n[o]=Ht(this,r,t,this!==p);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===p)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return p}}();function Kt(){}var Vt="listenerMiddleware";gt(`${Vt}/add`),gt(`${Vt}/removeAll`),gt(`${Vt}/remove`);const Bt=e=>a((t=>{const n=Jt(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(g)(t)){constructor(...e){super(...e);const t=Pt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),r=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{Wt(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},i=Object.keys(o).reduce(((e,t)=>(e[t]=r(o[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));var Yt;a((e=>class extends(g(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()}})),a((e=>class extends e{get baseStaticUrl(){return this.getAttribute("base-static-url")||""}})),function(e){e.oidc="oidc",e.saml="saml"}(Yt||(Yt={}));const Xt=ct((e=>e.ssoAppsList.data),(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===Yt.saml))})),Gt=ct(Xt,(e=>e.map((e=>({name:e.name,icon:e.logo,url:e.samlSettings.idpInitiatedUrl}))))),Zt=zt("ssoApps/load",((e,{extra:{api:t}})=>t.ssoApps.load())),Qt=(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)}))}))})(Zt)({onFulfilled:(e,t)=>{var n;e.ssoAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},(en=e=>e.ssoAppsList,{onFulfilled:e=>{en(e).loading=!1},onPending:e=>{en(e).loading=!0,en(e).error=null},onRejected:(e,t)=>{en(e).loading=!1,en(e).error=t.error}}));var en;const tn={action:Zt,reducer:Qt},nn={ssoAppsList:{data:[],loading:!1,error:null}};class on extends Error{}function rn(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 sn(e,t){if("string"!=typeof e)throw new on("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,o=e.split(".")[n];if("string"!=typeof o)throw new on(`Invalid token specified: missing part #${n+1}`);let r;try{r=rn(o)}catch(e){throw new on(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new on(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}on.prototype.name="InvalidTokenError";var an="/v1/auth/accesskey/exchange",cn="/v1/auth/otp/verify",ln="/v1/auth/otp/signin",un="/v1/auth/otp/signup",dn={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},pn="/v1/auth/otp/signup-in",hn="/v1/auth/magiclink/verify",fn="/v1/auth/magiclink/signin",gn="/v1/auth/magiclink/signup",mn={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},yn="/v1/auth/magiclink/signup-in",vn="/v1/auth/enchantedlink/verify",bn="/v1/auth/enchantedlink/signin",wn="/v1/auth/enchantedlink/signup",kn="/v1/auth/enchantedlink/pending-session",jn={email:"/v1/auth/enchantedlink/update/email"},In="/v1/auth/enchantedlink/signup-in",On="/v1/auth/oauth/authorize",Sn="/v1/auth/oauth/exchange",xn="v1/auth/oauth/native/start",En="v1/auth/oauth/native/finish",Cn="/v1/auth/saml/authorize",_n="/v1/auth/saml/exchange",An="/v1/auth/totp/verify",Tn="/v1/auth/totp/signup",Rn="/v1/auth/totp/update",Pn="/v1/auth/notp/whatsapp/signin",Un="/v1/auth/notp/whatsapp/signup",$n="/v1/auth/notp/whatsapp/signup-in",Mn="/v1/auth/notp/pending-session",Dn={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Ln={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Nn={start:"/v1/auth/webauthn/signup-in/start"},zn={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Wn="/v1/auth/password/signup",Fn="/v1/auth/password/signin",qn="/v1/auth/password/reset",Hn="/v1/auth/password/update",Jn="/v1/auth/password/replace",Kn="/v1/auth/password/policy",Vn="/v1/auth/refresh",Bn="/v1/auth/tenant/select",Yn="/v1/auth/logout",Xn="/v1/auth/logoutall",Gn="/v1/auth/me",Zn="/v1/auth/me/tenants",Qn="/v1/auth/me/history",eo="/v1/flow/start",to="/v1/flow/next";const no="<region>",oo=`https://api.${no}descope.com`,ro=6e5,io="dct",so=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let ao;const co=()=>{if(ao)return ao;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 ao=`${t}-${n}`,ao};var lo,uo;(uo=lo||(lo={})).get="GET",uo.delete="DELETE",uo.post="POST",uo.put="PUT",uo.patch="PATCH";const po=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(no,r?r+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{i=`${i}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return i},ho=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),fo={"Content-Type":"application/json"},go=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},mo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},yo=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>so().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return so().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,s),c=async o=>{var s;const c=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:l,body:u,headers:d,queryParams:p,method:h,token:f}=c,g=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:ho(go(t,f),{"x-descope-sdk-session-id":co(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.33.0"},(null==n?void 0:n.baseHeaders)||{},mo(g)?fo:{},d),method:h,body:g};null!==i&&(m.credentials=i||"include");const y=await a(po({path:l,baseUrl:e,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==y?void 0:y.clone()),null==r?void 0:r.transformResponse){const e=await y.json(),t=((null===(s=y.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return y};return{get:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:lo.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:lo.post,token:r}),patch:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:lo.patch,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:lo.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:lo.delete,token:o}),hooks:r,buildUrl:(n,o)=>po({projectId:t,baseUrl:e,path:n,queryParams:o})}};var vo=429;function bo(e,t,n){var o;let r=wo(e);if(t){if(!(null==r?void 0:r.tenants)&&(null==r?void 0:r[io])===t)return(null==r?void 0:r[n])||[];r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]}const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function wo(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return sn(e)}function ko(e){const{exp:t}=wo(e);return(new Date).getTime()/1e3>t}function jo(e){let t=wo(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Io(e,t){return bo(e,t,"permissions")}function Oo(e,t){return bo(e,t,"roles")}const So=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function xo(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=t?t(i):i:(r.error=i,o.status===vo&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const Eo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Co=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},_o=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Ao=e=>t=>e.test(t),To=Ao(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ro=Ao(/^\+[1-9]{1}[0-9]{3,14}$/),Po=Eo(To,'"{val}" is not a valid email'),Uo=Eo(Ro,'"{val}" is not a valid phone number'),$o=Eo((e=>e.length>=1),"Minimum length is 1");const Mo=Eo((e=>"string"==typeof e),"Input is not a string"),Do=Eo((e=>Array.isArray(e)),"Input is not an array"),Lo=Eo((e=>"boolean"==typeof e),"Input is not a boolean"),No=Eo((e=>void 0===e),"Input is defined"),zo=Co([Mo(),No()],"Input is not a string or undefined"),Wo=Co([Do(),Lo()],"Input is not an array or boolean"),Fo=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>_o(...e).validate(n[t]))),t(...n)),qo=e=>[Mo(`"${e}" must be a string`)],Ho=e=>[Mo(`"${e}" must be a string`),$o(`"${e}" must not be empty`)],Jo=e=>[Mo(`"${e}" must be a string`),Po()],Ko=e=>[Mo(`"${e}" must be a string`),Uo()],Vo=Fo(Ho("accessKey")),Bo=e=>({exchange:Vo(((t,n)=>xo(e.post(an,{loginOptions:n},{token:t}))))}),Yo=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const s=i[r];i[r]=n(s)})),e),Xo=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||ro,ro)});var Go,Zo;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(Go||(Go={})),function(e){e.email="email"}(Zo||(Zo={}));const Qo=Object.assign(Object.assign({},Go),Zo);var er;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(er||(er={}));const tr=Ho("loginId"),nr=Fo(Ho("token")),or=Fo(tr),rr=Fo(Ho("pendingRef")),ir=Fo(tr,Jo("email")),sr=e=>({verify:nr((t=>xo(e.post(vn,{token:t})))),signIn:or(((t,n,o,r)=>xo(e.post(So(bn,Qo.email),{loginId:t,URI:n,loginOptions:o},{token:r})))),signUpOrIn:or(((t,n,o)=>xo(e.post(So(In,Qo.email),{loginId:t,URI:n,loginOptions:o})))),signUp:or(((t,n,o,r)=>xo(e.post(So(wn,Qo.email),{loginId:t,URI:n,user:o,loginOptions:r})))),waitForSession:rr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=Xo(n);let s;const a=setInterval((async()=>{const n=await e.post(kn,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ir(((t,n,o,r,i)=>xo(e.post(jn.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),ar=Fo(Ho("flowId")),cr=Fo(Ho("executionId"),Ho("stepId"),Ho("interactionId")),lr=e=>({start:ar(((t,n,o,r,i,s,a)=>xo(e.post(eo,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,componentsVersion:i,flowVersions:s,input:a})))),next:cr(((t,n,o,r,i,s)=>xo(e.post(to,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:s}))))}),ur=Ho("loginId"),dr=Fo(Ho("token")),pr=Fo(ur),hr=Fo(ur,Ko("phone")),fr=Fo(ur,Jo("email")),gr=Object.keys(Qo).filter((e=>e!==Go.voice)),mr=e=>({verify:dr((t=>xo(e.post(hn,{token:t})))),signIn:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pr(((t,o,r,i)=>xo(e.post(So(fn,n),{loginId:t,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pr(((t,o,r,i)=>xo(e.post(So(gn,n),{loginId:t,URI:o,user:r,loginOptions:i}))))})),{}),signUpOrIn:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pr(((t,o,r)=>xo(e.post(So(yn,n),{loginId:t,URI:o,loginOptions:r}))))})),{}),update:{email:fr(((t,n,o,r,i)=>xo(e.post(mn.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(Go).filter((e=>e!==Go.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:hr(((t,o,r,i,s)=>xo(e.post(So(mn.phone,n),Object.assign({loginId:t,phone:o,URI:r},s),{token:i}))))})),{})}});var yr;!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"}(yr||(yr={}));const vr=Fo(Ho("code")),br=e=>({start:Object.assign(((t,n,o,r)=>xo(e.post(On,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:r}))),Object.keys(yr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r)=>xo(e.post(On,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:r}))})),{})),exchange:vr((t=>xo(e.post(Sn,{code:t})))),startNative:(t,n,o)=>xo(e.post(xn,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,r,i)=>xo(e.post(En,{provider:t,stateId:n,user:o,code:r,idToken:i}))}),wr=Ho("loginId"),kr=Fo(wr,Ho("code")),jr=Fo(wr),Ir=Fo(wr,Ko("phone")),Or=Fo(wr,Jo("email")),Sr=e=>({verify:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:kr(((t,o)=>xo(e.post(So(cn,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jr(((t,o,r)=>xo(e.post(So(ln,n),{loginId:t,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jr(((t,o,r)=>xo(e.post(So(un,n),{loginId:t,user:o,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jr(((t,o)=>xo(e.post(So(pn,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:Or(((t,n,o,r)=>xo(e.post(dn.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(Go).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ir(((t,o,r,i)=>xo(e.post(So(dn.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),xr=Fo(Ho("tenant")),Er=Fo(Ho("code")),Cr=e=>({start:xr(((t,n,o,r)=>xo(e.post(Cn,o||{},{queryParams:{tenant:t,redirectURL:n},token:r})))),exchange:Er((t=>xo(e.post(_n,{code:t}))))}),_r=Ho("loginId"),Ar=Fo(_r,Ho("code")),Tr=Fo(_r),Rr=Fo(_r),Pr=e=>({signUp:Tr(((t,n)=>xo(e.post(Tn,{loginId:t,user:n})))),verify:Ar(((t,n,o,r)=>xo(e.post(An,{loginId:t,code:n,loginOptions:o},{token:r})))),update:Rr(((t,n)=>xo(e.post(Rn,{loginId:t},{token:n}))))}),Ur=Ho("loginId"),$r=Ho("newPassword"),Mr=Fo(Ur,Ho("password")),Dr=Fo(Ur),Lr=Fo(Ur,$r),Nr=Fo(Ur,Ho("oldPassword"),$r),zr=e=>({signUp:Mr(((t,n,o,r)=>xo(e.post(Wn,{loginId:t,password:n,user:o,loginOptions:r})))),signIn:Mr(((t,n,o)=>xo(e.post(Fn,{loginId:t,password:n,loginOptions:o})))),sendReset:Dr(((t,n,o)=>xo(e.post(qn,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Lr(((t,n,o)=>xo(e.post(Hn,{loginId:t,newPassword:n},{token:o})))),replace:Nr(((t,n,o)=>xo(e.post(Jn,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>xo(e.get(Kn))}),Wr=qo("loginId"),Fr=Ho("loginId"),qr=Ho("origin"),Hr=Fo(Fr,qr,Ho("name")),Jr=Fo(Fr,qr),Kr=Fo(Wr,qr),Vr=Fo(Fr,qr,Ho("token")),Br=Fo(Ho("transactionId"),Ho("response")),Yr=e=>({signUp:{start:Hr(((t,n,o,r)=>xo(e.post(Dn.start,{user:{loginId:t,name:o},origin:n,passkeyOptions:r})))),finish:Br(((t,n)=>xo(e.post(Dn.finish,{transactionId:t,response:n}))))},signIn:{start:Kr(((t,n,o,r,i)=>xo(e.post(Ln.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i},{token:r})))),finish:Br(((t,n)=>xo(e.post(Ln.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Jr(((t,n,o)=>xo(e.post(Nn.start,{loginId:t,origin:n,passkeyOptions:o}))))},update:{start:Vr(((t,n,o,r)=>xo(e.post(zn.start,{loginId:t,origin:n,passkeyOptions:r},{token:o})))),finish:Br(((t,n)=>xo(e.post(zn.finish,{transactionId:t,response:n}))))}}),Xr=qo("loginId"),Gr=Fo(Xr),Zr=Fo(Ho("pendingRef")),Qr=e=>({signUpOrIn:Gr(((t,n)=>xo(e.post($n,{loginId:t,loginOptions:n})))),signUp:Gr(((t,n,o)=>xo(e.post(Un,{loginId:t,user:n,loginOptions:o})))),signIn:Gr(((t,n,o)=>xo(e.post(Pn,{loginId:t,loginOptions:n},{token:o})))),waitForSession:Zr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=Xo(n);let s;const a=setInterval((async()=>{const n=await e.post(Mn,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),ei=Fo(Ho("token")),ti=Fo([zo('"token" must be string or undefined')]);var ni,oi=Fo([(ni=Ho("projectId"),Eo(((e,t)=>n=>_o(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let r=0,i=e===Object(e)?e:void 0;for(;null!=i&&r<o;)i=i[n[r++]];return r&&r===o&&void 0!==i?i:void 0})(n,e)))("projectId",ni))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:s})=>{return a=yo({baseUrl:n||oo,projectId:e,logger:t,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:Bo(a),otp:Sr(a),magicLink:mr(a),enchantedLink:sr(a),oauth:br(a),saml:Cr(a),totp:Pr(a),notp:Qr(a),webauthn:Yr(a),password:zr(a),flow:lr(a),refresh:ti(((e,t)=>xo(a.post(Vn,{},{token:e,queryParams:t})))),selectTenant:Fo([Mo("tenantId")],[zo('"token" must be string or undefined')])(((e,t)=>xo(a.post(Bn,{tenant:e},{token:t})))),logout:ti((e=>xo(a.post(Yn,{},{token:e})))),logoutAll:ti((e=>xo(a.post(Xn,{},{token:e})))),me:ti((e=>xo(a.get(Gn,{token:e})))),myTenants:Fo([Wo('"tenants" must a string array or a boolean')],[zo('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,xo(a.post(Zn,n,{token:t}))})),history:ti((e=>xo(a.get(Qn,{token:e})))),isJwtExpired:ei(ko),getTenants:ei(jo),getJwtPermissions:ei(Io),getJwtRoles:ei(Oo),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=r.length&&(await Promise.allSettled(null==r?void 0:r.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}}))})),ri=Object.assign(oi,{DeliveryMethods:Qo});
5
+ this["descope-applications-portal-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function r(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const o=e(n);return o[t]=!0,o}};var c,l,u,d;function p(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!p(i,s))return!1}else if(i!==s)return!1}return!0}let h=class{constructor(e={},{updateOnlyOnChange:t=!0}={}){c.set(this,void 0),l.set(this,{}),u.set(this,0),d.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,c,"f")):e,n=Object.assign(Object.assign({},o(this,c,"f")),t);if(!o(this,d,"f")||!p(o(this,c,"f"),n)){const e=o(this,c,"f");r(this,c,n,"f"),Object.freeze(o(this,c,"f")),setTimeout((()=>{Object.values(o(this,l,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},r(this,c,e,"f"),r(this,d,t,"f")}get current(){return Object.assign({},o(this,c,"f"))}subscribe(e){return r(this,u,o(this,u,"f")+1,"f"),o(this,l,"f")[o(this,u,"f")]=e,o(this,u,"f").toString()}unsubscribe(e){const t=!!o(this,l,"f")[e];return t&&delete o(this,l,"f")[e],t}unsubscribeAll(){return r(this,l,{},"f"),!0}};c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap;const f=["error","warn","info","debug"],g=a((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",i).call(this,console))}set logger(e){r(this,n,o(this,t,"m",i).call(this,e),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return f.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),m="undefined"!=typeof localStorage,v=m&&localStorage.getItem("base.content.url")||"",y=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,b=a((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(r(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),w=a((e=>{var t,n;const r=i(g,b)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,r;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,r=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>r(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&r(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const r=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(r,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})),k=e=>t=>{var n,r,s;const a=i(g,b,w)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,o(this,n,"m",r).bind(this))}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),c.forEach((e=>o(this,n,"m",r).call(this,e,this.getAttribute(e))))}},n=new WeakSet,r=function(t,n){const o=e[t],r="function"==typeof o?o(t,n):o;r&&this.logger.error(r)},s};k.missingAttrValidator=y;const j=a((e=>{const t=i(k({"project-id":y}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),I=a((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}}));const O=a((e=>{const t=i(g,j,I)(e);return class extends t{async fetchStaticResource(e,t){const n=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const r=new URL(v||o||"https://static.descope.com/pages");return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,n,t),r.toString()}({projectId:this.projectId,filename:e,baseUrl:this.baseStaticUrl}),o=await fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:await o[t](),headers:Object.fromEntries(o.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),S=a((e=>{var t,n,s;const a=i(O)(e);return s=class extends a{constructor(){super(...arguments),t.set(this,void 0),n.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")}}))}get config(){return o(this,t,"f")||r(this,t,o(this,n,"f").call(this),"f"),o(this,t,"f")}},t=new WeakMap,n=new WeakMap,s})),x=a((e=>{var t,n,s,a,c,l,u;return u=class extends(i(b,g)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,r)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,r),"debug"===e&&o(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var r;null===(r=super.onLogEvent)||void 0===r||r.call(this,e,n),"error"===e&&o(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),r(this,n,null,"f")},a=async function(){r(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Cs})),document.body.appendChild(o(this,n,"f"))},c=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},l=function(e,t){var r;e&&(null===(r=o(this,n,"f"))||void 0===r||r.updateData({title:e,description:t}))},u})),E="load-descope-ui",C="base.ui.components.url",_=m&&localStorage.getItem(C)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",A=m&&localStorage.getItem(C)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",T=m&&localStorage.getItem(C)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",R=e=>{const t=document.createElement("script");return t.id=e,t},P=(e,t)=>e.replace("<version>",t),U=a((e=>{var t,n,s,a,c,l,u,d,p,h,f,m;const v=i(g,S)(e);return m=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),s.set(this,Symbol("loadCbs")),p.set(this,void 0)}get descopeUi(){return o(this,p,"f")||r(this,p,o(this,t,"m",f).call(this),"f"),o(this,p,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",h).call(this,e))))}},n=new WeakMap,s=new WeakMap,p=new WeakMap,t=new WeakSet,a=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},c=function(e){const t=o(this,n,"f"),r=o(this,s,"f");e[t]=[],e[r]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[r].push(t)}})},l=async function(e,n,r,i){this.logger.debug("Trying to load DescopeUI from a fallback URL");const s=R(r);document.body.append(s),s.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${s.src}"`)))})),s.addEventListener("load",(()=>{n.forEach((e=>e()))})),s.src=P(i,await o(this,t,"m",a).call(this))},u=function(e){e.addEventListener("error",(()=>{e[o(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),o(this,t,"m",l).call(this,[o(this,t,"m",l).bind(this,e[o(this,n,"f")],e[o(this,s,"f")],"load-descope-ui-fallback-script-2",T),...e[o(this,n,"f")]],e[o(this,s,"f")],"load-descope-ui-fallback-script",A)})),e.addEventListener("load",(()=>{e[o(this,s,"f")].forEach((e=>e()))}))},d=async function(){if(document.querySelector(`script#${E}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=R(E);document.body.append(e),o(this,t,"m",c).call(this,e),o(this,t,"m",u).call(this,e),e.src=P(_,await o(this,t,"m",a).call(this))}return document.getElementById(E)},h=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},f=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),o(this,t,"m",d).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},m})),$="content-root",M="root",D=a((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${M}, #${$} {\n height: 100%;\n }\n #${M} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${M}">\n <div id="${$}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById($),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(M)}})),L="descope-modal";var N;let z=class{constructor(e,t){N.set(this,void 0),this.nodeName="",r(this,N,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,N,"f"))}get ele(){var e,t;const n="function"==typeof o(this,N,"f")?o(this,N,"f").call(this):o(this,N,"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)}};var W;N=new WeakMap;let F=class extends z{constructor(){super(...arguments),W.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,W,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,W,"f").content.cloneNode(!0)))}setContent(e){r(this,W,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};W=new WeakMap;let q=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()}},H=class extends z{constructor(){super(...arguments),this.nodeName="descope-apps-list"}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}};a((e=>{var t,n;const r=i(b,D,U)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends F{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(L);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([L]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));const J="descope-notification";a((e=>{var t,n;const r=i(b,D,U)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends q{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(J);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([J])}},t=new WeakMap,n}));const K=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',V=a((e=>{var t,n,s,a,c,l,u,d,p,h,f,g,m,v;const y=i(k({theme:K}),O,b,U,S,D,w)(e);return v=class extends y{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{o(this,t,"m",g).call(this),o(this,m,"f").call(this,"os"===this.getAttribute("theme"))})),m.set(this,(e=>{var n,r,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(r=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===r?void 0:r[s])||void 0===i||i.call(r,"change",(()=>o(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this),o(this,t,"m",u).call(this),o(this,f,"f").call(this),this.observeAttributes(["theme"],o(this,f,"f")),this.observeAttributes(["style-id"],(()=>{r(this,s,null,"f"),o(this,t,"m",p).call(this),o(this,t,"m",l).call(this),o(this,t,"m",u).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,m=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(C))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(C),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},c=function(){return o(this,s,"f")||(r(this,s,o(this,t,"m",a).call(this),"f"),o(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,s,"f")},l=async function(){var e,i;const s=await o(this,t,"a",c);s&&(o(this,n,"f")||(r(this,n,document.createElement("style"),"f"),o(this,n,"f").id="global-style",this.shadowRoot.appendChild(o(this,n,"f"))),o(this,n,"f").innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||""))},u=async function(){var e,n;const r=Object.assign({},await o(this,t,"a",c));if(!r)return;const i=await this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components,dark:null===(n=null==r?void 0:r.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],r=null==n?void 0:n.cssTemplate,i=o||r;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},p=async function(){const e=await o(this,t,"m",d).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},h=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){o(this,t,"m",p).call(this),o(this,t,"m",h).call(this)},v}));var B=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),Y=()=>Math.random().toString(36).substring(7).split("").join("."),X={INIT:`@@redux/INIT${Y()}`,REPLACE:`@@redux/REPLACE${Y()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Y()}`};function G(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 Z(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 Q(e){let t=typeof e;return t=Z(e),t}function ee(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Q(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: '${Q(n)}'`);return n(ee)(e,t)}let o=e,r=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function u(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function d(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Q(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function p(e){if(!G(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Q(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: '${Q(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,r=o(r,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}p({type:X.INIT});return{dispatch:p,subscribe:d,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${Q(e)}`);o=e,p({type:X.REPLACE})},[B]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${Q(t)}'`);function n(){const e=t;e.next&&e.next(u())}n();return{unsubscribe:e(n)}},[B](){return this}}}}}function te(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ne(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const r=t[o];void 0===e[r]&&te(`No reducer provided for key "${r}"`),"function"==typeof e[r]&&(n[r]=e[r])}const o=Object.keys(n);let r,i;r={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:X.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:X.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 '${X.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){i=e}return function(e={},t){if(i)throw i;{const o=function(e,t,n,o){const r=Object.keys(t),i=n&&n.type===X.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!G(e))return`The ${i} has unexpected type of "${Q(e)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===X.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${r.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,r);o&&te(o)}let s=!1;const a={};for(let r=0;r<o.length;r++){const i=o[r],c=n[i],l=e[i],u=c(l,t);if(void 0===u){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 "${i}" 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[i]=u,s=s||u!==l}return s=s||o.length!==Object.keys(e).length,s?a:e}}function oe(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function re(e){return G(e)&&"type"in e&&"string"==typeof e.type}var ie=Symbol.for("immer-nothing"),se=Symbol.for("immer-draftable"),ae=Symbol.for("immer-state"),ce=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function le(e,...t){{const n=ce[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var ue=Object.getPrototypeOf;function de(e){return!!e&&!!e[ae]}function pe(e){return!!e&&(fe(e)||Array.isArray(e)||!!e[se]||!!e.constructor?.[se]||be(e)||we(e))}var he=Object.prototype.constructor.toString();function fe(e){if(!e||"object"!=typeof e)return!1;const t=ue(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)===he}function ge(e,t){0===me(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function me(e){const t=e[ae];return t?t.type_:Array.isArray(e)?1:be(e)?2:we(e)?3:0}function ve(e,t){return 2===me(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ye(e,t,n){const o=me(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function be(e){return e instanceof Map}function we(e){return e instanceof Set}function ke(e){return e.copy_||e.base_}function je(e,t){if(be(e))return new Map(e);if(we(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&fe(e)){if(!ue(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[ae];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const r=o[t],i=n[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[r]})}return Object.create(ue(e),n)}function Ie(e,t=!1){return Se(e)||de(e)||!pe(e)||(me(e)>1&&(e.set=e.add=e.clear=e.delete=Oe),Object.freeze(e),t&&ge(e,((e,t)=>Ie(t,!0)))),e}function Oe(){le(2)}function Se(e){return Object.isFrozen(e)}var xe,Ee={};function Ce(e){const t=Ee[e];return t||le(0,e),t}function _e(){return xe}function Ae(e,t){t&&(Ce("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Te(e){Re(e),e.drafts_.forEach(Ue),e.drafts_=null}function Re(e){e===xe&&(xe=e.parent_)}function Pe(e){return xe={drafts_:[],parent_:xe,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ue(e){const t=e[ae];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function $e(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[ae].modified_&&(Te(t),le(4)),pe(e)&&(e=Me(t,e),t.parent_||Le(t,e)),t.patches_&&Ce("Patches").generateReplacementPatches_(n[ae].base_,e,t.patches_,t.inversePatches_)):e=Me(t,n,[]),Te(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ie?e:void 0}function Me(e,t,n){if(Se(t))return t;const o=t[ae];if(!o)return ge(t,((r,i)=>De(e,o,t,r,i,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return Le(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let r=t,i=!1;3===o.type_&&(r=new Set(t),t.clear(),i=!0),ge(r,((r,s)=>De(e,o,t,r,s,n,i))),Le(e,t,!1),n&&e.patches_&&Ce("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function De(e,t,n,o,r,i,s){if(r===n&&le(5),de(r)){const s=Me(e,r,i&&t&&3!==t.type_&&!ve(t.assigned_,o)?i.concat(o):void 0);if(ye(n,o,s),!de(s))return;e.canAutoFreeze_=!1}else s&&n.add(r);if(pe(r)&&!Se(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Me(e,r),t&&t.scope_.parent_||Le(e,r)}}function Le(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ie(t,n)}var Ne={get(e,t){if(t===ae)return e;const n=ke(e);if(!ve(n,t))return function(e,t,n){const o=Fe(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!pe(o)?o:o===We(e.base_,t)?(He(e),e.copy_[t]=Je(o,e)):o},has:(e,t)=>t in ke(e),ownKeys:e=>Reflect.ownKeys(ke(e)),set(e,t,n){const o=Fe(ke(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=We(ke(e),t),r=o?.[ae];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||ve(e.base_,t)))return!0;He(e),qe(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!==We(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,He(e),qe(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=ke(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){le(11)},getPrototypeOf:e=>ue(e.base_),setPrototypeOf(){le(12)}},ze={};function We(e,t){const n=e[ae];return(n?ke(n):e)[t]}function Fe(e,t){if(!(t in e))return;let n=ue(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=ue(n)}}function qe(e){e.modified_||(e.modified_=!0,e.parent_&&qe(e.parent_))}function He(e){e.copy_||(e.copy_=je(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ge(Ne,((e,t)=>{ze[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ze.deleteProperty=function(e,t){return isNaN(parseInt(t))&&le(13),ze.set.call(this,e,t,void 0)},ze.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&le(14),Ne.set.call(this,e[0],t,n,e[0])};function Je(e,t){const n=be(e)?Ce("MapSet").proxyMap_(e,t):we(e)?Ce("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:_e(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=Ne;n&&(r=[o],i=ze);const{revoke:s,proxy:a}=Proxy.revocable(r,i);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:_e()).drafts_.push(n),n}function Ke(e){return de(e)||le(10,e),Ve(e)}function Ve(e){if(!pe(e)||Se(e))return e;const t=e[ae];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=je(e,t.scope_.immer_.useStrictShallowCopy_)}else n=je(e,!0);return ge(n,((e,t)=>{ye(n,e,Ve(t))})),t&&(t.finalized_=!1),n}var Be=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...r){return o.produce(e,(e=>t.call(this,e,...r)))}}let o;if("function"!=typeof t&&le(6),void 0!==n&&"function"!=typeof n&&le(7),pe(e)){const r=Pe(this),i=Je(e,void 0);let s=!0;try{o=t(i),s=!1}finally{s?Te(r):Re(r)}return Ae(r,n),$e(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===ie&&(o=void 0),this.autoFreeze_&&Ie(o,!0),n){const t=[],r=[];Ce("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}le(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const r=this.produce(e,t,((e,t)=>{n=e,o=t}));return[r,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){pe(e)||le(8),de(e)&&(e=Ke(e));const t=Pe(this),n=Je(e,void 0);return n[ae].isManual_=!0,Re(t),n}finishDraft(e,t){const n=e&&e[ae];n&&n.isManual_||le(9);const{scope_:o}=n;return Ae(o,t),$e(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Ce("Patches").applyPatches_;return de(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},Ye=Be.produce;Be.produceWithPatches.bind(Be),Be.setAutoFreeze.bind(Be),Be.setUseStrictShallowCopy.bind(Be),Be.applyPatches.bind(Be),Be.createDraft.bind(Be),Be.finishDraft.bind(Be);var Xe=(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})}}},Ge=(e,t,n)=>{const{memoize:o,memoizeOptions:r}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...r);if(!(a.apply(null,i)===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:i,secondInputs:s,stack:e})}},Ze={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Qe=e=>Array.isArray(e)?e:[e];function et(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 tt(e,t){const n=[],{length:o}=e;for(let r=0;r<o;r++)n.push(e[r].apply(null,t));return n}var nt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},ot=0,rt=1;function it(){return{s:ot,v:void 0,o:null,p:null}}function st(e,t={}){let n=it();const{resultEqualityCheck:o}=t;let r,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=it(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=it(),e.set(n,t)):t=o}}const a=t;let c;if(t.s===rt)c=t.v;else if(c=e.apply(null,arguments),i++,o){const e=r?.deref?.()??r;null!=e&&o(e,c)&&(c=e,0!==i&&i--);r="object"==typeof c&&null!==c||"function"==typeof c?new nt(c):c}return a.s=rt,a.v=c,c}return s.clearCache=()=>{n=it(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function at(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,r=0,i={},s=e.pop();"object"==typeof s&&(i=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,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:u=st,argsMemoizeOptions:d=[],devModeChecks:p={}}=a,h=Qe(l),f=Qe(d),g=et(e),m=c((function(){return o++,s.apply(null,arguments)}),...h);let v=!0;const y=u((function(){r++;const e=tt(g,arguments);t=m.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Ze,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Xe},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:Ge}}})(v,p);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=tt(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:h},arguments)}v&&(v=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:m,dependencies:g,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:c,argsMemoize:u})};return Object.assign(o,{withTypes:()=>o}),o}var ct=at(st),lt=Object.assign(((e,t=ct)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})))}),{withTypes:()=>lt});function ut(e){return({dispatch:t,getState:n})=>o=>r=>"function"==typeof r?r(t,n,e):o(r)}var dt=ut(),pt=ut;((...e)=>{const t=at(...e)})(st);var ht="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?oe:oe.apply(null,arguments)},ft=e=>e&&"function"==typeof e.match;function gt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>re(t)&&t.type===e,n}function mt(e){return"function"==typeof e&&"type"in e&&ft(e)}function vt(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 yt=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 bt(e){return pe(e)?Ye(e,(()=>{})):e}function wt(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function kt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function jt(e,t,n){const o=It(e,t,n);return{detectMutations:()=>Ot(e,t,o,n)}}function It(e,t=[],n,o="",r=new Set){const i={value:n};if(!e(n)&&!r.has(n)){r.add(n),i.children={};for(const r in n){const s=o?o+"."+r:r;t.length&&-1!==t.indexOf(s)||(i.children[r]=It(e,t,n[r],s))}}return i}function Ot(e,t=[],n,o,r=!1,i=""){const s=n?n.value:void 0,a=s===o;if(r&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:i};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let r in c){const s=i?i+"."+r:r;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Ot(e,t,n.children[r],o[r],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function St(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||G(e)}function xt(e,t="",n=St,o,r=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),c=r.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(r.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=xt(l,a,n,o,r,i),s))return s}return i&&Et(e)&&i.add(e),!1}function Et(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Et(t))return!1;return!0}function Ct(e){return"boolean"==typeof e}var _t=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:r=!0}=e??{};let i=new yt;if(t&&(Ct(t)?i.push(dt):i.push(pt(t.extraArgument))),n){let e={};Ct(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,o,r){return JSON.stringify(e,n(t,r),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(r,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,r):o.push(r),~n.indexOf(i)&&(i=t.call(this,r,i))}else n.push(i);return null==e?i:e.call(this,r,i)}},{isImmutable:o=kt,ignoredPaths:r,warnAfter:i=32}=e;const s=jt.bind(null,o,r);return({getState:e})=>{let n,o=e(),r=s(o);return a=>c=>{const l=vt(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const u=a(c);return l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),u}}}}(e))}if(o){let e={};Ct(o)||(e=o),i.push(function(e={}){{const{isSerializable:t=St,getEntries:n,ignoredActions:o=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,u=!l&&WeakSet?new WeakSet:void 0;return e=>l=>d=>{if(!re(d))return l(d);const p=l(d),h=vt(s,"SerializableStateInvariantMiddleware");return c||o.length&&-1!==o.indexOf(d.type)||h.measureTime((()=>{const e=xt(d,"",t,n,r,u);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: ",d,"\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||(h.measureTime((()=>{const o=xt(e.getState(),"",t,n,i,u);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${d.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),h.warnIfExceeded()),p}}}(e))}if(r){let e={};Ct(r)||(e=r),i.unshift(function(e={}){const{isActionCreator:t=mt}=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 i},At=e=>t=>{setTimeout(t,e)},Tt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:At(10),Rt=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new yt(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let r=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Tt:"callback"===e.type?e.queueNotification:At(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>r&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return r=!e?.meta?.RTK_autoBatch,i=!r,i&&(s||(s=!0,c(l))),o.dispatch(e)}finally{r=!0}}})})("object"==typeof n?n:void 0)),o};function Pt(e){const t=_t(),{reducer:n,middleware:o,devTools:r=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!G(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=ne(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(c=o(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=oe;r&&(l=ht({trace:!0,..."object"==typeof r&&r}));const u=function(...e){return t=>(n,o)=>{const r=t(n,o);let i=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:r.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=oe(...a)(r.dispatch),{...r,dispatch:i}}}(...c),d=Rt(u);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let p="function"==typeof s?s(d):d();if(!Array.isArray(p))throw new Error("`enhancers` callback must return an array");if(p.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!p.includes(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return ee(a,i,l(...p))}function Ut(e){const t={},n=[];let o;const r={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,r},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),r},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,r}};return e(r),[t,n,o]}function $t(...e){return t=>e.some((e=>((e,t)=>ft(e)?e.match(t):e(t))(e,t)))}var Mt=["name","message","stack","code"],Dt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Lt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Nt=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Mt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},zt=(()=>{function e(e,t,n){const o=gt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),r=gt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=gt(e+"/rejected",((e,t,o,r,i)=>({payload:r,error:(n&&n.serializeError||Nt)(e||"Rejected"),meta:{...i||{},arg:o,requestId:t,rejectedWithValue:!!r,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),u=new AbortController;let d;function p(e){d=e,u.abort()}const h=async function(){let h;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||u.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>u.signal.addEventListener("abort",(()=>t({name:"AbortError",message:d||"Aborted"})))));s(r(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),h=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:u.signal,abort:p,rejectWithValue:(e,t)=>new Dt(e,t),fulfillWithValue:(e,t)=>new Lt(e,t)})).then((t=>{if(t instanceof Dt)throw t;return t instanceof Lt?o(t.payload,l,e,t.meta):o(t,l,e)}))])}catch(t){h=t instanceof Dt?i(null,l,e,t.payload,t.meta):i(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(h)&&h.meta.condition||s(h),h}();return Object.assign(h,{abort:p,requestId:l,arg:e,unwrap:()=>h.then(Wt)})}}),{pending:r,rejected:i,fulfilled:o,settled:$t(i,o),typePrefix:e})}return e.withTypes=()=>e,e})();function Wt(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var Ft=Symbol.for("rtk-slice-createasyncthunk");function qt(e,t){return`${e}/${t}`}function Ht(e,t,n,o){function r(r,...i){let s=n.call(e,r);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return r.unwrapped=t,r}var Jt=function({creators:e}={}){const t=e?.asyncThunk?.[Ft];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const r=("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)||{},i=Object.keys(r),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?Ut(e.extraReducers):[e.extraReducers],r={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,r,i]=Ut(t);if(function(e){return"function"==typeof e}(e))n=()=>bt(e());else{const t=bt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...r.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(de(e)){const o=n(e,t);return void 0===o?e:o}if(pe(e))return Ye(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in r)e.addCase(t,r[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}i.forEach((o=>{const i=r[o],s={reducerName:o,type:qt(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,r){let i,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=o.reducer,s=o.prepare}else i=o;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?gt(e,s):gt(e))}(s,i,a):function({type:e,reducerName:t},n,o,r){if(!r)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:i,fulfilled:s,pending:a,rejected:c,settled:l,options:u}=n,d=r(e,i,u);o.exposeAction(t,d),s&&o.addCase(d.fulfilled,s);a&&o.addCase(d.pending,a);c&&o.addCase(d.rejected,c);l&&o.addMatcher(d.settled,l);o.exposeCaseReducer(t,{fulfilled:s||Kt,pending:a||Kt,rejected:c||Kt,settled:l||Kt})}(s,i,a,t)}));const l=e=>e,u=new WeakMap;let d;const p={name:n,reducerPath:o,reducer:(e,t)=>(d||(d=c()),d(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(d||(d=c()),d.getInitialState()),getSelectors(t=l){const n=wt(u,this,{insert:()=>new WeakMap});return wt(n,t,{insert:()=>{const n={};for(const[o,r]of Object.entries(e.selectors??{}))n[o]=Ht(this,r,t,this!==p);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===p)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return p}}();function Kt(){}var Vt="listenerMiddleware";gt(`${Vt}/add`),gt(`${Vt}/removeAll`),gt(`${Vt}/remove`);const Bt=e=>a((t=>{const n=Jt(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(g)(t)){constructor(...e){super(...e);const t=Pt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),r=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{Wt(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},i=Object.keys(o).reduce(((e,t)=>(e[t]=r(o[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));var Yt;a((e=>class extends(g(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()}})),a((e=>class extends e{get baseStaticUrl(){return this.getAttribute("base-static-url")||""}})),function(e){e.oidc="oidc",e.saml="saml"}(Yt||(Yt={}));const Xt=ct((e=>e.ssoAppsList.data),(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===Yt.saml))})),Gt=ct(Xt,(e=>e.map((e=>({name:e.name,icon:e.logo,url:e.samlSettings.idpInitiatedUrl}))))),Zt=zt("ssoApps/load",((e,{extra:{api:t}})=>t.ssoApps.load())),Qt=(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)}))}))})(Zt)({onFulfilled:(e,t)=>{var n;e.ssoAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},(en=e=>e.ssoAppsList,{onFulfilled:e=>{en(e).loading=!1},onPending:e=>{en(e).loading=!0,en(e).error=null},onRejected:(e,t)=>{en(e).loading=!1,en(e).error=t.error}}));var en;const tn={action:Zt,reducer:Qt},nn={ssoAppsList:{data:[],loading:!1,error:null}};class on extends Error{}function rn(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 sn(e,t){if("string"!=typeof e)throw new on("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,o=e.split(".")[n];if("string"!=typeof o)throw new on(`Invalid token specified: missing part #${n+1}`);let r;try{r=rn(o)}catch(e){throw new on(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new on(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}on.prototype.name="InvalidTokenError";var an="/v1/auth/accesskey/exchange",cn="/v1/auth/otp/verify",ln="/v1/auth/otp/signin",un="/v1/auth/otp/signup",dn={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},pn="/v1/auth/otp/signup-in",hn="/v1/auth/magiclink/verify",fn="/v1/auth/magiclink/signin",gn="/v1/auth/magiclink/signup",mn={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},vn="/v1/auth/magiclink/signup-in",yn="/v1/auth/enchantedlink/verify",bn="/v1/auth/enchantedlink/signin",wn="/v1/auth/enchantedlink/signup",kn="/v1/auth/enchantedlink/pending-session",jn={email:"/v1/auth/enchantedlink/update/email"},In="/v1/auth/enchantedlink/signup-in",On="/v1/auth/oauth/authorize",Sn="/v1/auth/oauth/exchange",xn="v1/auth/oauth/native/start",En="v1/auth/oauth/native/finish",Cn="/v1/auth/saml/authorize",_n="/v1/auth/saml/exchange",An="/v1/auth/totp/verify",Tn="/v1/auth/totp/signup",Rn="/v1/auth/totp/update",Pn="/v1/auth/notp/whatsapp/signin",Un="/v1/auth/notp/whatsapp/signup",$n="/v1/auth/notp/whatsapp/signup-in",Mn="/v1/auth/notp/pending-session",Dn={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Ln={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Nn={start:"/v1/auth/webauthn/signup-in/start"},zn={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Wn="/v1/auth/password/signup",Fn="/v1/auth/password/signin",qn="/v1/auth/password/reset",Hn="/v1/auth/password/update",Jn="/v1/auth/password/replace",Kn="/v1/auth/password/policy",Vn="/v1/auth/refresh",Bn="/v1/auth/tenant/select",Yn="/v1/auth/logout",Xn="/v1/auth/logoutall",Gn="/v1/auth/me",Zn="/v1/auth/me/tenants",Qn="/v1/auth/me/history",eo="/v1/flow/start",to="/v1/flow/next";const no="<region>",oo=`https://api.${no}descope.com`,ro=6e5,io="dct",so=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let ao;const co=()=>{if(ao)return ao;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 ao=`${t}-${n}`,ao};var lo,uo;(uo=lo||(lo={})).get="GET",uo.delete="DELETE",uo.post="POST",uo.put="PUT",uo.patch="PATCH";const po=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(no,r?r+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{i=`${i}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return i},ho=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),fo={"Content-Type":"application/json"},go=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},mo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},vo=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>so().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return so().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,s),c=async o=>{var s;const c=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:l,body:u,headers:d,queryParams:p,method:h,token:f}=c,g=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:ho(go(t,f),{"x-descope-sdk-session-id":co(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.33.0"},(null==n?void 0:n.baseHeaders)||{},mo(g)?fo:{},d),method:h,body:g};null!==i&&(m.credentials=i||"include");const v=await a(po({path:l,baseUrl:e,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==v?void 0:v.clone()),null==r?void 0:r.transformResponse){const e=await v.json(),t=((null===(s=v.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},v),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return v};return{get:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:lo.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:lo.post,token:r}),patch:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:lo.patch,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:lo.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:lo.delete,token:o}),hooks:r,buildUrl:(n,o)=>po({projectId:t,baseUrl:e,path:n,queryParams:o})}};var yo=429;function bo(e,t,n){var o;let r=wo(e);if(t){if(!(null==r?void 0:r.tenants)&&(null==r?void 0:r[io])===t)return(null==r?void 0:r[n])||[];r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]}const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function wo(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return sn(e)}function ko(e){const{exp:t}=wo(e);return(new Date).getTime()/1e3>t}function jo(e){let t=wo(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Io(e,t){return bo(e,t,"permissions")}function Oo(e,t){return bo(e,t,"roles")}const So=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function xo(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=t?t(i):i:(r.error=i,o.status===yo&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const Eo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Co=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},_o=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Ao=e=>t=>e.test(t),To=Ao(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ro=Ao(/^\+[1-9]{1}[0-9]{3,14}$/),Po=Eo(To,'"{val}" is not a valid email'),Uo=Eo(Ro,'"{val}" is not a valid phone number'),$o=Eo((e=>e.length>=1),"Minimum length is 1");const Mo=Eo((e=>"string"==typeof e),"Input is not a string"),Do=Eo((e=>Array.isArray(e)),"Input is not an array"),Lo=Eo((e=>"boolean"==typeof e),"Input is not a boolean"),No=Eo((e=>void 0===e),"Input is defined"),zo=Co([Mo(),No()],"Input is not a string or undefined"),Wo=Co([Do(),Lo()],"Input is not an array or boolean"),Fo=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>_o(...e).validate(n[t]))),t(...n)),qo=e=>[Mo(`"${e}" must be a string`)],Ho=e=>[Mo(`"${e}" must be a string`),$o(`"${e}" must not be empty`)],Jo=e=>[Mo(`"${e}" must be a string`),Po()],Ko=e=>[Mo(`"${e}" must be a string`),Uo()],Vo=Fo(Ho("accessKey")),Bo=e=>({exchange:Vo(((t,n)=>xo(e.post(an,{loginOptions:n},{token:t}))))}),Yo=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const s=i[r];i[r]=n(s)})),e),Xo=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||ro,ro)});var Go,Zo;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(Go||(Go={})),function(e){e.email="email"}(Zo||(Zo={}));const Qo=Object.assign(Object.assign({},Go),Zo);var er;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(er||(er={}));const tr=Ho("loginId"),nr=Fo(Ho("token")),or=Fo(tr),rr=Fo(Ho("pendingRef")),ir=Fo(tr,Jo("email")),sr=e=>({verify:nr((t=>xo(e.post(yn,{token:t})))),signIn:or(((t,n,o,r)=>xo(e.post(So(bn,Qo.email),{loginId:t,URI:n,loginOptions:o},{token:r})))),signUpOrIn:or(((t,n,o)=>xo(e.post(So(In,Qo.email),{loginId:t,URI:n,loginOptions:o})))),signUp:or(((t,n,o,r)=>xo(e.post(So(wn,Qo.email),{loginId:t,URI:n,user:o,loginOptions:r})))),waitForSession:rr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=Xo(n);let s;const a=setInterval((async()=>{const n=await e.post(kn,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ir(((t,n,o,r,i)=>xo(e.post(jn.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),ar=Fo(Ho("flowId")),cr=Fo(Ho("executionId"),Ho("stepId"),Ho("interactionId")),lr=e=>({start:ar(((t,n,o,r,i,s,a)=>xo(e.post(eo,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,componentsVersion:i,flowVersions:s,input:a})))),next:cr(((t,n,o,r,i,s)=>xo(e.post(to,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:s}))))}),ur=Ho("loginId"),dr=Fo(Ho("token")),pr=Fo(ur),hr=Fo(ur,Ko("phone")),fr=Fo(ur,Jo("email")),gr=Object.keys(Qo).filter((e=>e!==Go.voice)),mr=e=>({verify:dr((t=>xo(e.post(hn,{token:t})))),signIn:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pr(((t,o,r,i)=>xo(e.post(So(fn,n),{loginId:t,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pr(((t,o,r,i)=>xo(e.post(So(gn,n),{loginId:t,URI:o,user:r,loginOptions:i}))))})),{}),signUpOrIn:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pr(((t,o,r)=>xo(e.post(So(vn,n),{loginId:t,URI:o,loginOptions:r}))))})),{}),update:{email:fr(((t,n,o,r,i)=>xo(e.post(mn.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(Go).filter((e=>e!==Go.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:hr(((t,o,r,i,s)=>xo(e.post(So(mn.phone,n),Object.assign({loginId:t,phone:o,URI:r},s),{token:i}))))})),{})}});var vr;!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"}(vr||(vr={}));const yr=Fo(Ho("code")),br=e=>({start:Object.assign(((t,n,o,r)=>xo(e.post(On,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:r}))),Object.keys(vr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r)=>xo(e.post(On,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:r}))})),{})),exchange:yr((t=>xo(e.post(Sn,{code:t})))),startNative:(t,n,o)=>xo(e.post(xn,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,r,i)=>xo(e.post(En,{provider:t,stateId:n,user:o,code:r,idToken:i}))}),wr=Ho("loginId"),kr=Fo(wr,Ho("code")),jr=Fo(wr),Ir=Fo(wr,Ko("phone")),Or=Fo(wr,Jo("email")),Sr=e=>({verify:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:kr(((t,o)=>xo(e.post(So(cn,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jr(((t,o,r)=>xo(e.post(So(ln,n),{loginId:t,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jr(((t,o,r)=>xo(e.post(So(un,n),{loginId:t,user:o,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jr(((t,o)=>xo(e.post(So(pn,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:Or(((t,n,o,r)=>xo(e.post(dn.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(Go).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ir(((t,o,r,i)=>xo(e.post(So(dn.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),xr=Fo(Ho("tenant")),Er=Fo(Ho("code")),Cr=e=>({start:xr(((t,n,o,r)=>xo(e.post(Cn,o||{},{queryParams:{tenant:t,redirectURL:n},token:r})))),exchange:Er((t=>xo(e.post(_n,{code:t}))))}),_r=Ho("loginId"),Ar=Fo(_r,Ho("code")),Tr=Fo(_r),Rr=Fo(_r),Pr=e=>({signUp:Tr(((t,n)=>xo(e.post(Tn,{loginId:t,user:n})))),verify:Ar(((t,n,o,r)=>xo(e.post(An,{loginId:t,code:n,loginOptions:o},{token:r})))),update:Rr(((t,n)=>xo(e.post(Rn,{loginId:t},{token:n}))))}),Ur=Ho("loginId"),$r=Ho("newPassword"),Mr=Fo(Ur,Ho("password")),Dr=Fo(Ur),Lr=Fo(Ur,$r),Nr=Fo(Ur,Ho("oldPassword"),$r),zr=e=>({signUp:Mr(((t,n,o,r)=>xo(e.post(Wn,{loginId:t,password:n,user:o,loginOptions:r})))),signIn:Mr(((t,n,o)=>xo(e.post(Fn,{loginId:t,password:n,loginOptions:o})))),sendReset:Dr(((t,n,o)=>xo(e.post(qn,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Lr(((t,n,o)=>xo(e.post(Hn,{loginId:t,newPassword:n},{token:o})))),replace:Nr(((t,n,o)=>xo(e.post(Jn,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>xo(e.get(Kn))}),Wr=qo("loginId"),Fr=Ho("loginId"),qr=Ho("origin"),Hr=Fo(Fr,qr,Ho("name")),Jr=Fo(Fr,qr),Kr=Fo(Wr,qr),Vr=Fo(Fr,qr,Ho("token")),Br=Fo(Ho("transactionId"),Ho("response")),Yr=e=>({signUp:{start:Hr(((t,n,o,r)=>xo(e.post(Dn.start,{user:{loginId:t,name:o},origin:n,passkeyOptions:r})))),finish:Br(((t,n)=>xo(e.post(Dn.finish,{transactionId:t,response:n}))))},signIn:{start:Kr(((t,n,o,r,i)=>xo(e.post(Ln.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i},{token:r})))),finish:Br(((t,n)=>xo(e.post(Ln.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Jr(((t,n,o)=>xo(e.post(Nn.start,{loginId:t,origin:n,passkeyOptions:o}))))},update:{start:Vr(((t,n,o,r)=>xo(e.post(zn.start,{loginId:t,origin:n,passkeyOptions:r},{token:o})))),finish:Br(((t,n)=>xo(e.post(zn.finish,{transactionId:t,response:n}))))}}),Xr=qo("loginId"),Gr=Fo(Xr),Zr=Fo(Ho("pendingRef")),Qr=e=>({signUpOrIn:Gr(((t,n)=>xo(e.post($n,{loginId:t,loginOptions:n})))),signUp:Gr(((t,n,o)=>xo(e.post(Un,{loginId:t,user:n,loginOptions:o})))),signIn:Gr(((t,n,o)=>xo(e.post(Pn,{loginId:t,loginOptions:n},{token:o})))),waitForSession:Zr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=Xo(n);let s;const a=setInterval((async()=>{const n=await e.post(Mn,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),ei=Fo(Ho("token")),ti=Fo([zo('"token" must be string or undefined')]);var ni,oi=Fo([(ni=Ho("projectId"),Eo(((e,t)=>n=>_o(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let r=0,i=e===Object(e)?e:void 0;for(;null!=i&&r<o;)i=i[n[r++]];return r&&r===o&&void 0!==i?i:void 0})(n,e)))("projectId",ni))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:s})=>{return a=vo({baseUrl:n||oo,projectId:e,logger:t,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:Bo(a),otp:Sr(a),magicLink:mr(a),enchantedLink:sr(a),oauth:br(a),saml:Cr(a),totp:Pr(a),notp:Qr(a),webauthn:Yr(a),password:zr(a),flow:lr(a),refresh:ti(((e,t)=>xo(a.post(Vn,{},{token:e,queryParams:t})))),selectTenant:Fo([Mo("tenantId")],[zo('"token" must be string or undefined')])(((e,t)=>xo(a.post(Bn,{tenant:e},{token:t})))),logout:ti((e=>xo(a.post(Yn,{},{token:e})))),logoutAll:ti((e=>xo(a.post(Xn,{},{token:e})))),me:ti((e=>xo(a.get(Gn,{token:e})))),myTenants:Fo([Wo('"tenants" must a string array or a boolean')],[zo('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,xo(a.post(Zn,n,{token:t}))})),history:ti((e=>xo(a.get(Qn,{token:e})))),isJwtExpired:ei(ko),getTenants:ei(jo),getJwtPermissions:ei(Io),getJwtRoles:ei(Oo),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=r.length&&(await Promise.allSettled(null==r?void 0:r.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}}))})),ri=Object.assign(oi,{DeliveryMethods:Qo});
6
6
  /*! js-cookie v3.0.5 | MIT */
7
- function ii(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var si=function e(t,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=ii({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",ii({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,ii({},this.attributes,t))},withConverter:function(t){return e(ii({},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 ai={default:"endpoint"},ci="Blocked by CSP",li="The endpoint parameter is not a valid URL",ui="Failed to load the JS script of the agent",di="9319";function pi(e,t){var n,o,r,i,s=[],a=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),i=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},r=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===ci||s===li)n.exclude(),i=0;else if(s===di)n.exclude();else if(s===ui){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!r.has(c)&&(r.add(c),i=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=i?i:e.getTime()+o()-Date.now()]}]),c=a[0],l=a[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,o=function(t){return s.push({url:e,startedAt:n,finishedAt:new Date,error:t})},r=t(e);return r.then((function(){return o()}),o),r.catch((function(e){if(s.length>=5)throw e;var t=l(n,e);if(!t)throw e;var o,r=t[0],i=t[1];return(o=i,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(r)}))}))};return u(c).then((function(e){return[e,s]}))}var hi="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",fi=hi;function gi(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:hi,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),u=l[0],d=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.9.9"):e}))}(String(e),t)}))}(c,s);return pi(e,mi)})).catch((function(e){throw d(),function(e){return e instanceof Error&&e.message===di?new Error(ui):e}(e)})).then((function(t){var n=t[0],o=t[1];return d(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:u}}))}))}function mi(e){return function(e,t,n,o){var r,i=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return null==o||o.then(c,c),Promise.resolve().then(t).then((function(e){return c(),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(c(),r)return n(r);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(li);var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(ui))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)}),(function(){throw new Error(ci)})).then(yi)}function yi(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(di);return n}const vi=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},bi=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},wi=async e=>{const t=await bi(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},ki="undefined"!=typeof localStorage,ji=(e,t)=>ki&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Ii=e=>ki&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Oi=e=>ki&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Si=(...e)=>{console.debug(...e)},xi="undefined"!=typeof window,Ei=Math.pow(2,31)-1,Ci="DS",_i="DSR";function Ai(e=""){return Ii(`${e}${_i}`)||""}function Ti(e=""){return si.get(Ci)||Ii(`${e}${Ci}`)||""}function Ri(e=""){Oi(`${e}${_i}`),Oi(`${e}${Ci}`),si.remove(Ci)}const Pi=xi&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Ui="vsid",$i="vrid",Mi=(e=!1)=>{const t=localStorage.getItem("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Di=async(e,t=Pi)=>{try{if(Mi())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=r.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=gi({apiKey:e,endpoint:[o.toString(),ai],scriptUrlPattern:[i,fi]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Ui]:e,[$i]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Li=e=>{const t=Mi(!0);return t&&e.body&&(e.body.fpData=t),e},Ni="dls_last_user_login_id",zi="dls_last_user_display_name",Wi=()=>Ii(Ni),Fi=()=>Ii(zi),qi=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=Wi(),i=Fi();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await e(...t)};function Hi(){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 Ji(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Gi(n.publicKey.challenge),n.publicKey.user.id=Gi(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Gi(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Zi(n.rawId),type:n.type,response:{attestationObject:Zi(n.response.attestationObject),clientDataJSON:Zi(n.response.clientDataJSON)}});var n}async function Ki(e){const t=Yi(e);return Xi(await navigator.credentials.get(t))}async function Vi(e,t){const n=Yi(e);return n.signal=t.signal,n.mediation="conditional",Xi(await navigator.credentials.get(n))}async function Bi(e=!1){if(!xi)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Yi(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Gi(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Gi(e.id)})),n}function Xi(e){return JSON.stringify({id:e.id,rawId:Zi(e.rawId),type:e.type,response:{authenticatorData:Zi(e.response.authenticatorData),clientDataJSON:Zi(e.response.clientDataJSON),signature:Zi(e.response.signature),userHandle:e.response.userHandle?Zi(e.response.userHandle):void 0}})}function Gi(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Zi(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Qi,es=(Qi=e=>({async signUp(t,n,o){const r=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await Ji(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,i)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const r=await Ki(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,r)},async signUpOrIn(t,n){var o;const r=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!r.ok)return r;if(null===(o=r.data)||void 0===o?void 0:o.create){const t=await Ji(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,t)}{const t=await Ki(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,t)}},async update(t,n,o){const r=await e.webauthn.update.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await Ji(r.data.options);return await e.webauthn.update.finish(r.data.transactionId,i)},helpers:{create:Ji,get:Ki,isSupported:Bi,conditional:Vi}}),(...e)=>{const t=Qi(...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 ts="/fedcm/config",ns=(e,t)=>({async oneTap(t,n,o,r){const i=null!=t?t:"google",s=await e.oauth.startNative(i,o,!0);if(!s.ok)return s;const{clientId:a,stateId:c,nonce:l}=s.data,u=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")}}))}();return new Promise((t=>{var o,s;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(s=null==n?void 0:n.use_fedcm_for_prompt)||void 0===s||s,client_id:a,callback:n=>{t(e.oauth.finishNative(i,c,"","",n.credential))},nonce:l})),u.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==r||r())}))}))},async launch(n){var o;const r={identity:{context:n||"signin",providers:[{configURL:e.httpClient.buildUrl(t+ts),clientId:t}]}},i=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(r));return e.refresh(i.token)},isSupported:()=>xi&&"IdentityCredential"in window});var os=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Bi(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const rs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:r}=n,i=t(n,["fpKey","fpLoad"]);return xi?(o&&r&&Di(o).catch((()=>null)),e(vi(i,{beforeRequest:Li}))):e(i)}),(e=>n=>{var{autoRefresh:o}=n,r=t(n,["autoRefresh"]);if(!o)return e(r);const{clearAllTimers:i,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;xi&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(Si("Expiration time passed, refreshing session"),l.refresh(Ai()||c))}));const l=e(vi(r,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await bi(t);if(401===(null==t?void 0:t.status))Si("Received 401, canceling all timers"),i();else if(o){if(a=(e=>{try{const t=sn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(o),!a)return void Si("Could not extract expiration time from session token");c=n;let e=((r=a)?r.getTime()-(new Date).getTime():0)-2e4;e>Ei&&(Si(`Timeout is too large (${e}ms), setting it to ${Ei}ms`),e=Ei),i();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Si(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Si("Refreshing session due to timer"),l.refresh(Ai()||n)}),e)}var r}}));return Yo(l,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Si("Clearing all timers"),i(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.22.0"},t.baseHeaders)}))),(e=>t=>{const n=Hi(),o=Hi(),r=e(vi(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),o.pub(null);else{const e=await wi(t);e&&o.pub(e);const{sessionJwt:r}=await bi(t);r&&n.pub(r)}}})),i=Yo(r,["logout","logoutAll"],(e=>async(...t)=>{const r=await e(...t);return n.pub(null),o.pub(null),r}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(i),{getLastUserLoginId:Wi,getLastUserDisplayName:Fi});const s=e(vi(i,{afterRequest:async(e,t)=>{var n;const o=await wi(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((e=>{ji(Ni,e)})(r),(e=>{ji(zi,e)})(i))}}));let a=Yo(s,["flow.start"],qi);return a=Yo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(Oi(Ni),Oi(zi)),o})(r)),Object.assign(a,{getLastUserLoginId:Wi,getLastUserDisplayName:Fi})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:r,storagePrefix:i}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!xi)return e(s);const a=e(vi(s,{beforeRequest:(c=i,e=>Object.assign(e,{token:e.token||Ai(c)})),afterRequest:async(e,n)=>{const o=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?o||Ri(i):((e={},n,o)=>{var{refreshJwt:r,sessionJwt:i}=e,s=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),r&&ji(`${o}${_i}`,r),i&&(n?function(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(t){const i=new Date(1e3*r),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);si.set(e,t,{path:n,domain:s?o:void 0,expires:i,sameSite:"Strict",secure:!0})}}(Ci,i,s):ji(`${o}${Ci}`,i))})(await bi(n),r,i)}}));var c;const l=Yo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return Ri(e),o})(i));return Object.assign(l,{getRefreshToken:()=>Ai(i),getSessionToken:()=>Ti(i)})}))(((...e)=>{const t=ri(...e);return Object.assign(Object.assign({},t),{refresh:e=>{const n=Ti();return t.refresh(e,{dcs:n?"t":"f"})},flow:os(t),webauthn:es(t),fedcm:ns(t,e[0].projectId)})})),is={load:"/v1/mgmt/sso/idp/apps/load"},ss=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"ssoapp1",name:"App 1",description:"This is the first SAML app",enabled:!0,appType:Yt.saml,logo:"logo1",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp2",name:"App 2",description:"This is the first OIDC app",enabled:!0,appType:Yt.oidc,logo:"logo2"},{id:"ssoapp3",name:"App 3",description:"This is the second SAML app",enabled:!0,appType:Yt.saml,logo:"logo3",samlSettings:{idpInitiatedUrl:""}}]})}))})),as=({httpClient:e,mock:t})=>({load:()=>n(void 0,void 0,void 0,(function*(){if(t)return ss();const o=yield e.get(is.load);return yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(o),o.json()}))}),cs=a((e=>{var t,s,a,c;const l=i(j,w,g,I)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),r(this,s,((e,t,n)=>{const o=rs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"applications-portal-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.2.6"}}));return{ssoApps:as({httpClient:o.httpClient,mock:t})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},c})),ls=a((e=>{const t=i(Bt({name:"widget",initialState:nn,reducers:{},extraReducers:e=>{tn.reducer(e)},asyncActions:{loadSSOApps:tn.action}}),b,g,cs)(e);return class extends t{constructor(...e){super(...e),this.state=nn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),us=a((e=>{const t=i(O,k({"widget-id":k.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`applications-portal-widget/${this.widgetId}/${e}`,"text")).body}))}}})),ds=a((e=>{var t,r,a,c;return c=class extends(i(g,b,U,D,us,ls)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const[i]=yield Promise.all([o(this,t,"m",r).call(this),this.actions.loadSSOApps()]);o(this,t,"m",a).call(this,i),this.onWidgetRootReady()}))}},t=new WeakSet,r=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))},c})),ps=a((e=>{var t,r,s;return s=class extends(i(ls,g,ds)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this,Gt(this.state))}))}},t=new WeakSet,r=function(e){this.appsList=new H((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-apps-list")}),{logger:this.logger}),this.appsList.data=e},s})),hs=a((e=>class extends(i(x,V,ps)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),fs=i((e=>class extends(hs(e)){}))(HTMLElement);customElements.define("descope-applications-portal-widget",fs);const gs=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var ms,ys,vs,bs,ws,ks,js,Is,Os,Ss;const xs=document.createElement("template");xs.innerHTML=`\n<style>\n .debugger {\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</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class Es extends HTMLElement{constructor(){var e;super(),ms.add(this),ys.set(this,new h({messages:[]})),vs.set(this,void 0),bs.set(this,void 0),ws.set(this,void 0),ks.set(this,{resize:o(this,ms,"m",Ss).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(xs.content.cloneNode(!0)),r(this,vs,this.shadowRoot.querySelector(".debugger"),"f"),r(this,bs,o(this,vs,"f").querySelector(".content"),"f"),r(this,ws,o(this,vs,"f").querySelector(".header"),"f")}updateData(e){o(this,ys,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=gs(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,vs,"f"),o(this,ws,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ks,"f").resize),(e=o(this,vs,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,vs,"f").onresize=o(this,ms,"m",Os).bind(this),o(this,ys,"f").subscribe(o(this,ms,"m",js).bind(this))}disconnectedCallback(){o(this,ys,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ks,"f").resize)}}ys=new WeakMap,vs=new WeakMap,bs=new WeakMap,ws=new WeakMap,ks=new WeakMap,ms=new WeakSet,js=function(e){o(this,ms,"m",Is).call(this,e),o(this,ms,"m",Os).call(this)},Is=function(e){o(this,bs,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Os=function(){o(this,bs,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,r=n.clientHeight>20;o||r?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Ss=function(){const[e,t]=gs(o(this,vs,"f"),Number.parseInt(o(this,vs,"f").style.left,10),Number.parseInt(o(this,vs,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,vs,"f").style.top=`${t}px`,o(this,vs,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Es);var Cs=Object.freeze({__proto__:null,default:Es});return fs}();
7
+ function ii(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var si=function e(t,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=ii({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",ii({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,ii({},this.attributes,t))},withConverter:function(t){return e(ii({},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 ai={default:"endpoint"},ci="Blocked by CSP",li="The endpoint parameter is not a valid URL",ui="Failed to load the JS script of the agent",di="9319";function pi(e,t){var n,o,r,i,s=[],a=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),i=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},r=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===ci||s===li)n.exclude(),i=0;else if(s===di)n.exclude();else if(s===ui){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!r.has(c)&&(r.add(c),i=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=i?i:e.getTime()+o()-Date.now()]}]),c=a[0],l=a[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,o=function(t){return s.push({url:e,startedAt:n,finishedAt:new Date,error:t})},r=t(e);return r.then((function(){return o()}),o),r.catch((function(e){if(s.length>=5)throw e;var t=l(n,e);if(!t)throw e;var o,r=t[0],i=t[1];return(o=i,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(r)}))}))};return u(c).then((function(e){return[e,s]}))}var hi="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",fi=hi;function gi(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:hi,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),u=l[0],d=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.9.9"):e}))}(String(e),t)}))}(c,s);return pi(e,mi)})).catch((function(e){throw d(),function(e){return e instanceof Error&&e.message===di?new Error(ui):e}(e)})).then((function(t){var n=t[0],o=t[1];return d(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:u}}))}))}function mi(e){return function(e,t,n,o){var r,i=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return null==o||o.then(c,c),Promise.resolve().then(t).then((function(e){return c(),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(c(),r)return n(r);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(li);var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(ui))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)}),(function(){throw new Error(ci)})).then(vi)}function vi(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(di);return n}const yi=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},bi=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},wi=async e=>{const t=await bi(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},ki="undefined"!=typeof localStorage,ji=(e,t)=>ki&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Ii=e=>ki&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Oi=e=>ki&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Si=(...e)=>{console.debug(...e)},xi="undefined"!=typeof window,Ei=Math.pow(2,31)-1,Ci="DS",_i="DSR";function Ai(e=""){return Ii(`${e}${_i}`)||""}function Ti(e=""){return si.get(Ci)||Ii(`${e}${Ci}`)||""}function Ri(e=""){Oi(`${e}${_i}`),Oi(`${e}${Ci}`),si.remove(Ci)}const Pi=xi&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Ui="vsid",$i="vrid",Mi=(e=!1)=>{const t=localStorage.getItem("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Di=async(e,t=Pi)=>{try{if(Mi())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=r.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=gi({apiKey:e,endpoint:[o.toString(),ai],scriptUrlPattern:[i,fi]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Ui]:e,[$i]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Li=e=>{const t=Mi(!0);return t&&e.body&&(e.body.fpData=t),e},Ni="dls_last_user_login_id",zi="dls_last_user_display_name",Wi=()=>Ii(Ni),Fi=()=>Ii(zi),qi=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=Wi(),i=Fi();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await e(...t)};function Hi(){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 Ji(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Gi(n.publicKey.challenge),n.publicKey.user.id=Gi(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Gi(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Zi(n.rawId),type:n.type,response:{attestationObject:Zi(n.response.attestationObject),clientDataJSON:Zi(n.response.clientDataJSON)}});var n}async function Ki(e){const t=Yi(e);return Xi(await navigator.credentials.get(t))}async function Vi(e,t){const n=Yi(e);return n.signal=t.signal,n.mediation="conditional",Xi(await navigator.credentials.get(n))}async function Bi(e=!1){if(!xi)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Yi(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Gi(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Gi(e.id)})),n}function Xi(e){return JSON.stringify({id:e.id,rawId:Zi(e.rawId),type:e.type,response:{authenticatorData:Zi(e.response.authenticatorData),clientDataJSON:Zi(e.response.clientDataJSON),signature:Zi(e.response.signature),userHandle:e.response.userHandle?Zi(e.response.userHandle):void 0}})}function Gi(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Zi(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Qi,es=(Qi=e=>({async signUp(t,n,o){const r=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await Ji(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,i)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const r=await Ki(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,r)},async signUpOrIn(t,n){var o;const r=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!r.ok)return r;if(null===(o=r.data)||void 0===o?void 0:o.create){const t=await Ji(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,t)}{const t=await Ki(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,t)}},async update(t,n,o){const r=await e.webauthn.update.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await Ji(r.data.options);return await e.webauthn.update.finish(r.data.transactionId,i)},helpers:{create:Ji,get:Ki,isSupported:Bi,conditional:Vi}}),(...e)=>{const t=Qi(...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 ts="/fedcm/config",ns=(e,t)=>({async oneTap(t,n,o,r,i){const s=null!=t?t:"google",a=await e.oauth.startNative(s,o,!0);if(!a.ok)return a;const{clientId:c,stateId:l,nonce:u}=a.data,d=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")}}))}();return new Promise((t=>{var o,a;d.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(a=null==n?void 0:n.use_fedcm_for_prompt)||void 0===a||a,client_id:c,callback:n=>{t(e.oauth.finishNative(s,l,"","",n.credential))},nonce:u})),d.prompt((e=>{var t,n;if(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);null==i||i(n)}else if(r&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);null==r||r(t)}}))}))},async launch(n){var o;const r={identity:{context:n||"signin",providers:[{configURL:e.httpClient.buildUrl(t+ts),clientId:t}]}},i=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(r));return e.refresh(i.token)},isSupported:()=>xi&&"IdentityCredential"in window,async isLoggedIn(n){var o;const r=e.httpClient.buildUrl(t+ts);try{const e={identity:{context:n||"signin",providers:[{configURL:r,clientId:t}]}},i=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(e));return!!i&&!!i.token}catch(e){return!1}}});var os=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Bi(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const rs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:r}=n,i=t(n,["fpKey","fpLoad"]);return xi?(o&&r&&Di(o).catch((()=>null)),e(yi(i,{beforeRequest:Li}))):e(i)}),(e=>n=>{var{autoRefresh:o}=n,r=t(n,["autoRefresh"]);if(!o)return e(r);const{clearAllTimers:i,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;xi&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(Si("Expiration time passed, refreshing session"),l.refresh(Ai()||c))}));const l=e(yi(r,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await bi(t);if(401===(null==t?void 0:t.status))Si("Received 401, canceling all timers"),i();else if(o){if(a=(e=>{try{const t=sn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(o),!a)return void Si("Could not extract expiration time from session token");c=n;let e=((r=a)?r.getTime()-(new Date).getTime():0)-2e4;e>Ei&&(Si(`Timeout is too large (${e}ms), setting it to ${Ei}ms`),e=Ei),i();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Si(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Si("Refreshing session due to timer"),l.refresh(Ai()||n)}),e)}var r}}));return Yo(l,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Si("Clearing all timers"),i(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.23.0"},t.baseHeaders)}))),(e=>t=>{const n=Hi(),o=Hi(),r=e(yi(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),o.pub(null);else{const e=await wi(t);e&&o.pub(e);const{sessionJwt:r}=await bi(t);r&&n.pub(r)}}})),i=Yo(r,["logout","logoutAll"],(e=>async(...t)=>{const r=await e(...t);return n.pub(null),o.pub(null),r}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(i),{getLastUserLoginId:Wi,getLastUserDisplayName:Fi});const s=e(yi(i,{afterRequest:async(e,t)=>{var n;const o=await wi(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((e=>{ji(Ni,e)})(r),(e=>{ji(zi,e)})(i))}}));let a=Yo(s,["flow.start"],qi);return a=Yo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(Oi(Ni),Oi(zi)),o})(r)),Object.assign(a,{getLastUserLoginId:Wi,getLastUserDisplayName:Fi})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:r,storagePrefix:i}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!xi)return e(s);const a=e(yi(s,{beforeRequest:(c=i,e=>Object.assign(e,{token:e.token||Ai(c)})),afterRequest:async(e,n)=>{const o=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?o||Ri(i):((e={},n,o)=>{var{refreshJwt:r,sessionJwt:i}=e,s=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),r&&ji(`${o}${_i}`,r),i&&(n?function(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(t){const i=new Date(1e3*r),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);si.set(e,t,{path:n,domain:s?o:void 0,expires:i,sameSite:"Strict",secure:!0})}}(Ci,i,s):ji(`${o}${Ci}`,i))})(await bi(n),r,i)}}));var c;const l=Yo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return Ri(e),o})(i));return Object.assign(l,{getRefreshToken:()=>Ai(i),getSessionToken:()=>Ti(i)})}))(((...e)=>{const t=ri(...e);return Object.assign(Object.assign({},t),{refresh:e=>{const n=Ti();return t.refresh(e,{dcs:n?"t":"f"})},flow:os(t),webauthn:es(t),fedcm:ns(t,e[0].projectId)})})),is={load:"/v1/mgmt/sso/idp/apps/load"},ss=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"ssoapp1",name:"App 1",description:"This is the first SAML app",enabled:!0,appType:Yt.saml,logo:"logo1",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp2",name:"App 2",description:"This is the first OIDC app",enabled:!0,appType:Yt.oidc,logo:"logo2"},{id:"ssoapp3",name:"App 3",description:"This is the second SAML app",enabled:!0,appType:Yt.saml,logo:"logo3",samlSettings:{idpInitiatedUrl:""}}]})}))})),as=({httpClient:e,mock:t})=>({load:()=>n(void 0,void 0,void 0,(function*(){if(t)return ss();const o=yield e.get(is.load);return yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(o),o.json()}))}),cs=a((e=>{var t,s,a,c;const l=i(j,w,g,I)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),r(this,s,((e,t,n)=>{const o=rs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"applications-portal-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.2.7"}}));return{ssoApps:as({httpClient:o.httpClient,mock:t})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},c})),ls=a((e=>{const t=i(Bt({name:"widget",initialState:nn,reducers:{},extraReducers:e=>{tn.reducer(e)},asyncActions:{loadSSOApps:tn.action}}),b,g,cs)(e);return class extends t{constructor(...e){super(...e),this.state=nn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),us=a((e=>{const t=i(O,k({"widget-id":k.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`applications-portal-widget/${this.widgetId}/${e}`,"text")).body}))}}})),ds=a((e=>{var t,r,a,c;return c=class extends(i(g,b,U,D,us,ls)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const[i]=yield Promise.all([o(this,t,"m",r).call(this),this.actions.loadSSOApps()]);o(this,t,"m",a).call(this,i),this.onWidgetRootReady()}))}},t=new WeakSet,r=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))},c})),ps=a((e=>{var t,r,s;return s=class extends(i(ls,g,ds)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this,Gt(this.state))}))}},t=new WeakSet,r=function(e){this.appsList=new H((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-apps-list")}),{logger:this.logger}),this.appsList.data=e},s})),hs=a((e=>class extends(i(x,V,ps)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),fs=i((e=>class extends(hs(e)){}))(HTMLElement);customElements.define("descope-applications-portal-widget",fs);const gs=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var ms,vs,ys,bs,ws,ks,js,Is,Os,Ss;const xs=document.createElement("template");xs.innerHTML=`\n<style>\n .debugger {\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</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class Es extends HTMLElement{constructor(){var e;super(),ms.add(this),vs.set(this,new h({messages:[]})),ys.set(this,void 0),bs.set(this,void 0),ws.set(this,void 0),ks.set(this,{resize:o(this,ms,"m",Ss).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(xs.content.cloneNode(!0)),r(this,ys,this.shadowRoot.querySelector(".debugger"),"f"),r(this,bs,o(this,ys,"f").querySelector(".content"),"f"),r(this,ws,o(this,ys,"f").querySelector(".header"),"f")}updateData(e){o(this,vs,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=gs(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,ys,"f"),o(this,ws,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ks,"f").resize),(e=o(this,ys,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,ys,"f").onresize=o(this,ms,"m",Os).bind(this),o(this,vs,"f").subscribe(o(this,ms,"m",js).bind(this))}disconnectedCallback(){o(this,vs,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ks,"f").resize)}}vs=new WeakMap,ys=new WeakMap,bs=new WeakMap,ws=new WeakMap,ks=new WeakMap,ms=new WeakSet,js=function(e){o(this,ms,"m",Is).call(this,e),o(this,ms,"m",Os).call(this)},Is=function(e){o(this,bs,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Os=function(){o(this,bs,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,r=n.clientHeight>20;o||r?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Ss=function(){const[e,t]=gs(o(this,ys,"f"),Number.parseInt(o(this,ys,"f").style.left,10),Number.parseInt(o(this,ys,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,ys,"f").style.top=`${t}px`,o(this,ys,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Es);var Cs=Object.freeze({__proto__:null,default:Es});return fs}();
8
8
  //# sourceMappingURL=index.js.map