@descope/role-management-widget 0.10.5 → 0.10.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,7 +1,7 @@
1
1
 
2
2
  /**
3
- * @descope/role-management-widget v0.10.5
3
+ * @descope/role-management-widget v0.10.7
4
4
  */
5
- this["descope-role-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),l=e=>{let t,n;return(...o)=>(t&&a(t,o)||(t=o,n=e(...o)),n)},c=e=>(t,...n)=>t.reduce(((t,o,i)=>{var r;return`${t}${o}${(null===(r=null==n?void 0:n[i])||void 0===r?void 0:r[e>1?1:0])||""}`}),""),d=(e,t=500)=>{let n;return function(...o){clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}},u=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:"boolean"==typeof e?String(e):(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},h=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 p,f,g,v;function m(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!m(r,s))return!1}else if(r!==s)return!1}return!0}let y=class{constructor(e={},{forceUpdate:t=!1}={}){p.set(this,void 0),f.set(this,{}),g.set(this,0),v.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,p,"f")):e,n=Object.assign(Object.assign({},o(this,p,"f")),t);if(o(this,v,"f")||!m(o(this,p,"f"),n)){const e=o(this,p,"f");i(this,p,n,"f"),Object.freeze(o(this,p,"f")),setTimeout((()=>{Object.values(o(this,f,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,p,e,"f"),i(this,v,t,"f")}get current(){return Object.assign({},o(this,p,"f"))}subscribe(e){return i(this,g,o(this,g,"f")+1,"f"),o(this,f,"f")[o(this,g,"f")]=e,o(this,g,"f").toString()}unsubscribe(e){const t=!!o(this,f,"f")[e];return t&&delete o(this,f,"f")[e],t}unsubscribeAll(){return i(this,f,{},"f"),!0}};p=new WeakMap,f=new WeakMap,g=new WeakMap,v=new WeakMap;const w=["error","warn","info","debug"],b={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},k=h((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,b))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||b),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return w.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})),I="undefined"!=typeof localStorage,S="https://static.descope.com/pages",O="https://static2.descope.com/pages",j=I&&localStorage.getItem("base.content.url")||"",x=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,C=h((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),R=h((e=>{var t,n;const i=r(k,C)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),E=e=>t=>{var n,i,s;const a=r(k,C,R)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",i).bind(this))}async init(){var e;l.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};E.missingAttrValidator=x;const _=h((e=>{const t=r(E({"project-id":x}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),A=h((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),T="Trying the next fallback URL...",M=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(o){return null==n||n.debug(`Network error fetching URL ${e} [${o.message}], retrying...`),fetch(e,t)}};const $=h((e=>{var t,n,s,a,l,c,d;const u=r(k,_,A)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=o(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];i(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;o(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;e++){const r=i[e],s=e===i.length-1;try{const i=await M(r.toString(),t,{logger:n});if(i.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${r}`),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${T}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${T}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=j||this.baseStaticUrl;if(r)return o(this,t,"m",c).call(this,e,r);o(this,n,"f")!==this.baseUrl&&(i(this,n,this.baseUrl,"f"),i(this,s,void 0,"f"),o(this,a,"f").clear());const l=[];if(o(this,s,"f"))l.push(o(this,t,"m",c).call(this,e,o(this,s,"f"))),o(this,s,"f")===S&&l.push(o(this,t,"m",c).call(this,e,O));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&l.push(o(this,t,"m",c).call(this,e,n)),o(this,a,"f").has(S)||l.push(o(this,t,"m",c).call(this,e,S)),l.push(o(this,t,"m",c).call(this,e,O))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=S}){const i=new URL(o);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=o,i}({projectId:this.projectId,filename:e,baseUrl:t})},d})),P=h((e=>{var t,n;const i=r(E({"project-id":x}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),U=h((e=>{var t,n,s,a,l;const c=r($,P,C)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",o(this,t,"m",n).bind(this))}get config(){return o(this,s,"f")||i(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){i(this,s,void 0,"f")},l})),D=h((e=>{var t,n,s,a,l,c,d;return d=class extends(r(C,k)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return al})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),N=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],L=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},W=(e,t,n)=>new Promise(((o,i)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),i(e)},r.onload=()=>{r.setAttribute("status","loaded"),o(r)},r.src=t.toString(),document.body.appendChild(r)})),F=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},q=h((e=>{const t=r(k)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[],i){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${i?" with SRI integrity check":""}`),(async(e,t)=>{for(const o of e){const{id:e,url:i,integrity:r}=o,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await F(s,r),o}catch(e){t(o,!0)}else try{return await W(e,i,r),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="",i)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${o}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${L(a)}`};return i&&(l.integrity=i),[...e,l]}),[]))([...o,this.baseCdnUrl,...N],e,t,n,i),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),z="base.ui.components.url",B=I&&localStorage.getItem(z),J=h((e=>{var t,n,s,a,l,c,d;const u=r(k,U,q)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return o(this,a,"f")||i(this,a,o(this,t,"m",c).call(this),"f"),o(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await o(this,t,"m",n).call(this),i=B?void 0:await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[B],i),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),V=h((e=>{var t,n,i;const s=r(C,R)(e);return i=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",o(this,t,"m",n).bind(this)),o(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},i}));class H{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const K=h((e=>{const t=r(V)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new H(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const o=[...e.adoptedStyleSheets||[]];o[t?"unshift":"push"](n),e.adoptedStyleSheets=o}}return n}}})),Y="content-root",Z="root",G=h((e=>{const t=r(K)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Z}">\n <div id="${Y}"></div>\n </div>\n `,this.injectStyle(`\n #${Z}, #${Y} {\n height: 100%;\n }\n #${Z} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Y),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Z)}}})),X="descope-modal";var Q,ee;let te=class{constructor(e,t){Q.set(this,void 0),this.nodeName="",i(this,Q,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,Q,"f"))}get ele(){var e,t;const n="function"==typeof o(this,Q,"f")?o(this,Q,"f").call(this):o(this,Q,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};Q=new WeakMap;let ne=class extends te{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const oe=/^descope-grid-([^-]+)-column$/,ie={text:class extends te{constructor(){super(...arguments),this.nodeName="descope-grid-text-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}},custom:class extends te{constructor(){super(...arguments),this.nodeName="descope-grid-custom-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}}};let re=class extends te{constructor(){super(...arguments),this.nodeName="descope-grid",ee.set(this,void 0)}onSelectedItemsChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("selected-items-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get columns(){return this.ele?Array.from(this.ele.children).reduce(((e,t)=>{var n;const o=null===(n=oe.exec(t.localName))||void 0===n?void 0:n[1],i=ie[o];return i?(e.push(new i(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const i=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);i&&this.ele.columns&&(a(i,this.ele.columns)||(this.ele.columns=i,null===(n=o(this,ee,"f"))||void 0===n||n.call(this,i)))}onColumnsChange(e){i(this,ee,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var se,ae,le,ce;ee=new WeakMap;let de=class extends te{constructor(...e){super(...e),se.add(this),ae.set(this,void 0),le.set(this,void 0),this.nodeName="descope-modal",o(this,se,"m",ce).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),o(this,se,"m",ce).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,ae,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,ae,"f").content.cloneNode(!0)))}setContent(e){i(this,ae,e,"f"),this.reset()}remove(){var e,t;null===(e=o(this,le,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};ae=new WeakMap,le=new WeakMap,se=new WeakSet,ce=function(){if(o(this,le,"f"))return;const e=this.ele;e&&(i(this,le,new MutationObserver((t=>{t.forEach(((n,o)=>{var i;const r="true"===n.oldValue,s=t[o+1]?t[o+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(i=this.afterClose)||void 0===i||i.call(this))}))})),"f"),o(this,le,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};const ue=({label:e,value:t,description:n})=>{const o=document.createElement("span");o.setAttribute("data-name",e),o.setAttribute("data-id",t),o.style.display="flex",o.style.flexDirection="column";const i=document.createElement("span");if(i.textContent=e,o.appendChild(i),n){const e=document.createElement("span");e.textContent=n,e.style.opacity="0.6",e.style.fontSize="0.85em",o.appendChild(e)}return o.outerHTML};let he=class extends te{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){const t=await this.asyncEle;t&&(e.some((e=>e.description))&&(t.renderItem=ue),t.setAttribute("data",JSON.stringify([...e].sort(((e,t)=>e.label.localeCompare(t.label))))))}},pe=class extends te{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()}},fe=class extends te{constructor(){super(...arguments),this.nodeName="descope-text"}get ele(){return super.ele}get text(){var e;return null===(e=this.ele)||void 0===e?void 0:e.innerText}set text(e){this.ele&&(this.ele.innerText=e)}},ge=class extends te{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const ve=h((e=>{var t,n;const i=r(C,G,J)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends de{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return o(this,t,"f")}createModal(e,n=o(this,t,"f")){const i=((e={})=>{const t=document.createElement(X);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(i),new n(i,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([X]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));h((e=>class extends(ve(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,n;await super.open(),null===(n=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===n||n.call(t)}})}}));const me="descope-notification",ye=h((e=>{var t,n;const i=r(C,G,J)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends pe{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(me);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([me])}},t=new WeakMap,n})),we=(e,t,n="")=>Object.entries(e).reduce(((e,[o,i])=>{if(!/^[a-zA-Z0-9-]+$/.test(o))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${o}`:o;if("object"==typeof i&&null!==i)return e+we(i,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(i);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),"");function be(e,t){const n=Object.assign({},e);for(const[e,o]of Object.entries(t||{}))if(null!=o)if("object"==typeof o){if(0===Object.keys(o).length)continue;n[e]=be(n[e]||{},o)}else n[e]="string"==typeof o?(n[e]||"")+o:o;return n}const ke=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",Ie=h((e=>{const t=r(E({tenant:ke}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),Se=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Oe=h((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,y,w,b,k,I,S,O,j;const x=r(E({theme:Se}),Ie,$,C,J,U,G,R,K)(e);return j=class extends x{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),I.set(this,(()=>{o(this,t,"m",S).call(this),o(this,O,"f").call(this,"os"===this.getAttribute("theme"))})),O.set(this,(e=>{var n,i,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(this,t,"m",S).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"}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,I,"f").call(this),await Promise.all([o(this,t,"m",p).call(this),o(this,t,"m",v).call(this),o(this,t,"m",y).call(this)]),o(this,t,"m",m).call(this),this.observeAttributes(["theme"],o(this,I,"f")),this.observeAttributes(["theme-override"],(()=>o(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{i(this,d,null,"f"),o(this,t,"m",v).call(this),o(this,t,"m",y).call(this)})),this.observeAttributes(["style-id"],(()=>{i(this,c,null,"f"),o(this,t,"m",b).call(this),o(this,t,"m",p).call(this),o(this,t,"m",y).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,I=new WeakMap,O=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,i,r,s,a;const l=null===(i=null===(o=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===o?void 0:o.colors)||void 0===i?void 0:i.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${we({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},u=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(z))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(z),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},h=function(){return o(this,c,"f")||(i(this,c,o(this,t,"m",u).call(this),"f"),o(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,c,"f")},p=async function(){var e,r;const s=await o(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"");o(this,n,"f")?o(this,n,"f").replaceSync(a):i(this,n,this.injectStyle(a,{prepend:!0}),"f")},f=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.warn("No tenant style exists, using project default theme.")}},g=function(){return o(this,d,"f")||i(this,d,o(this,t,"m",f).call(this),"f"),o(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=o(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await o(this,t,"a",g);if(!l)return void(null===(n=o(this,s,"f"))||void 0===n||n.replaceSync(""));const c=((null===(r=l.light)||void 0===r?void 0:r.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");o(this,s,"f")?o(this,s,"f").replaceSync(c):i(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=o(this,a,"f"))||void 0===e||e.replaceSync(""));const n=o(this,t,"m",l).call(this);o(this,a,"f")?o(this,a,"f").replaceSync(n):i(this,a,this.injectStyle(n),"f")},y=async function(){var e,n,i,r;const s=await o(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await o(this,t,"a",g);a.componentsThemeManager.themes={light:be((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==l?void 0:l.light)||void 0===n?void 0:n.components)||{}),dark:be((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},b=async function(){const e=await o(this,t,"m",w).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},k=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},S=function(){o(this,t,"m",b).call(this),o(this,t,"m",k).call(this)},j}));var je=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),xe=()=>Math.random().toString(36).substring(7).split("").join("."),Ce={INIT:`@@redux/INIT${xe()}`,REPLACE:`@@redux/REPLACE${xe()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${xe()}`};function Re(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 Ee(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 _e(e){let t=typeof e;return t=Ee(e),t}function Ae(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${_e(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: '${_e(n)}'`);return n(Ae)(e,t)}let o=e,i=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${_e(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),r=null}}}function h(e){if(!Re(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${_e(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: '${_e(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=o(i,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:Ce.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${_e(e)}`);o=e,h({type:Ce.REPLACE})},[je]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${_e(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[je](){return this}}}}}function Te(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Me(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&Te(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:Ce.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:Ce.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Ce.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===Ce.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Re(e))return`The ${r} has unexpected type of "${_e(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===Ce.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&Te(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||o.length!==Object.keys(e).length,s?a:e}}function $e(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Pe(e){return Re(e)&&"type"in e&&"string"==typeof e.type}var Ue=Symbol.for("immer-nothing"),De=Symbol.for("immer-draftable"),Ne=Symbol.for("immer-state"),Le=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function We(e,...t){{const n=Le[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Fe=Object.getPrototypeOf;function qe(e){return!!e&&!!e[Ne]}function ze(e){return!!e&&(Je(e)||Array.isArray(e)||!!e[De]||!!e.constructor?.[De]||Ze(e)||Ge(e))}var Be=Object.prototype.constructor.toString();function Je(e){if(!e||"object"!=typeof e)return!1;const t=Fe(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)===Be}function Ve(e,t){0===He(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function He(e){const t=e[Ne];return t?t.type_:Array.isArray(e)?1:Ze(e)?2:Ge(e)?3:0}function Ke(e,t){return 2===He(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ye(e,t,n){const o=He(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function Ze(e){return e instanceof Map}function Ge(e){return e instanceof Set}function Xe(e){return e.copy_||e.base_}function Qe(e,t){if(Ze(e))return new Map(e);if(Ge(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Je(e)){if(!Fe(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ne];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(Fe(e),n)}function et(e,t=!1){return nt(e)||qe(e)||!ze(e)||(He(e)>1&&(e.set=e.add=e.clear=e.delete=tt),Object.freeze(e),t&&Ve(e,((e,t)=>et(t,!0)))),e}function tt(){We(2)}function nt(e){return Object.isFrozen(e)}var ot,it={};function rt(e){const t=it[e];return t||We(0,e),t}function st(){return ot}function at(e,t){t&&(rt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function lt(e){ct(e),e.drafts_.forEach(ut),e.drafts_=null}function ct(e){e===ot&&(ot=e.parent_)}function dt(e){return ot={drafts_:[],parent_:ot,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ut(e){const t=e[Ne];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function ht(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ne].modified_&&(lt(t),We(4)),ze(e)&&(e=pt(t,e),t.parent_||gt(t,e)),t.patches_&&rt("Patches").generateReplacementPatches_(n[Ne].base_,e,t.patches_,t.inversePatches_)):e=pt(t,n,[]),lt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ue?e:void 0}function pt(e,t,n){if(nt(t))return t;const o=t[Ne];if(!o)return Ve(t,((i,r)=>ft(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return gt(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),Ve(i,((i,s)=>ft(e,o,t,i,s,n,r))),gt(e,t,!1),n&&e.patches_&&rt("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function ft(e,t,n,o,i,r,s){if(i===n&&We(5),qe(i)){const s=pt(e,i,r&&t&&3!==t.type_&&!Ke(t.assigned_,o)?r.concat(o):void 0);if(Ye(n,o,s),!qe(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(ze(i)&&!nt(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;pt(e,i),t&&t.scope_.parent_||gt(e,i)}}function gt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&et(t,n)}var vt={get(e,t){if(t===Ne)return e;const n=Xe(e);if(!Ke(n,t))return function(e,t,n){const o=wt(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_||!ze(o)?o:o===yt(e.base_,t)?(kt(e),e.copy_[t]=It(o,e)):o},has:(e,t)=>t in Xe(e),ownKeys:e=>Reflect.ownKeys(Xe(e)),set(e,t,n){const o=wt(Xe(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=yt(Xe(e),t),i=o?.[Ne];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||Ke(e.base_,t)))return!0;kt(e),bt(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!==yt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,kt(e),bt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Xe(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){We(11)},getPrototypeOf:e=>Fe(e.base_),setPrototypeOf(){We(12)}},mt={};function yt(e,t){const n=e[Ne];return(n?Xe(n):e)[t]}function wt(e,t){if(!(t in e))return;let n=Fe(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Fe(n)}}function bt(e){e.modified_||(e.modified_=!0,e.parent_&&bt(e.parent_))}function kt(e){e.copy_||(e.copy_=Qe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ve(vt,((e,t)=>{mt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),mt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&We(13),mt.set.call(this,e,t,void 0)},mt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&We(14),vt.set.call(this,e[0],t,n,e[0])};function It(e,t){const n=Ze(e)?rt("MapSet").proxyMap_(e,t):Ge(e)?rt("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:st(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=vt;n&&(i=[o],r=mt);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:st()).drafts_.push(n),n}function St(e){return qe(e)||We(10,e),Ot(e)}function Ot(e){if(!ze(e)||nt(e))return e;const t=e[Ne];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Qe(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Qe(e,!0);return Ve(n,((e,t)=>{Ye(n,e,Ot(t))})),t&&(t.finalized_=!1),n}var jt=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&We(6),void 0!==n&&"function"!=typeof n&&We(7),ze(e)){const i=dt(this),r=It(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?lt(i):ct(i)}return at(i,n),ht(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Ue&&(o=void 0),this.autoFreeze_&&et(o,!0),n){const t=[],i=[];rt("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}We(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ze(e)||We(8),qe(e)&&(e=St(e));const t=dt(this),n=It(e,void 0);return n[Ne].isManual_=!0,ct(t),n}finishDraft(e,t){const n=e&&e[Ne];n&&n.isManual_||We(9);const{scope_:o}=n;return at(o,t),ht(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=rt("Patches").applyPatches_;return qe(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},xt=jt.produce;jt.produceWithPatches.bind(jt),jt.setAutoFreeze.bind(jt),jt.setUseStrictShallowCopy.bind(jt),jt.applyPatches.bind(jt),jt.createDraft.bind(jt),jt.finishDraft.bind(jt);var Ct=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},Rt=(e,t,n)=>{const{memoize:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},Et={inputStabilityCheck:"once",identityFunctionCheck:"once"};var _t=e=>Array.isArray(e)?e:[e];function At(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 i=0;i<o;i++)n.push(e[i].apply(null,t));return n}var Mt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},$t=0,Pt=1;function Ut(){return{s:$t,v:void 0,o:null,p:null}}function Dt(e,t={}){let n=Ut();const{resultEqualityCheck:o}=t;let i,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=Ut(),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=Ut(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===Pt)l=t.v;else if(l=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,l)&&(l=e,0!==r&&r--);i="object"==typeof l&&null!==l||"function"==typeof l?new Mt(l):l}return a.s=Pt,a.v=l,l}return s.clearCache=()=>{n=Ut(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Nt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,i=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=Dt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=_t(c),f=_t(u),g=At(e),v=l((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){i++;const e=Tt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Et,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Ct},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:Rt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=Tt(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Lt=Nt(Dt),Wt=Object.assign(((e,t=Lt)=>{!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:()=>Wt});function Ft(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var qt=Ft(),zt=Ft;((...e)=>{const t=Nt(...e)})(Dt);var Bt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?$e:$e.apply(null,arguments)},Jt=e=>e&&"function"==typeof e.match;function Vt(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=>Pe(t)&&t.type===e,n}function Ht(e){return"function"==typeof e&&"type"in e&&Jt(e)}function Kt(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 Zt(e){return ze(e)?xt(e,(()=>{})):e}function Gt(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 Xt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Qt(e,t,n){const o=en(e,t,n);return{detectMutations:()=>tn(e,t,o,n)}}function en(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=en(e,t,n[i],s))}}return r}function tn(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let i in l){const s=r?r+"."+i:i;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=tn(e,t,n.children[i],o[i],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function nn(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Re(e)}function on(e,t="",n=nn,o,i=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),l=i.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=on(c,a,n,o,i,r),s))return s}return r&&rn(e)&&r.add(e),!1}function rn(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!rn(t))return!1;return!0}function sn(e){return"boolean"==typeof e}var an=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new Yt;if(t&&(sn(t)?r.push(qt):r.push(zt(t.extraArgument))),n){let e={};sn(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=Xt,ignoredPaths:i,warnAfter:r=32}=e;const s=Qt.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>l=>{const c=Kt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(o){let e={};sn(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=nn,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!Pe(u))return c(u);const h=c(u),p=Kt(s,"SerializableStateInvariantMiddleware");return l||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=on(u,"",t,n,i,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const o=on(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(i){let e={};sn(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Ht}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},ln=e=>t=>{setTimeout(t,e)},cn="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:ln(10),dn=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 i=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?cn:"callback"===e.type?e.queueNotification:ln(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,l(c))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function un(e){const t=an(),{reducer:n,middleware:o,devTools:i=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!Re(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=Me(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=$e;i&&(c=Bt({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=$e(...a)(i.dispatch),{...i,dispatch:r}}}(...l),u=dn(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Ae(a,r,c(...h))}function hn(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function pn(...e){return t=>e.some((e=>((e,t)=>Jt(e)?e.match(t):e(t))(e,t)))}var fn=["name","message","stack","code"],gn=class{constructor(e,t){this.payload=e,this.meta=t}_type},vn=class{constructor(e,t){this.payload=e,this.meta=t}_type},mn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of fn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},yn=(()=>{function e(e,t,n){const o=Vt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Vt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Vt(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||mn)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(i(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new gn(e,t),fulfillWithValue:(e,t)=>new vn(e,t)})).then((t=>{if(t instanceof gn)throw t;return t instanceof vn?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof gn?r(null,c,e,t.payload,t.meta):r(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(wn)})}}),{pending:i,rejected:r,fulfilled:o,settled:pn(r,o),typePrefix:e})}return e.withTypes=()=>e,e})();function wn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var bn=Symbol.for("rtk-slice-createasyncthunk");function kn(e,t){return`${e}/${t}`}function In(e,t,n,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var Sn=function({creators:e}={}){const t=e?.asyncThunk?.[bn];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const i=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(i),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?hn(e.extraReducers):[e.extraReducers],i={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,i,r]=hn(t);if(function(e){return"function"==typeof e}(e))n=()=>Zt(e());else{const t=Zt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...i.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(qe(e)){const o=n(e,t);return void 0===o?e:o}if(ze(e))return xt(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:kn(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Vt(e,s):Vt(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.exposeCaseReducer(t,{fulfilled:s||On,pending:a||On,rejected:l||On,settled:c||On})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=Gt(d,this,{insert:()=>new WeakMap});return Gt(n,t,{insert:()=>{const n={};for(const[o,i]of Object.entries(e.selectors??{}))n[o]=In(this,i,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function On(){}var jn="listenerMiddleware";Vt(`${jn}/add`),Vt(`${jn}/removeAll`),Vt(`${jn}/remove`);const xn=e=>h((t=>{const n=Sn(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(k)(t)){constructor(...e){super(...e);const t=un({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{wn(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),Cn=h((e=>class extends(k(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()}})),Rn=h((e=>{const t=r(E({"widget-id":x}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),En=h((e=>{const t=r(U,Rn)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}})),_n=h((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=function(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),An=e=>h((t=>{var n,i,s;const a=r($,Rn,En,_n)(t);return s=class extends a{constructor(){super(...arguments),n.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const r=await o(this,n,"m",i).call(this,t);if(void 0!==r)return r;const s=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==s?void 0:s.body}},n=new WeakSet,i=async function(t){var n;const o=await this.getWidgetConfig(),i=this.firstAvailableLocale(null!==(n=null==o?void 0:o.targetLocales)&&void 0!==n?n:[]);if(!i)return;const r=".html",s=t.endsWith(r)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${i}${r}`,"text");return null==t?void 0:t.body}catch(e){return}},s})),Tn=h((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),Mn=I&&localStorage.getItem("base.debug.logs.url"),$n=h((e=>{const t=r(E({"flow-id":x}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function Pn(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const o=Math.floor(n/60);return o<24?`${o} hours`:`${Math.floor(o/24)} days`}h((e=>{var t,n,s,a,l,c,d,u,h,p,f,g;const v=r(q,k,C,U,_,$n)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),s.set(this,!1),a.set(this,null),f.set(this,null)}get telemetryManager(){return o(this,n,"f")}updateTelemetryContext(e){if(o(this,n,"f"))try{o(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";i(this,f,o(this,t,"m",h).call(this).then((e=>o(this,t,"m",l).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=o(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),o(this,t,"m",d).call(this)}},n=new WeakMap,s=new WeakMap,a=new WeakMap,f=new WeakMap,t=new WeakSet,l=async function(e,r){if(null==e?void 0:e.enabled)if(o(this,s,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const a=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",a,"dist/index.js",[Mn]);const l=window.DescopeDebugLogs;if(!l)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(i(this,n,new l({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:r.projectId,flowId:r.flowId,version:r.sdkVersion||"1.0.0"},this.logger),"f"),!o(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void i(this,n,null,"f");i(this,s,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&o(this,t,"m",c).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),i(this,s,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},c=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void o(this,t,"m",d).call(this);const r=864e5,s=Math.min(n,r);n>r&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${Pn(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${Pn(s)})`),i(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),o(this,t,"m",d).call(this)}),s),"f")},d=function(){if(o(this,a,"f")&&(clearTimeout(o(this,a,"f")),i(this,a,null,"f")),o(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),o(this,n,"f").shutdown(),i(this,n,null,"f"),i(this,s,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},u=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},h=async function(){var e;const n=await this.config,i=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let r;try{const e=Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);r={enabled:"true"===(process.env.DESCOPE_TELEMETRY_ENABLED||"").toLowerCase(),rumConfig:Object.assign({applicationId:process.env.DESCOPE_TELEMETRY_APPLICATION_ID||"",identityPoolId:process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID||"",region:process.env.DESCOPE_TELEMETRY_REGION||"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})}}catch(e){r={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const s=Object.assign(Object.assign(Object.assign({},r),i),{rumConfig:Object.assign(Object.assign({},r.rumConfig),null==i?void 0:i.rumConfig),capture:o(this,t,"m",p).call(this,null==i?void 0:i.capture)});return s.enabled&&!o(this,t,"m",u).call(this,s.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),s.enabled=!1),i||(s.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),s},p=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},g})),h((e=>{var n,i,r;return r=class extends(Oe(e)){constructor(){super(...arguments),n.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:r,client:s,form:a}=e,l=t(e,["flowId","client","form"]);return u(Object.assign({projectId:this.getAttribute("project-id"),flowId:r,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:o(this,n,"m",i).call(this,a),client:Object.assign(Object.assign({},this.clientInput),s)},l))}},n=new WeakSet,i=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r}));const Un=/(["\\])/g;function Dn(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(Un,"\\$1")}"]`));var n}function Nn(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{Dn(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}const Ln=h((e=>{var t,n,s,a,l,c;const d=r(k,G)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,{})}async init(){var e,r;if("true"===this.getAttribute("mock"))return i(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=o(this,t,"m",a).call(this);i(this,n,o(this,t,"m",l).call(this,s),"f"),await(null===(r=super.init)||void 0===r?void 0:r.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),i(this,s,null!==(t=await o(this,n,"f"))&&void 0!==t?t:{},"f"),Nn(this.contentRootElement,o(this,s,"f"))}async reevaluateComponentsState(){const e=o(this,t,"m",a).call(this);var n,r;n=this.contentRootElement,r=o(this,s,"f"),n&&r&&Object.entries(r).forEach((([e,t])=>{Dn(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),i(this,s,await o(this,t,"m",l).call(this,e),"f"),Nn(this.contentRootElement,o(this,s,"f"))}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},l=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const o=await n.json();return null!==(t=null==o?void 0:o.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},c})),Wn=e=>e.selectedRolesIds,Fn=e=>e.notifications,qn=e=>e.tenantPermissions.data||[],zn=Lt((e=>e.rolesList.data),(e=>e.map((e=>{var t;return Object.assign(Object.assign({},e),{editable:0===(null===(t=null==e?void 0:e.tenantId)||void 0===t?void 0:t.length)?"no":"yes"})})))),Bn=Lt(Wn,zn,((e,t)=>t.filter((t=>e.includes(t.name))))),Jn=Lt(Wn,(e=>!!e.length)),Vn=Lt(Wn,(e=>1===e.length)),Hn=Lt(Bn,Vn,((e,t)=>t&&"yes"===e[0].editable)),Kn=Lt(Bn,(e=>1===e.length?e[0].name:`${e.length} roles`)),Yn=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)}))}))},Zn=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Gn=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),Xn=yn("roles/create",((e,{extra:{api:t}})=>t.role.create(e))),Qn=Yn(Xn)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Zn((e=>e.createRole)),Gn({getSuccessMsg:()=>"Role created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),eo={action:Xn,reducer:Qn},to=yn("roles/delete",((e,{extra:{api:t}})=>t.role.deleteBatch(e))),no=Yn(to)({onFulfilled:(e,t)=>{e.rolesList.data=e.rolesList.data.filter((e=>{var n;return 0===(null===(n=null==e?void 0:e.tenantId)||void 0===n?void 0:n.length)||!t.meta.arg.includes(e.name)})),e.selectedRolesIds=[]}},Zn((e=>e.deleteRole)),Gn({getSuccessMsg:e=>c(e.meta.arg.length)`${["",e.meta.arg.length]} ${["R","r"]}ole${["","s"]} deleted successfully`,getErrorMsg:e=>c(e.meta.arg.length)`Failed to delete role${["","s"]}`})),oo={action:to,reducer:no},io=yn("roles/duplicate",((e,{extra:{api:t}})=>t.role.create(e))),ro=Yn(io)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Zn((e=>e.duplicateRole)),Gn({getSuccessMsg:()=>"Role duplicated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to duplicate role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),so={action:io,reducer:ro},ao=yn("roles/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.role.search(Object.assign(Object.assign({},o),e))})),lo=Yn(ao)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.rolesList.data=t.payload}},Zn((e=>e.rolesList))),co={action:ao,reducer:lo},uo=yn("roles/update",((e,{extra:{api:t}})=>t.role.update(e))),ho=Yn(uo)({onFulfilled:(e,t)=>{const n=e.rolesList.data.findIndex((e=>e.name===t.payload.oldName));-1!==n&&(e.rolesList.data[n]=t.payload)}},Zn((e=>e.updateRole)),Gn({getSuccessMsg:()=>"Role updated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to update role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),po={action:uo,reducer:ho},fo=yn("tenant/getTenantPermissions",((e,{extra:{api:t}})=>t.tenant.getTenantPermissions())),go={action:fo,reducer:Yn(fo)({onFulfilled:(e,t)=>{e.tenantPermissions.data=t.payload.permissions}},Zn((e=>e.tenantPermissions)))},vo={rolesList:{data:[],loading:!1,error:null},createRole:{loading:!1,error:null},duplicateRole:{loading:!1,error:null},updateRole:{loading:!1,error:null},deleteRole:{loading:!1,error:null},tenantPermissions:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedRolesIds:[],notifications:[]};class mo extends Error{}function yo(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 wo(e,t){if("string"!=typeof e)throw new mo("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 mo(`Invalid token specified: missing part #${n+1}`);let i;try{i=yo(o)}catch(e){throw new mo(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new mo(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}mo.prototype.name="InvalidTokenError";var bo={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email",phone:"/v1/auth/enchantedlink/update/phone"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next",event:"/v1/flow/event"}};const ko="<region>",Io=`https://api.${ko}descope.com`,So=6e5,Oo=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},jo=[503,520,521,522,524,530],xo=[100,5e3,5e3],Co=e=>new Promise((t=>setTimeout(t,e))),Ro=e=>async function(...t){let n=await e(...t);const o=!!(null==(i=t[1])?void 0:i.disableRetry);var i;let r=0;for(;!o&&jo.includes(n.status)&&r<xo.length;)await Co(xo[r]),n=await e(...t),r++;r>0&&(n.retries=r);const s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n},Eo=(e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async function(...t){if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Oo().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await Ro(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return Oo().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:Ro(n)};let _o;const Ao=()=>{if(_o)return _o;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 _o=`${t}-${n}`,_o};var To,Mo;(Mo=To||(To={})).get="GET",Mo.delete="DELETE",Mo.post="POST",Mo.put="PUT",Mo.patch="PATCH";const $o=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(ko,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return r},Po=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),Uo={"Content-Type":"application/json"},Do=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},No=(e,t)=>{const n={"x-descope-sdk-session-id":Ao(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.73.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Lo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var Wo=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||Io,c=Eo(i,a),d=async e=>{var i;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g,keepalive:v,disableRetry:m}=a,y=(e=>void 0===e?void 0:JSON.stringify(e))(u),w=Object.assign(Object.assign({headers:Po(Do(t,g),No(t,o),(null==n?void 0:n.baseHeaders)||{},Lo(y)?Uo:{},h),method:f,body:y},v?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(w.credentials=s||"include");const b=await c($o({path:d,baseUrl:l,queryParams:p,projectId:t}),w);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==b?void 0:b.clone()),null==r?void 0:r.transformResponse){const e=await b.json(),t=(k=(null===(i=b.headers)||void 0===i?void 0:i.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function o(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function i(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;o();)if(","===e.charAt(n)){for(s=n,n+=1,o(),a=n;n<e.length&&i();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(k).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),o=new Proxy(b,{get:(e,t)=>{if(t in n)return n[t];const o=e[t];return"function"==typeof o?o.bind(e):o},set:(e,t,o)=>(n[t]=o,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>o,r.transformResponse(o)}var k;return b};return{get:(e,{headers:t,queryParams:n,token:o,keepalive:i,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:To.get,token:o,keepalive:i,disableRetry:r}),post:(e,t,{headers:n,queryParams:o,token:i,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:o,body:t,method:To.post,token:i,keepalive:r,disableRetry:s}),patch:(e,t,{headers:n,queryParams:o,token:i,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:o,body:t,method:To.patch,token:i,keepalive:r,disableRetry:s}),put:(e,t,{headers:n,queryParams:o,token:i,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:o,body:t,method:To.put,token:i,keepalive:r,disableRetry:s}),delete:(e,{headers:t,queryParams:n,token:o,keepalive:i,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:To.delete,token:o,keepalive:i,disableRetry:r}),hooks:r,buildUrl:(e,n)=>$o({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},Fo=429;function qo(e,t,n){var o;let i=zo(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i.dct)===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function zo(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return wo(e)}function Bo(e){const{exp:t}=zo(e);return(new Date).getTime()/1e3>t}function Jo(e){let t=zo(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Vo(e,t){return qo(e,t,"permissions")}function Ho(e,t){return qo(e,t,"roles")}const Ko=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Yo(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=r:(i.error=r,o.status===Fo&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function Zo(e){var t;return(null===(t=zo(e))||void 0===t?void 0:t.dct)||""}const Go=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Xo=(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 "))},Qo=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ei=e=>t=>e.test(t),ti=ei(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ni=ei(/^\+[1-9]{1}[0-9]{3,14}$/),oi=Go(ti,'"{val}" is not a valid email'),ii=Go(ni,'"{val}" is not a valid phone number'),ri=Go((e=>e.length>=1),"Minimum length is 1");const si=Go((e=>"string"==typeof e),"Input is not a string"),ai=Go((e=>Array.isArray(e)),"Input is not an array"),li=Go((e=>"boolean"==typeof e),"Input is not a boolean"),ci=Go((e=>void 0===e),"Input is defined"),di=Xo([si(),ci()],"Input is not a string or undefined"),ui=Xo([ai(),li()],"Input is not an array or boolean"),hi=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Qo(...e).validate(n[t]))),t(...n)),pi=e=>[si(`"${e}" must be a string`)],fi=e=>[di(`"${e}" must be string or undefined`)],gi=e=>[si(`"${e}" must be a string`),ri(`"${e}" must not be empty`)],vi=e=>[si(`"${e}" must be a string`),oi()],mi=e=>[si(`"${e}" must be a string`),ii()],yi=hi(gi("accessKey")),wi=e=>({exchange:yi(((t,n)=>Yo(e.post(bo.accessKey.exchange,{loginOptions:n},{token:t}))))}),bi=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),ki=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||So,So)});var Ii,Si;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Ii||(Ii={})),function(e){e.email="email"}(Si||(Si={}));const Oi=Object.assign(Object.assign({},Ii),Si);var ji;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(ji||(ji={}));const xi=gi("loginId"),Ci=hi(gi("token")),Ri=hi(xi),Ei=hi(gi("pendingRef")),_i=hi(xi,mi("phone")),Ai=hi(xi,vi("email")),Ti=e=>{const n=n=>(o,i,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Yo(e.post(Ko(bo.enchantedLink.signIn,n),{loginId:o,URI:i,loginOptions:l,providerId:a},{token:s}))},o=n=>(o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Yo(e.post(Ko(bo.enchantedLink.signUpOrIn,n),{loginId:o,URI:i,loginOptions:a,providerId:s}))},i=n=>(o,i,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Yo(e.post(Ko(bo.enchantedLink.signUp,n),{loginId:o,URI:i,user:r,loginOptions:l,providerId:a}))};return{verify:Ci((t=>Yo(e.post(bo.enchantedLink.verify,{token:t})))),signIn:Ri(n(Oi.email)),signInWithPhone:Ri(n(Ii.sms)),signUpOrIn:Ri(o(Oi.email)),signUpOrInWithPhone:Ri(o(Ii.sms)),signUp:Ri(i(Oi.email)),signUpWithPhone:Ri(i(Ii.sms)),waitForSession:Ei(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=ki(n);let s;const a=setInterval((async()=>{const n=await e.post(bo.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Yo(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ai(((t,n,o,i,r)=>Yo(e.post(bo.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:{sms:_i(((t,n,o,i,r)=>Yo(e.post(Ko(bo.enchantedLink.update.phone,Ii.sms),Object.assign({loginId:t,phone:n,URI:o},r),{token:i}))))}}}},Mi=hi(gi("flowId")),$i=hi(gi("executionId"),gi("stepId"),gi("interactionId")),Pi=hi(gi("executionId")),Ui=e=>({start:Mi(((t,n,o,i,r,s,a,l=!1)=>Yo(e.post(bo.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:$i(((t,n,o,i,r,s,a=!1,l)=>Yo(e.post(bo.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a,options:l})))),event:Pi(((t,n,o)=>Yo(e.post(bo.flow.event,{executionId:t,events:n},{keepalive:o,disableRetry:!0}))))}),Di=gi("loginId"),Ni=hi(gi("token")),Li=hi(Di),Wi=hi(Di,mi("phone")),Fi=hi(Di,vi("email")),qi=Object.keys(Oi).filter((e=>e!==Ii.voice&&e!==Ii.im)),zi=e=>({verify:Ni((t=>Yo(e.post(bo.magicLink.verify,{token:t})))),signIn:qi.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Li(((n,i,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Yo(e.post(Ko(bo.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:qi.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Li(((n,i,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Yo(e.post(Ko(bo.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:qi.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Li(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Yo(e.post(Ko(bo.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:Fi(((t,n,o,i,r)=>Yo(e.post(bo.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Ii).filter((e=>e!==Ii.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Wi(((t,o,i,r,s)=>Yo(e.post(Ko(bo.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var Bi;!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"}(Bi||(Bi={}));const Ji=hi(gi("code")),Vi=e=>({start:Object.assign(((t,n,o,i,r)=>Yo(e.post(bo.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(Bi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>Yo(e.post(bo.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:Ji((t=>Yo(e.post(bo.oauth.exchange,{code:t})))),startNative:(t,n,o)=>Yo(e.post(bo.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>Yo(e.post(bo.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>Yo(e.get(bo.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>Yo(e.post(bo.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>Yo(e.post(bo.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Hi=gi("appId"),Ki=hi(Hi),Yi=e=>({connect:Ki(((t,n,o)=>{const i=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Yo(e.post(bo.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),Zi=gi("loginId"),Gi=hi(Zi,gi("code")),Xi=hi(Zi),Qi=hi(Zi,mi("phone")),er=hi(Zi,vi("email")),tr=e=>({verify:Object.keys(Oi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gi(((t,o)=>Yo(e.post(Ko(bo.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Oi).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Xi(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return Yo(e.post(Ko(bo.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Oi).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Xi(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Yo(e.post(Ko(bo.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Oi).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Xi(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Yo(e.post(Ko(bo.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:er(((t,n,o,i)=>Yo(e.post(bo.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Ii).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qi(((t,o,i,r)=>Yo(e.post(Ko(bo.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),nr=hi(gi("tenant")),or=hi(gi("code")),ir=e=>({start:nr(((t,n,o,i,r,s,a,l)=>Yo(e.post(bo.sso.start,o||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},i&&{token:i}))))),exchange:or((t=>Yo(e.post(bo.sso.exchange,{code:t}))))}),rr=gi("loginId"),sr=hi(rr,gi("code")),ar=hi(rr),lr=hi(rr),cr=e=>({signUp:ar(((t,n)=>Yo(e.post(bo.totp.signUp,{loginId:t,user:n})))),verify:sr(((t,n,o,i)=>Yo(e.post(bo.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:lr(((t,n)=>Yo(e.post(bo.totp.update,{loginId:t},{token:n}))))}),dr=gi("loginId"),ur=gi("newPassword"),hr=hi(dr,gi("password")),pr=hi(dr),fr=hi(dr,ur),gr=hi(dr,gi("oldPassword"),ur),vr=e=>({signUp:hr(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Yo(e.post(bo.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:hr(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Yo(e.post(bo.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:pr(((t,n,o)=>Yo(e.post(bo.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:fr(((t,n,o)=>Yo(e.post(bo.password.update,{loginId:t,newPassword:n},{token:o})))),replace:gr(((t,n,o)=>Yo(e.post(bo.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>Yo(e.get(bo.password.policy))}),mr=pi("loginId"),yr=gi("loginId"),wr=pi("origin"),br=hi(yr,wr,gi("name")),kr=hi(yr,wr),Ir=hi(mr,wr),Sr=hi(yr,wr,fi("token")),Or=hi(gi("transactionId"),gi("response")),jr=e=>({signUp:{start:br(((t,n,o,i,r)=>Yo(e.post(bo.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:r,passkeyOptions:i})))),finish:Or(((t,n)=>Yo(e.post(bo.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Ir(((t,n,o,i,r)=>Yo(e.post(bo.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:Or(((t,n)=>Yo(e.post(bo.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:kr(((t,n,o,i)=>Yo(e.post(bo.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:o}))))},update:{start:Sr(((t,n,o,i,r)=>Yo(e.post(bo.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i,mfa:r},{token:o})))),finish:Or(((t,n)=>Yo(e.post(bo.webauthn.update.finish,{transactionId:t,response:n}))))}}),xr=pi("loginId"),Cr=hi(xr),Rr=hi(gi("pendingRef")),Er=e=>({signUpOrIn:Cr(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return Yo(e.post(bo.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:Cr(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Yo(e.post(bo.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:Cr(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return Yo(e.post(bo.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:Rr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=ki(n);let s;const a=setInterval((async()=>{const n=await e.post(bo.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Yo(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),_r=hi(gi("token")),Ar=hi(fi("token"));var Tr,Mr=hi([(Tr=gi("projectId"),Go(((e,t)=>n=>Qo(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",Tr))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=Wo({baseUrl:o,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:i,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:wi(l),otp:tr(l),magicLink:zi(l),enchantedLink:Ti(l),oauth:Vi(l),outbound:Yi(l),sso:ir(l),saml:ir(l),totp:cr(l),notp:Er(l),webauthn:jr(l),password:vr(l),flow:Ui(l),refresh:Ar(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?bo.tryRefresh:bo.refresh;return Yo(l.post(r,i,{token:e,queryParams:t}))})),selectTenant:hi([si("tenantId")],[di('"token" must be string or undefined')])(((e,t)=>Yo(l.post(bo.selectTenant,{tenant:e},{token:t})))),logout:Ar((e=>Yo(l.post(bo.logout,{},{token:e})))),logoutAll:Ar((e=>Yo(l.post(bo.logoutAll,{},{token:e})))),me:Ar((e=>Yo(l.get(bo.me,{token:e})))),myTenants:hi([ui('"tenants" must a string array or a boolean')],[di('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Yo(l.post(bo.myTenants,n,{token:t}))})),history:Ar((e=>Yo(l.get(bo.history,{token:e})))),isJwtExpired:_r(Bo),getTenants:_r(Jo),getJwtPermissions:_r(Vo),getJwtRoles:_r(Ho),getCurrentTenant:_r(Zo),httpClient:l};var l})),$r=Object.assign(Mr,{DeliveryMethods:Oi});
6
- /*! js-cookie v3.0.8 | MIT */function Pr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)"__proto__"!==o&&(e[o]=n[o])}return e}var Ur=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=Pr({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in o||(o[a]=t.read(s,a)),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",Pr({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Pr({},this.attributes,t))},withConverter:function(t){return e(Pr({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var Dr={default:"endpoint"},Nr="Blocked by CSP",Lr="The endpoint parameter is not a valid URL",Wr="Failed to load the JS script of the agent",Fr="9319";function qr(e,t){var n,o,i,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Nr||s===Lr)n.exclude(),r=0;else if(s===Fr)n.exclude();else if(s===Wr){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+o()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(i)}))}))};return u(c).then((function(e){return[e,a]}))}var zr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Br=zr;function Jr(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:zr,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return qr(e,Vr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Fr?new Error(Wr):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function Vr(e){return function(e,t,n){var o,i=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,a())};i.addEventListener(r,s);var a=function(){return i.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),o)return n(o);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(Lr);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(Wr))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(Nr)})).then(Hr)}function Hr(){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(Fr);return n}const Kr="3.2.0",Yr="undefined"!=typeof window,Zr=Math.pow(2,31)-1,Gr=`https://descopecdn.com/npm/oidc-client-ts@${Kr}/dist/browser/oidc-client-ts.min.js`,Xr=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Kr}/dist/browser/oidc-client-ts.min.js`,Qr=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let es;const ts=e=>{try{return wo(e).exp}catch(e){return null}},ns=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ts(n)},os=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?ts(o):void 0)},is=e=>{const{access_token:n,id_token:o,refresh_token:i,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:o,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||os(e),cookieExpiration:e.cookieExpiration||ns(e)},s)},rs=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},ss=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return is(n)},as=()=>Yr&&!!window.descopeBridge,ls=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return Qr.includes(n)},cs=void 0!==es||Yr&&void 0!==window.localStorage,ds=(e,t)=>{var n,o;return null===(o=null===(n=es||Yr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},us=e=>{var t,n;return null===(n=null===(t=es||Yr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},hs=e=>{var t,n;return null===(n=null===(t=es||Yr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},ps=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==es?void 0:es.key)||void 0===t?void 0:t.call(es,e))&&void 0!==n?n:Yr&&(null===(i=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===i?void 0:i.call(o,e)))&&void 0!==r?r:null},fs=e=>{var t,n;return Yr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},gs=e=>{var t,n;try{Yr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},vs=(...e)=>{console.debug(...e)},ms=(...e)=>{console.warn(...e)},ys=(e,t)=>{let n;var o;return t>0?(n=1e3*t,vs(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>Zr&&(vs(`Timeout is too large (${n}ms), setting it to ${Zr}ms`),n=Zr),n},ws="DS",bs="DSR",ks="DSI",Is="DSRCN";function Ss(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Os(o);Ur.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}function Os(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const js=e=>(null==e?void 0:e.cookieName)||ws,xs=e=>(null==e?void 0:e.cookieName)||bs;function Cs(e="",t){return Ur.get(xs(t))||us(`${e}${bs}`)||""}function Rs(e="",t){return Ur.get(js(t))||us(`${e}${ws}`)||""}function Es(e=""){return us(`${e}${ks}`)||""}function _s(e="",t,n,o){hs(`${e}${bs}`),hs(`${e}${ws}`),hs(`${e}${ks}`),hs(`${e}${Is}`);const i=js(t);Ur.remove(i,null==o?void 0:o.session);const r=xs(n);Ur.remove(r,null==o?void 0:o.refresh)}const As=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||Cs(e,t)});if(!n){const t=function(e=""){return us(`${e}${Is}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return us(`${e}DTD`)||""}(e);r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return us(`${e}DKD`)||""}(e);return s&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-known-device-token":s})),i},Ts=Yr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Ms="vsid",$s="vrid",Ps=(e=!1)=>{const t=us("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Us=async(e,t=Ts)=>{try{if(Ps())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Jr({apiKey:e,endpoint:[o.toString(),Dr],scriptUrlPattern:[r,Br]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Ms]:e,[$s]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};ds("fp",JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Ds=e=>{const t=Ps(!0);return t&&e.body&&(e.body.fpData=t),e},Ns="descopeFlowNonce",Ls="X-Descope-Flow-Nonce",Ws="/v1/flow/start",Fs="/v1/flow/next",qs=(e,t=Ns)=>`${t}${e}`,zs=(e,t=Ns)=>{try{const n=qs(e,t),o=us(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(Bs(e,t),null):{value:i.value,seq:i.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},Bs=(e,t=Ns)=>{try{const n=qs(e,t);hs(n)}catch(e){console.error("Error removing flow nonce:",e)}},Js=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Vs=e=>{var t;return e.path===Fs&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Js(e.body.executionId):null},Hs="dls_last_user_login_id",Ks="dls_last_user_display_name",Ys=e=>ds(Hs,e),Zs=()=>us(Hs),Gs=()=>us(Ks),Xs=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=Zs(),r=Gs();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},Qs="DSLI",ea=e=>async(...t)=>{const n=await e(...t);return gs(Qs),n};function ta(){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 na(e,t){const n=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ca(n.publicKey.challenge),n.publicKey.user.id=ca(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=ca(e.id)})),n}(e);t&&(n.signal=t.signal);try{return o=await navigator.credentials.create(n),JSON.stringify({id:o.id,rawId:da(o.rawId),type:o.type,response:{attestationObject:da(o.response.attestationObject),clientDataJSON:da(o.response.clientDataJSON)}})}catch(e){throw await ra(e,n,!0)}var o}async function oa(e,t){const n=aa(e);t&&(n.signal=t.signal);try{return la(await navigator.credentials.get(n))}catch(e){throw await ra(e,n,!1)}}async function ia(e,t){const n=aa(e);n.signal=t.signal,n.mediation="conditional";try{return la(await navigator.credentials.get(n))}catch(e){throw await ra(e,n,!1)}}async function ra(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var o,i;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await sa())return"webauthn_unsupported";const s="platform"===(null===(i=null===(o=null==t?void 0:t.publicKey)||void 0===o?void 0:o.authenticatorSelection)||void 0===i?void 0:i.authenticatorAttachment);return n&&s&&!await sa(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function sa(e=!1){var t,n;if(!Yr)return Promise.resolve(!1);if(as()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function aa(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ca(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=ca(e.id)})),n}function la(e){return JSON.stringify({id:e.id,rawId:da(e.rawId),type:e.type,response:{authenticatorData:da(e.response.authenticatorData),clientDataJSON:da(e.response.clientDataJSON),signature:da(e.response.signature),userHandle:e.response.userHandle?da(e.response.userHandle):void 0}})}function ca(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function da(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ua,ha=(ua=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await na(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await oa(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await na(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await oa(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await na(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:na,get:oa,isSupported:sa,conditional:ia}}),(...e)=>{const t=ua(...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 pa="/fedcm/config";async function fa(e,t){var n;try{await ga(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function ga(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var va=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await sa(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let ma;const ya=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{ya(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),wa=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{ma||(ma=(async()=>{try{return require("oidc-client-ts")}catch(e){return ya([Gr,Xr],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await ma;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new i({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}})(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),ds(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var i;const{client:r}=await o(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=us(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await i.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||Es(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return hs(i),t||window.location.replace(s),r}}},ba=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,es=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Yr?(o&&i&&Us(o).catch((()=>null)),e(rs(r,{beforeRequest:Ds}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.53.2"},t.baseHeaders)}))),(e=>t=>{const n=ta(),o=ta(),i=ta(),r=ta(),s=e(rs(t,{afterRequest:async(e,t)=>{if(ls(e,t))vs("Session invalidated, notifying subscribers with empty values"),o.pub(null),i.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await ss(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&i.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await ss(t);s&&o.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=bi(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return o.pub(null),i.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:o.sub,onUserChange:i.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var o;const{enableFlowNonce:i=!0,nonceStoragePrefix:r=Ns}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(s);((e=Ns)=>{try{if(!cs)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==es?void 0:es.length)&&void 0!==t?t:Yr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=ps(i);if(t&&t.startsWith(e)){const n=us(t);if(n)try{JSON.parse(n).expiry<Date.now()&&hs(t)}catch(e){hs(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=e(rs(s,{afterRequest:async(e,t)=>{var n;if(e.path!==Ws&&e.path!==Fs)return;const{nonce:o,seq:i,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Ls),o=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const o=Number(n);return Number.isSafeInteger(o)?o:void 0})(n);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=Vs(e)),{nonce:n,seq:o,executionId:Js(i)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!o||!s)return;const a=e.path===Ws,l=null===(n=zs(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==i&&void 0!==l&&i<=l||((e,t,n,o=Ns,i)=>{try{const r=qs(e,o),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:i};ds(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,o,a,r,null!=i?i:a?void 0:l)},beforeRequest:e=>{if(e.path===Fs){const t=Vs(e);if(t){const n=((e,t=Ns)=>{var n,o;return null!==(o=null===(n=zs(e,t))||void 0===n?void 0:n.value)&&void 0!==o?o:null})(t,r);n&&(e.headers=e.headers||{},e.headers[Ls]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let i;e=new Promise((e=>{i=e})),await o;try{return await t(...n)}finally{i()}}}return a}),(e=>t=>{const n=e(rs(t,{afterRequest:async(e,t)=>{if(ls(e,t))return void gs(Qs);const n=await ss(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,o;try{Yr&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o||o.call(n,e,t))}catch(e){}})(Qs,String(n.sessionExpiration))}}));return bi(n,["logout","logoutAll","oidc.logout"],ea)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);const r=!!o,s="object"==typeof o&&(null==o?void 0:o.customActivityTracking);if(!r||as())return Object.assign(e(i),{markUserActive:()=>{ms("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(vs("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Yr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(vs("Expiration time passed, refreshing session"),f.refresh(Cs()||d))}));const f=e(rs(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i,nextRefreshSeconds:r}=await ss(t);if(ls(e,t))vs("Session invalidated, canceling all timers"),a();else if(n||i){if(c=((e,t)=>{if(t)return new Date(1e3*t);vs("Could not extract expiration time from session token, trying to decode the token");try{const t=wo(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!c)return void vs("Could not extract expiration time from session token");d=o,h=r>0;const e=ys(c,r);if(a(),e<=2e4)return void vs("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});vs(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Yr&&"hidden"===document.visibilityState)vs("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return vs("Skipping refresh due to timer - user is idle"),void(p=!0);vs("Refreshing session due to timer"),f.refresh(Cs()||o)}}),e)}}}));return Object.assign(bi(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return vs("Clearing all timers"),a(),n})),{markUserActive:u?()=>{vs("markUserActive() called"),h||vs("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(vs("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Cs()||d))}:()=>{ms("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:Zs,getLastUserDisplayName:Gs});const s=e(rs(r,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:i}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=is((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;r?(Ys(r),(e=>{ds(Ks,e)})(s)):(null==i?void 0:i.loginId)&&Ys(i.loginId)}}));let a=bi(s,["flow.start"],Xs);return a=bi(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(hs(Hs),hs(Ks)),o})(i)),Object.assign(a,{getLastUserLoginId:Zs,getLastUserDisplayName:Gs})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!Yr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(rs(Object.assign({refreshCookieName:a},l),{beforeRequest:As(s,r,a),afterRequest:async(e,t)=>{if(ls(e,t))vs("Session invalidated, clearing persisted tokens"),_s(s,i,r,c);else{const e=await ss(t);e.cookieName?ds(`${s||""}${Is}`,e.cookieName):e.refreshJwt&&hs(`${s||""}${Is}`);const n=((e={},t=!1,n="",o=!1)=>{var i,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d,knownDeviceJwt:u}=e;let h;if(c)if(o){hs(`${n}${bs}`);const t=o.sameSite||"Strict",s=null===(i=o.secure)||void 0===i||i,a=null!==(r=o.domain)&&void 0!==r?r:e.cookieDomain,l=xs(o);s&&"https:"!==window.location.protocol&&ms("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Ss(l,c,d);const u=Os(a);h=Object.assign(Object.assign({},h),{refresh:{path:d.cookiePath,domain:u?a:void 0}})}else{const e=xs(o);Ur.remove(e),ds(`${n}${bs}`,c)}if(l)if(t){const n=t.sameSite||"Strict",o=null===(s=t.secure)||void 0===s||s,i=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=js(t);o&&"https:"!==window.location.protocol&&ms("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});Ss(r,l,c);const d=Os(i);h=Object.assign(Object.assign({},h),{session:{path:c.cookiePath,domain:d?i:void 0}})}else ds(`${n}${ws}`,l);return e.idToken&&ds(`${n}${ks}`,e.idToken),d&&ds(`${n}DTD`,d),u&&ds(`${n}DKD`,u),h})(e,i,s,r);n&&(c=n)}}})),u=bi(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return _s(e,t,n,null==o?void 0:o()),s})(s,i,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Cs(s,r),getSessionToken:()=>Rs(s,i),getIdToken:()=>Es(s)})}))((e=>{const t=$r(e),n=wa(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(as())return vs(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(i&&Yr&&void 0!==window.localStorage&&!fs(Qs)&&!us(Hs)&&!fs("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Rs(),a=Cs();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){vs("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},l,i)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:va(t),webauthn:ha(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){fa(o,e)},requestAuthentication(e){fa(o,e)}},async oneTap(e,t,n,i,r){await ga(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:i,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(i+pa),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>Yr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+pa);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var o,i})),ka={search:"/v1/mgmt/role/search",deleteBatch:"/v1/mgmt/role/delete/batch",create:"/v1/mgmt/role/create",update:"/v1/mgmt/role/update"},Ia={permissions:"/v1/mgmt/permission/all"},Sa=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)})),Oa=(e,t)=>n(void 0,[e,t],void 0,(function*({text:e,sort:t},n){return new Promise((o=>{const i=[];for(let e=1;e<10;e+=1)i.push({name:`Role ${e}`,description:`Role description ${e}`,permissionNames:[`Permission ${e}`],createdTime:new Date,tenantId:n});t.forEach((e=>{i.sort(((t,n)=>{var o,i;return e.desc?null===(i=n[e.field])||void 0===i?void 0:i.localeCompare(t[e.field]):null===(o=t[e.field])||void 0===o?void 0:o.localeCompare(n[e.field])}))})),o(i.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()))))}))})),ja=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,description:t,permissionNames:n},o){return new Promise((i=>{i({name:e,description:t,permissionNames:n,createdTime:new Date,tenantId:o})}))})),xa=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,newName:t,description:n,permissionNames:o},i){return new Promise((r=>{r({name:t,description:n,permissionNames:o,createdTime:new Date,oldName:e,tenantId:i})}))})),Ca=()=>n(void 0,void 0,void 0,(function*(){})),Ra=()=>new Promise((e=>{const t=[];for(let e=1;e<5;e+=1)t.push({name:`Permission ${e}`});e({permissions:t})})),Ea=({httpClient:e,tenant:t,mock:o})=>({search:(...i)=>n(void 0,[...i],void 0,(function*({page:n,limit:i=1e4,text:r,sort:s}={}){if(o)return Oa({page:n,limit:i,text:r,sort:s},t);const a=yield e.post(ka.search,{limit:i,page:n,text:r,sort:s},{queryParams:{tenant:t}});yield Sa(a);return(yield a.json()).roles})),deleteBatch:i=>n(void 0,void 0,void 0,(function*(){if(o)return Ca();const n=yield e.post(ka.deleteBatch,{roleNames:i},{queryParams:{tenant:t}});return yield Sa(n),n.json()})),create:i=>n(void 0,[i],void 0,(function*({name:n,description:i,permissionNames:r}){if(o)return ja({name:n,description:i,permissionNames:r},t);const s=yield e.post(ka.create,{name:n,description:i,permissionNames:r,tenantId:t},{queryParams:{tenant:t}});yield Sa(s);return yield s.json()})),update:i=>n(void 0,[i],void 0,(function*({name:n,newName:i,description:r,permissionNames:s}){if(o)return xa({name:n,newName:i,description:r,permissionNames:s},t);const a=yield e.post(ka.update,{name:n,newName:i,description:r,permissionNames:s,tenantId:t},{queryParams:{tenant:t}});yield Sa(a);const l=yield a.json();return l.oldName=n,l}))}),_a=({httpClient:e,tenant:t,mock:o})=>({getTenantPermissions:()=>n(void 0,void 0,void 0,(function*(){if(o)return Ra();const n=yield e.get(Ia.permissions,{queryParams:{tenant:t}});return yield Sa(n),n.json()}))}),Aa=h((e=>{var t,s,a,l;const c=r(_,R,k,A,Tn,E({tenant:E.missingAttrValidator}))(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get 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","tenant"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,n,o)=>{const i=ba(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"role-management-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.10.5"}}));return{role:Ea({httpClient:i.httpClient,tenant:t,mock:n}),tenant:_a({httpClient:i.httpClient,tenant:t,mock:n}),httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},l})),Ta=h((e=>{const t=r(xn({name:"widget",initialState:vo,reducers:{setSelectedRolesIds:(e,{payload:t})=>{e.selectedRolesIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{eo.reducer(e),so.reducer(e),po.reducer(e),oo.reducer(e),co.reducer(e),go.reducer(e)},asyncActions:{searchRoles:co.action,createRole:eo.action,duplicateRole:so.action,updateRole:po.action,deleteRoles:oo.action,getTenantPermissions:go.action}}),C,k,Aa)(e);return class extends t{constructor(...e){super(...e),this.state=vo,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ma=h((e=>{var t,i,a;return a=class extends(r(k,C,J,G,An("role-management-widget"),Ta)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([o(this,t,"m",i).call(this),this.actions.searchRoles(),this.actions.getTenantPermissions()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),$a=h((e=>{var t,a,l,c,d,u,h;return h=class extends(r(Ta,ve,Cn,k,Ma)(e)){constructor(){super(...arguments),t.add(this),a.set(this,void 0),l.set(this,"create"),c.set(this,null),u.set(this,(()=>n(this,void 0,void 0,(function*(){var e;yield o(this,a,"f").setData(null===(e=qn(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}openRoleModal(e="create",t){i(this,l,e,"f"),i(this,c,null!=t?t:null,"f"),this.roleFormModal.open()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",d).call(this)}))}},a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,t=new WeakSet,d=function(){return n(this,void 0,void 0,(function*(){this.roleFormModal=this.createModal(),this.roleFormModal.setContent(s(yield this.fetchWidgetPage("create-role-modal.html")));new ne((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}));new ne((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>n(this,void 0,void 0,(function*(){if(this.validateForm(this.roleFormModal.ele)){const e=this.getFormData(this.roleFormModal.ele);"duplicate"===o(this,l,"f")?this.actions.duplicateRole(Object.assign({},e)):this.actions.createRole(Object.assign({},e)),this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}})))),i(this,a,new he((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),o(this,u,"f").call(this),this.roleFormModal.beforeOpen=()=>n(this,void 0,void 0,(function*(){yield o(this,u,"f").call(this),o(this,c,"f")&&(this.setFormData(this.roleFormModal.ele,o(this,c,"f")),i(this,c,null,"f"))}))}))},h})),Pa=h((e=>{var t,i,s;return s=class extends(r(k,$a,Ma)(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",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.createButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-role"]'),{logger:this.logger}),this.createButton.onClick((()=>this.openRoleModal()))},s})),Ua=h((e=>{var t,i,a;return a=class extends(r(Ta,ve,k,Ma)(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),yield o(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){var e;this.deleteRolesModal=this.createModal(),this.deleteRolesModal.setContent(s(yield this.fetchWidgetPage("delete-roles-modal.html")));const t=new ne((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteRolesModal.close()));const n=new ne((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Bn(this.state);this.actions.deleteRoles(null==e?void 0:e.map((e=>e.name))),this.deleteRolesModal.close()}));const o=new fe(null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteRolesModal.beforeOpen=()=>{const e=Kn(this.state);o.text=`Delete ${e}?`}}))},a})),Da=h((e=>{var t,i,s,a;return a=class extends(r(k,Ma,Ta,Ua)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}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",i).call(this),this.subscribe(o(this,s,"f").bind(this),Jn)}))}},s=new WeakMap,t=new WeakSet,i=function(){var e;this.deleteButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-roles"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteRolesModal.open()}))},a})),Na=h((e=>{var t,i,s,a;return a=class extends(r(k,Ma,Ta,$a)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.duplicateButton.enable():this.duplicateButton.disable()})))}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",i).call(this),this.subscribe(o(this,s,"f").bind(this),Vn)}))}},s=new WeakMap,t=new WeakSet,i=function(){var e;this.duplicateButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="duplicate-role"]'),{logger:this.logger}),this.duplicateButton.disable(),this.duplicateButton.onClick((()=>{var e,t,n;const o=null===(e=Bn(this.state))||void 0===e?void 0:e[0];o&&this.openRoleModal("duplicate",{name:`${o.name} Copy`,description:null!==(t=o.description)&&void 0!==t?t:"",permissionNames:null!==(n=o.permissionNames)&&void 0!==n?n:[]})}))},a})),La=h((e=>{var a,l,c,d,u,h,p,f;return f=class extends(r(Ta,ve,k,Cn,Ma)(e)){constructor(){super(...arguments),a.add(this),l.set(this,void 0),u.set(this,(()=>n(this,void 0,void 0,(function*(){var e;yield o(this,l,"f").setData(null===(e=qn(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),h.set(this,(()=>{var e;const t=null===(e=Bn(this.state))||void 0===e?void 0:e[0],n={name:null==t?void 0:t.name,description:null==t?void 0:t.description,permissionNames:null==t?void 0:t.permissionNames};this.setFormData(this.editRoleModal.ele,n)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),yield o(this,a,"m",p).call(this)}))}},l=new WeakMap,u=new WeakMap,h=new WeakMap,a=new WeakSet,c=function(){new ne((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editRoleModal.close()))},d=function(){new ne((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{var e;if(this.validateForm(this.editRoleModal.ele)){const n=this.getFormData(this.editRoleModal.ele),{name:o}=n,i=t(n,["name"]),r=null===(e=Bn(this.state))||void 0===e?void 0:e[0];this.actions.updateRole(Object.assign({newName:o,name:r.name},i)),this.editRoleModal.close(),this.resetFormData(this.editRoleModal.ele)}}))},p=function(){return n(this,void 0,void 0,(function*(){this.editRoleModal=this.createModal(),this.editRoleModal.setContent(s(yield this.fetchWidgetPage("edit-role-modal.html"))),o(this,a,"m",c).call(this),o(this,a,"m",d).call(this),i(this,l,new he((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),this.editRoleModal.beforeOpen=()=>n(this,void 0,void 0,(function*(){yield o(this,u,"f").call(this),o(this,h,"f").call(this)}))}))},f})),Wa=h((e=>{var t,i,s,a;return a=class extends(r(k,Ma,Ta,La,Cn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.editButton.enable():this.editButton.disable()})))}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",i).call(this),this.subscribe(o(this,s,"f").bind(this),Hn)}))}},s=new WeakMap,t=new WeakSet,i=function(){var e;this.editButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-role"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editRoleModal.open()}))},a})),Fa=h((e=>{var t,i,s,a;return a=class extends(r(k,Ma,Ta)(e)){constructor(){super(...arguments),t.add(this),i.set(this,d((()=>{this.actions.searchRoles({text:this.searchInput.value})})))}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",s).call(this)}))}},i=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new ge(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(o(this,i,"f"))},a}));const qa={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},za=h((e=>{var t,i,s,a,c;return c=class extends(r(k,Ta,ye,C)(e)){constructor(){super(...arguments),t.add(this),a.set(this,l((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const r=o(this,t,"m",s).call(this,e);r.setContent(o(this,t,"m",i).call(this,{type:e,msg:n})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}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),this.subscribe(o(this,a,"f").bind(this),Fn)}))}},a=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const n=qa[e],o=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${o.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},c})),Ba=h((e=>{var t,i,s,a,c;return c=class extends(r(Ta,k,Ma)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{this.rolesTable.data=e}))),a.set(this,d(((e,t)=>{const n=[],{value:o}=t;if(o){const t=e.path;n.push({field:t,desc:"desc"===o})}this.actions.searchRoles({sort:n})})))}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",i).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{o(this,a,"f").call(this,e.target,e.detail)}))})),o(this,s,"f").call(this,zn(this.state)),this.subscribe(o(this,s,"f").bind(this),zn)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,i=function(){var e;this.rolesTable=new re(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-table"]'),{logger:this.logger}),this.rolesTable.onSelectedItemsChange((e=>{this.actions.setSelectedRolesIds(e.detail.value.map((({name:e})=>e)))}))},c})),Ja=h((e=>class extends(r(D,Oe,Ba,Pa,Da,Na,Wa,Fa,za,Ln)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Va=r((e=>class extends(Ja(e)){}))(HTMLElement);customElements.define("descope-role-management-widget",Va);const Ha=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Ka,Ya,Za,Ga,Xa,Qa,el,tl,nl,ol;const il=document.createElement("template");il.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const rl=r(K)(HTMLElement);class sl extends rl{constructor(){var e;super(),Ka.add(this),Ya.set(this,new y({messages:[]})),Za.set(this,void 0),Ga.set(this,void 0),Xa.set(this,void 0),Qa.set(this,{resize:o(this,Ka,"m",ol).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(il.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,Za,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Za,"f").style.top="32px",o(this,Za,"f").style.left=window.innerWidth-300-32+"px",i(this,Ga,o(this,Za,"f").querySelector(".content"),"f"),i(this,Xa,o(this,Za,"f").querySelector(".header"),"f")}updateData(e){o(this,Ya,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Ha(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(o(this,Za,"f"),o(this,Xa,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Qa,"f").resize),(e=o(this,Za,"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,Za,"f").onresize=o(this,Ka,"m",nl).bind(this),o(this,Ya,"f").subscribe(o(this,Ka,"m",el).bind(this))}disconnectedCallback(){o(this,Ya,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Qa,"f").resize)}}Ya=new WeakMap,Za=new WeakMap,Ga=new WeakMap,Xa=new WeakMap,Qa=new WeakMap,Ka=new WeakSet,el=function(e){o(this,Ka,"m",tl).call(this,e),o(this,Ka,"m",nl).call(this)},tl=function(e){o(this,Ga,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},nl=function(){o(this,Ga,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},ol=function(){const[e,t]=Ha(o(this,Za,"f"),Number.parseInt(o(this,Za,"f").style.left,10),Number.parseInt(o(this,Za,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Za,"f").style.top=`${t}px`,o(this,Za,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",sl);var al=Object.freeze({__proto__:null,default:sl});return Va}();
5
+ this["descope-role-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),l=e=>{let t,n;return(...o)=>(t&&a(t,o)||(t=o,n=e(...o)),n)},c=e=>(t,...n)=>t.reduce(((t,o,i)=>{var r;return`${t}${o}${(null===(r=null==n?void 0:n[i])||void 0===r?void 0:r[e>1?1:0])||""}`}),""),d=(e,t=500)=>{let n;return function(...o){clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}},u=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:"boolean"==typeof e?String(e):(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},h=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 p,f,g,v;function m(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!m(r,s))return!1}else if(r!==s)return!1}return!0}let y=class{constructor(e={},{forceUpdate:t=!1}={}){p.set(this,void 0),f.set(this,{}),g.set(this,0),v.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,p,"f")):e,n=Object.assign(Object.assign({},o(this,p,"f")),t);if(o(this,v,"f")||!m(o(this,p,"f"),n)){const e=o(this,p,"f");i(this,p,n,"f"),Object.freeze(o(this,p,"f")),setTimeout((()=>{Object.values(o(this,f,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,p,e,"f"),i(this,v,t,"f")}get current(){return Object.assign({},o(this,p,"f"))}subscribe(e){return i(this,g,o(this,g,"f")+1,"f"),o(this,f,"f")[o(this,g,"f")]=e,o(this,g,"f").toString()}unsubscribe(e){const t=!!o(this,f,"f")[e];return t&&delete o(this,f,"f")[e],t}unsubscribeAll(){return i(this,f,{},"f"),!0}};p=new WeakMap,f=new WeakMap,g=new WeakMap,v=new WeakMap;const w=e=>String(null!=e?e:"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");const b=["error","warn","info","debug"],k={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},I=h((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,k))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||k),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return b.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})),S="undefined"!=typeof localStorage,O="https://static.descope.com/pages",j="https://static2.descope.com/pages",x=S&&localStorage.getItem("base.content.url")||"",C=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,R=h((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),E=h((e=>{var t,n;const i=r(I,R)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),_=e=>t=>{var n,i,s;const a=r(I,R,E)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",i).bind(this))}async init(){var e;l.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};_.missingAttrValidator=C;const A=h((e=>{const t=r(_({"project-id":C}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),T=h((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),M="Trying the next fallback URL...",$=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(o){return null==n||n.debug(`Network error fetching URL ${e} [${o.message}], retrying...`),fetch(e,t)}};const P=h((e=>{var t,n,s,a,l,c,d;const u=r(I,A,T)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=o(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];i(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;o(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;e++){const r=i[e],s=e===i.length-1;try{const i=await $(r.toString(),t,{logger:n});if(i.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${r}`),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${M}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${M}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=x||this.baseStaticUrl;if(r)return o(this,t,"m",c).call(this,e,r);o(this,n,"f")!==this.baseUrl&&(i(this,n,this.baseUrl,"f"),i(this,s,void 0,"f"),o(this,a,"f").clear());const l=[];if(o(this,s,"f"))l.push(o(this,t,"m",c).call(this,e,o(this,s,"f"))),o(this,s,"f")===O&&l.push(o(this,t,"m",c).call(this,e,j));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&l.push(o(this,t,"m",c).call(this,e,n)),o(this,a,"f").has(O)||l.push(o(this,t,"m",c).call(this,e,O)),l.push(o(this,t,"m",c).call(this,e,j))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=O}){const i=new URL(o);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=o,i}({projectId:this.projectId,filename:e,baseUrl:t})},d})),U=h((e=>{var t,n;const i=r(_({"project-id":C}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),D=h((e=>{var t,n,s,a,l;const c=r(P,U,R)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",o(this,t,"m",n).bind(this))}get config(){return o(this,s,"f")||i(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){i(this,s,void 0,"f")},l})),N=h((e=>{var t,n,s,a,l,c,d;return d=class extends(r(R,I)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return ll})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),L=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],W=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},F=(e,t,n)=>new Promise(((o,i)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),i(e)},r.onload=()=>{r.setAttribute("status","loaded"),o(r)},r.src=t.toString(),document.body.appendChild(r)})),q=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},z=h((e=>{const t=r(I)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[],i){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${i?" with SRI integrity check":""}`),(async(e,t)=>{for(const o of e){const{id:e,url:i,integrity:r}=o,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await q(s,r),o}catch(e){t(o,!0)}else try{return await F(e,i,r),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="",i)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${o}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${W(a)}`};return i&&(l.integrity=i),[...e,l]}),[]))([...o,this.baseCdnUrl,...L],e,t,n,i),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),B="base.ui.components.url",J=S&&localStorage.getItem(B),V=h((e=>{var t,n,s,a,l,c,d;const u=r(I,D,z)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return o(this,a,"f")||i(this,a,o(this,t,"m",c).call(this),"f"),o(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await o(this,t,"m",n).call(this),i=J?void 0:await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[J],i),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),H=h((e=>{var t,n,i;const s=r(R,E)(e);return i=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",o(this,t,"m",n).bind(this)),o(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},i}));class K{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const Y=h((e=>{const t=r(H)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new K(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const o=[...e.adoptedStyleSheets||[]];o[t?"unshift":"push"](n),e.adoptedStyleSheets=o}}return n}}})),Z="content-root",G="root",X=h((e=>{const t=r(Y)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${G}">\n <div id="${Z}"></div>\n </div>\n `,this.injectStyle(`\n #${G}, #${Z} {\n height: 100%;\n }\n #${G} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Z),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(G)}}})),Q="descope-modal";var ee,te;let ne=class{constructor(e,t){ee.set(this,void 0),this.nodeName="",i(this,ee,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,ee,"f"))}get ele(){var e,t;const n="function"==typeof o(this,ee,"f")?o(this,ee,"f").call(this):o(this,ee,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};ee=new WeakMap;let oe=class extends ne{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const ie=/^descope-grid-([^-]+)-column$/,re={text:class extends ne{constructor(){super(...arguments),this.nodeName="descope-grid-text-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}},custom:class extends ne{constructor(){super(...arguments),this.nodeName="descope-grid-custom-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}}};let se=class extends ne{constructor(){super(...arguments),this.nodeName="descope-grid",te.set(this,void 0)}onSelectedItemsChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("selected-items-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get columns(){return this.ele?Array.from(this.ele.children).reduce(((e,t)=>{var n;const o=null===(n=ie.exec(t.localName))||void 0===n?void 0:n[1],i=re[o];return i?(e.push(new i(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const i=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);i&&this.ele.columns&&(a(i,this.ele.columns)||(this.ele.columns=i,null===(n=o(this,te,"f"))||void 0===n||n.call(this,i)))}onColumnsChange(e){i(this,te,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var ae,le,ce,de;te=new WeakMap;let ue=class extends ne{constructor(...e){super(...e),ae.add(this),le.set(this,void 0),ce.set(this,void 0),this.nodeName="descope-modal",o(this,ae,"m",de).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),o(this,ae,"m",de).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,le,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,le,"f").content.cloneNode(!0)))}setContent(e){i(this,le,e,"f"),this.reset()}remove(){var e,t;null===(e=o(this,ce,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};le=new WeakMap,ce=new WeakMap,ae=new WeakSet,de=function(){if(o(this,ce,"f"))return;const e=this.ele;e&&(i(this,ce,new MutationObserver((t=>{t.forEach(((n,o)=>{var i;const r="true"===n.oldValue,s=t[o+1]?t[o+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(i=this.afterClose)||void 0===i||i.call(this))}))})),"f"),o(this,ce,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};const he=({label:e,value:t,description:n})=>{const o=document.createElement("span");o.setAttribute("data-name",e),o.setAttribute("data-id",t),o.style.display="flex",o.style.flexDirection="column";const i=document.createElement("span");if(i.textContent=e,o.appendChild(i),n){const e=document.createElement("span");e.textContent=n,e.style.opacity="0.6",e.style.fontSize="0.85em",o.appendChild(e)}return o.outerHTML};let pe=class extends ne{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){const t=await this.asyncEle;t&&(e.some((e=>e.description))&&(t.renderItem=he),t.setAttribute("data",JSON.stringify([...e].sort(((e,t)=>e.label.localeCompare(t.label))))))}},fe=class extends ne{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()}},ge=class extends ne{constructor(){super(...arguments),this.nodeName="descope-text"}get ele(){return super.ele}get text(){var e;return null===(e=this.ele)||void 0===e?void 0:e.innerText}set text(e){this.ele&&(this.ele.innerText=e)}},ve=class extends ne{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const me=h((e=>{var t,n;const i=r(R,X,V)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ue{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return o(this,t,"f")}createModal(e,n=o(this,t,"f")){const i=((e={})=>{const t=document.createElement(Q);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(i),new n(i,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Q]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));h((e=>class extends(me(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,n;await super.open(),null===(n=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===n||n.call(t)}})}}));const ye="descope-notification",we=h((e=>{var t,n;const i=r(R,X,V)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends fe{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ye);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([ye])}},t=new WeakMap,n})),be=(e,t,n="")=>Object.entries(e).reduce(((e,[o,i])=>{if(!/^[a-zA-Z0-9-]+$/.test(o))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${o}`:o;if("object"==typeof i&&null!==i)return e+be(i,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(i);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),"");function ke(e,t){const n=Object.assign({},e);for(const[e,o]of Object.entries(t||{}))if(null!=o)if("object"==typeof o){if(0===Object.keys(o).length)continue;n[e]=ke(n[e]||{},o)}else n[e]="string"==typeof o?(n[e]||"")+o:o;return n}const Ie=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",Se=h((e=>{const t=r(_({tenant:Ie}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),Oe=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',je=h((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,y,w,b,k,I,S,O,j;const x=r(_({theme:Oe}),Se,P,R,V,D,X,E,Y)(e);return j=class extends x{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),I.set(this,(()=>{o(this,t,"m",S).call(this),o(this,O,"f").call(this,"os"===this.getAttribute("theme"))})),O.set(this,(e=>{var n,i,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(this,t,"m",S).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"}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,I,"f").call(this),await Promise.all([o(this,t,"m",p).call(this),o(this,t,"m",v).call(this),o(this,t,"m",y).call(this)]),o(this,t,"m",m).call(this),this.observeAttributes(["theme"],o(this,I,"f")),this.observeAttributes(["theme-override"],(()=>o(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{i(this,d,null,"f"),o(this,t,"m",v).call(this),o(this,t,"m",y).call(this)})),this.observeAttributes(["style-id"],(()=>{i(this,c,null,"f"),o(this,t,"m",b).call(this),o(this,t,"m",p).call(this),o(this,t,"m",y).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,I=new WeakMap,O=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,i,r,s,a;const l=null===(i=null===(o=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===o?void 0:o.colors)||void 0===i?void 0:i.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${be({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},u=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(B))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(B),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},h=function(){return o(this,c,"f")||(i(this,c,o(this,t,"m",u).call(this),"f"),o(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,c,"f")},p=async function(){var e,r;const s=await o(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"");o(this,n,"f")?o(this,n,"f").replaceSync(a):i(this,n,this.injectStyle(a,{prepend:!0}),"f")},f=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.warn("No tenant style exists, using project default theme.")}},g=function(){return o(this,d,"f")||i(this,d,o(this,t,"m",f).call(this),"f"),o(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=o(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await o(this,t,"a",g);if(!l)return void(null===(n=o(this,s,"f"))||void 0===n||n.replaceSync(""));const c=((null===(r=l.light)||void 0===r?void 0:r.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");o(this,s,"f")?o(this,s,"f").replaceSync(c):i(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=o(this,a,"f"))||void 0===e||e.replaceSync(""));const n=o(this,t,"m",l).call(this);o(this,a,"f")?o(this,a,"f").replaceSync(n):i(this,a,this.injectStyle(n),"f")},y=async function(){var e,n,i,r;const s=await o(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await o(this,t,"a",g);a.componentsThemeManager.themes={light:ke((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==l?void 0:l.light)||void 0===n?void 0:n.components)||{}),dark:ke((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},b=async function(){const e=await o(this,t,"m",w).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},k=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},S=function(){o(this,t,"m",b).call(this),o(this,t,"m",k).call(this)},j}));var xe=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),Ce=()=>Math.random().toString(36).substring(7).split("").join("."),Re={INIT:`@@redux/INIT${Ce()}`,REPLACE:`@@redux/REPLACE${Ce()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Ce()}`};function Ee(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 _e(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 Ae(e){let t=typeof e;return t=_e(e),t}function Te(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Ae(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: '${Ae(n)}'`);return n(Te)(e,t)}let o=e,i=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Ae(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),r=null}}}function h(e){if(!Ee(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Ae(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: '${Ae(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=o(i,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:Re.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${Ae(e)}`);o=e,h({type:Re.REPLACE})},[xe]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${Ae(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[xe](){return this}}}}}function Me(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function $e(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&Me(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:Re.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:Re.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Re.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===Re.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Ee(e))return`The ${r} has unexpected type of "${Ae(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===Re.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&Me(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||o.length!==Object.keys(e).length,s?a:e}}function Pe(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Ue(e){return Ee(e)&&"type"in e&&"string"==typeof e.type}var De=Symbol.for("immer-nothing"),Ne=Symbol.for("immer-draftable"),Le=Symbol.for("immer-state"),We=[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 Fe(e,...t){{const n=We[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var qe=Object.getPrototypeOf;function ze(e){return!!e&&!!e[Le]}function Be(e){return!!e&&(Ve(e)||Array.isArray(e)||!!e[Ne]||!!e.constructor?.[Ne]||Ge(e)||Xe(e))}var Je=Object.prototype.constructor.toString();function Ve(e){if(!e||"object"!=typeof e)return!1;const t=qe(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)===Je}function He(e,t){0===Ke(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Ke(e){const t=e[Le];return t?t.type_:Array.isArray(e)?1:Ge(e)?2:Xe(e)?3:0}function Ye(e,t){return 2===Ke(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ze(e,t,n){const o=Ke(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function Ge(e){return e instanceof Map}function Xe(e){return e instanceof Set}function Qe(e){return e.copy_||e.base_}function et(e,t){if(Ge(e))return new Map(e);if(Xe(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ve(e)){if(!qe(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Le];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(qe(e),n)}function tt(e,t=!1){return ot(e)||ze(e)||!Be(e)||(Ke(e)>1&&(e.set=e.add=e.clear=e.delete=nt),Object.freeze(e),t&&He(e,((e,t)=>tt(t,!0)))),e}function nt(){Fe(2)}function ot(e){return Object.isFrozen(e)}var it,rt={};function st(e){const t=rt[e];return t||Fe(0,e),t}function at(){return it}function lt(e,t){t&&(st("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ct(e){dt(e),e.drafts_.forEach(ht),e.drafts_=null}function dt(e){e===it&&(it=e.parent_)}function ut(e){return it={drafts_:[],parent_:it,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ht(e){const t=e[Le];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function pt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Le].modified_&&(ct(t),Fe(4)),Be(e)&&(e=ft(t,e),t.parent_||vt(t,e)),t.patches_&&st("Patches").generateReplacementPatches_(n[Le].base_,e,t.patches_,t.inversePatches_)):e=ft(t,n,[]),ct(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==De?e:void 0}function ft(e,t,n){if(ot(t))return t;const o=t[Le];if(!o)return He(t,((i,r)=>gt(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return vt(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),He(i,((i,s)=>gt(e,o,t,i,s,n,r))),vt(e,t,!1),n&&e.patches_&&st("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function gt(e,t,n,o,i,r,s){if(i===n&&Fe(5),ze(i)){const s=ft(e,i,r&&t&&3!==t.type_&&!Ye(t.assigned_,o)?r.concat(o):void 0);if(Ze(n,o,s),!ze(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(Be(i)&&!ot(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ft(e,i),t&&t.scope_.parent_||vt(e,i)}}function vt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&tt(t,n)}var mt={get(e,t){if(t===Le)return e;const n=Qe(e);if(!Ye(n,t))return function(e,t,n){const o=bt(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_||!Be(o)?o:o===wt(e.base_,t)?(It(e),e.copy_[t]=St(o,e)):o},has:(e,t)=>t in Qe(e),ownKeys:e=>Reflect.ownKeys(Qe(e)),set(e,t,n){const o=bt(Qe(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=wt(Qe(e),t),i=o?.[Le];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||Ye(e.base_,t)))return!0;It(e),kt(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!==wt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,It(e),kt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Qe(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Fe(11)},getPrototypeOf:e=>qe(e.base_),setPrototypeOf(){Fe(12)}},yt={};function wt(e,t){const n=e[Le];return(n?Qe(n):e)[t]}function bt(e,t){if(!(t in e))return;let n=qe(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=qe(n)}}function kt(e){e.modified_||(e.modified_=!0,e.parent_&&kt(e.parent_))}function It(e){e.copy_||(e.copy_=et(e.base_,e.scope_.immer_.useStrictShallowCopy_))}He(mt,((e,t)=>{yt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),yt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Fe(13),yt.set.call(this,e,t,void 0)},yt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Fe(14),mt.set.call(this,e[0],t,n,e[0])};function St(e,t){const n=Ge(e)?st("MapSet").proxyMap_(e,t):Xe(e)?st("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:at(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=mt;n&&(i=[o],r=yt);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:at()).drafts_.push(n),n}function Ot(e){return ze(e)||Fe(10,e),jt(e)}function jt(e){if(!Be(e)||ot(e))return e;const t=e[Le];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=et(e,t.scope_.immer_.useStrictShallowCopy_)}else n=et(e,!0);return He(n,((e,t)=>{Ze(n,e,jt(t))})),t&&(t.finalized_=!1),n}var xt=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&Fe(6),void 0!==n&&"function"!=typeof n&&Fe(7),Be(e)){const i=ut(this),r=St(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?ct(i):dt(i)}return lt(i,n),pt(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===De&&(o=void 0),this.autoFreeze_&&tt(o,!0),n){const t=[],i=[];st("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Fe(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Be(e)||Fe(8),ze(e)&&(e=Ot(e));const t=ut(this),n=St(e,void 0);return n[Le].isManual_=!0,dt(t),n}finishDraft(e,t){const n=e&&e[Le];n&&n.isManual_||Fe(9);const{scope_:o}=n;return lt(o,t),pt(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=st("Patches").applyPatches_;return ze(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},Ct=xt.produce;xt.produceWithPatches.bind(xt),xt.setAutoFreeze.bind(xt),xt.setUseStrictShallowCopy.bind(xt),xt.applyPatches.bind(xt),xt.createDraft.bind(xt),xt.finishDraft.bind(xt);var Rt=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},Et=(e,t,n)=>{const{memoize:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},_t={inputStabilityCheck:"once",identityFunctionCheck:"once"};var At=e=>Array.isArray(e)?e:[e];function Tt(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Mt(e,t){const n=[],{length:o}=e;for(let i=0;i<o;i++)n.push(e[i].apply(null,t));return n}var $t="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Pt=0,Ut=1;function Dt(){return{s:Pt,v:void 0,o:null,p:null}}function Nt(e,t={}){let n=Dt();const{resultEqualityCheck:o}=t;let i,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=Dt(),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=Dt(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===Ut)l=t.v;else if(l=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,l)&&(l=e,0!==r&&r--);i="object"==typeof l&&null!==l||"function"==typeof l?new $t(l):l}return a.s=Ut,a.v=l,l}return s.clearCache=()=>{n=Dt(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Lt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,i=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=Nt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=At(c),f=At(u),g=Tt(e),v=l((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){i++;const e=Mt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={..._t,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Rt},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:Et}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=Mt(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Wt=Lt(Nt),Ft=Object.assign(((e,t=Wt)=>{!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:()=>Ft});function qt(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var zt=qt(),Bt=qt;((...e)=>{const t=Lt(...e)})(Nt);var Jt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Pe:Pe.apply(null,arguments)},Vt=e=>e&&"function"==typeof e.match;function Ht(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=>Ue(t)&&t.type===e,n}function Kt(e){return"function"==typeof e&&"type"in e&&Vt(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 Zt=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 Gt(e){return Be(e)?Ct(e,(()=>{})):e}function Xt(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 Qt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function en(e,t,n){const o=tn(e,t,n);return{detectMutations:()=>nn(e,t,o,n)}}function tn(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=tn(e,t,n[i],s))}}return r}function nn(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let i in l){const s=r?r+"."+i:i;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=nn(e,t,n.children[i],o[i],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function on(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Ee(e)}function rn(e,t="",n=on,o,i=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),l=i.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=rn(c,a,n,o,i,r),s))return s}return r&&sn(e)&&r.add(e),!1}function sn(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!sn(t))return!1;return!0}function an(e){return"boolean"==typeof e}var ln=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new Zt;if(t&&(an(t)?r.push(zt):r.push(Bt(t.extraArgument))),n){let e={};an(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=Qt,ignoredPaths:i,warnAfter:r=32}=e;const s=en.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>l=>{const c=Yt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(o){let e={};an(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=on,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!Ue(u))return c(u);const h=c(u),p=Yt(s,"SerializableStateInvariantMiddleware");return l||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=rn(u,"",t,n,i,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const o=rn(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(i){let e={};an(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Kt}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},cn=e=>t=>{setTimeout(t,e)},dn="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:cn(10),un=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Zt(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let i=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?dn:"callback"===e.type?e.queueNotification:cn(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,l(c))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function hn(e){const t=ln(),{reducer:n,middleware:o,devTools:i=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!Ee(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=$e(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=Pe;i&&(c=Jt({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Pe(...a)(i.dispatch),{...i,dispatch:r}}}(...l),u=un(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Te(a,r,c(...h))}function pn(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function fn(...e){return t=>e.some((e=>((e,t)=>Vt(e)?e.match(t):e(t))(e,t)))}var gn=["name","message","stack","code"],vn=class{constructor(e,t){this.payload=e,this.meta=t}_type},mn=class{constructor(e,t){this.payload=e,this.meta=t}_type},yn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of gn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},wn=(()=>{function e(e,t,n){const o=Ht(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Ht(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ht(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||yn)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(i(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new vn(e,t),fulfillWithValue:(e,t)=>new mn(e,t)})).then((t=>{if(t instanceof vn)throw t;return t instanceof mn?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof vn?r(null,c,e,t.payload,t.meta):r(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(bn)})}}),{pending:i,rejected:r,fulfilled:o,settled:fn(r,o),typePrefix:e})}return e.withTypes=()=>e,e})();function bn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var kn=Symbol.for("rtk-slice-createasyncthunk");function In(e,t){return`${e}/${t}`}function Sn(e,t,n,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var On=function({creators:e}={}){const t=e?.asyncThunk?.[kn];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const i=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(i),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?pn(e.extraReducers):[e.extraReducers],i={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,i,r]=pn(t);if(function(e){return"function"==typeof e}(e))n=()=>Gt(e());else{const t=Gt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...i.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(ze(e)){const o=n(e,t);return void 0===o?e:o}if(Be(e))return Ct(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:In(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Ht(e,s):Ht(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.exposeCaseReducer(t,{fulfilled:s||jn,pending:a||jn,rejected:l||jn,settled:c||jn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=Xt(d,this,{insert:()=>new WeakMap});return Xt(n,t,{insert:()=>{const n={};for(const[o,i]of Object.entries(e.selectors??{}))n[o]=Sn(this,i,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function jn(){}var xn="listenerMiddleware";Ht(`${xn}/add`),Ht(`${xn}/removeAll`),Ht(`${xn}/remove`);const Cn=e=>h((t=>{const n=On(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(I)(t)){constructor(...e){super(...e);const t=hn({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{bn(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),Rn=h((e=>class extends(I(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()}})),En=h((e=>{const t=r(_({"widget-id":C}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),_n=h((e=>{const t=r(D,En)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}})),An=h((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=function(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),Tn=e=>h((t=>{var n,i,s;const a=r(P,En,_n,An)(t);return s=class extends a{constructor(){super(...arguments),n.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const r=await o(this,n,"m",i).call(this,t);if(void 0!==r)return r;const s=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==s?void 0:s.body}},n=new WeakSet,i=async function(t){var n;const o=await this.getWidgetConfig(),i=this.firstAvailableLocale(null!==(n=null==o?void 0:o.targetLocales)&&void 0!==n?n:[]);if(!i)return;const r=".html",s=t.endsWith(r)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${i}${r}`,"text");return null==t?void 0:t.body}catch(e){return}},s})),Mn=h((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),$n=S&&localStorage.getItem("base.debug.logs.url"),Pn=h((e=>{const t=r(_({"flow-id":C}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function Un(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const o=Math.floor(n/60);return o<24?`${o} hours`:`${Math.floor(o/24)} days`}h((e=>{var t,n,s,a,l,c,d,u,h,p,f,g;const v=r(z,I,R,D,A,Pn)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),s.set(this,!1),a.set(this,null),f.set(this,null)}get telemetryManager(){return o(this,n,"f")}updateTelemetryContext(e){if(o(this,n,"f"))try{o(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";i(this,f,o(this,t,"m",h).call(this).then((e=>o(this,t,"m",l).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=o(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),o(this,t,"m",d).call(this)}},n=new WeakMap,s=new WeakMap,a=new WeakMap,f=new WeakMap,t=new WeakSet,l=async function(e,r){if(null==e?void 0:e.enabled)if(o(this,s,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const a=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",a,"dist/index.js",[$n]);const l=window.DescopeDebugLogs;if(!l)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(i(this,n,new l({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:r.projectId,flowId:r.flowId,version:r.sdkVersion||"1.0.0"},this.logger),"f"),!o(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void i(this,n,null,"f");i(this,s,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&o(this,t,"m",c).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),i(this,s,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},c=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void o(this,t,"m",d).call(this);const r=864e5,s=Math.min(n,r);n>r&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${Un(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${Un(s)})`),i(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),o(this,t,"m",d).call(this)}),s),"f")},d=function(){if(o(this,a,"f")&&(clearTimeout(o(this,a,"f")),i(this,a,null,"f")),o(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),o(this,n,"f").shutdown(),i(this,n,null,"f"),i(this,s,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},u=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},h=async function(){var e;const n=await this.config,i=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let r;try{const e=Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);r={enabled:"true"===(process.env.DESCOPE_TELEMETRY_ENABLED||"").toLowerCase(),rumConfig:Object.assign({applicationId:process.env.DESCOPE_TELEMETRY_APPLICATION_ID||"",identityPoolId:process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID||"",region:process.env.DESCOPE_TELEMETRY_REGION||"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})}}catch(e){r={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const s=Object.assign(Object.assign(Object.assign({},r),i),{rumConfig:Object.assign(Object.assign({},r.rumConfig),null==i?void 0:i.rumConfig),capture:o(this,t,"m",p).call(this,null==i?void 0:i.capture)});return s.enabled&&!o(this,t,"m",u).call(this,s.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),s.enabled=!1),i||(s.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),s},p=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},g})),h((e=>{var n,i,r;return r=class extends(je(e)){constructor(){super(...arguments),n.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:r,client:s,form:a}=e,l=t(e,["flowId","client","form"]);return u(Object.assign({projectId:this.getAttribute("project-id"),flowId:r,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:o(this,n,"m",i).call(this,a),client:Object.assign(Object.assign({},this.clientInput),s)},l))}},n=new WeakSet,i=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r}));const Dn=/(["\\])/g;function Nn(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(Dn,"\\$1")}"]`));var n}function Ln(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{Nn(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}const Wn=h((e=>{var t,n,s,a,l,c;const d=r(I,X)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,{})}async init(){var e,r;if("true"===this.getAttribute("mock"))return i(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=o(this,t,"m",a).call(this);i(this,n,o(this,t,"m",l).call(this,s),"f"),await(null===(r=super.init)||void 0===r?void 0:r.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),i(this,s,null!==(t=await o(this,n,"f"))&&void 0!==t?t:{},"f"),Ln(this.contentRootElement,o(this,s,"f"))}async reevaluateComponentsState(){const e=o(this,t,"m",a).call(this);var n,r;n=this.contentRootElement,r=o(this,s,"f"),n&&r&&Object.entries(r).forEach((([e,t])=>{Nn(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),i(this,s,await o(this,t,"m",l).call(this,e),"f"),Ln(this.contentRootElement,o(this,s,"f"))}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},l=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const o=await n.json();return null!==(t=null==o?void 0:o.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},c})),Fn=e=>e.selectedRolesIds,qn=e=>e.notifications,zn=e=>e.tenantPermissions.data||[],Bn=Wt((e=>e.rolesList.data),(e=>e.map((e=>{var t;return Object.assign(Object.assign({},e),{editable:0===(null===(t=null==e?void 0:e.tenantId)||void 0===t?void 0:t.length)?"no":"yes"})})))),Jn=Wt(Fn,Bn,((e,t)=>t.filter((t=>e.includes(t.name))))),Vn=Wt(Fn,(e=>!!e.length)),Hn=Wt(Fn,(e=>1===e.length)),Kn=Wt(Jn,Hn,((e,t)=>t&&"yes"===e[0].editable)),Yn=Wt(Jn,(e=>1===e.length?e[0].name:`${e.length} roles`)),Zn=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)}))}))},Gn=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Xn=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),Qn=wn("roles/create",((e,{extra:{api:t}})=>t.role.create(e))),eo=Zn(Qn)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Gn((e=>e.createRole)),Xn({getSuccessMsg:()=>"Role created successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to create role</div>\n ${w(n)}\n </div>`}})),to={action:Qn,reducer:eo},no=wn("roles/delete",((e,{extra:{api:t}})=>t.role.deleteBatch(e))),oo=Zn(no)({onFulfilled:(e,t)=>{e.rolesList.data=e.rolesList.data.filter((e=>{var n;return 0===(null===(n=null==e?void 0:e.tenantId)||void 0===n?void 0:n.length)||!t.meta.arg.includes(e.name)})),e.selectedRolesIds=[]}},Gn((e=>e.deleteRole)),Xn({getSuccessMsg:e=>c(e.meta.arg.length)`${["",e.meta.arg.length]} ${["R","r"]}ole${["","s"]} deleted successfully`,getErrorMsg:e=>c(e.meta.arg.length)`Failed to delete role${["","s"]}`})),io={action:no,reducer:oo},ro=wn("roles/duplicate",((e,{extra:{api:t}})=>t.role.create(e))),so=Zn(ro)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Gn((e=>e.duplicateRole)),Xn({getSuccessMsg:()=>"Role duplicated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to duplicate role</div>\n ${w(n)}\n </div>`}})),ao={action:ro,reducer:so},lo=wn("roles/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.role.search(Object.assign(Object.assign({},o),e))})),co=Zn(lo)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.rolesList.data=t.payload}},Gn((e=>e.rolesList))),uo={action:lo,reducer:co},ho=wn("roles/update",((e,{extra:{api:t}})=>t.role.update(e))),po=Zn(ho)({onFulfilled:(e,t)=>{const n=e.rolesList.data.findIndex((e=>e.name===t.payload.oldName));-1!==n&&(e.rolesList.data[n]=t.payload)}},Gn((e=>e.updateRole)),Xn({getSuccessMsg:()=>"Role updated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to update role</div>\n ${w(n)}\n </div>`}})),fo={action:ho,reducer:po},go=wn("tenant/getTenantPermissions",((e,{extra:{api:t}})=>t.tenant.getTenantPermissions())),vo={action:go,reducer:Zn(go)({onFulfilled:(e,t)=>{e.tenantPermissions.data=t.payload.permissions}},Gn((e=>e.tenantPermissions)))},mo={rolesList:{data:[],loading:!1,error:null},createRole:{loading:!1,error:null},duplicateRole:{loading:!1,error:null},updateRole:{loading:!1,error:null},deleteRole:{loading:!1,error:null},tenantPermissions:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedRolesIds:[],notifications:[]};class yo extends Error{}function wo(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 bo(e,t){if("string"!=typeof e)throw new yo("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 yo(`Invalid token specified: missing part #${n+1}`);let i;try{i=wo(o)}catch(e){throw new yo(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new yo(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}yo.prototype.name="InvalidTokenError";var ko={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email",phone:"/v1/auth/enchantedlink/update/phone"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next",event:"/v1/flow/event"}};const Io="<region>",So=`https://api.${Io}descope.com`,Oo=6e5,jo=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},xo=[503,520,521,522,524,530],Co=[100,5e3,5e3],Ro=e=>new Promise((t=>setTimeout(t,e))),Eo=e=>async function(...t){let n=await e(...t);const o=!!(null==(i=t[1])?void 0:i.disableRetry);var i;let r=0;for(;!o&&xo.includes(n.status)&&r<Co.length;)await Ro(Co[r]),n=await e(...t),r++;r>0&&(n.retries=r);const s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n},_o=(e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async function(...t){if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>jo().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await Eo(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return jo().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:Eo(n)};let Ao;const To=()=>{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 Mo,$o;($o=Mo||(Mo={})).get="GET",$o.delete="DELETE",$o.post="POST",$o.put="PUT",$o.patch="PATCH";const Po=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(Io,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return r},Uo=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),Do={"Content-Type":"application/json"},No=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Lo=(e,t)=>{const n={"x-descope-sdk-session-id":To(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.74.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Wo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var Fo=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||So,c=_o(i,a),d=async e=>{var i;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g,keepalive:v,disableRetry:m}=a,y=(e=>void 0===e?void 0:JSON.stringify(e))(u),w=Object.assign(Object.assign({headers:Uo(No(t,g),Lo(t,o),(null==n?void 0:n.baseHeaders)||{},Wo(y)?Do:{},h),method:f,body:y},v?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(w.credentials=s||"include");const b=await c(Po({path:d,baseUrl:l,queryParams:p,projectId:t}),w);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==b?void 0:b.clone()),null==r?void 0:r.transformResponse){const e=await b.json(),t=(k=(null===(i=b.headers)||void 0===i?void 0:i.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function o(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function i(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;o();)if(","===e.charAt(n)){for(s=n,n+=1,o(),a=n;n<e.length&&i();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(k).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),o=new Proxy(b,{get:(e,t)=>{if(t in n)return n[t];const o=e[t];return"function"==typeof o?o.bind(e):o},set:(e,t,o)=>(n[t]=o,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>o,r.transformResponse(o)}var k;return b};return{get:(e,{headers:t,queryParams:n,token:o,keepalive:i,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Mo.get,token:o,keepalive:i,disableRetry:r}),post:(e,t,{headers:n,queryParams:o,token:i,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Mo.post,token:i,keepalive:r,disableRetry:s}),patch:(e,t,{headers:n,queryParams:o,token:i,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Mo.patch,token:i,keepalive:r,disableRetry:s}),put:(e,t,{headers:n,queryParams:o,token:i,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Mo.put,token:i,keepalive:r,disableRetry:s}),delete:(e,{headers:t,queryParams:n,token:o,keepalive:i,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Mo.delete,token:o,keepalive:i,disableRetry:r}),hooks:r,buildUrl:(e,n)=>Po({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},qo=429;function zo(e,t,n){var o;let i=Bo(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i.dct)===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function Bo(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return bo(e)}function Jo(e){const{exp:t}=Bo(e);return(new Date).getTime()/1e3>t}function Vo(e){let t=Bo(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Ho(e,t){return zo(e,t,"permissions")}function Ko(e,t){return zo(e,t,"roles")}const Yo=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Zo(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=r:(i.error=r,o.status===qo&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function Go(e){var t;return(null===(t=Bo(e))||void 0===t?void 0:t.dct)||""}const Xo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Qo=(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 "))},ei=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ti=e=>t=>e.test(t),ni=ti(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),oi=ti(/^\+[1-9]{1}[0-9]{3,14}$/),ii=Xo(ni,'"{val}" is not a valid email'),ri=Xo(oi,'"{val}" is not a valid phone number'),si=Xo((e=>e.length>=1),"Minimum length is 1");const ai=Xo((e=>"string"==typeof e),"Input is not a string"),li=Xo((e=>Array.isArray(e)),"Input is not an array"),ci=Xo((e=>"boolean"==typeof e),"Input is not a boolean"),di=Xo((e=>void 0===e),"Input is defined"),ui=Qo([ai(),di()],"Input is not a string or undefined"),hi=Qo([li(),ci()],"Input is not an array or boolean"),pi=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>ei(...e).validate(n[t]))),t(...n)),fi=e=>[ai(`"${e}" must be a string`)],gi=e=>[ui(`"${e}" must be string or undefined`)],vi=e=>[ai(`"${e}" must be a string`),si(`"${e}" must not be empty`)],mi=e=>[ai(`"${e}" must be a string`),ii()],yi=e=>[ai(`"${e}" must be a string`),ri()],wi=pi(vi("accessKey")),bi=e=>({exchange:wi(((t,n)=>Zo(e.post(ko.accessKey.exchange,{loginOptions:n},{token:t}))))}),ki=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),Ii=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Oo,Oo)});var Si,Oi;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Si||(Si={})),function(e){e.email="email"}(Oi||(Oi={}));const ji=Object.assign(Object.assign({},Si),Oi);var xi;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(xi||(xi={}));const Ci=vi("loginId"),Ri=pi(vi("token")),Ei=pi(Ci),_i=pi(vi("pendingRef")),Ai=pi(Ci,yi("phone")),Ti=pi(Ci,mi("email")),Mi=e=>{const n=n=>(o,i,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Zo(e.post(Yo(ko.enchantedLink.signIn,n),{loginId:o,URI:i,loginOptions:l,providerId:a},{token:s}))},o=n=>(o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zo(e.post(Yo(ko.enchantedLink.signUpOrIn,n),{loginId:o,URI:i,loginOptions:a,providerId:s}))},i=n=>(o,i,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Zo(e.post(Yo(ko.enchantedLink.signUp,n),{loginId:o,URI:i,user:r,loginOptions:l,providerId:a}))};return{verify:Ri((t=>Zo(e.post(ko.enchantedLink.verify,{token:t})))),signIn:Ei(n(ji.email)),signInWithPhone:Ei(n(Si.sms)),signUpOrIn:Ei(o(ji.email)),signUpOrInWithPhone:Ei(o(Si.sms)),signUp:Ei(i(ji.email)),signUpWithPhone:Ei(i(Si.sms)),waitForSession:_i(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ii(n);let s;const a=setInterval((async()=>{const n=await e.post(ko.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Zo(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ti(((t,n,o,i,r)=>Zo(e.post(ko.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:{sms:Ai(((t,n,o,i,r)=>Zo(e.post(Yo(ko.enchantedLink.update.phone,Si.sms),Object.assign({loginId:t,phone:n,URI:o},r),{token:i}))))}}}},$i=pi(vi("flowId")),Pi=pi(vi("executionId"),vi("stepId"),vi("interactionId")),Ui=pi(vi("executionId")),Di=e=>({start:$i(((t,n,o,i,r,s,a,l=!1)=>Zo(e.post(ko.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:Pi(((t,n,o,i,r,s,a=!1,l)=>Zo(e.post(ko.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a,options:l})))),event:Ui(((t,n,o)=>Zo(e.post(ko.flow.event,{executionId:t,events:n},{keepalive:o,disableRetry:!0}))))}),Ni=vi("loginId"),Li=pi(vi("token")),Wi=pi(Ni),Fi=pi(Ni,yi("phone")),qi=pi(Ni,mi("email")),zi=Object.keys(ji).filter((e=>e!==Si.voice&&e!==Si.im)),Bi=e=>({verify:Li((t=>Zo(e.post(ko.magicLink.verify,{token:t})))),signIn:zi.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Wi(((n,i,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Zo(e.post(Yo(ko.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:zi.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Wi(((n,i,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Zo(e.post(Yo(ko.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:zi.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Wi(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zo(e.post(Yo(ko.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:qi(((t,n,o,i,r)=>Zo(e.post(ko.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Si).filter((e=>e!==Si.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Fi(((t,o,i,r,s)=>Zo(e.post(Yo(ko.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var Ji;!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"}(Ji||(Ji={}));const Vi=pi(vi("code")),Hi=e=>({start:Object.assign(((t,n,o,i,r)=>Zo(e.post(ko.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(Ji).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>Zo(e.post(ko.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:Vi((t=>Zo(e.post(ko.oauth.exchange,{code:t})))),startNative:(t,n,o)=>Zo(e.post(ko.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>Zo(e.post(ko.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>Zo(e.get(ko.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>Zo(e.post(ko.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>Zo(e.post(ko.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Ki=vi("appId"),Yi=pi(Ki),Zi=e=>({connect:Yi(((t,n,o)=>{const i=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Zo(e.post(ko.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),Gi=vi("loginId"),Xi=pi(Gi,vi("code")),Qi=pi(Gi),er=pi(Gi,yi("phone")),tr=pi(Gi,mi("email")),nr=e=>({verify:Object.keys(ji).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xi(((t,o)=>Zo(e.post(Yo(ko.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(ji).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Qi(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return Zo(e.post(Yo(ko.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(ji).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Qi(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zo(e.post(Yo(ko.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(ji).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Qi(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Zo(e.post(Yo(ko.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:tr(((t,n,o,i)=>Zo(e.post(ko.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Si).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:er(((t,o,i,r)=>Zo(e.post(Yo(ko.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),or=pi(vi("tenant")),ir=pi(vi("code")),rr=e=>({start:or(((t,n,o,i,r,s,a,l)=>Zo(e.post(ko.sso.start,o||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},i&&{token:i}))))),exchange:ir((t=>Zo(e.post(ko.sso.exchange,{code:t}))))}),sr=vi("loginId"),ar=pi(sr,vi("code")),lr=pi(sr),cr=pi(sr),dr=e=>({signUp:lr(((t,n)=>Zo(e.post(ko.totp.signUp,{loginId:t,user:n})))),verify:ar(((t,n,o,i)=>Zo(e.post(ko.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:cr(((t,n)=>Zo(e.post(ko.totp.update,{loginId:t},{token:n}))))}),ur=vi("loginId"),hr=vi("newPassword"),pr=pi(ur,vi("password")),fr=pi(ur),gr=pi(ur,hr),vr=pi(ur,vi("oldPassword"),hr),mr=e=>({signUp:pr(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zo(e.post(ko.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:pr(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Zo(e.post(ko.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:fr(((t,n,o)=>Zo(e.post(ko.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:gr(((t,n,o)=>Zo(e.post(ko.password.update,{loginId:t,newPassword:n},{token:o})))),replace:vr(((t,n,o)=>Zo(e.post(ko.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>Zo(e.get(ko.password.policy))}),yr=fi("loginId"),wr=vi("loginId"),br=fi("origin"),kr=pi(wr,br,vi("name")),Ir=pi(wr,br),Sr=pi(yr,br),Or=pi(wr,br,gi("token")),jr=pi(vi("transactionId"),vi("response")),xr=e=>({signUp:{start:kr(((t,n,o,i,r)=>Zo(e.post(ko.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:r,passkeyOptions:i})))),finish:jr(((t,n)=>Zo(e.post(ko.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Sr(((t,n,o,i,r)=>Zo(e.post(ko.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:jr(((t,n)=>Zo(e.post(ko.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ir(((t,n,o,i)=>Zo(e.post(ko.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:o}))))},update:{start:Or(((t,n,o,i,r)=>Zo(e.post(ko.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i,mfa:r},{token:o})))),finish:jr(((t,n)=>Zo(e.post(ko.webauthn.update.finish,{transactionId:t,response:n}))))}}),Cr=fi("loginId"),Rr=pi(Cr),Er=pi(vi("pendingRef")),_r=e=>({signUpOrIn:Rr(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return Zo(e.post(ko.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:Rr(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return Zo(e.post(ko.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:Rr(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return Zo(e.post(ko.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:Er(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ii(n);let s;const a=setInterval((async()=>{const n=await e.post(ko.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Zo(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ar=pi(vi("token")),Tr=pi(gi("token"));var Mr,$r=pi([(Mr=vi("projectId"),Xo(((e,t)=>n=>ei(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",Mr))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=Fo({baseUrl:o,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:i,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:bi(l),otp:nr(l),magicLink:Bi(l),enchantedLink:Mi(l),oauth:Hi(l),outbound:Zi(l),sso:rr(l),saml:rr(l),totp:dr(l),notp:_r(l),webauthn:xr(l),password:mr(l),flow:Di(l),refresh:Tr(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?ko.tryRefresh:ko.refresh;return Zo(l.post(r,i,{token:e,queryParams:t}))})),selectTenant:pi([ai("tenantId")],[ui('"token" must be string or undefined')])(((e,t)=>Zo(l.post(ko.selectTenant,{tenant:e},{token:t})))),logout:Tr((e=>Zo(l.post(ko.logout,{},{token:e})))),logoutAll:Tr((e=>Zo(l.post(ko.logoutAll,{},{token:e})))),me:Tr((e=>Zo(l.get(ko.me,{token:e})))),myTenants:pi([hi('"tenants" must a string array or a boolean')],[ui('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Zo(l.post(ko.myTenants,n,{token:t}))})),history:Tr((e=>Zo(l.get(ko.history,{token:e})))),isJwtExpired:Ar(Jo),getTenants:Ar(Vo),getJwtPermissions:Ar(Ho),getJwtRoles:Ar(Ko),getCurrentTenant:Ar(Go),httpClient:l};var l})),Pr=Object.assign($r,{DeliveryMethods:ji});
6
+ /*! js-cookie v3.0.8 | MIT */function Ur(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)"__proto__"!==o&&(e[o]=n[o])}return e}var Dr=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=Ur({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in o||(o[a]=t.read(s,a)),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",Ur({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Ur({},this.attributes,t))},withConverter:function(t){return e(Ur({},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 Nr={default:"endpoint"},Lr="Blocked by CSP",Wr="The endpoint parameter is not a valid URL",Fr="Failed to load the JS script of the agent",qr="9319";function zr(e,t){var n,o,i,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Lr||s===Wr)n.exclude(),r=0;else if(s===qr)n.exclude();else if(s===Fr){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+o()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(i)}))}))};return u(c).then((function(e){return[e,a]}))}var Br="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Jr=Br;function Vr(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:Br,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return zr(e,Hr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===qr?new Error(Fr):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function Hr(e){return function(e,t,n){var o,i=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,a())};i.addEventListener(r,s);var a=function(){return i.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),o)return n(o);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(Wr);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(Fr))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(Lr)})).then(Kr)}function Kr(){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(qr);return n}const Yr="3.2.0",Zr="undefined"!=typeof window,Gr=Math.pow(2,31)-1,Xr=`https://descopecdn.com/npm/oidc-client-ts@${Yr}/dist/browser/oidc-client-ts.min.js`,Qr=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Yr}/dist/browser/oidc-client-ts.min.js`,es=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let ts;const ns=e=>{try{return bo(e).exp}catch(e){return null}},os=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ns(n)},is=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?ns(o):void 0)},rs=e=>{const{access_token:n,id_token:o,refresh_token:i,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:o,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||is(e),cookieExpiration:e.cookieExpiration||os(e)},s)},ss=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},as=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return rs(n)},ls=()=>Zr&&!!window.descopeBridge,cs=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return es.includes(n)},ds=void 0!==ts||Zr&&void 0!==window.localStorage,us=(e,t)=>{var n,o;return null===(o=null===(n=ts||Zr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},hs=e=>{var t,n;return null===(n=null===(t=ts||Zr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},ps=e=>{var t,n;return null===(n=null===(t=ts||Zr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},fs=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==ts?void 0:ts.key)||void 0===t?void 0:t.call(ts,e))&&void 0!==n?n:Zr&&(null===(i=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===i?void 0:i.call(o,e)))&&void 0!==r?r:null},gs=e=>{var t,n;return Zr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},vs=e=>{var t,n;try{Zr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},ms=(...e)=>{console.debug(...e)},ys=(...e)=>{console.warn(...e)},ws=(e,t)=>{let n;var o;return t>0?(n=1e3*t,ms(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>Gr&&(ms(`Timeout is too large (${n}ms), setting it to ${Gr}ms`),n=Gr),n},bs="DS",ks="DSR",Is="DSI",Ss="DSRCN";function Os(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=js(o);Dr.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}function js(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const xs=e=>(null==e?void 0:e.cookieName)||bs,Cs=e=>(null==e?void 0:e.cookieName)||ks;function Rs(e="",t){return Dr.get(Cs(t))||hs(`${e}${ks}`)||""}function Es(e="",t){return Dr.get(xs(t))||hs(`${e}${bs}`)||""}function _s(e=""){return hs(`${e}${Is}`)||""}function As(e="",t,n,o){ps(`${e}${ks}`),ps(`${e}${bs}`),ps(`${e}${Is}`),ps(`${e}${Ss}`);const i=xs(t);Dr.remove(i,null==o?void 0:o.session);const r=Cs(n);Dr.remove(r,null==o?void 0:o.refresh)}const Ts=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||Rs(e,t)});if(!n){const t=function(e=""){return hs(`${e}${Ss}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return hs(`${e}DTD`)||""}(e);r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return hs(`${e}DKD`)||""}(e);return s&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-known-device-token":s})),i},Ms=Zr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",$s="vsid",Ps="vrid",Us=(e=!1)=>{const t=hs("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Ds=async(e,t=Ms)=>{try{if(Us())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Vr({apiKey:e,endpoint:[o.toString(),Nr],scriptUrlPattern:[r,Jr]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[$s]:e,[Ps]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};us("fp",JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Ns=e=>{const t=Us(!0);return t&&e.body&&(e.body.fpData=t),e},Ls="descopeFlowNonce",Ws="X-Descope-Flow-Nonce",Fs="/v1/flow/start",qs="/v1/flow/next",zs=(e,t=Ls)=>`${t}${e}`,Bs=(e,t=Ls)=>{try{const n=zs(e,t),o=hs(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(Js(e,t),null):{value:i.value,seq:i.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},Js=(e,t=Ls)=>{try{const n=zs(e,t);ps(n)}catch(e){console.error("Error removing flow nonce:",e)}},Vs=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Hs=e=>{var t;return e.path===qs&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Vs(e.body.executionId):null},Ks="dls_last_user_login_id",Ys="dls_last_user_display_name",Zs=e=>us(Ks,e),Gs=()=>hs(Ks),Xs=()=>hs(Ys),Qs=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=Gs(),r=Xs();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},ea="DSLI",ta=e=>async(...t)=>{const n=await e(...t);return vs(ea),n};function na(){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 oa(e,t){const n=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=da(n.publicKey.challenge),n.publicKey.user.id=da(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=da(e.id)})),n}(e);t&&(n.signal=t.signal);try{return o=await navigator.credentials.create(n),JSON.stringify({id:o.id,rawId:ua(o.rawId),type:o.type,response:{attestationObject:ua(o.response.attestationObject),clientDataJSON:ua(o.response.clientDataJSON)}})}catch(e){throw await sa(e,n,!0)}var o}async function ia(e,t){const n=la(e);t&&(n.signal=t.signal);try{return ca(await navigator.credentials.get(n))}catch(e){throw await sa(e,n,!1)}}async function ra(e,t){const n=la(e);n.signal=t.signal,n.mediation="conditional";try{return ca(await navigator.credentials.get(n))}catch(e){throw await sa(e,n,!1)}}async function sa(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var o,i;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await aa())return"webauthn_unsupported";const s="platform"===(null===(i=null===(o=null==t?void 0:t.publicKey)||void 0===o?void 0:o.authenticatorSelection)||void 0===i?void 0:i.authenticatorAttachment);return n&&s&&!await aa(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function aa(e=!1){var t,n;if(!Zr)return Promise.resolve(!1);if(ls()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function la(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=da(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=da(e.id)})),n}function ca(e){return JSON.stringify({id:e.id,rawId:ua(e.rawId),type:e.type,response:{authenticatorData:ua(e.response.authenticatorData),clientDataJSON:ua(e.response.clientDataJSON),signature:ua(e.response.signature),userHandle:e.response.userHandle?ua(e.response.userHandle):void 0}})}function da(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ua(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ha,pa=(ha=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await oa(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await ia(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await oa(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await ia(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await oa(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:oa,get:ia,isSupported:aa,conditional:ra}}),(...e)=>{const t=ha(...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 fa="/fedcm/config";async function ga(e,t){var n;try{await va(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function va(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var ma=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await aa(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let ya;const wa=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{wa(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),ba=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{ya||(ya=(async()=>{try{return require("oidc-client-ts")}catch(e){return wa([Xr,Qr],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await ya;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new i({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}})(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),us(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var i;const{client:r}=await o(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=hs(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await i.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||_s(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return ps(i),t||window.location.replace(s),r}}},ka=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,ts=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Zr?(o&&i&&Ds(o).catch((()=>null)),e(ss(r,{beforeRequest:Ns}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.54.0"},t.baseHeaders)}))),(e=>t=>{const n=na(),o=na(),i=na(),r=na(),s=e(ss(t,{afterRequest:async(e,t)=>{if(cs(e,t))ms("Session invalidated, notifying subscribers with empty values"),o.pub(null),i.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await as(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&i.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await as(t);s&&o.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=ki(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return o.pub(null),i.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:o.sub,onUserChange:i.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var o;const{enableFlowNonce:i=!0,nonceStoragePrefix:r=Ls}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(s);((e=Ls)=>{try{if(!ds)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==ts?void 0:ts.length)&&void 0!==t?t:Zr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=fs(i);if(t&&t.startsWith(e)){const n=hs(t);if(n)try{JSON.parse(n).expiry<Date.now()&&ps(t)}catch(e){ps(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=e(ss(s,{afterRequest:async(e,t)=>{var n;if(e.path!==Fs&&e.path!==qs)return;const{nonce:o,seq:i,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Ws),o=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const o=Number(n);return Number.isSafeInteger(o)?o:void 0})(n);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=Hs(e)),{nonce:n,seq:o,executionId:Vs(i)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!o||!s)return;const a=e.path===Fs,l=null===(n=Bs(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==i&&void 0!==l&&i<=l||((e,t,n,o=Ls,i)=>{try{const r=zs(e,o),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:i};us(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,o,a,r,null!=i?i:a?void 0:l)},beforeRequest:e=>{if(e.path===qs){const t=Hs(e);if(t){const n=((e,t=Ls)=>{var n,o;return null!==(o=null===(n=Bs(e,t))||void 0===n?void 0:n.value)&&void 0!==o?o:null})(t,r);n&&(e.headers=e.headers||{},e.headers[Ws]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let i;e=new Promise((e=>{i=e})),await o;try{return await t(...n)}finally{i()}}}return a}),(e=>t=>{const n=e(ss(t,{afterRequest:async(e,t)=>{if(cs(e,t))return void vs(ea);const n=await as(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,o;try{Zr&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o||o.call(n,e,t))}catch(e){}})(ea,String(n.sessionExpiration))}}));return ki(n,["logout","logoutAll","oidc.logout"],ta)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);const r=!!o,s="object"==typeof o&&(null==o?void 0:o.customActivityTracking);if(!r||ls())return Object.assign(e(i),{markUserActive:()=>{ys("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(ms("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Zr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(ms("Expiration time passed, refreshing session"),f.refresh(Rs()||d))}));const f=e(ss(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i,nextRefreshSeconds:r}=await as(t);if(cs(e,t))ms("Session invalidated, canceling all timers"),a();else if(n||i){if(c=((e,t)=>{if(t)return new Date(1e3*t);ms("Could not extract expiration time from session token, trying to decode the token");try{const t=bo(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!c)return void ms("Could not extract expiration time from session token");d=o,h=r>0;const e=ws(c,r);if(a(),e<=2e4)return void ms("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});ms(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Zr&&"hidden"===document.visibilityState)ms("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return ms("Skipping refresh due to timer - user is idle"),void(p=!0);ms("Refreshing session due to timer"),f.refresh(Rs()||o)}}),e)}}}));return Object.assign(ki(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return ms("Clearing all timers"),a(),n})),{markUserActive:u?()=>{ms("markUserActive() called"),h||ms("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(ms("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Rs()||d))}:()=>{ys("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:Gs,getLastUserDisplayName:Xs});const s=e(ss(r,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:i}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=rs((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;r?(Zs(r),(e=>{us(Ys,e)})(s)):(null==i?void 0:i.loginId)&&Zs(i.loginId)}}));let a=ki(s,["flow.start"],Qs);return a=ki(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(ps(Ks),ps(Ys)),o})(i)),Object.assign(a,{getLastUserLoginId:Gs,getLastUserDisplayName:Xs})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!Zr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(ss(Object.assign({refreshCookieName:a},l),{beforeRequest:Ts(s,r,a),afterRequest:async(e,t)=>{if(cs(e,t))ms("Session invalidated, clearing persisted tokens"),As(s,i,r,c);else{const e=await as(t);e.cookieName?us(`${s||""}${Ss}`,e.cookieName):e.refreshJwt&&ps(`${s||""}${Ss}`);const n=((e={},t=!1,n="",o=!1)=>{var i,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d,knownDeviceJwt:u}=e;let h;if(c)if(o){ps(`${n}${ks}`);const t=o.sameSite||"Strict",s=null===(i=o.secure)||void 0===i||i,a=null!==(r=o.domain)&&void 0!==r?r:e.cookieDomain,l=Cs(o);s&&"https:"!==window.location.protocol&&ys("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Os(l,c,d);const u=js(a);h=Object.assign(Object.assign({},h),{refresh:{path:d.cookiePath,domain:u?a:void 0}})}else{const e=Cs(o);Dr.remove(e),us(`${n}${ks}`,c)}if(l)if(t){const n=t.sameSite||"Strict",o=null===(s=t.secure)||void 0===s||s,i=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=xs(t);o&&"https:"!==window.location.protocol&&ys("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});Os(r,l,c);const d=js(i);h=Object.assign(Object.assign({},h),{session:{path:c.cookiePath,domain:d?i:void 0}})}else us(`${n}${bs}`,l);return e.idToken&&us(`${n}${Is}`,e.idToken),d&&us(`${n}DTD`,d),u&&us(`${n}DKD`,u),h})(e,i,s,r);n&&(c=n)}}})),u=ki(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return As(e,t,n,null==o?void 0:o()),s})(s,i,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Rs(s,r),getSessionToken:()=>Es(s,i),getIdToken:()=>_s(s)})}))((e=>{const t=Pr(e),n=ba(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(ls())return ms(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(i&&Zr&&void 0!==window.localStorage&&!gs(ea)&&!hs(Ks)&&!gs("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Es(),a=Rs();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){ms("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},l,i)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:ma(t),webauthn:pa(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){ga(o,e)},requestAuthentication(e){ga(o,e)}},async oneTap(e,t,n,i,r){await va(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:i,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(i+fa),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>Zr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+fa);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var o,i})),Ia={search:"/v1/mgmt/role/search",deleteBatch:"/v1/mgmt/role/delete/batch",create:"/v1/mgmt/role/create",update:"/v1/mgmt/role/update"},Sa={permissions:"/v1/mgmt/permission/all"},Oa=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)})),ja=(e,t)=>n(void 0,[e,t],void 0,(function*({text:e,sort:t},n){return new Promise((o=>{const i=[];for(let e=1;e<10;e+=1)i.push({name:`Role ${e}`,description:`Role description ${e}`,permissionNames:[`Permission ${e}`],createdTime:new Date,tenantId:n});t.forEach((e=>{i.sort(((t,n)=>{var o,i;return e.desc?null===(i=n[e.field])||void 0===i?void 0:i.localeCompare(t[e.field]):null===(o=t[e.field])||void 0===o?void 0:o.localeCompare(n[e.field])}))})),o(i.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()))))}))})),xa=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,description:t,permissionNames:n},o){return new Promise((i=>{i({name:e,description:t,permissionNames:n,createdTime:new Date,tenantId:o})}))})),Ca=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,newName:t,description:n,permissionNames:o},i){return new Promise((r=>{r({name:t,description:n,permissionNames:o,createdTime:new Date,oldName:e,tenantId:i})}))})),Ra=()=>n(void 0,void 0,void 0,(function*(){})),Ea=()=>new Promise((e=>{const t=[];for(let e=1;e<5;e+=1)t.push({name:`Permission ${e}`});e({permissions:t})})),_a=({httpClient:e,tenant:t,mock:o})=>({search:(...i)=>n(void 0,[...i],void 0,(function*({page:n,limit:i=1e4,text:r,sort:s}={}){if(o)return ja({page:n,limit:i,text:r,sort:s},t);const a=yield e.post(Ia.search,{limit:i,page:n,text:r,sort:s},{queryParams:{tenant:t}});yield Oa(a);return(yield a.json()).roles})),deleteBatch:i=>n(void 0,void 0,void 0,(function*(){if(o)return Ra();const n=yield e.post(Ia.deleteBatch,{roleNames:i},{queryParams:{tenant:t}});return yield Oa(n),n.json()})),create:i=>n(void 0,[i],void 0,(function*({name:n,description:i,permissionNames:r}){if(o)return xa({name:n,description:i,permissionNames:r},t);const s=yield e.post(Ia.create,{name:n,description:i,permissionNames:r,tenantId:t},{queryParams:{tenant:t}});yield Oa(s);return yield s.json()})),update:i=>n(void 0,[i],void 0,(function*({name:n,newName:i,description:r,permissionNames:s}){if(o)return Ca({name:n,newName:i,description:r,permissionNames:s},t);const a=yield e.post(Ia.update,{name:n,newName:i,description:r,permissionNames:s,tenantId:t},{queryParams:{tenant:t}});yield Oa(a);const l=yield a.json();return l.oldName=n,l}))}),Aa=({httpClient:e,tenant:t,mock:o})=>({getTenantPermissions:()=>n(void 0,void 0,void 0,(function*(){if(o)return Ea();const n=yield e.get(Sa.permissions,{queryParams:{tenant:t}});return yield Oa(n),n.json()}))}),Ta=h((e=>{var t,s,a,l;const c=r(A,E,I,T,Mn,_({tenant:_.missingAttrValidator}))(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get 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","tenant"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,n,o)=>{const i=ka(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"role-management-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.10.7"}}));return{role:_a({httpClient:i.httpClient,tenant:t,mock:n}),tenant:Aa({httpClient:i.httpClient,tenant:t,mock:n}),httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},l})),Ma=h((e=>{const t=r(Cn({name:"widget",initialState:mo,reducers:{setSelectedRolesIds:(e,{payload:t})=>{e.selectedRolesIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{to.reducer(e),ao.reducer(e),fo.reducer(e),io.reducer(e),uo.reducer(e),vo.reducer(e)},asyncActions:{searchRoles:uo.action,createRole:to.action,duplicateRole:ao.action,updateRole:fo.action,deleteRoles:io.action,getTenantPermissions:vo.action}}),R,I,Ta)(e);return class extends t{constructor(...e){super(...e),this.state=mo,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),$a=h((e=>{var t,i,a;return a=class extends(r(I,R,V,X,Tn("role-management-widget"),Ma)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([o(this,t,"m",i).call(this),this.actions.searchRoles(),this.actions.getTenantPermissions()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),Pa=h((e=>{var t,a,l,c,d,u,h;return h=class extends(r(Ma,me,Rn,I,$a)(e)){constructor(){super(...arguments),t.add(this),a.set(this,void 0),l.set(this,"create"),c.set(this,null),u.set(this,(()=>n(this,void 0,void 0,(function*(){var e;yield o(this,a,"f").setData(null===(e=zn(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}openRoleModal(e="create",t){i(this,l,e,"f"),i(this,c,null!=t?t:null,"f"),this.roleFormModal.open()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",d).call(this)}))}},a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,t=new WeakSet,d=function(){return n(this,void 0,void 0,(function*(){this.roleFormModal=this.createModal(),this.roleFormModal.setContent(s(yield this.fetchWidgetPage("create-role-modal.html")));new oe((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}));new oe((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>n(this,void 0,void 0,(function*(){if(this.validateForm(this.roleFormModal.ele)){const e=this.getFormData(this.roleFormModal.ele);"duplicate"===o(this,l,"f")?this.actions.duplicateRole(Object.assign({},e)):this.actions.createRole(Object.assign({},e)),this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}})))),i(this,a,new pe((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),o(this,u,"f").call(this),this.roleFormModal.beforeOpen=()=>n(this,void 0,void 0,(function*(){yield o(this,u,"f").call(this),o(this,c,"f")&&(this.setFormData(this.roleFormModal.ele,o(this,c,"f")),i(this,c,null,"f"))}))}))},h})),Ua=h((e=>{var t,i,s;return s=class extends(r(I,Pa,$a)(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",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.createButton=new oe(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-role"]'),{logger:this.logger}),this.createButton.onClick((()=>this.openRoleModal()))},s})),Da=h((e=>{var t,i,a;return a=class extends(r(Ma,me,I,$a)(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),yield o(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){var e;this.deleteRolesModal=this.createModal(),this.deleteRolesModal.setContent(s(yield this.fetchWidgetPage("delete-roles-modal.html")));const t=new oe((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteRolesModal.close()));const n=new oe((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Jn(this.state);this.actions.deleteRoles(null==e?void 0:e.map((e=>e.name))),this.deleteRolesModal.close()}));const o=new ge(null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteRolesModal.beforeOpen=()=>{const e=Yn(this.state);o.text=`Delete ${e}?`}}))},a})),Na=h((e=>{var t,i,s,a;return a=class extends(r(I,$a,Ma,Da)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}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",i).call(this),this.subscribe(o(this,s,"f").bind(this),Vn)}))}},s=new WeakMap,t=new WeakSet,i=function(){var e;this.deleteButton=new oe(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-roles"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteRolesModal.open()}))},a})),La=h((e=>{var t,i,s,a;return a=class extends(r(I,$a,Ma,Pa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.duplicateButton.enable():this.duplicateButton.disable()})))}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",i).call(this),this.subscribe(o(this,s,"f").bind(this),Hn)}))}},s=new WeakMap,t=new WeakSet,i=function(){var e;this.duplicateButton=new oe(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="duplicate-role"]'),{logger:this.logger}),this.duplicateButton.disable(),this.duplicateButton.onClick((()=>{var e,t,n;const o=null===(e=Jn(this.state))||void 0===e?void 0:e[0];o&&this.openRoleModal("duplicate",{name:`${o.name} Copy`,description:null!==(t=o.description)&&void 0!==t?t:"",permissionNames:null!==(n=o.permissionNames)&&void 0!==n?n:[]})}))},a})),Wa=h((e=>{var a,l,c,d,u,h,p,f;return f=class extends(r(Ma,me,I,Rn,$a)(e)){constructor(){super(...arguments),a.add(this),l.set(this,void 0),u.set(this,(()=>n(this,void 0,void 0,(function*(){var e;yield o(this,l,"f").setData(null===(e=zn(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),h.set(this,(()=>{var e;const t=null===(e=Jn(this.state))||void 0===e?void 0:e[0],n={name:null==t?void 0:t.name,description:null==t?void 0:t.description,permissionNames:null==t?void 0:t.permissionNames};this.setFormData(this.editRoleModal.ele,n)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),yield o(this,a,"m",p).call(this)}))}},l=new WeakMap,u=new WeakMap,h=new WeakMap,a=new WeakSet,c=function(){new oe((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editRoleModal.close()))},d=function(){new oe((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{var e;if(this.validateForm(this.editRoleModal.ele)){const n=this.getFormData(this.editRoleModal.ele),{name:o}=n,i=t(n,["name"]),r=null===(e=Jn(this.state))||void 0===e?void 0:e[0];this.actions.updateRole(Object.assign({newName:o,name:r.name},i)),this.editRoleModal.close(),this.resetFormData(this.editRoleModal.ele)}}))},p=function(){return n(this,void 0,void 0,(function*(){this.editRoleModal=this.createModal(),this.editRoleModal.setContent(s(yield this.fetchWidgetPage("edit-role-modal.html"))),o(this,a,"m",c).call(this),o(this,a,"m",d).call(this),i(this,l,new pe((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),this.editRoleModal.beforeOpen=()=>n(this,void 0,void 0,(function*(){yield o(this,u,"f").call(this),o(this,h,"f").call(this)}))}))},f})),Fa=h((e=>{var t,i,s,a;return a=class extends(r(I,$a,Ma,Wa,Rn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.editButton.enable():this.editButton.disable()})))}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",i).call(this),this.subscribe(o(this,s,"f").bind(this),Kn)}))}},s=new WeakMap,t=new WeakSet,i=function(){var e;this.editButton=new oe(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-role"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editRoleModal.open()}))},a})),qa=h((e=>{var t,i,s,a;return a=class extends(r(I,$a,Ma)(e)){constructor(){super(...arguments),t.add(this),i.set(this,d((()=>{this.actions.searchRoles({text:this.searchInput.value})})))}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",s).call(this)}))}},i=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new ve(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(o(this,i,"f"))},a}));const za={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Ba=h((e=>{var t,i,s,a,c;return c=class extends(r(I,Ma,we,R)(e)){constructor(){super(...arguments),t.add(this),a.set(this,l((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const r=o(this,t,"m",s).call(this,e);r.setContent(o(this,t,"m",i).call(this,{type:e,msg:n})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}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),this.subscribe(o(this,a,"f").bind(this),qn)}))}},a=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const n=za[e],o=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${o.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},c})),Ja=h((e=>{var t,i,s,a,c;return c=class extends(r(Ma,I,$a)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{this.rolesTable.data=e}))),a.set(this,d(((e,t)=>{const n=[],{value:o}=t;if(o){const t=e.path;n.push({field:t,desc:"desc"===o})}this.actions.searchRoles({sort:n})})))}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",i).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{o(this,a,"f").call(this,e.target,e.detail)}))})),o(this,s,"f").call(this,Bn(this.state)),this.subscribe(o(this,s,"f").bind(this),Bn)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,i=function(){var e;this.rolesTable=new se(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-table"]'),{logger:this.logger}),this.rolesTable.onSelectedItemsChange((e=>{this.actions.setSelectedRolesIds(e.detail.value.map((({name:e})=>e)))}))},c})),Va=h((e=>class extends(r(N,je,Ja,Ua,Na,La,Fa,qa,Ba,Wn)(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)}))}})),Ha=r((e=>class extends(Va(e)){}))(HTMLElement);customElements.define("descope-role-management-widget",Ha);const Ka=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Ya,Za,Ga,Xa,Qa,el,tl,nl,ol,il;const rl=document.createElement("template");rl.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const sl=r(Y)(HTMLElement);class al extends sl{constructor(){var e;super(),Ya.add(this),Za.set(this,new y({messages:[]})),Ga.set(this,void 0),Xa.set(this,void 0),Qa.set(this,void 0),el.set(this,{resize:o(this,Ya,"m",il).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(rl.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,Ga,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Ga,"f").style.top="32px",o(this,Ga,"f").style.left=window.innerWidth-300-32+"px",i(this,Xa,o(this,Ga,"f").querySelector(".content"),"f"),i(this,Qa,o(this,Ga,"f").querySelector(".header"),"f")}updateData(e){o(this,Za,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Ka(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(o(this,Ga,"f"),o(this,Qa,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,el,"f").resize),(e=o(this,Ga,"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,Ga,"f").onresize=o(this,Ya,"m",ol).bind(this),o(this,Za,"f").subscribe(o(this,Ya,"m",tl).bind(this))}disconnectedCallback(){o(this,Za,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,el,"f").resize)}}Za=new WeakMap,Ga=new WeakMap,Xa=new WeakMap,Qa=new WeakMap,el=new WeakMap,Ya=new WeakSet,tl=function(e){o(this,Ya,"m",nl).call(this,e),o(this,Ya,"m",ol).call(this)},nl=function(e){o(this,Xa,"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 ${w(e.title)}\n </div>\n <div class="msg_desc">\n ${w(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},ol=function(){o(this,Xa,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},il=function(){const[e,t]=Ka(o(this,Ga,"f"),Number.parseInt(o(this,Ga,"f").style.left,10),Number.parseInt(o(this,Ga,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Ga,"f").style.top=`${t}px`,o(this,Ga,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",al);var ll=Object.freeze({__proto__:null,default:al});return Ha}();
7
7
  //# sourceMappingURL=index.js.map