@descope/access-key-management-widget 0.10.2 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
- * @descope/access-key-management-widget v0.10.2
3
+ * @descope/access-key-management-widget v0.10.4
4
4
  */
5
- this["descope-access-key-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{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function 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])),c=e=>{let t,n;return(...o)=>(t&&a(t,o)||(t=o,n=e(...o)),n)},l=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:(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",x="https://static2.descope.com/pages",O=I&&localStorage.getItem("base.content.url")||"",j=(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})),A=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,A)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,o(this,n,"m",i).bind(this))}async init(){var e;c.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=j;const R=h((e=>{const t=r(E({"project-id":j}))(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")||""}})),_="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,c,l,d;const u=r(k,R,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",c).call(this,e),l=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}. ${_}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${_}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(e){const r=O||this.baseStaticUrl;if(r)return o(this,t,"m",l).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 c=[];if(o(this,s,"f"))c.push(o(this,t,"m",l).call(this,e,o(this,s,"f"))),o(this,s,"f")===S&&c.push(o(this,t,"m",l).call(this,e,x));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&c.push(o(this,t,"m",l).call(this,e,n)),o(this,a,"f").has(S)||c.push(o(this,t,"m",l).call(this,e,S)),c.push(o(this,t,"m",l).call(this,e,x))}return 1===c.length?c[0]:c},l=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":j}))(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,c;const l=r($,P,C)(e);return c=class extends l{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")},c})),U=h((e=>{var t,n,s,a,c,l,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",c).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",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),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 yc})),document.body.appendChild(o(this,n,"f"))},c=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},l=function(e,t){var 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()}`},N=(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)})),K=(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 K(s,r),o}catch(e){t(o,!0)}else try{return await N(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 c={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${W(a)}`};return i&&(c.integrity=i),[...e,c]}),[]))([...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}"`)}))}}})),F="base.ui.components.url",z=I&&localStorage.getItem(F),B=h((e=>{var t,n,s,a,c,l,d;const u=r(k,D,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",l).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",c).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},c=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},l=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await o(this,t,"m",n).call(this),i=z?void 0:await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[z],i),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),J=h((e=>{var t,n,i;const s=r(C,A)(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 V{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const H=h((e=>{const t=r(J)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new V(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(H)(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,ce,le;ee=new WeakMap;let de=class extends te{constructor(...e){super(...e),se.add(this),ae.set(this,void 0),ce.set(this,void 0),this.nodeName="descope-modal",o(this,se,"m",le).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",le).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,ce,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};ae=new WeakMap,ce=new WeakMap,se=new WeakSet,le=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 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,B)(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)}}})())}createModal(e){const n=((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(n),new(o(this,t,"f"))(n,{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})),me="descope-notification",ye=h((e=>{var t,n;const i=r(C,G,B)(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',xe=h((e=>{var t,n,s,a,c,l,d,u,h,p,f,g,v,m,y,w,b,k,I,S,x,O;const j=r(E({theme:Se}),Ie,$,C,B,D,G,A,H)(e);return O=class extends j{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),l.set(this,void 0),d.set(this,void 0),I.set(this,(()=>{o(this,t,"m",S).call(this),o(this,x,"f").call(this,"os"===this.getAttribute("theme"))})),x.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,l,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,l=new WeakMap,d=new WeakMap,I=new WeakMap,x=new WeakMap,t=new WeakSet,c=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,i,r,s,a;const c=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,l=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 c||l?`[data-theme="${t}"]{${we({colors:{primary:c,secondary:l}},(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(F))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(F),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,l,"f")||(i(this,l,o(this,t,"m",u).call(this),"f"),o(this,l,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,l,"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 c=await o(this,t,"a",g);if(!c)return void(null===(n=o(this,s,"f"))||void 0===n||n.replaceSync(""));const l=((null===(r=c.light)||void 0===r?void 0:r.globals)||"")+((null===(a=c.dark)||void 0===a?void 0:a.globals)||"");o(this,s,"f")?o(this,s,"f").replaceSync(l):i(this,s,this.injectStyle(l),"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",c).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 c=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==c?void 0:c.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==c?void 0:c.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)},O}));var Oe=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),je=()=>Math.random().toString(36).substring(7).split("").join("."),Ce={INIT:`@@redux/INIT${je()}`,REPLACE:`@@redux/REPLACE${je()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${je()}`};function Ae(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 Re(e){let t=typeof e;return t=Ee(e),t}function Te(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Re(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: '${Re(n)}'`);return n(Te)(e,t)}let o=e,i=t,r=new Map,s=r,a=0,c=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Re(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),r=null}}}function h(e){if(!Ae(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Re(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: '${Re(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,i=o(i,e)}finally{c=!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: '${Re(e)}`);o=e,h({type:Ce.REPLACE})},[Oe]: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: '${Re(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[Oe](){return this}}}}}function _e(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]&&_e(`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(!Ae(e))return`The ${r} has unexpected type of "${Re(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&&_e(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],c=n[r],l=e[r],d=c(l,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!==l}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 Ae(e)&&"type"in e&&"string"==typeof e.type}var De=Symbol.for("immer-nothing"),Ue=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 Ne(e,...t){{const n=We[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Ke=Object.getPrototypeOf;function qe(e){return!!e&&!!e[Le]}function Fe(e){return!!e&&(Be(e)||Array.isArray(e)||!!e[Ue]||!!e.constructor?.[Ue]||Ze(e)||Ge(e))}var ze=Object.prototype.constructor.toString();function Be(e){if(!e||"object"!=typeof e)return!1;const t=Ke(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)===ze}function Je(e,t){0===Ve(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Ve(e){const t=e[Le];return t?t.type_:Array.isArray(e)?1:Ze(e)?2:Ge(e)?3:0}function He(e,t){return 2===Ve(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ye(e,t,n){const o=Ve(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&&Be(e)){if(!Ke(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(Ke(e),n)}function et(e,t=!1){return nt(e)||qe(e)||!Fe(e)||(Ve(e)>1&&(e.set=e.add=e.clear=e.delete=tt),Object.freeze(e),t&&Je(e,((e,t)=>et(t,!0)))),e}function tt(){Ne(2)}function nt(e){return Object.isFrozen(e)}var ot,it={};function rt(e){const t=it[e];return t||Ne(0,e),t}function st(){return ot}function at(e,t){t&&(rt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ct(e){lt(e),e.drafts_.forEach(ut),e.drafts_=null}function lt(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[Le];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[Le].modified_&&(ct(t),Ne(4)),Fe(e)&&(e=pt(t,e),t.parent_||gt(t,e)),t.patches_&&rt("Patches").generateReplacementPatches_(n[Le].base_,e,t.patches_,t.inversePatches_)):e=pt(t,n,[]),ct(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==De?e:void 0}function pt(e,t,n){if(nt(t))return t;const o=t[Le];if(!o)return Je(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),Je(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&&Ne(5),qe(i)){const s=pt(e,i,r&&t&&3!==t.type_&&!He(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(Fe(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===Le)return e;const n=Xe(e);if(!He(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_||!Fe(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?.[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||He(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(){Ne(11)},getPrototypeOf:e=>Ke(e.base_),setPrototypeOf(){Ne(12)}},mt={};function yt(e,t){const n=e[Le];return(n?Xe(n):e)[t]}function wt(e,t){if(!(t in e))return;let n=Ke(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ke(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_))}Je(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))&&Ne(13),mt.set.call(this,e,t,void 0)},mt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Ne(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)||Ne(10,e),xt(e)}function xt(e){if(!Fe(e)||nt(e))return e;const t=e[Le];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 Je(n,((e,t)=>{Ye(n,e,xt(t))})),t&&(t.finalized_=!1),n}var Ot=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&&Ne(6),void 0!==n&&"function"!=typeof n&&Ne(7),Fe(e)){const i=dt(this),r=It(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?ct(i):lt(i)}return at(i,n),ht(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===De&&(o=void 0),this.autoFreeze_&&et(o,!0),n){const t=[],i=[];rt("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Ne(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){Fe(e)||Ne(8),qe(e)&&(e=St(e));const t=dt(this),n=It(e,void 0);return n[Le].isManual_=!0,lt(t),n}finishDraft(e,t){const n=e&&e[Le];n&&n.isManual_||Ne(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)))}},jt=Ot.produce;Ot.produceWithPatches.bind(Ot),Ot.setAutoFreeze.bind(Ot),Ot.setUseStrictShallowCopy.bind(Ot),Ot.applyPatches.bind(Ot),Ot.createDraft.bind(Ot),Ot.finishDraft.bind(Ot);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})}}},At=(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 Rt=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 _t(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 Dt(){return{s:$t,v:void 0,o:null,p:null}}function Ut(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 c;if(t.s===Pt)c=t.v;else if(c=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,c)&&(c=e,0!==r&&r--);i="object"==typeof c&&null!==c||"function"==typeof c?new Mt(c):c}return a.s=Pt,a.v=c,c}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:c,memoizeOptions:l=[],argsMemoize:d=Ut,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Rt(l),f=Rt(u),g=Tt(e),v=c((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){i++;const e=_t(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:At}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=_t(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,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:c,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Wt=Lt(Ut),Nt=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:()=>Nt});function Kt(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var qt=Kt(),Ft=Kt;((...e)=>{const t=Lt(...e)})(Ut);var zt="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)},Bt=e=>e&&"function"==typeof e.match;function Jt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Pe(t)&&t.type===e,n}function Vt(e){return"function"==typeof e&&"type"in e&&Bt(e)}function Ht(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 Fe(e)?jt(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 c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let i in c){const s=r?r+"."+i:i;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=tn(e,t,n.children[i],o[i],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function nn(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Ae(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),c=i.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=on(l,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(Ft(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=>c=>{const l=Ht(r,"ImmutableStateInvariantMiddleware");l.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(c);return l.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(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.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:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!Pe(u))return l(u);const h=l(u),p=Ht(s,"SerializableStateInvariantMiddleware");return c||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=Vt}=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)},ln="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:cn(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,c="tick"===e.type?queueMicrotask:"raf"===e.type?ln:"callback"===e.type?e.queueNotification:cn(e.timeout),l=()=>{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,c(l))),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,c;if("function"==typeof n)a=n;else{if(!Ae(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(c=o(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=$e;i&&(l=zt({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}}}(...c),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");c.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,l(...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)=>Bt(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=Jt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Jt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Jt(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||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,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),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:c});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(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,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,l,e,t.meta):o(t,l,e)}))])}catch(t){p=t instanceof gn?r(null,l,e,t.payload,t.meta):r(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,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 c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?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(Fe(e))return jt(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?Jt(e,s):Jt(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:c,settled:l,options:d}=n,u=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);c&&o.addCase(u.rejected,c);l&&o.addMatcher(u.settled,l);o.exposeCaseReducer(t,{fulfilled:s||xn,pending:a||xn,rejected:c||xn,settled:l||xn})}(s,r,a,t)}));const l=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,reducer:(e,t)=>(u||(u=c()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=c()),u.getInitialState()),getSelectors(t=l){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 xn(){}var On="listenerMiddleware";Jt(`${On}/add`),Jt(`${On}/removeAll`),Jt(`${On}/remove`);const jn=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()}})),An=h((e=>{const t=r(E({"widget-id":j}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),En=h((e=>{const t=r(D,An)(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]}}})),Rn=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($,An,En,Rn)(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})),_n=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":j}))(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,c,l,d,u,h,p,f,g;const v=r(q,k,C,D,R,$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",c).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,c=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 c=window.DescopeDebugLogs;if(!c)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 c({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",l).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")},l=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(xe(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,c=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)},c))}},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 Un(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])=>{Un(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,c,l;const d=r(k,G)(e);return l=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",c).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])=>{Un(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",c).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},c=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),{}}},l})),Nn=e=>e.selectedAccessKeysIds,Kn=e=>e.notifications,qn=Wt((e=>e.accessKeysList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{expireTimeFormatted:(null==e?void 0:e.expireTime)?new Date(1e3*((null==e?void 0:e.expireTime)||0)).toLocaleString():"Never",createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:(null==e?void 0:e.expireTime)&&new Date(1e3*((null==e?void 0:e.expireTime)||0))<new Date?"expired":null==e?void 0:e.status}))))),Fn=Wt(Nn,qn,((e,t)=>t.filter((t=>e.includes(t.id))))),zn=Wt(Nn,(e=>!!e.length)),Bn=Wt(Fn,(e=>e.every((e=>e.editable)))),Jn=Wt(Bn,zn,((e,t)=>e&&t)),Vn=Wt(Fn,(e=>e.some((e=>"expired"===e.status)))),Hn=Wt(Jn,Vn,((e,t)=>e&&!t)),Yn=Wt(Nn,(e=>1===e.length)),Zn=Wt(Fn,(e=>1===e.length?e[0].name:`${e.length} access keys`)),Gn=Wt(Hn,Yn,Fn,((e,t,n)=>{var o;return e&&t&&"active"===(null===(o=n[0])||void 0===o?void 0:o.status)})),Xn=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)}))}))},Qn=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}}),eo=({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)})}}),to=yn("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),no=Xn(to)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},Qn((e=>e.createAccessKey)),eo({getSuccessMsg:()=>"Access Key created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create access key</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),oo={action:to,reducer:no},io=yn("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),ro=Xn(io)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},Qn((e=>e.deleteAccessKey)),eo({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deleted successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to delete access key${["","s"]}`})),so={action:io,reducer:ro},ao=yn("accessKeys/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.accesskey.search(Object.assign(Object.assign({},o),e))})),co=Xn(ao)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},Qn((e=>e.accessKeysList))),lo={action:ao,reducer:co},uo=yn("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),ho=Xn(uo)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},Qn((e=>e.activateAccessKey)),eo({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} activated successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to activate access key${["","s"]}`})),po={action:uo,reducer:ho},fo=yn("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),go=Xn(fo)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},Qn((e=>e.deactivateAccessKey)),eo({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deactivated successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to deactivate access key${["","s"]}`})),vo={action:fo,reducer:go},mo=yn("accessKeys/rotate",((e,{extra:{api:t}})=>t.accesskey.rotate(e))),yo=Xn(mo)({onFulfilled:(e,t)=>{const n=e.accessKeysList.data.findIndex((e=>e.id===t.payload.key.id));n>=0&&(e.accessKeysList.data[n]=t.payload.key)}},Qn((e=>e.rotateAccessKey)),eo({getSuccessMsg:()=>"Access key rotated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to rotate access key</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),wo={action:mo,reducer:yo},bo=yn("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),ko={action:bo,reducer:Xn(bo)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},Qn((e=>e.tenantRoles)))},Io={accessKeysList:{data:[],loading:!1,error:null},createAccessKey:{loading:!1,error:null},activateAccessKey:{loading:!1,error:null},deactivateAccessKey:{loading:!1,error:null},deleteAccessKey:{loading:!1,error:null},rotateAccessKey:{loading:!1,error:null},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]};class So extends Error{}function xo(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 Oo(e,t){if("string"!=typeof e)throw new So("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 So(`Invalid token specified: missing part #${n+1}`);let i;try{i=xo(o)}catch(e){throw new So(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new So(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}So.prototype.name="InvalidTokenError";var jo={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},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"}};const Co="<region>",Ao=`https://api.${Co}descope.com`,Eo=6e5,Ro=()=>{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")}},To=[503,520,521,522,524,530],_o=[100,5e3,5e3],Mo=e=>new Promise((t=>setTimeout(t,e))),$o=e=>async function(...t){let n=await e(...t),o=0;for(;To.includes(n.status)&&o<_o.length;)await Mo(_o[o]),n=await e(...t),o++;o>0&&(n.retries=o);const i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n},Po=(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=>Ro().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await $o(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return Ro().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:$o(n)};let Do;const Uo=()=>{if(Do)return Do;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 Do=`${t}-${n}`,Do};var Lo,Wo;(Wo=Lo||(Lo={})).get="GET",Wo.delete="DELETE",Wo.post="POST",Wo.put="PUT",Wo.patch="PATCH";const No=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(Co,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},Ko=(...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)),{})),qo={"Content-Type":"application/json"},Fo=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},zo=(e,t)=>{const n={"x-descope-sdk-session-id":Uo(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.70.1","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Bo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var Jo=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const c=e||Ao,l=Po(i,a),d=async e=>{var i;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:Ko(Fo(t,g),zo(t,o),(null==n?void 0:n.baseHeaders)||{},Bo(v)?qo:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const y=await l(No({path:d,baseUrl:c,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==y?void 0:y.clone()),null==r?void 0:r.transformResponse){const e=await y.json(),t=(w=(null===(i=y.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,c=!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)){c=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!c||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),o=new Proxy(y,{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 w;return y};return{get:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Lo.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Lo.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Lo.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>d({path:e,headers:n,queryParams:o,body:t,method:Lo.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Lo.delete,token:o}),hooks:r,buildUrl:(e,n)=>No({projectId:t,baseUrl:c,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}}))},Vo=429;function Ho(e,t,n){var o;let i=Yo(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 Yo(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Oo(e)}function Zo(e){const{exp:t}=Yo(e);return(new Date).getTime()/1e3>t}function Go(e){let t=Yo(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Xo(e,t){return Ho(e,t,"permissions")}function Qo(e,t){return Ho(e,t,"roles")}const ei=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function ti(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===Vo&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function ni(e){var t;return(null===(t=Yo(e))||void 0===t?void 0:t.dct)||""}const oi=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),ii=(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 "))},ri=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),si=e=>t=>e.test(t),ai=si(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ci=si(/^\+[1-9]{1}[0-9]{3,14}$/),li=oi(ai,'"{val}" is not a valid email'),di=oi(ci,'"{val}" is not a valid phone number'),ui=oi((e=>e.length>=1),"Minimum length is 1");const hi=oi((e=>"string"==typeof e),"Input is not a string"),pi=oi((e=>Array.isArray(e)),"Input is not an array"),fi=oi((e=>"boolean"==typeof e),"Input is not a boolean"),gi=oi((e=>void 0===e),"Input is defined"),vi=ii([hi(),gi()],"Input is not a string or undefined"),mi=ii([pi(),fi()],"Input is not an array or boolean"),yi=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>ri(...e).validate(n[t]))),t(...n)),wi=e=>[hi(`"${e}" must be a string`)],bi=e=>[vi(`"${e}" must be string or undefined`)],ki=e=>[hi(`"${e}" must be a string`),ui(`"${e}" must not be empty`)],Ii=e=>[hi(`"${e}" must be a string`),li()],Si=e=>[hi(`"${e}" must be a string`),di()],xi=yi(ki("accessKey")),Oi=e=>({exchange:xi(((t,n)=>ti(e.post(jo.accessKey.exchange,{loginOptions:n},{token:t}))))}),ji=(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),Ci=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Eo,Eo)});var Ai,Ei;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Ai||(Ai={})),function(e){e.email="email"}(Ei||(Ei={}));const Ri=Object.assign(Object.assign({},Ai),Ei);var Ti;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ti||(Ti={}));const _i=ki("loginId"),Mi=yi(ki("token")),$i=yi(_i),Pi=yi(ki("pendingRef")),Di=yi(_i,Ii("email")),Ui=e=>({verify:Mi((t=>ti(e.post(jo.enchantedLink.verify,{token:t})))),signIn:$i(((n,o,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return ti(e.post(ei(jo.enchantedLink.signIn,Ri.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:$i(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return ti(e.post(ei(jo.enchantedLink.signUpOrIn,Ri.email),{loginId:n,URI:o,loginOptions:s,providerId:r}))})),signUp:$i(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ti(e.post(ei(jo.enchantedLink.signUp,Ri.email),{loginId:n,URI:o,user:i,loginOptions:a,providerId:s}))})),waitForSession:Pi(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ci(n);let s;const a=setInterval((async()=>{const n=await e.post(jo.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(ti(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Di(((t,n,o,i,r)=>ti(e.post(jo.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),Li=yi(ki("flowId")),Wi=yi(ki("executionId"),ki("stepId"),ki("interactionId")),Ni=e=>({start:Li(((t,n,o,i,r,s,a,c=!1)=>ti(e.post(jo.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:c})))),next:Wi(((t,n,o,i,r,s,a=!1,c)=>ti(e.post(jo.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a,options:c}))))}),Ki=ki("loginId"),qi=yi(ki("token")),Fi=yi(Ki),zi=yi(Ki,Si("phone")),Bi=yi(Ki,Ii("email")),Ji=Object.keys(Ri).filter((e=>e!==Ai.voice&&e!==Ai.im)),Vi=e=>({verify:qi((t=>ti(e.post(jo.magicLink.verify,{token:t})))),signIn:Ji.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Fi(((n,i,r={},s)=>{var{providerId:a}=r,c=t(r,["providerId"]);return ti(e.post(ei(jo.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:c,providerId:a},{token:s}))}))})),{}),signUp:Ji.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Fi(((n,i,r,s={})=>{var{providerId:a}=s,c=t(s,["providerId"]);return ti(e.post(ei(jo.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:c,providerId:a}))}))})),{}),signUpOrIn:Ji.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Fi(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ti(e.post(ei(jo.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:Bi(((t,n,o,i,r)=>ti(e.post(jo.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Ai).filter((e=>e!==Ai.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:zi(((t,o,i,r,s)=>ti(e.post(ei(jo.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var Hi;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(Hi||(Hi={}));const Yi=yi(ki("code")),Zi=e=>({start:Object.assign(((t,n,o,i,r)=>ti(e.post(jo.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(Hi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>ti(e.post(jo.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:Yi((t=>ti(e.post(jo.oauth.exchange,{code:t})))),startNative:(t,n,o)=>ti(e.post(jo.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>ti(e.post(jo.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>ti(e.get(jo.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>ti(e.post(jo.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>ti(e.post(jo.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Gi=ki("appId"),Xi=yi(Gi),Qi=e=>({connect:Xi(((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,ti(e.post(jo.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),er=ki("loginId"),tr=yi(er,ki("code")),nr=yi(er),or=yi(er,Si("phone")),ir=yi(er,Ii("email")),rr=e=>({verify:Object.keys(Ri).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:tr(((t,o)=>ti(e.post(ei(jo.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Ri).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:nr(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return ti(e.post(ei(jo.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Ri).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:nr(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ti(e.post(ei(jo.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Ri).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:nr(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return ti(e.post(ei(jo.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:ir(((t,n,o,i)=>ti(e.post(jo.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Ai).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:or(((t,o,i,r)=>ti(e.post(ei(jo.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),sr=yi(ki("tenant")),ar=yi(ki("code")),cr=e=>({start:sr(((t,n,o,i,r,s,a,c)=>ti(e.post(jo.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}),c&&{initiatedEmail:t})},i&&{token:i}))))),exchange:ar((t=>ti(e.post(jo.sso.exchange,{code:t}))))}),lr=ki("loginId"),dr=yi(lr,ki("code")),ur=yi(lr),hr=yi(lr),pr=e=>({signUp:ur(((t,n)=>ti(e.post(jo.totp.signUp,{loginId:t,user:n})))),verify:dr(((t,n,o,i)=>ti(e.post(jo.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:hr(((t,n)=>ti(e.post(jo.totp.update,{loginId:t},{token:n}))))}),fr=ki("loginId"),gr=ki("newPassword"),vr=yi(fr,ki("password")),mr=yi(fr),yr=yi(fr,gr),wr=yi(fr,ki("oldPassword"),gr),br=e=>({signUp:vr(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ti(e.post(jo.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:vr(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return ti(e.post(jo.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:mr(((t,n,o)=>ti(e.post(jo.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:yr(((t,n,o)=>ti(e.post(jo.password.update,{loginId:t,newPassword:n},{token:o})))),replace:wr(((t,n,o)=>ti(e.post(jo.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>ti(e.get(jo.password.policy))}),kr=wi("loginId"),Ir=ki("loginId"),Sr=wi("origin"),xr=yi(Ir,Sr,ki("name")),Or=yi(Ir,Sr),jr=yi(kr,Sr),Cr=yi(Ir,Sr,bi("token")),Ar=yi(ki("transactionId"),ki("response")),Er=e=>({signUp:{start:xr(((t,n,o,i,r)=>ti(e.post(jo.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:r,passkeyOptions:i})))),finish:Ar(((t,n)=>ti(e.post(jo.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:jr(((t,n,o,i,r)=>ti(e.post(jo.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:Ar(((t,n)=>ti(e.post(jo.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Or(((t,n,o,i)=>ti(e.post(jo.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:o}))))},update:{start:Cr(((t,n,o,i,r)=>ti(e.post(jo.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i,mfa:r},{token:o})))),finish:Ar(((t,n)=>ti(e.post(jo.webauthn.update.finish,{transactionId:t,response:n}))))}}),Rr=wi("loginId"),Tr=yi(Rr),_r=yi(ki("pendingRef")),Mr=e=>({signUpOrIn:Tr(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return ti(e.post(jo.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:Tr(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return ti(e.post(jo.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:Tr(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return ti(e.post(jo.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:_r(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ci(n);let s;const a=setInterval((async()=>{const n=await e.post(jo.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(ti(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),$r=yi(ki("token")),Pr=yi(bi("token"));var Dr,Ur=yi([(Dr=ki("projectId"),oi(((e,t)=>n=>ri(...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",Dr))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return c=Jo({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:Oi(c),otp:rr(c),magicLink:Vi(c),enchantedLink:Ui(c),oauth:Zi(c),outbound:Qi(c),sso:cr(c),saml:cr(c),totp:pr(c),notp:Mr(c),webauthn:Er(c),password:br(c),flow:Ni(c),refresh:Pr(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?jo.tryRefresh:jo.refresh;return ti(c.post(r,i,{token:e,queryParams:t}))})),selectTenant:yi([hi("tenantId")],[vi('"token" must be string or undefined')])(((e,t)=>ti(c.post(jo.selectTenant,{tenant:e},{token:t})))),logout:Pr((e=>ti(c.post(jo.logout,{},{token:e})))),logoutAll:Pr((e=>ti(c.post(jo.logoutAll,{},{token:e})))),me:Pr((e=>ti(c.get(jo.me,{token:e})))),myTenants:yi([mi('"tenants" must a string array or a boolean')],[vi('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,ti(c.post(jo.myTenants,n,{token:t}))})),history:Pr((e=>ti(c.get(jo.history,{token:e})))),isJwtExpired:$r(Zo),getTenants:$r(Go),getJwtPermissions:$r(Xo),getJwtRoles:$r(Qo),getCurrentTenant:$r(ni),httpClient:c};var c})),Lr=Object.assign(Ur,{DeliveryMethods:Ri});
6
- /*! js-cookie v3.0.8 | MIT */function Wr(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 Nr=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=Wr({},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,"",Wr({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Wr({},this.attributes,t))},withConverter:function(t){return e(Wr({},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 Kr={default:"endpoint"},qr="Blocked by CSP",Fr="The endpoint parameter is not a valid URL",zr="Failed to load the JS script of the agent",Br="9319";function Jr(e,t){var n,o,i,r,s,a=[],c=(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===qr||s===Fr)n.exclude(),r=0;else if(s===Br)n.exclude();else if(s===zr){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!i.has(c)&&(i.add(c),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+o()-Date.now()]}]),l=c[0],d=c[1];if(void 0===l)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(l).then((function(e){return[e,a]}))}var Vr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Hr=Vr;function Yr(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:Vr,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=l[0],u=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(c,s);return Jr(e,Zr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Br?new Error(zr):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 Zr(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(Fr);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(zr))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(qr)})).then(Gr)}function Gr(){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(Br);return n}const Xr="3.2.0",Qr="undefined"!=typeof window,es=Math.pow(2,31)-1,ts=`https://descopecdn.com/npm/oidc-client-ts@${Xr}/dist/browser/oidc-client-ts.min.js`,ns=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Xr}/dist/browser/oidc-client-ts.min.js`,os=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let is;const rs=e=>{try{return Oo(e).exp}catch(e){return null}},ss=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:rs(n)},as=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?rs(o):void 0)},cs=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||as(e),cookieExpiration:e.cookieExpiration||ss(e)},s)},ls=(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},ds=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 cs(n)},us=()=>Qr&&!!window.descopeBridge,hs=(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 os.includes(n)},ps=void 0!==is||Qr&&void 0!==window.localStorage,fs=(e,t)=>{var n,o;return null===(o=null===(n=is||Qr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},gs=e=>{var t,n;return null===(n=null===(t=is||Qr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},vs=e=>{var t,n;return null===(n=null===(t=is||Qr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},ms=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==is?void 0:is.key)||void 0===t?void 0:t.call(is,e))&&void 0!==n?n:Qr&&(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},ys=e=>{var t,n;return Qr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},ws=e=>{var t,n;try{Qr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},bs=(...e)=>{console.debug(...e)},ks=(...e)=>{console.warn(...e)},Is=(e,t)=>{let n;var o;return t>0?(n=1e3*t,bs(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>es&&(bs(`Timeout is too large (${n}ms), setting it to ${es}ms`),n=es),n},Ss="DS",xs="DSR",Os="DSI",js="DSRCN";function Cs(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=As(o);Nr.set(e,t,{path:i,domain:l?o:void 0,expires:c,sameSite:r,secure:a})}}function As(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 Es=e=>(null==e?void 0:e.cookieName)||Ss,Rs=e=>(null==e?void 0:e.cookieName)||xs;function Ts(e="",t){return Nr.get(Rs(t))||gs(`${e}${xs}`)||""}function _s(e="",t){return Nr.get(Es(t))||gs(`${e}${Ss}`)||""}function Ms(e=""){return gs(`${e}${Os}`)||""}function $s(e="",t,n,o){vs(`${e}${xs}`),vs(`${e}${Ss}`),vs(`${e}${Os}`),vs(`${e}${js}`);const i=Es(t);Nr.remove(i,null==o?void 0:o.session);const r=Rs(n);Nr.remove(r,null==o?void 0:o.refresh)}const Ps=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||Ts(e,t)});if(!n){const t=function(e=""){return gs(`${e}${js}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return gs(`${e}DTD`)||""}(e);return r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r})),i},Ds=Qr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Us="vsid",Ls="vrid",Ws=(e=!1)=>{const t=gs("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Ns=async(e,t=Ds)=>{try{if(Ws())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=Yr({apiKey:e,endpoint:[o.toString(),Kr],scriptUrlPattern:[r,Hr]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Us]:e,[Ls]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};fs("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Ks=e=>{const t=Ws(!0);return t&&e.body&&(e.body.fpData=t),e},qs="descopeFlowNonce",Fs="X-Descope-Flow-Nonce",zs="/v1/flow/start",Bs="/v1/flow/next",Js=(e,t=qs)=>`${t}${e}`,Vs=(e,t=qs)=>{try{const n=Js(e,t),o=gs(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(Hs(e,t),null):{value:i.value,seq:i.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},Hs=(e,t=qs)=>{try{const n=Js(e,t);vs(n)}catch(e){console.error("Error removing flow nonce:",e)}},Ys=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Zs=e=>{var t;return e.path===Bs&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Ys(e.body.executionId):null},Gs="dls_last_user_login_id",Xs="dls_last_user_display_name",Qs=e=>fs(Gs,e),ea=()=>gs(Gs),ta=()=>gs(Xs),na=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=ea(),r=ta();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},oa="DSLI",ia=e=>async(...t)=>{const n=await e(...t);return ws(oa),n};function ra(){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 sa(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=pa(n.publicKey.challenge),n.publicKey.user.id=pa(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=pa(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:fa(n.rawId),type:n.type,response:{attestationObject:fa(n.response.attestationObject),clientDataJSON:fa(n.response.clientDataJSON)}})}catch(e){throw await la(e,t,!0)}var n}async function aa(e){const t=ua(e);try{return ha(await navigator.credentials.get(t))}catch(e){throw await la(e,t,!1)}}async function ca(e,t){const n=ua(e);n.signal=t.signal,n.mediation="conditional";try{return ha(await navigator.credentials.get(n))}catch(e){throw await la(e,n,!1)}}async function la(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 da())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 da(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function da(e=!1){var t,n;if(!Qr)return Promise.resolve(!1);if(us()){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 ua(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=pa(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=pa(e.id)})),n}function ha(e){return JSON.stringify({id:e.id,rawId:fa(e.rawId),type:e.type,response:{authenticatorData:fa(e.response.authenticatorData),clientDataJSON:fa(e.response.clientDataJSON),signature:fa(e.response.signature),userHandle:e.response.userHandle?fa(e.response.userHandle):void 0}})}function pa(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function fa(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ga,va=(ga=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 sa(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 aa(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 sa(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await aa(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 sa(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:sa,get:aa,isSupported:da,conditional:ca}}),(...e)=>{const t=ga(...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 ma="/fedcm/config";async function ya(e,t){var n;try{await wa(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function wa(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 c=a.data.clientId;return new Promise((e=>{var a,l;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===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,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 ba=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await da(),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 ka;const Ia=(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",(()=>{Ia(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Sa=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{ka||(ka=(async()=>{try{return require("oidc-client-ts")}catch(e){return Ia([ts,ns],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await ka;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,c,l;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,c=`${a}_user`,l="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,c=`${a}_user`,l="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)||l,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:c}})(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)))),fs(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=gs(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 c=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(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||Ms(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return vs(i),t||window.location.replace(s),r}}},xa=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,is=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Qr?(o&&i&&Ns(o).catch((()=>null)),e(ls(r,{beforeRequest:Ks}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.52.1"},t.baseHeaders)}))),(e=>t=>{const n=ra(),o=ra(),i=ra(),r=ra(),s=e(ls(t,{afterRequest:async(e,t)=>{if(hs(e,t))bs("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 ds(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:c}=await ds(t);s&&o.pub(s),c&&r.pub(c),(a||s)&&n.pub(a||42)}}})),a=ji(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=qs}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(s);((e=qs)=>{try{if(!ps)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==is?void 0:is.length)&&void 0!==t?t:Qr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=ms(i);if(t&&t.startsWith(e)){const n=gs(t);if(n)try{JSON.parse(n).expiry<Date.now()&&vs(t)}catch(e){vs(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=e(ls(s,{afterRequest:async(e,t)=>{var n;if(e.path!==zs&&e.path!==Bs)return;const{nonce:o,seq:i,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Fs),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=Zs(e)),{nonce:n,seq:o,executionId:Ys(i)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!o||!s)return;const a=e.path===zs,c=null===(n=Vs(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==i&&void 0!==c&&i<=c||((e,t,n,o=qs,i)=>{try{const r=Js(e,o),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:i};fs(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,o,a,r,null!=i?i:a?void 0:c)},beforeRequest:e=>{if(e.path===Bs){const t=Zs(e);if(t){const n=((e,t=qs)=>{var n,o;return null!==(o=null===(n=Vs(e,t))||void 0===n?void 0:n.value)&&void 0!==o?o:null})(t,r);n&&(e.headers=e.headers||{},e.headers[Fs]=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(ls(t,{afterRequest:async(e,t)=>{if(hs(e,t))return void ws(oa);const n=await ds(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,o;try{Qr&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o||o.call(n,e,t))}catch(e){}})(oa,String(n.sessionExpiration))}}));return ji(n,["logout","logoutAll","oidc.logout"],ia)}),(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||us())return Object.assign(e(i),{markUserActive:()=>{ks("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,d,u=null,h=!1,p=!1;s&&(bs("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Qr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(bs("Expiration time passed, refreshing session"),f.refresh(Ts()||d))}));const f=e(ls(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i,nextRefreshSeconds:r}=await ds(t);if(hs(e,t))bs("Session invalidated, canceling all timers"),a();else if(n||i){if(l=((e,t)=>{if(t)return new Date(1e3*t);bs("Could not extract expiration time from session token, trying to decode the token");try{const t=Oo(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!l)return void bs("Could not extract expiration time from session token");d=o,h=r>0;const e=Is(l,r);if(a(),e<=2e4)return void bs("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});bs(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),c((()=>{if(Qr&&"hidden"===document.visibilityState)bs("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return bs("Skipping refresh due to timer - user is idle"),void(p=!0);bs("Refreshing session due to timer"),f.refresh(Ts()||o)}}),e)}}}));return Object.assign(ji(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return bs("Clearing all timers"),a(),n})),{markUserActive:u?()=>{bs("markUserActive() called"),h||bs("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(bs("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Ts()||d))}:()=>{ks("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:ea,getLastUserDisplayName:ta});const s=e(ls(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=cs((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?(Qs(r),(e=>{fs(Xs,e)})(s)):(null==i?void 0:i.loginId)&&Qs(i.loginId)}}));let a=ji(s,["flow.start"],na);return a=ji(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(vs(Gs),vs(Xs)),o})(i)),Object.assign(a,{getLastUserLoginId:ea,getLastUserDisplayName:ta})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,c=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!Qr)return e(Object.assign({refreshCookieName:a},c));let l;const d=e(ls(Object.assign({refreshCookieName:a},c),{beforeRequest:Ps(s,r,a),afterRequest:async(e,t)=>{if(hs(e,t))bs("Session invalidated, clearing persisted tokens"),$s(s,i,r,l);else{const e=await ds(t);e.cookieName?fs(`${s||""}${js}`,e.cookieName):e.refreshJwt&&vs(`${s||""}${js}`);const n=((e={},t=!1,n="",o=!1)=>{var i,r,s,a;const{sessionJwt:c,refreshJwt:l,trustedDeviceJwt:d}=e;let u;if(l)if(o){vs(`${n}${xs}`);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,c=Rs(o);s&&"https:"!==window.location.protocol&&ks("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});Cs(c,l,d);const h=As(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=Rs(o);Nr.remove(e),fs(`${n}${xs}`,l)}if(c)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=Es(t);o&&"https:"!==window.location.protocol&&ks("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 l=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});Cs(r,c,l);const d=As(i);u=Object.assign(Object.assign({},u),{session:{path:l.cookiePath,domain:d?i:void 0}})}else fs(`${n}${Ss}`,c);return e.idToken&&fs(`${n}${Os}`,e.idToken),d&&fs(`${n}DTD`,d),u})(e,i,s,r);n&&(l=n)}}})),u=ji(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,(()=>l)));return Object.assign(u,{getRefreshToken:()=>Ts(s,r),getSessionToken:()=>_s(s,i),getIdToken:()=>Ms(s)})}))((e=>{const t=Lr(e),n=Sa(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(us())return bs(`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&&Qr&&void 0!==window.localStorage&&!ys(oa)&&!gs(Gs)&&!ys("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=_s(),a=Ts();let c="";if(e.getExternalToken)try{c=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){bs("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},c,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:ba(t),webauthn:va(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){ya(o,e)},requestAuthentication(e){ya(o,e)}},async oneTap(e,t,n,i,r){await wa(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+ma),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>Qr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+ma);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})),Oa={search:"/v1/mgmt/accesskey/search",deleteBatch:"/v1/mgmt/accesskey/delete/batch",create:"/v1/mgmt/accesskey/create",deactivate:"/v1/mgmt/accesskey/deactivate/batch",activate:"/v1/mgmt/accesskey/activate/batch",rotate:"/v1/mgmt/accesskey/rotate"},ja={roles:"/v1/mgmt/role/all"},Ca=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)})),Aa=(...e)=>n(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((n=>{const o=[],i=(new Date).getTime()/1e3+2592e3,r=new Date(i).toLocaleString();for(let e=1;e<10;e+=1)o.push({id:`access-key-id-${e}`,name:`Access Key ${e}`,createdBy:`User ${e}`,editable:!0,expireTime:i,expireTimeFormatted:r,createdTime:i,createdTimeFormatted:r,roleNames:[`Role ${e}`],permittedIps:["127.1.2.3"],status:"active",clientId:`Client ID ${e}`,boundUserId:`User ${e}`});t.forEach((e=>{o.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])}))})),n(o.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.createdBy.toLowerCase().includes(e.toLowerCase()))))}))})),Ea=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:n,permittedIps:o},i){const r=Math.random().toString(10).substring(15);return new Promise((s=>{s({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${r}`,name:e||`Access Key ${r}`,createdBy:n||`User ${r}`,editable:!0,expireTime:i,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:o,status:"active",clientId:`Client ID ${r}`,boundUserId:n||`User ${r}`}})}))})),Ra=()=>n(void 0,void 0,void 0,(function*(){})),Ta=()=>n(void 0,void 0,void 0,(function*(){})),_a=()=>n(void 0,void 0,void 0,(function*(){})),Ma=e=>n(void 0,[e],void 0,(function*({id:e}){return new Promise((t=>{t({cleartext:Math.random().toString(20).substring(2),key:{id:e,name:`Access Key ${e}`,createdBy:"User",editable:!0,expireTime:(new Date).getTime()/1e3+2592e3,createdTime:(new Date).getTime()/1e3,roleNames:[],permittedIps:[],status:"active",clientId:`Client ID ${e}`,boundUserId:"User"}})}))})),$a=e=>new Promise((t=>{const n=[];for(let t=1;t<5;t+=1)n.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:n})})),Pa=({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 Aa({page:n,limit:i,text:r,sort:s});const a=yield e.post(Oa.search,{limit:i,page:n,text:r,sort:s},{queryParams:{tenant:t}});yield Ca(a);return(yield a.json()).keys})),deleteBatch:i=>n(void 0,void 0,void 0,(function*(){if(o)return _a();const n=yield e.post(Oa.deleteBatch,{ids:i},{queryParams:{tenant:t}});return yield Ca(n),n.json()})),create:i=>n(void 0,[i],void 0,(function*({name:n,expiration:i,roleNames:r,userId:s,permittedIps:a}){const c=new Date;c.setDate(c.getDate()+ +i);const l="0"===i[0]?0:Math.floor(c.getTime()/1e3);if(o)return Ea({name:n,expiration:i,roleNames:r,userId:s,permittedIps:a},l);const d=yield e.post(Oa.create,{name:n,expireTime:l,roleNames:r,userId:s,permittedIps:a},{queryParams:{tenant:t}});yield Ca(d);return yield d.json()})),activate:i=>n(void 0,void 0,void 0,(function*(){if(o)return Ra();const n=yield e.post(Oa.activate,{ids:i},{queryParams:{tenant:t}});yield Ca(n);return yield n.json()})),deactivate:i=>n(void 0,void 0,void 0,(function*(){if(o)return Ta();const n=yield e.post(Oa.deactivate,{ids:i},{queryParams:{tenant:t}});yield Ca(n);return yield n.json()})),rotate:i=>n(void 0,[i],void 0,(function*({id:n}){if(o)return Ma({id:n});const i=yield e.post(Oa.rotate,{id:n},{queryParams:{tenant:t}});yield Ca(i);return yield i.json()}))}),Da=({httpClient:e,tenant:t,mock:o})=>({getTenantRoles:()=>n(void 0,void 0,void 0,(function*(){if(o)return $a(t);const n=yield e.get(ja.roles,{queryParams:{tenant:t}});return yield Ca(n),n.json()}))}),Ua=h((e=>{var t,s,a,c;const l=r(R,A,k,T,_n,E({tenant:E.missingAttrValidator}))(e);return c=class extends l{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=xa(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"access-key-management-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.10.2"}}));return{accesskey:Pa({httpClient:i.httpClient,tenant:t,mock:n}),tenant:Da({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")},c})),La=h((e=>{const t=r(jn({name:"widget",initialState:Io,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{oo.reducer(e),so.reducer(e),lo.reducer(e),po.reducer(e),vo.reducer(e),wo.reducer(e),ko.reducer(e)},asyncActions:{searchAccessKeys:lo.action,createAccessKey:oo.action,activateAccessKeys:po.action,deactivateAccessKeys:vo.action,deleteAccessKeys:so.action,rotateAccessKey:wo.action,getTenantRoles:ko.action}}),C,k,Ua)(e);return class extends t{constructor(...e){super(...e),this.state=Io,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Wa=h((e=>{var t,i,a;return a=class extends(r(k,C,B,G,Tn("access-key-management-widget"),La)(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.searchAccessKeys(),this.actions.getTenantRoles()]),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})),Na=h((e=>{var t,i,s,a,l;return l=class extends(r(La,k,Wa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{this.accessKeysTable.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.searchAccessKeys({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.accessKeysTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{o(this,a,"f").call(this,e.target,e.detail)}))})),o(this,s,"f").call(this,qn(this.state)),this.subscribe(o(this,s,"f").bind(this),qn)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,i=function(){var e;this.accessKeysTable=new re(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="access-keys-table"]'),{logger:this.logger}),this.accessKeysTable.onSelectedItemsChange((e=>{this.actions.setSelectedAccessKeysIds(e.detail.value.map((({id:e})=>e)))}))},l})),Ka=h((e=>{var t,i,a;return a=class extends(r(La,ve,k,Wa)(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.activateAccessKeysModal=this.createModal(),this.activateAccessKeysModal.setContent(s(yield this.fetchWidgetPage("activate-access-keys-modal.html")));const t=new ne((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.activateAccessKeysModal.close()));const n=new ne((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Fn(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const o=new fe(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=Zn(this.state);o.text=`Activate ${e}?`}}))},a})),qa=h((e=>{var t,i,s,a;return a=class extends(r(k,Wa,La,Ka)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{e?this.activateButton.enable():this.activateButton.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.activateButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="activate-access-keys"]'),{logger:this.logger}),this.activateButton.disable(),this.activateButton.onClick((()=>{this.activateAccessKeysModal.open()}))},a})),Fa=h((e=>{var t,i,a;return a=class extends(r(La,ve,Cn,k,Wa)(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(){return n(this,void 0,void 0,(function*(){this.createdAccessKeyModal=this.createModal(),this.createdAccessKeyModal.setContent(s(yield this.fetchWidgetPage("created-access-key-modal.html")));new ne((()=>{var e;return null===(e=this.createdAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.createdAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.createdAccessKeyModal.ele),this.createdAccessKeyModal.close()}))}))},a})),za=h((e=>{var t,a,c,l,d;return d=class extends(r(La,ve,Cn,k,Wa,Fa)(e)){constructor(){super(...arguments),t.add(this),a.set(this,void 0),l.set(this,(()=>n(this,void 0,void 0,(function*(){var e,t;yield o(this,a,"f").setData(null===(t=this.state,e=t.tenantRoles.data||[])||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",c).call(this)}))}},a=new WeakMap,l=new WeakMap,t=new WeakSet,c=function e(){return n(this,void 0,void 0,(function*(){this.createAccessKeyModal=this.createModal(),this.createAccessKeyModal.setContent(s(yield this.fetchWidgetPage("create-access-key-modal.html")));new ne((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.createAccessKeyModal.close(),this.resetFormData(this.createAccessKeyModal.ele)}));new ne((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>n(this,void 0,void 0,(function*(){var e,t;if(this.validateForm(this.createAccessKeyModal.ele)){const n=yield this.actions.createAccessKey(Object.assign({},this.getFormData(this.createAccessKeyModal.ele)));this.createAccessKeyModal.close(),(null===(e=null==n?void 0:n.payload)||void 0===e?void 0:e.cleartext)&&(this.setFormData(this.createdAccessKeyModal.ele,{"generated-key":null===(t=null==n?void 0:n.payload)||void 0===t?void 0:t.cleartext}),this.createdAccessKeyModal.open())}})))),i(this,a,new he((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),o(this,l,"f").call(this),this.createAccessKeyModal.afterClose=()=>{o(this,t,"m",e).call(this)}}))},d})),Ba=h((e=>{var t,i,s;return s=class extends(r(k,za,Wa)(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-access-key"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createAccessKeyModal.open()))},s})),Ja=h((e=>{var t,i,a;return a=class extends(r(La,ve,k,Wa)(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.deactivateAccessKeysModal=this.createModal(),this.deactivateAccessKeysModal.setContent(s(yield this.fetchWidgetPage("deactivate-access-keys-modal.html")));const t=new ne((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deactivateAccessKeysModal.close()));const n=new ne((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Fn(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const o=new fe(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=Zn(this.state);o.text=`Deactivate ${e}?`}}))},a})),Va=h((e=>{var t,i,s,a;return a=class extends(r(k,Wa,La,Ja)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{e?this.deactivateButton.enable():this.deactivateButton.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.deactivateButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="deactivate-access-keys"]'),{logger:this.logger}),this.deactivateButton.disable(),this.deactivateButton.onClick((()=>{this.deactivateAccessKeysModal.open()}))},a})),Ha=h((e=>{var t,i,a;return a=class extends(r(La,ve,k,Wa)(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.deleteAccessKeysModal=this.createModal(),this.deleteAccessKeysModal.setContent(s(yield this.fetchWidgetPage("delete-access-keys-modal.html")));const t=new ne((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteAccessKeysModal.close()));const n=new ne((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Fn(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const o=new fe(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=Zn(this.state);o.text=`Delete ${e}?`}}))},a})),Ya=h((e=>{var t,i,s,a;return a=class extends(r(k,Wa,La,Ha)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((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-access-keys"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteAccessKeysModal.open()}))},a})),Za=h((e=>{var t,i,s,a;return a=class extends(r(k,Wa,La)(e)){constructor(){super(...arguments),t.add(this),i.set(this,d((()=>{this.actions.searchAccessKeys({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 Ga={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},Xa=h((e=>{var t,i,s,a,l;return l=class extends(r(k,La,ye,C)(e)){constructor(){super(...arguments),t.add(this),a.set(this,c((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),Kn)}))}},a=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const n=Ga[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"})},l})),Qa=h((e=>{var t,i,a;return a=class extends(r(La,ve,Cn,k,Wa)(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(){return n(this,void 0,void 0,(function*(){this.rotatedAccessKeyModal=this.createModal(),this.rotatedAccessKeyModal.setContent(s(yield this.fetchWidgetPage("rotated-access-key-modal.html")));new ne((()=>{var e;return null===(e=this.rotatedAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.rotatedAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.rotatedAccessKeyModal.ele),this.rotatedAccessKeyModal.close()}))}))},a})),ec=h((e=>{var t,i,a;return a=class extends(r(La,ve,Cn,k,Wa,Qa)(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.rotateAccessKeyModal=this.createModal(),this.rotateAccessKeyModal.setContent(s(yield this.fetchWidgetPage("rotate-access-key-modal.html")));const t=new ne((()=>{var e;return null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.rotateAccessKeyModal.close()));const o=new ne((()=>{var e;return null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});o.onClick((()=>n(this,void 0,void 0,(function*(){var e,t;const n=null===(e=Fn(this.state))||void 0===e?void 0:e[0];if(!n)return void this.rotateAccessKeyModal.close();const o=yield this.actions.rotateAccessKey({id:n.id});this.rotateAccessKeyModal.close(),(null===(t=null==o?void 0:o.payload)||void 0===t?void 0:t.cleartext)&&(this.setFormData(this.rotatedAccessKeyModal.ele,{"generated-key":o.payload.cleartext}),this.rotatedAccessKeyModal.open())}))));const i=new fe(null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.rotateAccessKeyModal.beforeOpen=()=>{const e=Zn(this.state);i.text=`Rotate ${e}?`}}))},a})),tc=h((e=>{var t,i,s,a;return a=class extends(r(k,Wa,La,ec)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{e?this.rotateButton.enable():this.rotateButton.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),Gn)}))}},s=new WeakMap,t=new WeakSet,i=function(){var e;this.rotateButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="rotate-access-keys"]'),{logger:this.logger}),this.rotateButton.disable(),this.rotateButton.onClick((()=>{this.rotateAccessKeyModal.open()}))},a})),nc=h((e=>class extends(r(U,xe,Na,Ba,Ya,Za,qa,Va,tc,Xa,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)}))}})),oc=r((e=>class extends(nc(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",oc);const ic=(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 rc,sc,ac,cc,lc,dc,uc,hc,pc,fc;const gc=document.createElement("template");gc.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 vc=r(H)(HTMLElement);class mc extends vc{constructor(){var e;super(),rc.add(this),sc.set(this,new y({messages:[]})),ac.set(this,void 0),cc.set(this,void 0),lc.set(this,void 0),dc.set(this,{resize:o(this,rc,"m",fc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(gc.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,ac,this.shadowRoot.querySelector(".debugger"),"f"),o(this,ac,"f").style.top="32px",o(this,ac,"f").style.left=window.innerWidth-300-32+"px",i(this,cc,o(this,ac,"f").querySelector(".content"),"f"),i(this,lc,o(this,ac,"f").querySelector(".header"),"f")}updateData(e){o(this,sc,"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,c]=ic(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,ac,"f"),o(this,lc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,dc,"f").resize),(e=o(this,ac,"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,ac,"f").onresize=o(this,rc,"m",pc).bind(this),o(this,sc,"f").subscribe(o(this,rc,"m",uc).bind(this))}disconnectedCallback(){o(this,sc,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,dc,"f").resize)}}sc=new WeakMap,ac=new WeakMap,cc=new WeakMap,lc=new WeakMap,dc=new WeakMap,rc=new WeakSet,uc=function(e){o(this,rc,"m",hc).call(this,e),o(this,rc,"m",pc).call(this)},hc=function(e){o(this,cc,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},pc=function(){o(this,cc,"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)}))},fc=function(){const[e,t]=ic(o(this,ac,"f"),Number.parseInt(o(this,ac,"f").style.left,10),Number.parseInt(o(this,ac,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,ac,"f").style.top=`${t}px`,o(this,ac,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",mc);var yc=Object.freeze({__proto__:null,default:mc});return oc}();
5
+ this["descope-access-key-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{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function 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])),c=e=>{let t,n;return(...o)=>(t&&a(t,o)||(t=o,n=e(...o)),n)},l=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",x="https://static2.descope.com/pages",O=I&&localStorage.getItem("base.content.url")||"",j=(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})),A=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})),R=e=>t=>{var n,i,s;const a=r(k,C,A)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,o(this,n,"m",i).bind(this))}async init(){var e;c.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};R.missingAttrValidator=j;const E=h((e=>{const t=r(R({"project-id":j}))(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")||""}})),_="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,c,l,d;const u=r(k,E,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",c).call(this,e),l=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}. ${_}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${_}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(e){const r=O||this.baseStaticUrl;if(r)return o(this,t,"m",l).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 c=[];if(o(this,s,"f"))c.push(o(this,t,"m",l).call(this,e,o(this,s,"f"))),o(this,s,"f")===S&&c.push(o(this,t,"m",l).call(this,e,x));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&c.push(o(this,t,"m",l).call(this,e,n)),o(this,a,"f").has(S)||c.push(o(this,t,"m",l).call(this,e,S)),c.push(o(this,t,"m",l).call(this,e,x))}return 1===c.length?c[0]:c},l=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(R({"project-id":j}))(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,c;const l=r($,P,C)(e);return c=class extends l{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")},c})),U=h((e=>{var t,n,s,a,c,l,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",c).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",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),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 wc})),document.body.appendChild(o(this,n,"f"))},c=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},l=function(e,t){var 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()}`},N=(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)})),K=(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 K(s,r),o}catch(e){t(o,!0)}else try{return await N(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 c={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${W(a)}`};return i&&(c.integrity=i),[...e,c]}),[]))([...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}"`)}))}}})),F="base.ui.components.url",z=I&&localStorage.getItem(F),B=h((e=>{var t,n,s,a,c,l,d;const u=r(k,D,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",l).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",c).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},c=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},l=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await o(this,t,"m",n).call(this),i=z?void 0:await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[z],i),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),J=h((e=>{var t,n,i;const s=r(C,A)(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 V{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const H=h((e=>{const t=r(J)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new V(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(H)(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,ce,le;ee=new WeakMap;let de=class extends te{constructor(...e){super(...e),se.add(this),ae.set(this,void 0),ce.set(this,void 0),this.nodeName="descope-modal",o(this,se,"m",le).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",le).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,ce,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};ae=new WeakMap,ce=new WeakMap,se=new WeakSet,le=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 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,B)(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,B)(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(R({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',xe=h((e=>{var t,n,s,a,c,l,d,u,h,p,f,g,v,m,y,w,b,k,I,S,x,O;const j=r(R({theme:Se}),Ie,$,C,B,D,G,A,H)(e);return O=class extends j{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),l.set(this,void 0),d.set(this,void 0),I.set(this,(()=>{o(this,t,"m",S).call(this),o(this,x,"f").call(this,"os"===this.getAttribute("theme"))})),x.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,l,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,l=new WeakMap,d=new WeakMap,I=new WeakMap,x=new WeakMap,t=new WeakSet,c=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,i,r,s,a;const c=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,l=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 c||l?`[data-theme="${t}"]{${we({colors:{primary:c,secondary:l}},(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(F))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(F),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,l,"f")||(i(this,l,o(this,t,"m",u).call(this),"f"),o(this,l,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,l,"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 c=await o(this,t,"a",g);if(!c)return void(null===(n=o(this,s,"f"))||void 0===n||n.replaceSync(""));const l=((null===(r=c.light)||void 0===r?void 0:r.globals)||"")+((null===(a=c.dark)||void 0===a?void 0:a.globals)||"");o(this,s,"f")?o(this,s,"f").replaceSync(l):i(this,s,this.injectStyle(l),"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",c).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 c=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==c?void 0:c.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==c?void 0:c.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)},O}));var Oe=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),je=()=>Math.random().toString(36).substring(7).split("").join("."),Ce={INIT:`@@redux/INIT${je()}`,REPLACE:`@@redux/REPLACE${je()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${je()}`};function Ae(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 Re(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 Ee(e){let t=typeof e;return t=Re(e),t}function Te(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Ee(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: '${Ee(n)}'`);return n(Te)(e,t)}let o=e,i=t,r=new Map,s=r,a=0,c=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Ee(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),r=null}}}function h(e){if(!Ae(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Ee(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: '${Ee(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,i=o(i,e)}finally{c=!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: '${Ee(e)}`);o=e,h({type:Ce.REPLACE})},[Oe]: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: '${Ee(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[Oe](){return this}}}}}function _e(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]&&_e(`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(!Ae(e))return`The ${r} has unexpected type of "${Ee(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&&_e(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],c=n[r],l=e[r],d=c(l,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!==l}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 Ae(e)&&"type"in e&&"string"==typeof e.type}var De=Symbol.for("immer-nothing"),Ue=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 Ne(e,...t){{const n=We[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Ke=Object.getPrototypeOf;function qe(e){return!!e&&!!e[Le]}function Fe(e){return!!e&&(Be(e)||Array.isArray(e)||!!e[Ue]||!!e.constructor?.[Ue]||Ze(e)||Ge(e))}var ze=Object.prototype.constructor.toString();function Be(e){if(!e||"object"!=typeof e)return!1;const t=Ke(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)===ze}function Je(e,t){0===Ve(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Ve(e){const t=e[Le];return t?t.type_:Array.isArray(e)?1:Ze(e)?2:Ge(e)?3:0}function He(e,t){return 2===Ve(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ye(e,t,n){const o=Ve(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&&Be(e)){if(!Ke(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(Ke(e),n)}function et(e,t=!1){return nt(e)||qe(e)||!Fe(e)||(Ve(e)>1&&(e.set=e.add=e.clear=e.delete=tt),Object.freeze(e),t&&Je(e,((e,t)=>et(t,!0)))),e}function tt(){Ne(2)}function nt(e){return Object.isFrozen(e)}var ot,it={};function rt(e){const t=it[e];return t||Ne(0,e),t}function st(){return ot}function at(e,t){t&&(rt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ct(e){lt(e),e.drafts_.forEach(ut),e.drafts_=null}function lt(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[Le];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[Le].modified_&&(ct(t),Ne(4)),Fe(e)&&(e=pt(t,e),t.parent_||gt(t,e)),t.patches_&&rt("Patches").generateReplacementPatches_(n[Le].base_,e,t.patches_,t.inversePatches_)):e=pt(t,n,[]),ct(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==De?e:void 0}function pt(e,t,n){if(nt(t))return t;const o=t[Le];if(!o)return Je(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),Je(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&&Ne(5),qe(i)){const s=pt(e,i,r&&t&&3!==t.type_&&!He(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(Fe(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===Le)return e;const n=Xe(e);if(!He(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_||!Fe(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?.[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||He(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(){Ne(11)},getPrototypeOf:e=>Ke(e.base_),setPrototypeOf(){Ne(12)}},mt={};function yt(e,t){const n=e[Le];return(n?Xe(n):e)[t]}function wt(e,t){if(!(t in e))return;let n=Ke(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ke(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_))}Je(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))&&Ne(13),mt.set.call(this,e,t,void 0)},mt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Ne(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)||Ne(10,e),xt(e)}function xt(e){if(!Fe(e)||nt(e))return e;const t=e[Le];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 Je(n,((e,t)=>{Ye(n,e,xt(t))})),t&&(t.finalized_=!1),n}var Ot=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&&Ne(6),void 0!==n&&"function"!=typeof n&&Ne(7),Fe(e)){const i=dt(this),r=It(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?ct(i):lt(i)}return at(i,n),ht(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===De&&(o=void 0),this.autoFreeze_&&et(o,!0),n){const t=[],i=[];rt("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Ne(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){Fe(e)||Ne(8),qe(e)&&(e=St(e));const t=dt(this),n=It(e,void 0);return n[Le].isManual_=!0,lt(t),n}finishDraft(e,t){const n=e&&e[Le];n&&n.isManual_||Ne(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)))}},jt=Ot.produce;Ot.produceWithPatches.bind(Ot),Ot.setAutoFreeze.bind(Ot),Ot.setUseStrictShallowCopy.bind(Ot),Ot.applyPatches.bind(Ot),Ot.createDraft.bind(Ot),Ot.finishDraft.bind(Ot);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})}}},At=(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})}},Rt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Et=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 _t(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 Dt(){return{s:$t,v:void 0,o:null,p:null}}function Ut(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 c;if(t.s===Pt)c=t.v;else if(c=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,c)&&(c=e,0!==r&&r--);i="object"==typeof c&&null!==c||"function"==typeof c?new Mt(c):c}return a.s=Pt,a.v=c,c}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:c,memoizeOptions:l=[],argsMemoize:d=Ut,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Et(l),f=Et(u),g=Tt(e),v=c((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){i++;const e=_t(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Rt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Ct},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:At}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=_t(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,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:c,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Wt=Lt(Ut),Nt=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:()=>Nt});function Kt(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var qt=Kt(),Ft=Kt;((...e)=>{const t=Lt(...e)})(Ut);var zt="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)},Bt=e=>e&&"function"==typeof e.match;function Jt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Pe(t)&&t.type===e,n}function Vt(e){return"function"==typeof e&&"type"in e&&Bt(e)}function Ht(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 Fe(e)?jt(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 c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let i in c){const s=r?r+"."+i:i;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=tn(e,t,n.children[i],o[i],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function nn(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Ae(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),c=i.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=on(l,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(Ft(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=>c=>{const l=Ht(r,"ImmutableStateInvariantMiddleware");l.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(c);return l.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(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.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:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!Pe(u))return l(u);const h=l(u),p=Ht(s,"SerializableStateInvariantMiddleware");return c||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=Vt}=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)},ln="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:cn(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,c="tick"===e.type?queueMicrotask:"raf"===e.type?ln:"callback"===e.type?e.queueNotification:cn(e.timeout),l=()=>{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,c(l))),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,c;if("function"==typeof n)a=n;else{if(!Ae(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(c=o(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=$e;i&&(l=zt({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}}}(...c),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");c.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,l(...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)=>Bt(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=Jt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Jt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Jt(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||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,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),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:c});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(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,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,l,e,t.meta):o(t,l,e)}))])}catch(t){p=t instanceof gn?r(null,l,e,t.payload,t.meta):r(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,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 c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?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(Fe(e))return jt(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?Jt(e,s):Jt(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:c,settled:l,options:d}=n,u=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);c&&o.addCase(u.rejected,c);l&&o.addMatcher(u.settled,l);o.exposeCaseReducer(t,{fulfilled:s||xn,pending:a||xn,rejected:c||xn,settled:l||xn})}(s,r,a,t)}));const l=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,reducer:(e,t)=>(u||(u=c()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=c()),u.getInitialState()),getSelectors(t=l){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 xn(){}var On="listenerMiddleware";Jt(`${On}/add`),Jt(`${On}/removeAll`),Jt(`${On}/remove`);const jn=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()}})),An=h((e=>{const t=r(R({"widget-id":j}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),Rn=h((e=>{const t=r(D,An)(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]}}})),En=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($,An,Rn,En)(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})),_n=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(R({"flow-id":j}))(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,c,l,d,u,h,p,f,g;const v=r(q,k,C,D,E,$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",c).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,c=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 c=window.DescopeDebugLogs;if(!c)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 c({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",l).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")},l=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(xe(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,c=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)},c))}},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 Un(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])=>{Un(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,c,l;const d=r(k,G)(e);return l=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",c).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])=>{Un(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",c).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},c=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),{}}},l})),Nn=e=>e.selectedAccessKeysIds,Kn=e=>e.notifications,qn=Wt((e=>e.accessKeysList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{expireTimeFormatted:(null==e?void 0:e.expireTime)?new Date(1e3*((null==e?void 0:e.expireTime)||0)).toLocaleString():"Never",createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:(null==e?void 0:e.expireTime)&&new Date(1e3*((null==e?void 0:e.expireTime)||0))<new Date?"expired":null==e?void 0:e.status}))))),Fn=Wt(Nn,qn,((e,t)=>t.filter((t=>e.includes(t.id))))),zn=Wt(Nn,(e=>!!e.length)),Bn=Wt(Fn,(e=>e.every((e=>e.editable)))),Jn=Wt(Bn,zn,((e,t)=>e&&t)),Vn=Wt(Fn,(e=>e.some((e=>"expired"===e.status)))),Hn=Wt(Jn,Vn,((e,t)=>e&&!t)),Yn=Wt(Nn,(e=>1===e.length)),Zn=Wt(Fn,(e=>1===e.length?e[0].name:`${e.length} access keys`)),Gn=Wt(Hn,Yn,Fn,((e,t,n)=>{var o;return e&&t&&"active"===(null===(o=n[0])||void 0===o?void 0:o.status)})),Xn=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)}))}))},Qn=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}}),eo=({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)})}}),to=yn("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),no=Xn(to)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},Qn((e=>e.createAccessKey)),eo({getSuccessMsg:()=>"Access Key created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create access key</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),oo={action:to,reducer:no},io=yn("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),ro=Xn(io)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},Qn((e=>e.deleteAccessKey)),eo({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deleted successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to delete access key${["","s"]}`})),so={action:io,reducer:ro},ao=yn("accessKeys/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.accesskey.search(Object.assign(Object.assign({},o),e))})),co=Xn(ao)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},Qn((e=>e.accessKeysList))),lo={action:ao,reducer:co},uo=yn("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),ho=Xn(uo)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},Qn((e=>e.activateAccessKey)),eo({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} activated successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to activate access key${["","s"]}`})),po={action:uo,reducer:ho},fo=yn("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),go=Xn(fo)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},Qn((e=>e.deactivateAccessKey)),eo({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deactivated successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to deactivate access key${["","s"]}`})),vo={action:fo,reducer:go},mo=yn("accessKeys/rotate",((e,{extra:{api:t}})=>t.accesskey.rotate(e))),yo=Xn(mo)({onFulfilled:(e,t)=>{const n=e.accessKeysList.data.findIndex((e=>e.id===t.payload.key.id));n>=0&&(e.accessKeysList.data[n]=t.payload.key)}},Qn((e=>e.rotateAccessKey)),eo({getSuccessMsg:()=>"Access key rotated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to rotate access key</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),wo={action:mo,reducer:yo},bo=yn("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),ko={action:bo,reducer:Xn(bo)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},Qn((e=>e.tenantRoles)))},Io={accessKeysList:{data:[],loading:!1,error:null},createAccessKey:{loading:!1,error:null},activateAccessKey:{loading:!1,error:null},deactivateAccessKey:{loading:!1,error:null},deleteAccessKey:{loading:!1,error:null},rotateAccessKey:{loading:!1,error:null},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]};class So extends Error{}function xo(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 Oo(e,t){if("string"!=typeof e)throw new So("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 So(`Invalid token specified: missing part #${n+1}`);let i;try{i=xo(o)}catch(e){throw new So(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new So(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}So.prototype.name="InvalidTokenError";var jo={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},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 Co="<region>",Ao=`https://api.${Co}descope.com`,Ro=6e5,Eo=()=>{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")}},To=[503,520,521,522,524,530],_o=[100,5e3,5e3],Mo=e=>new Promise((t=>setTimeout(t,e))),$o=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&&To.includes(n.status)&&r<_o.length;)await Mo(_o[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},Po=(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=>Eo().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await $o(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return Eo().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:$o(n)};let Do;const Uo=()=>{if(Do)return Do;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 Do=`${t}-${n}`,Do};var Lo,Wo;(Wo=Lo||(Lo={})).get="GET",Wo.delete="DELETE",Wo.post="POST",Wo.put="PUT",Wo.patch="PATCH";const No=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(Co,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},Ko=(...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)),{})),qo={"Content-Type":"application/json"},Fo=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},zo=(e,t)=>{const n={"x-descope-sdk-session-id":Uo(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.72.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Bo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var Jo=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const c=e||Ao,l=Po(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:Ko(Fo(t,g),zo(t,o),(null==n?void 0:n.baseHeaders)||{},Bo(y)?qo:{},h),method:f,body:y},v?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(w.credentials=s||"include");const b=await l(No({path:d,baseUrl:c,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,c=!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)){c=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!c||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:Lo.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:Lo.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:Lo.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:Lo.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:Lo.delete,token:o,keepalive:i,disableRetry:r}),hooks:r,buildUrl:(e,n)=>No({projectId:t,baseUrl:c,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}}))},Vo=429;function Ho(e,t,n){var o;let i=Yo(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 Yo(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Oo(e)}function Zo(e){const{exp:t}=Yo(e);return(new Date).getTime()/1e3>t}function Go(e){let t=Yo(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Xo(e,t){return Ho(e,t,"permissions")}function Qo(e,t){return Ho(e,t,"roles")}const ei=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function ti(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===Vo&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function ni(e){var t;return(null===(t=Yo(e))||void 0===t?void 0:t.dct)||""}const oi=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),ii=(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 "))},ri=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),si=e=>t=>e.test(t),ai=si(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ci=si(/^\+[1-9]{1}[0-9]{3,14}$/),li=oi(ai,'"{val}" is not a valid email'),di=oi(ci,'"{val}" is not a valid phone number'),ui=oi((e=>e.length>=1),"Minimum length is 1");const hi=oi((e=>"string"==typeof e),"Input is not a string"),pi=oi((e=>Array.isArray(e)),"Input is not an array"),fi=oi((e=>"boolean"==typeof e),"Input is not a boolean"),gi=oi((e=>void 0===e),"Input is defined"),vi=ii([hi(),gi()],"Input is not a string or undefined"),mi=ii([pi(),fi()],"Input is not an array or boolean"),yi=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>ri(...e).validate(n[t]))),t(...n)),wi=e=>[hi(`"${e}" must be a string`)],bi=e=>[vi(`"${e}" must be string or undefined`)],ki=e=>[hi(`"${e}" must be a string`),ui(`"${e}" must not be empty`)],Ii=e=>[hi(`"${e}" must be a string`),li()],Si=e=>[hi(`"${e}" must be a string`),di()],xi=yi(ki("accessKey")),Oi=e=>({exchange:xi(((t,n)=>ti(e.post(jo.accessKey.exchange,{loginOptions:n},{token:t}))))}),ji=(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),Ci=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Ro,Ro)});var Ai,Ri;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Ai||(Ai={})),function(e){e.email="email"}(Ri||(Ri={}));const Ei=Object.assign(Object.assign({},Ai),Ri);var Ti;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ti||(Ti={}));const _i=ki("loginId"),Mi=yi(ki("token")),$i=yi(_i),Pi=yi(ki("pendingRef")),Di=yi(_i,Ii("email")),Ui=e=>({verify:Mi((t=>ti(e.post(jo.enchantedLink.verify,{token:t})))),signIn:$i(((n,o,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return ti(e.post(ei(jo.enchantedLink.signIn,Ei.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:$i(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return ti(e.post(ei(jo.enchantedLink.signUpOrIn,Ei.email),{loginId:n,URI:o,loginOptions:s,providerId:r}))})),signUp:$i(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ti(e.post(ei(jo.enchantedLink.signUp,Ei.email),{loginId:n,URI:o,user:i,loginOptions:a,providerId:s}))})),waitForSession:Pi(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ci(n);let s;const a=setInterval((async()=>{const n=await e.post(jo.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(ti(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Di(((t,n,o,i,r)=>ti(e.post(jo.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),Li=yi(ki("flowId")),Wi=yi(ki("executionId"),ki("stepId"),ki("interactionId")),Ni=yi(ki("executionId")),Ki=e=>({start:Li(((t,n,o,i,r,s,a,c=!1)=>ti(e.post(jo.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:c})))),next:Wi(((t,n,o,i,r,s,a=!1,c)=>ti(e.post(jo.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s,isCustomScreen:a,options:c})))),event:Ni(((t,n,o)=>ti(e.post(jo.flow.event,{executionId:t,events:n},{keepalive:o,disableRetry:!0}))))}),qi=ki("loginId"),Fi=yi(ki("token")),zi=yi(qi),Bi=yi(qi,Si("phone")),Ji=yi(qi,Ii("email")),Vi=Object.keys(Ei).filter((e=>e!==Ai.voice&&e!==Ai.im)),Hi=e=>({verify:Fi((t=>ti(e.post(jo.magicLink.verify,{token:t})))),signIn:Vi.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:zi(((n,i,r={},s)=>{var{providerId:a}=r,c=t(r,["providerId"]);return ti(e.post(ei(jo.magicLink.signIn,o),{loginId:n,URI:i,loginOptions:c,providerId:a},{token:s}))}))})),{}),signUp:Vi.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:zi(((n,i,r,s={})=>{var{providerId:a}=s,c=t(s,["providerId"]);return ti(e.post(ei(jo.magicLink.signUp,o),{loginId:n,URI:i,user:r,loginOptions:c,providerId:a}))}))})),{}),signUpOrIn:Vi.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:zi(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ti(e.post(ei(jo.magicLink.signUpOrIn,o),{loginId:n,URI:i,loginOptions:a,providerId:s}))}))})),{}),update:{email:Ji(((t,n,o,i,r)=>ti(e.post(jo.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(Ai).filter((e=>e!==Ai.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Bi(((t,o,i,r,s)=>ti(e.post(ei(jo.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var Yi;!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"}(Yi||(Yi={}));const Zi=yi(ki("code")),Gi=e=>({start:Object.assign(((t,n,o,i,r)=>ti(e.post(jo.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:i}))),Object.keys(Yi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i,r)=>ti(e.post(jo.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:i}))})),{})),exchange:Zi((t=>ti(e.post(jo.oauth.exchange,{code:t})))),startNative:(t,n,o)=>ti(e.post(jo.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>ti(e.post(jo.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>ti(e.get(jo.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>ti(e.post(jo.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>ti(e.post(jo.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Xi=ki("appId"),Qi=yi(Xi),er=e=>({connect:Qi(((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,ti(e.post(jo.outbound.connect,{appId:t,tenantId:i,tenantLevel:r,options:n},{token:o}))}))}),tr=ki("loginId"),nr=yi(tr,ki("code")),or=yi(tr),ir=yi(tr,Si("phone")),rr=yi(tr,Ii("email")),sr=e=>({verify:Object.keys(Ei).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:nr(((t,o)=>ti(e.post(ei(jo.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Ei).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:or(((n,i={},r)=>{var{providerId:s}=i,a=t(i,["providerId"]);return ti(e.post(ei(jo.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Ei).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:or(((n,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ti(e.post(ei(jo.otp.signUp,o),{loginId:n,user:i,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Ei).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:or(((n,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return ti(e.post(ei(jo.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:rr(((t,n,o,i)=>ti(e.post(jo.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(Ai).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ir(((t,o,i,r)=>ti(e.post(ei(jo.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),ar=yi(ki("tenant")),cr=yi(ki("code")),lr=e=>({start:ar(((t,n,o,i,r,s,a,c)=>ti(e.post(jo.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}),c&&{initiatedEmail:t})},i&&{token:i}))))),exchange:cr((t=>ti(e.post(jo.sso.exchange,{code:t}))))}),dr=ki("loginId"),ur=yi(dr,ki("code")),hr=yi(dr),pr=yi(dr),fr=e=>({signUp:hr(((t,n)=>ti(e.post(jo.totp.signUp,{loginId:t,user:n})))),verify:ur(((t,n,o,i)=>ti(e.post(jo.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:pr(((t,n)=>ti(e.post(jo.totp.update,{loginId:t},{token:n}))))}),gr=ki("loginId"),vr=ki("newPassword"),mr=yi(gr,ki("password")),yr=yi(gr),wr=yi(gr,vr),br=yi(gr,ki("oldPassword"),vr),kr=e=>({signUp:mr(((n,o,i,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ti(e.post(jo.password.signUp,{loginId:n,password:o,user:i,loginOptions:a,providerId:s}))})),signIn:mr(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return ti(e.post(jo.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:r}))})),sendReset:yr(((t,n,o)=>ti(e.post(jo.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:wr(((t,n,o)=>ti(e.post(jo.password.update,{loginId:t,newPassword:n},{token:o})))),replace:br(((t,n,o)=>ti(e.post(jo.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>ti(e.get(jo.password.policy))}),Ir=wi("loginId"),Sr=ki("loginId"),xr=wi("origin"),Or=yi(Sr,xr,ki("name")),jr=yi(Sr,xr),Cr=yi(Ir,xr),Ar=yi(Sr,xr,bi("token")),Rr=yi(ki("transactionId"),ki("response")),Er=e=>({signUp:{start:Or(((t,n,o,i,r)=>ti(e.post(jo.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:r,passkeyOptions:i})))),finish:Rr(((t,n)=>ti(e.post(jo.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Cr(((t,n,o,i,r)=>ti(e.post(jo.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:Rr(((t,n)=>ti(e.post(jo.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:jr(((t,n,o,i)=>ti(e.post(jo.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:o}))))},update:{start:Ar(((t,n,o,i,r)=>ti(e.post(jo.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i,mfa:r},{token:o})))),finish:Rr(((t,n)=>ti(e.post(jo.webauthn.update.finish,{transactionId:t,response:n}))))}}),Tr=wi("loginId"),_r=yi(Tr),Mr=yi(ki("pendingRef")),$r=e=>({signUpOrIn:_r(((n,o={})=>{var{providerId:i}=o,r=t(o,["providerId"]);return ti(e.post(jo.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:i}))})),signUp:_r(((n,o,i={})=>{var{providerId:r}=i,s=t(i,["providerId"]);return ti(e.post(jo.notp.signUp,{loginId:n,user:o,providerId:r,loginOptions:s}))})),signIn:_r(((n,o={},i)=>{var{providerId:r}=o,s=t(o,["providerId"]);return ti(e.post(jo.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:i}))})),waitForSession:Mr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Ci(n);let s;const a=setInterval((async()=>{const n=await e.post(jo.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(ti(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Pr=yi(ki("token")),Dr=yi(bi("token"));var Ur,Lr=yi([(Ur=ki("projectId"),oi(((e,t)=>n=>ri(...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",Ur))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return c=Jo({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:Oi(c),otp:sr(c),magicLink:Hi(c),enchantedLink:Ui(c),oauth:Gi(c),outbound:er(c),sso:lr(c),saml:lr(c),totp:fr(c),notp:$r(c),webauthn:Er(c),password:kr(c),flow:Ki(c),refresh:Dr(((e,t,n,o)=>{const i={};n&&(i.externalToken=n);const r=o?jo.tryRefresh:jo.refresh;return ti(c.post(r,i,{token:e,queryParams:t}))})),selectTenant:yi([hi("tenantId")],[vi('"token" must be string or undefined')])(((e,t)=>ti(c.post(jo.selectTenant,{tenant:e},{token:t})))),logout:Dr((e=>ti(c.post(jo.logout,{},{token:e})))),logoutAll:Dr((e=>ti(c.post(jo.logoutAll,{},{token:e})))),me:Dr((e=>ti(c.get(jo.me,{token:e})))),myTenants:yi([mi('"tenants" must a string array or a boolean')],[vi('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,ti(c.post(jo.myTenants,n,{token:t}))})),history:Dr((e=>ti(c.get(jo.history,{token:e})))),isJwtExpired:Pr(Zo),getTenants:Pr(Go),getJwtPermissions:Pr(Xo),getJwtRoles:Pr(Qo),getCurrentTenant:Pr(ni),httpClient:c};var c})),Wr=Object.assign(Lr,{DeliveryMethods:Ei});
6
+ /*! js-cookie v3.0.8 | MIT */function Nr(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 Kr=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=Nr({},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,"",Nr({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Nr({},this.attributes,t))},withConverter:function(t){return e(Nr({},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 qr={default:"endpoint"},Fr="Blocked by CSP",zr="The endpoint parameter is not a valid URL",Br="Failed to load the JS script of the agent",Jr="9319";function Vr(e,t){var n,o,i,r,s,a=[],c=(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===Fr||s===zr)n.exclude(),r=0;else if(s===Jr)n.exclude();else if(s===Br){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!i.has(c)&&(i.add(c),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+o()-Date.now()]}]),l=c[0],d=c[1];if(void 0===l)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(l).then((function(e){return[e,a]}))}var Hr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Yr=Hr;function Zr(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:Hr,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=l[0],u=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(c,s);return Vr(e,Gr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Jr?new Error(Br):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 Gr(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(zr);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(Br))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(Fr)})).then(Xr)}function Xr(){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(Jr);return n}const Qr="3.2.0",es="undefined"!=typeof window,ts=Math.pow(2,31)-1,ns=`https://descopecdn.com/npm/oidc-client-ts@${Qr}/dist/browser/oidc-client-ts.min.js`,os=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Qr}/dist/browser/oidc-client-ts.min.js`,is=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let rs;const ss=e=>{try{return Oo(e).exp}catch(e){return null}},as=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ss(n)},cs=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?ss(o):void 0)},ls=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||cs(e),cookieExpiration:e.cookieExpiration||as(e)},s)},ds=(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},us=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 ls(n)},hs=()=>es&&!!window.descopeBridge,ps=(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 is.includes(n)},fs=void 0!==rs||es&&void 0!==window.localStorage,gs=(e,t)=>{var n,o;return null===(o=null===(n=rs||es&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},vs=e=>{var t,n;return null===(n=null===(t=rs||es&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},ms=e=>{var t,n;return null===(n=null===(t=rs||es&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},ys=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==rs?void 0:rs.key)||void 0===t?void 0:t.call(rs,e))&&void 0!==n?n:es&&(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},ws=e=>{var t,n;return es&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},bs=e=>{var t,n;try{es&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},ks=(...e)=>{console.debug(...e)},Is=(...e)=>{console.warn(...e)},Ss=(e,t)=>{let n;var o;return t>0?(n=1e3*t,ks(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>ts&&(ks(`Timeout is too large (${n}ms), setting it to ${ts}ms`),n=ts),n},xs="DS",Os="DSR",js="DSI",Cs="DSRCN";function As(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=Rs(o);Kr.set(e,t,{path:i,domain:l?o:void 0,expires:c,sameSite:r,secure:a})}}function Rs(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 Es=e=>(null==e?void 0:e.cookieName)||xs,Ts=e=>(null==e?void 0:e.cookieName)||Os;function _s(e="",t){return Kr.get(Ts(t))||vs(`${e}${Os}`)||""}function Ms(e="",t){return Kr.get(Es(t))||vs(`${e}${xs}`)||""}function $s(e=""){return vs(`${e}${js}`)||""}function Ps(e="",t,n,o){ms(`${e}${Os}`),ms(`${e}${xs}`),ms(`${e}${js}`),ms(`${e}${Cs}`);const i=Es(t);Kr.remove(i,null==o?void 0:o.session);const r=Ts(n);Kr.remove(r,null==o?void 0:o.refresh)}const Ds=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||_s(e,t)});if(!n){const t=function(e=""){return vs(`${e}${Cs}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return vs(`${e}DTD`)||""}(e);r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return vs(`${e}DKD`)||""}(e);return s&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-known-device-token":s})),i},Us=es&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Ls="vsid",Ws="vrid",Ns=(e=!1)=>{const t=vs("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Ks=async(e,t=Us)=>{try{if(Ns())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=Zr({apiKey:e,endpoint:[o.toString(),qr],scriptUrlPattern:[r,Yr]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Ls]:e,[Ws]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};gs("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},qs=e=>{const t=Ns(!0);return t&&e.body&&(e.body.fpData=t),e},Fs="descopeFlowNonce",zs="X-Descope-Flow-Nonce",Bs="/v1/flow/start",Js="/v1/flow/next",Vs=(e,t=Fs)=>`${t}${e}`,Hs=(e,t=Fs)=>{try{const n=Vs(e,t),o=vs(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(Ys(e,t),null):{value:i.value,seq:i.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},Ys=(e,t=Fs)=>{try{const n=Vs(e,t);ms(n)}catch(e){console.error("Error removing flow nonce:",e)}},Zs=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Gs=e=>{var t;return e.path===Js&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Zs(e.body.executionId):null},Xs="dls_last_user_login_id",Qs="dls_last_user_display_name",ea=e=>gs(Xs,e),ta=()=>vs(Xs),na=()=>vs(Qs),oa=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=ta(),r=na();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)},ia="DSLI",ra=e=>async(...t)=>{const n=await e(...t);return bs(ia),n};function sa(){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 aa(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=fa(n.publicKey.challenge),n.publicKey.user.id=fa(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=fa(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:ga(n.rawId),type:n.type,response:{attestationObject:ga(n.response.attestationObject),clientDataJSON:ga(n.response.clientDataJSON)}})}catch(e){throw await da(e,t,!0)}var n}async function ca(e){const t=ha(e);try{return pa(await navigator.credentials.get(t))}catch(e){throw await da(e,t,!1)}}async function la(e,t){const n=ha(e);n.signal=t.signal,n.mediation="conditional";try{return pa(await navigator.credentials.get(n))}catch(e){throw await da(e,n,!1)}}async function da(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 ua())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 ua(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function ua(e=!1){var t,n;if(!es)return Promise.resolve(!1);if(hs()){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 ha(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=fa(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=fa(e.id)})),n}function pa(e){return JSON.stringify({id:e.id,rawId:ga(e.rawId),type:e.type,response:{authenticatorData:ga(e.response.authenticatorData),clientDataJSON:ga(e.response.clientDataJSON),signature:ga(e.response.signature),userHandle:e.response.userHandle?ga(e.response.userHandle):void 0}})}function fa(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ga(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var va,ma=(va=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 aa(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 ca(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 aa(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await ca(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 aa(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:aa,get:ca,isSupported:ua,conditional:la}}),(...e)=>{const t=va(...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 ya="/fedcm/config";async function wa(e,t){var n;try{await ba(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function ba(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 c=a.data.clientId;return new Promise((e=>{var a,l;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===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,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 ka=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await ua(),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 Ia;const Sa=(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",(()=>{Sa(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),xa=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{Ia||(Ia=(async()=>{try{return require("oidc-client-ts")}catch(e){return Sa([ns,os],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await Ia;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,c,l;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,c=`${a}_user`,l="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,c=`${a}_user`,l="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)||l,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:c}})(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)))),gs(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=vs(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 c=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(c)))),c},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 ms(i),t||window.location.replace(s),r}}},Oa=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,rs=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return es?(o&&i&&Ks(o).catch((()=>null)),e(ds(r,{beforeRequest:qs}))):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.1"},t.baseHeaders)}))),(e=>t=>{const n=sa(),o=sa(),i=sa(),r=sa(),s=e(ds(t,{afterRequest:async(e,t)=>{if(ps(e,t))ks("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 us(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:c}=await us(t);s&&o.pub(s),c&&r.pub(c),(a||s)&&n.pub(a||42)}}})),a=ji(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=Fs}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(s);((e=Fs)=>{try{if(!fs)return;for(let i=0;i<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==rs?void 0:rs.length)&&void 0!==t?t:es&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=ys(i);if(t&&t.startsWith(e)){const n=vs(t);if(n)try{JSON.parse(n).expiry<Date.now()&&ms(t)}catch(e){ms(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=e(ds(s,{afterRequest:async(e,t)=>{var n;if(e.path!==Bs&&e.path!==Js)return;const{nonce:o,seq:i,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(zs),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=Gs(e)),{nonce:n,seq:o,executionId:Zs(i)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!o||!s)return;const a=e.path===Bs,c=null===(n=Hs(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==i&&void 0!==c&&i<=c||((e,t,n,o=Fs,i)=>{try{const r=Vs(e,o),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:i};gs(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,o,a,r,null!=i?i:a?void 0:c)},beforeRequest:e=>{if(e.path===Js){const t=Gs(e);if(t){const n=((e,t=Fs)=>{var n,o;return null!==(o=null===(n=Hs(e,t))||void 0===n?void 0:n.value)&&void 0!==o?o:null})(t,r);n&&(e.headers=e.headers||{},e.headers[zs]=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(ds(t,{afterRequest:async(e,t)=>{if(ps(e,t))return void bs(ia);const n=await us(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,o;try{es&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o||o.call(n,e,t))}catch(e){}})(ia,String(n.sessionExpiration))}}));return ji(n,["logout","logoutAll","oidc.logout"],ra)}),(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||hs())return Object.assign(e(i),{markUserActive:()=>{Is("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,d,u=null,h=!1,p=!1;s&&(ks("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),es&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(ks("Expiration time passed, refreshing session"),f.refresh(_s()||d))}));const f=e(ds(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i,nextRefreshSeconds:r}=await us(t);if(ps(e,t))ks("Session invalidated, canceling all timers"),a();else if(n||i){if(l=((e,t)=>{if(t)return new Date(1e3*t);ks("Could not extract expiration time from session token, trying to decode the token");try{const t=Oo(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!l)return void ks("Could not extract expiration time from session token");d=o,h=r>0;const e=Ss(l,r);if(a(),e<=2e4)return void ks("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});ks(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),c((()=>{if(es&&"hidden"===document.visibilityState)ks("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return ks("Skipping refresh due to timer - user is idle"),void(p=!0);ks("Refreshing session due to timer"),f.refresh(_s()||o)}}),e)}}}));return Object.assign(ji(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return ks("Clearing all timers"),a(),n})),{markUserActive:u?()=>{ks("markUserActive() called"),h||ks("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(ks("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(_s()||d))}:()=>{Is("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:ta,getLastUserDisplayName:na});const s=e(ds(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=ls((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?(ea(r),(e=>{gs(Qs,e)})(s)):(null==i?void 0:i.loginId)&&ea(i.loginId)}}));let a=ji(s,["flow.start"],oa);return a=ji(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(ms(Xs),ms(Qs)),o})(i)),Object.assign(a,{getLastUserLoginId:ta,getLastUserDisplayName:na})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,c=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!es)return e(Object.assign({refreshCookieName:a},c));let l;const d=e(ds(Object.assign({refreshCookieName:a},c),{beforeRequest:Ds(s,r,a),afterRequest:async(e,t)=>{if(ps(e,t))ks("Session invalidated, clearing persisted tokens"),Ps(s,i,r,l);else{const e=await us(t);e.cookieName?gs(`${s||""}${Cs}`,e.cookieName):e.refreshJwt&&ms(`${s||""}${Cs}`);const n=((e={},t=!1,n="",o=!1)=>{var i,r,s,a;const{sessionJwt:c,refreshJwt:l,trustedDeviceJwt:d,knownDeviceJwt:u}=e;let h;if(l)if(o){ms(`${n}${Os}`);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,c=Ts(o);s&&"https:"!==window.location.protocol&&Is("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});As(c,l,d);const u=Rs(a);h=Object.assign(Object.assign({},h),{refresh:{path:d.cookiePath,domain:u?a:void 0}})}else{const e=Ts(o);Kr.remove(e),gs(`${n}${Os}`,l)}if(c)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=Es(t);o&&"https:"!==window.location.protocol&&Is("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 l=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});As(r,c,l);const d=Rs(i);h=Object.assign(Object.assign({},h),{session:{path:l.cookiePath,domain:d?i:void 0}})}else gs(`${n}${xs}`,c);return e.idToken&&gs(`${n}${js}`,e.idToken),d&&gs(`${n}DTD`,d),u&&gs(`${n}DKD`,u),h})(e,i,s,r);n&&(l=n)}}})),u=ji(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return Ps(e,t,n,null==o?void 0:o()),s})(s,i,r,(()=>l)));return Object.assign(u,{getRefreshToken:()=>_s(s,r),getSessionToken:()=>Ms(s,i),getIdToken:()=>$s(s)})}))((e=>{const t=Wr(e),n=xa(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,i)=>{var r;if(hs())return ks(`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&&es&&void 0!==window.localStorage&&!ws(ia)&&!vs(Xs)&&!ws("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Ms(),a=_s();let c="";if(e.getExternalToken)try{c=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){ks("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},c,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:ka(t),webauthn:ma(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){wa(o,e)},requestAuthentication(e){wa(o,e)}},async oneTap(e,t,n,i,r){await ba(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+ya),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>es&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+ya);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})),ja={search:"/v1/mgmt/accesskey/search",deleteBatch:"/v1/mgmt/accesskey/delete/batch",create:"/v1/mgmt/accesskey/create",deactivate:"/v1/mgmt/accesskey/deactivate/batch",activate:"/v1/mgmt/accesskey/activate/batch",rotate:"/v1/mgmt/accesskey/rotate"},Ca={roles:"/v1/mgmt/role/all"},Aa=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)})),Ra=(...e)=>n(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((n=>{const o=[],i=(new Date).getTime()/1e3+2592e3,r=new Date(i).toLocaleString();for(let e=1;e<10;e+=1)o.push({id:`access-key-id-${e}`,name:`Access Key ${e}`,createdBy:`User ${e}`,editable:!0,expireTime:i,expireTimeFormatted:r,createdTime:i,createdTimeFormatted:r,roleNames:[`Role ${e}`],permittedIps:["127.1.2.3"],status:"active",clientId:`Client ID ${e}`,boundUserId:`User ${e}`});t.forEach((e=>{o.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])}))})),n(o.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.createdBy.toLowerCase().includes(e.toLowerCase()))))}))})),Ea=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:n,permittedIps:o},i){const r=Math.random().toString(10).substring(15);return new Promise((s=>{s({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${r}`,name:e||`Access Key ${r}`,createdBy:n||`User ${r}`,editable:!0,expireTime:i,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:o,status:"active",clientId:`Client ID ${r}`,boundUserId:n||`User ${r}`}})}))})),Ta=()=>n(void 0,void 0,void 0,(function*(){})),_a=()=>n(void 0,void 0,void 0,(function*(){})),Ma=()=>n(void 0,void 0,void 0,(function*(){})),$a=e=>n(void 0,[e],void 0,(function*({id:e}){return new Promise((t=>{t({cleartext:Math.random().toString(20).substring(2),key:{id:e,name:`Access Key ${e}`,createdBy:"User",editable:!0,expireTime:(new Date).getTime()/1e3+2592e3,createdTime:(new Date).getTime()/1e3,roleNames:[],permittedIps:[],status:"active",clientId:`Client ID ${e}`,boundUserId:"User"}})}))})),Pa=e=>new Promise((t=>{const n=[];for(let t=1;t<5;t+=1)n.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:n})})),Da=({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 Ra({page:n,limit:i,text:r,sort:s});const a=yield e.post(ja.search,{limit:i,page:n,text:r,sort:s},{queryParams:{tenant:t}});yield Aa(a);return(yield a.json()).keys})),deleteBatch:i=>n(void 0,void 0,void 0,(function*(){if(o)return Ma();const n=yield e.post(ja.deleteBatch,{ids:i},{queryParams:{tenant:t}});return yield Aa(n),n.json()})),create:i=>n(void 0,[i],void 0,(function*({name:n,expiration:i,roleNames:r,userId:s,permittedIps:a}){const c=new Date;c.setDate(c.getDate()+ +i);const l="0"===i[0]?0:Math.floor(c.getTime()/1e3);if(o)return Ea({name:n,expiration:i,roleNames:r,userId:s,permittedIps:a},l);const d=yield e.post(ja.create,{name:n,expireTime:l,roleNames:r,userId:s,permittedIps:a},{queryParams:{tenant:t}});yield Aa(d);return yield d.json()})),activate:i=>n(void 0,void 0,void 0,(function*(){if(o)return Ta();const n=yield e.post(ja.activate,{ids:i},{queryParams:{tenant:t}});yield Aa(n);return yield n.json()})),deactivate:i=>n(void 0,void 0,void 0,(function*(){if(o)return _a();const n=yield e.post(ja.deactivate,{ids:i},{queryParams:{tenant:t}});yield Aa(n);return yield n.json()})),rotate:i=>n(void 0,[i],void 0,(function*({id:n}){if(o)return $a({id:n});const i=yield e.post(ja.rotate,{id:n},{queryParams:{tenant:t}});yield Aa(i);return yield i.json()}))}),Ua=({httpClient:e,tenant:t,mock:o})=>({getTenantRoles:()=>n(void 0,void 0,void 0,(function*(){if(o)return Pa(t);const n=yield e.get(Ca.roles,{queryParams:{tenant:t}});return yield Aa(n),n.json()}))}),La=h((e=>{var t,s,a,c;const l=r(E,A,k,T,_n,R({tenant:R.missingAttrValidator}))(e);return c=class extends l{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=Oa(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"access-key-management-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.10.4"}}));return{accesskey:Da({httpClient:i.httpClient,tenant:t,mock:n}),tenant:Ua({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")},c})),Wa=h((e=>{const t=r(jn({name:"widget",initialState:Io,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{oo.reducer(e),so.reducer(e),lo.reducer(e),po.reducer(e),vo.reducer(e),wo.reducer(e),ko.reducer(e)},asyncActions:{searchAccessKeys:lo.action,createAccessKey:oo.action,activateAccessKeys:po.action,deactivateAccessKeys:vo.action,deleteAccessKeys:so.action,rotateAccessKey:wo.action,getTenantRoles:ko.action}}),C,k,La)(e);return class extends t{constructor(...e){super(...e),this.state=Io,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Na=h((e=>{var t,i,a;return a=class extends(r(k,C,B,G,Tn("access-key-management-widget"),Wa)(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.searchAccessKeys(),this.actions.getTenantRoles()]),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})),Ka=h((e=>{var t,i,s,a,l;return l=class extends(r(Wa,k,Na)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{this.accessKeysTable.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.searchAccessKeys({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.accessKeysTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{o(this,a,"f").call(this,e.target,e.detail)}))})),o(this,s,"f").call(this,qn(this.state)),this.subscribe(o(this,s,"f").bind(this),qn)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,i=function(){var e;this.accessKeysTable=new re(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="access-keys-table"]'),{logger:this.logger}),this.accessKeysTable.onSelectedItemsChange((e=>{this.actions.setSelectedAccessKeysIds(e.detail.value.map((({id:e})=>e)))}))},l})),qa=h((e=>{var t,i,a;return a=class extends(r(Wa,ve,k,Na)(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.activateAccessKeysModal=this.createModal(),this.activateAccessKeysModal.setContent(s(yield this.fetchWidgetPage("activate-access-keys-modal.html")));const t=new ne((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.activateAccessKeysModal.close()));const n=new ne((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Fn(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const o=new fe(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=Zn(this.state);o.text=`Activate ${e}?`}}))},a})),Fa=h((e=>{var t,i,s,a;return a=class extends(r(k,Na,Wa,qa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{e?this.activateButton.enable():this.activateButton.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.activateButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="activate-access-keys"]'),{logger:this.logger}),this.activateButton.disable(),this.activateButton.onClick((()=>{this.activateAccessKeysModal.open()}))},a})),za=h((e=>{var t,i,a;return a=class extends(r(Wa,ve,Cn,k,Na)(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(){return n(this,void 0,void 0,(function*(){this.createdAccessKeyModal=this.createModal(),this.createdAccessKeyModal.setContent(s(yield this.fetchWidgetPage("created-access-key-modal.html")));new ne((()=>{var e;return null===(e=this.createdAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.createdAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.createdAccessKeyModal.ele),this.createdAccessKeyModal.close()}))}))},a})),Ba=h((e=>{var t,a,c,l,d;return d=class extends(r(Wa,ve,Cn,k,Na,za)(e)){constructor(){super(...arguments),t.add(this),a.set(this,void 0),l.set(this,(()=>n(this,void 0,void 0,(function*(){var e,t;yield o(this,a,"f").setData(null===(t=this.state,e=t.tenantRoles.data||[])||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",c).call(this)}))}},a=new WeakMap,l=new WeakMap,t=new WeakSet,c=function e(){return n(this,void 0,void 0,(function*(){this.createAccessKeyModal=this.createModal(),this.createAccessKeyModal.setContent(s(yield this.fetchWidgetPage("create-access-key-modal.html")));new ne((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.createAccessKeyModal.close(),this.resetFormData(this.createAccessKeyModal.ele)}));new ne((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>n(this,void 0,void 0,(function*(){var e,t;if(this.validateForm(this.createAccessKeyModal.ele)){const n=yield this.actions.createAccessKey(Object.assign({},this.getFormData(this.createAccessKeyModal.ele)));this.createAccessKeyModal.close(),(null===(e=null==n?void 0:n.payload)||void 0===e?void 0:e.cleartext)&&(this.setFormData(this.createdAccessKeyModal.ele,{"generated-key":null===(t=null==n?void 0:n.payload)||void 0===t?void 0:t.cleartext}),this.createdAccessKeyModal.open())}})))),i(this,a,new he((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),o(this,l,"f").call(this),this.createAccessKeyModal.afterClose=()=>{o(this,t,"m",e).call(this)}}))},d})),Ja=h((e=>{var t,i,s;return s=class extends(r(k,Ba,Na)(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-access-key"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createAccessKeyModal.open()))},s})),Va=h((e=>{var t,i,a;return a=class extends(r(Wa,ve,k,Na)(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.deactivateAccessKeysModal=this.createModal(),this.deactivateAccessKeysModal.setContent(s(yield this.fetchWidgetPage("deactivate-access-keys-modal.html")));const t=new ne((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deactivateAccessKeysModal.close()));const n=new ne((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Fn(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const o=new fe(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=Zn(this.state);o.text=`Deactivate ${e}?`}}))},a})),Ha=h((e=>{var t,i,s,a;return a=class extends(r(k,Na,Wa,Va)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{e?this.deactivateButton.enable():this.deactivateButton.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.deactivateButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="deactivate-access-keys"]'),{logger:this.logger}),this.deactivateButton.disable(),this.deactivateButton.onClick((()=>{this.deactivateAccessKeysModal.open()}))},a})),Ya=h((e=>{var t,i,a;return a=class extends(r(Wa,ve,k,Na)(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.deleteAccessKeysModal=this.createModal(),this.deleteAccessKeysModal.setContent(s(yield this.fetchWidgetPage("delete-access-keys-modal.html")));const t=new ne((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteAccessKeysModal.close()));const n=new ne((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Fn(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const o=new fe(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=Zn(this.state);o.text=`Delete ${e}?`}}))},a})),Za=h((e=>{var t,i,s,a;return a=class extends(r(k,Na,Wa,Ya)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((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-access-keys"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteAccessKeysModal.open()}))},a})),Ga=h((e=>{var t,i,s,a;return a=class extends(r(k,Na,Wa)(e)){constructor(){super(...arguments),t.add(this),i.set(this,d((()=>{this.actions.searchAccessKeys({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 Xa={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},Qa=h((e=>{var t,i,s,a,l;return l=class extends(r(k,Wa,ye,C)(e)){constructor(){super(...arguments),t.add(this),a.set(this,c((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),Kn)}))}},a=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const n=Xa[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"})},l})),ec=h((e=>{var t,i,a;return a=class extends(r(Wa,ve,Cn,k,Na)(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(){return n(this,void 0,void 0,(function*(){this.rotatedAccessKeyModal=this.createModal(),this.rotatedAccessKeyModal.setContent(s(yield this.fetchWidgetPage("rotated-access-key-modal.html")));new ne((()=>{var e;return null===(e=this.rotatedAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.rotatedAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.rotatedAccessKeyModal.ele),this.rotatedAccessKeyModal.close()}))}))},a})),tc=h((e=>{var t,i,a;return a=class extends(r(Wa,ve,Cn,k,Na,ec)(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.rotateAccessKeyModal=this.createModal(),this.rotateAccessKeyModal.setContent(s(yield this.fetchWidgetPage("rotate-access-key-modal.html")));const t=new ne((()=>{var e;return null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.rotateAccessKeyModal.close()));const o=new ne((()=>{var e;return null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});o.onClick((()=>n(this,void 0,void 0,(function*(){var e,t;const n=null===(e=Fn(this.state))||void 0===e?void 0:e[0];if(!n)return void this.rotateAccessKeyModal.close();const o=yield this.actions.rotateAccessKey({id:n.id});this.rotateAccessKeyModal.close(),(null===(t=null==o?void 0:o.payload)||void 0===t?void 0:t.cleartext)&&(this.setFormData(this.rotatedAccessKeyModal.ele,{"generated-key":o.payload.cleartext}),this.rotatedAccessKeyModal.open())}))));const i=new fe(null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.rotateAccessKeyModal.beforeOpen=()=>{const e=Zn(this.state);i.text=`Rotate ${e}?`}}))},a})),nc=h((e=>{var t,i,s,a;return a=class extends(r(k,Na,Wa,tc)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{e?this.rotateButton.enable():this.rotateButton.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),Gn)}))}},s=new WeakMap,t=new WeakSet,i=function(){var e;this.rotateButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="rotate-access-keys"]'),{logger:this.logger}),this.rotateButton.disable(),this.rotateButton.onClick((()=>{this.rotateAccessKeyModal.open()}))},a})),oc=h((e=>class extends(r(U,xe,Ka,Ja,Za,Ga,Fa,Ha,nc,Qa,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)}))}})),ic=r((e=>class extends(oc(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",ic);const rc=(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 sc,ac,cc,lc,dc,uc,hc,pc,fc,gc;const vc=document.createElement("template");vc.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 mc=r(H)(HTMLElement);class yc extends mc{constructor(){var e;super(),sc.add(this),ac.set(this,new y({messages:[]})),cc.set(this,void 0),lc.set(this,void 0),dc.set(this,void 0),uc.set(this,{resize:o(this,sc,"m",gc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(vc.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,cc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,cc,"f").style.top="32px",o(this,cc,"f").style.left=window.innerWidth-300-32+"px",i(this,lc,o(this,cc,"f").querySelector(".content"),"f"),i(this,dc,o(this,cc,"f").querySelector(".header"),"f")}updateData(e){o(this,ac,"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,c]=rc(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,cc,"f"),o(this,dc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,uc,"f").resize),(e=o(this,cc,"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,cc,"f").onresize=o(this,sc,"m",fc).bind(this),o(this,ac,"f").subscribe(o(this,sc,"m",hc).bind(this))}disconnectedCallback(){o(this,ac,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,uc,"f").resize)}}ac=new WeakMap,cc=new WeakMap,lc=new WeakMap,dc=new WeakMap,uc=new WeakMap,sc=new WeakSet,hc=function(e){o(this,sc,"m",pc).call(this,e),o(this,sc,"m",fc).call(this)},pc=function(e){o(this,lc,"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("")},fc=function(){o(this,lc,"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)}))},gc=function(){const[e,t]=rc(o(this,cc,"f"),Number.parseInt(o(this,cc,"f").style.left,10),Number.parseInt(o(this,cc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,cc,"f").style.top=`${t}px`,o(this,cc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",yc);var wc=Object.freeze({__proto__:null,default:yc});return ic}();
7
7
  //# sourceMappingURL=index.js.map