@descope/access-key-management-widget 0.5.6 → 0.5.8

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.5.6
3
+ * @descope/access-key-management-widget v0.5.8
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 r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function r(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,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,r)=>{var i;return`${t}${o}${(null===(i=null==n?void 0:n[r])||void 0===i?void 0:i[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=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 h,p,f,g;function v(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!v(i,s))return!1}else if(i!==s)return!1}return!0}let m=class{constructor(e={},{forceUpdate:t=!1}={}){h.set(this,void 0),p.set(this,{}),f.set(this,0),g.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,h,"f")):e,n=Object.assign(Object.assign({},o(this,h,"f")),t);if(o(this,g,"f")||!v(o(this,h,"f"),n)){const e=o(this,h,"f");r(this,h,n,"f"),Object.freeze(o(this,h,"f")),setTimeout((()=>{Object.values(o(this,p,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},r(this,h,e,"f"),r(this,g,t,"f")}get current(){return Object.assign({},o(this,h,"f"))}subscribe(e){return r(this,f,o(this,f,"f")+1,"f"),o(this,p,"f")[o(this,f,"f")]=e,o(this,f,"f").toString()}unsubscribe(e){const t=!!o(this,p,"f")[e];return t&&delete o(this,p,"f")[e],t}unsubscribeAll(){return r(this,p,{},"f"),!0}};h=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap;const y=["error","warn","info","debug"],w=u((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",i).call(this,console))}set logger(e){r(this,n,o(this,t,"m",i).call(this,e||console),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return y.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})),b="undefined"!=typeof localStorage,k=b&&localStorage.getItem("base.content.url")||"",S=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,I=u((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(r(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),x=u((e=>{var t,n;const r=i(w,I)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,r;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,r=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>r(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&r(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const r=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(r,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),O=e=>t=>{var n,r,s;const a=i(w,I,x)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,o(this,n,"m",r).bind(this))}async init(){var e;c.forEach((e=>o(this,n,"m",r).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,r=function(t,n){const o=e[t],r="function"==typeof o?o(t,n):o;r&&this.logger.error(r)},s};O.missingAttrValidator=S;const j=u((e=>{const t=i(O({"project-id":S}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),C=u((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),R="Trying the next fallback URL...",A=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)}};function E({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o="https://static.descope.com/pages"}){const r=new URL(o);return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,n,t),r.baseUrl=o,r}const T=u((e=>{var t,n,s,a,c;const l=i(w,j,C)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0)}async fetchStaticResource(e,n){const i=o(this,t,"m",a).call(this,e),c=Array.isArray(i)?e=>{if(e!==i.length-1){const{baseUrl:t}=i[e];r(this,s,t,"f")}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const r=Array.isArray(e)?e:[e];for(let e=0;e<r.length;e++){const i=r[e],s=e===r.length-1;try{const r=await A(i.toString(),t,{logger:n});if(r.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${i}`),r;const a=`Error fetching URL ${i} [${r.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${R}`)}catch(e){const t=`Error fetching URL ${i} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${R}`)}}})(i,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(e){const t=k||this.baseStaticUrl;if(t)return E({projectId:this.projectId,filename:e,baseUrl:t});const i=o(this,n,"f")!==this.baseUrl,a=i&&!!this.baseUrl;i&&(r(this,n,this.baseUrl,"f"),r(this,s,void 0,"f"));const c=E({projectId:this.projectId,filename:e,baseUrl:o(this,s,"f")});if(!a)return c;return[E({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),c]},c})),_=u((e=>{var t,n;const r=i(O({"project-id":S}))(e);return n=class extends r{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})),M=u((e=>{var t,n,s,a,c;const l=i(T,_,I)(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")||r(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){r(this,s,void 0,"f")},c})),$=u((e=>{var t,n,s,a,c,l,d;return d=class extends(i(I,w)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,r)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,r),"debug"===e&&o(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var r;null===(r=super.onLogEvent)||void 0===r||r.call(this,e,n),"error"===e&&o(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),r(this,n,null,"f")},a=async function(){r(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return ya})),document.body.appendChild(o(this,n,"f"))},c=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},l=function(e,t){var r;e&&(null===(r=o(this,n,"f"))||void 0===r||r.updateData({title:e,description:t}))},d})),U=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],P=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()}`},D=(e,t)=>new Promise(((n,o)=>{const r=(e=>{const t=document.createElement("script");return t.id=e,t})(e);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),n(r)},r.src=t.toString(),document.body.appendChild(r)})),L=e=>"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)}))})),W=u((e=>{const t=i(w)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[]){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"`),(async(e,t)=>{for(const o of e){const{id:e,url:r}=o,i=(n=e,document.querySelector(`script#${n}`));if(i)try{return await L(i),o}catch(e){t(o,!0)}else try{return await D(e,r),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="")=>e.reduce(((e,r)=>{const i=r;if(!i)return e;let s;try{s=new URL(i)}catch(e){throw new Error(`Invalid URL: ${i}`)}return"/"!==s.pathname||(s.pathname=`/npm/${t}@${n}/${o}`),[...e,{url:s,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${P(s)}`}]}),[]))([...o,this.baseCdnUrl,...U],e,t,n),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),N="base.ui.components.url",K=b&&localStorage.getItem(N),q=u((e=>{var t,n,s,a,c,l;const d=i(w,M,W)(e);return l=class extends d{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get descopeUi(){return o(this,s,"f")||r(this,s,o(this,t,"m",c).call(this),"f"),o(this,s,"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",a).call(this,e))))}},s=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},a=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{return await this.injectNpmLib("@descope/web-components-ui",await o(this,t,"m",n).call(this),"dist/umd/index.js",[K]),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},l})),F=u((e=>{var t,n,r;const s=i(I,x)(e);return r=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(){window.DESCOPE_NONCE=this.nonce},r}));class z{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 B=u((e=>{const t=i(F)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new z(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}}})),J="content-root",H="root",V=u((e=>{const t=i(B)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${H}">\n <div id="${J}"></div>\n </div>\n `,this.injectStyle(`\n #${H}, #${J} {\n height: 100%;\n }\n #${H} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(J),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(H)}}})),Z="descope-modal";var X,Y;let G=class{constructor(e,t){X.set(this,void 0),this.nodeName="",r(this,X,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,X,"f"))}get ele(){var e,t;const n="function"==typeof o(this,X,"f")?o(this,X,"f").call(this):o(this,X,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}};X=new WeakMap;let Q=class extends G{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 ee=/^descope-grid-([^-]+)-column$/,te={text:class extends G{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 G{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 ne=class extends G{constructor(){super(...arguments),this.nodeName="descope-grid",Y.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=ee.exec(t.localName))||void 0===n?void 0:n[1],r=te[o];return r?(e.push(new r(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const r=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);a(r,this.ele.columns)||(this.ele.columns=r,null===(n=o(this,Y,"f"))||void 0===n||n.call(this,r))}onColumnsChange(e){r(this,Y,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var oe;Y=new WeakMap;let re=class extends G{constructor(){super(...arguments),oe.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,oe,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,oe,"f").content.cloneNode(!0)))}setContent(e){r(this,oe,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};oe=new WeakMap;let ie=class extends G{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}},se=class extends G{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()}},ae=class extends G{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)}},ce=class extends G{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 le=u((e=>{var t,n;const r=i(I,V,q)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends re{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Z);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([Z]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),de="descope-notification",ue=u((e=>{var t,n;const r=i(I,V,q)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends se{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(de);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([de])}},t=new WeakMap,n})),he=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',pe=u((e=>{var t,n,s,a,c,l,d,u,h,p,f,g,v,m;const y=i(O({theme:he}),T,I,q,M,V,x,B)(e);return m=class extends y{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{o(this,t,"m",g).call(this),o(this,v,"f").call(this,"os"===this.getAttribute("theme"))})),v.set(this,(e=>{var n,r,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(r=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===r?void 0:r[s])||void 0===i||i.call(r,"change",(()=>o(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,f,"f").call(this),await Promise.all([o(this,t,"m",l).call(this),o(this,t,"m",d).call(this)]),this.observeAttributes(["theme"],o(this,f,"f")),this.observeAttributes(["style-id"],(()=>{r(this,s,null,"f"),o(this,t,"m",h).call(this),o(this,t,"m",l).call(this),o(this,t,"m",d).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(N))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(N),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},c=function(){return o(this,s,"f")||(r(this,s,o(this,t,"m",a).call(this),"f"),o(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,s,"f")},l=async function(){var e,i;const s=await o(this,t,"a",c);s&&(o(this,n,"f")||r(this,n,this.injectStyle(""),"f"),o(this,n,"f").replaceSync(((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||"")))},d=async function(){var e,n;const r=await o(this,t,"a",c);if(!r)return;const i=await this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components,dark:null===(n=null==r?void 0:r.dark)||void 0===n?void 0:n.components})},u=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],r=null==n?void 0:n.cssTemplate,i=o||r;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},h=async function(){const e=await o(this,t,"m",u).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")},p=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){o(this,t,"m",h).call(this),o(this,t,"m",p).call(this)},m}));var fe=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ge=()=>Math.random().toString(36).substring(7).split("").join("."),ve={INIT:`@@redux/INIT${ge()}`,REPLACE:`@@redux/REPLACE${ge()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ge()}`};function me(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 ye(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 we(e){let t=typeof e;return t=ye(e),t}function be(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${we(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: '${we(n)}'`);return n(be)(e,t)}let o=e,r=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function 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 r}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${we(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function h(e){if(!me(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${we(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: '${we(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,r=o(r,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}h({type:ve.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: '${we(e)}`);o=e,h({type:ve.REPLACE})},[fe]: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: '${we(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[fe](){return this}}}}}function ke(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Se(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const r=t[o];void 0===e[r]&&ke(`No reducer provided for key "${r}"`),"function"==typeof e[r]&&(n[r]=e[r])}const o=Object.keys(n);let r,i;r={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:ve.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:ve.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 '${ve.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;{const o=function(e,t,n,o){const r=Object.keys(t),i=n&&n.type===ve.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!me(e))return`The ${i} has unexpected type of "${we(e)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===ve.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${r.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,r);o&&ke(o)}let s=!1;const a={};for(let r=0;r<o.length;r++){const i=o[r],c=n[i],l=e[i],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 "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=d,s=s||d!==l}return s=s||o.length!==Object.keys(e).length,s?a:e}}function Ie(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function xe(e){return me(e)&&"type"in e&&"string"==typeof e.type}var Oe=Symbol.for("immer-nothing"),je=Symbol.for("immer-draftable"),Ce=Symbol.for("immer-state"),Re=[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 Ae(e,...t){{const n=Re[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Ee=Object.getPrototypeOf;function Te(e){return!!e&&!!e[Ce]}function _e(e){return!!e&&($e(e)||Array.isArray(e)||!!e[je]||!!e.constructor?.[je]||We(e)||Ne(e))}var Me=Object.prototype.constructor.toString();function $e(e){if(!e||"object"!=typeof e)return!1;const t=Ee(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Me}function Ue(e,t){0===Pe(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Pe(e){const t=e[Ce];return t?t.type_:Array.isArray(e)?1:We(e)?2:Ne(e)?3:0}function De(e,t){return 2===Pe(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Le(e,t,n){const o=Pe(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function We(e){return e instanceof Map}function Ne(e){return e instanceof Set}function Ke(e){return e.copy_||e.base_}function qe(e,t){if(We(e))return new Map(e);if(Ne(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&$e(e)){if(!Ee(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ce];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const r=o[t],i=n[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[r]})}return Object.create(Ee(e),n)}function Fe(e,t=!1){return Be(e)||Te(e)||!_e(e)||(Pe(e)>1&&(e.set=e.add=e.clear=e.delete=ze),Object.freeze(e),t&&Ue(e,((e,t)=>Fe(t,!0)))),e}function ze(){Ae(2)}function Be(e){return Object.isFrozen(e)}var Je,He={};function Ve(e){const t=He[e];return t||Ae(0,e),t}function Ze(){return Je}function Xe(e,t){t&&(Ve("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ye(e){Ge(e),e.drafts_.forEach(et),e.drafts_=null}function Ge(e){e===Je&&(Je=e.parent_)}function Qe(e){return Je={drafts_:[],parent_:Je,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function et(e){const t=e[Ce];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function tt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ce].modified_&&(Ye(t),Ae(4)),_e(e)&&(e=nt(t,e),t.parent_||rt(t,e)),t.patches_&&Ve("Patches").generateReplacementPatches_(n[Ce].base_,e,t.patches_,t.inversePatches_)):e=nt(t,n,[]),Ye(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Oe?e:void 0}function nt(e,t,n){if(Be(t))return t;const o=t[Ce];if(!o)return Ue(t,((r,i)=>ot(e,o,t,r,i,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return rt(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let r=t,i=!1;3===o.type_&&(r=new Set(t),t.clear(),i=!0),Ue(r,((r,s)=>ot(e,o,t,r,s,n,i))),rt(e,t,!1),n&&e.patches_&&Ve("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function ot(e,t,n,o,r,i,s){if(r===n&&Ae(5),Te(r)){const s=nt(e,r,i&&t&&3!==t.type_&&!De(t.assigned_,o)?i.concat(o):void 0);if(Le(n,o,s),!Te(s))return;e.canAutoFreeze_=!1}else s&&n.add(r);if(_e(r)&&!Be(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;nt(e,r),t&&t.scope_.parent_||rt(e,r)}}function rt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Fe(t,n)}var it={get(e,t){if(t===Ce)return e;const n=Ke(e);if(!De(n,t))return function(e,t,n){const o=ct(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_||!_e(o)?o:o===at(e.base_,t)?(dt(e),e.copy_[t]=ut(o,e)):o},has:(e,t)=>t in Ke(e),ownKeys:e=>Reflect.ownKeys(Ke(e)),set(e,t,n){const o=ct(Ke(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=at(Ke(e),t),r=o?.[Ce];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||De(e.base_,t)))return!0;dt(e),lt(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!==at(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,dt(e),lt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ke(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Ae(11)},getPrototypeOf:e=>Ee(e.base_),setPrototypeOf(){Ae(12)}},st={};function at(e,t){const n=e[Ce];return(n?Ke(n):e)[t]}function ct(e,t){if(!(t in e))return;let n=Ee(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ee(n)}}function lt(e){e.modified_||(e.modified_=!0,e.parent_&&lt(e.parent_))}function dt(e){e.copy_||(e.copy_=qe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ue(it,((e,t)=>{st[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),st.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Ae(13),st.set.call(this,e,t,void 0)},st.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Ae(14),it.set.call(this,e[0],t,n,e[0])};function ut(e,t){const n=We(e)?Ve("MapSet").proxyMap_(e,t):Ne(e)?Ve("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Ze(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=it;n&&(r=[o],i=st);const{revoke:s,proxy:a}=Proxy.revocable(r,i);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Ze()).drafts_.push(n),n}function ht(e){return Te(e)||Ae(10,e),pt(e)}function pt(e){if(!_e(e)||Be(e))return e;const t=e[Ce];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 Ue(n,((e,t)=>{Le(n,e,pt(t))})),t&&(t.finalized_=!1),n}var ft=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...r){return o.produce(e,(e=>t.call(this,e,...r)))}}let o;if("function"!=typeof t&&Ae(6),void 0!==n&&"function"!=typeof n&&Ae(7),_e(e)){const r=Qe(this),i=ut(e,void 0);let s=!0;try{o=t(i),s=!1}finally{s?Ye(r):Ge(r)}return Xe(r,n),tt(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Oe&&(o=void 0),this.autoFreeze_&&Fe(o,!0),n){const t=[],r=[];Ve("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}Ae(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const r=this.produce(e,t,((e,t)=>{n=e,o=t}));return[r,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){_e(e)||Ae(8),Te(e)&&(e=ht(e));const t=Qe(this),n=ut(e,void 0);return n[Ce].isManual_=!0,Ge(t),n}finishDraft(e,t){const n=e&&e[Ce];n&&n.isManual_||Ae(9);const{scope_:o}=n;return Xe(o,t),tt(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Ve("Patches").applyPatches_;return Te(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},gt=ft.produce;ft.produceWithPatches.bind(ft),ft.setAutoFreeze.bind(ft),ft.setUseStrictShallowCopy.bind(ft),ft.applyPatches.bind(ft),ft.createDraft.bind(ft),ft.finishDraft.bind(ft);var vt=(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})}}},mt=(e,t,n)=>{const{memoize:o,memoizeOptions:r}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...r);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},yt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var wt=e=>Array.isArray(e)?e:[e];function bt(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 kt(e,t){const n=[],{length:o}=e;for(let r=0;r<o;r++)n.push(e[r].apply(null,t));return n}var St="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},It=0,xt=1;function Ot(){return{s:It,v:void 0,o:null,p:null}}function jt(e,t={}){let n=Ot();const{resultEqualityCheck:o}=t;let r,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=Ot(),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=Ot(),e.set(n,t)):t=o}}const a=t;let c;if(t.s===xt)c=t.v;else if(c=e.apply(null,arguments),i++,o){const e=r?.deref?.()??r;null!=e&&o(e,c)&&(c=e,0!==i&&i--);r="object"==typeof c&&null!==c||"function"==typeof c?new St(c):c}return a.s=xt,a.v=c,c}return s.clearCache=()=>{n=Ot(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function Ct(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,r=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:d=jt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=wt(l),f=wt(u),g=bt(e),v=c((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){r++;const e=kt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...yt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:vt},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:mt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=kt(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:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:c,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Rt=Ct(jt),At=Object.assign(((e,t=Rt)=>{!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:()=>At});function Et(e){return({dispatch:t,getState:n})=>o=>r=>"function"==typeof r?r(t,n,e):o(r)}var Tt=Et(),_t=Et;((...e)=>{const t=Ct(...e)})(jt);var Mt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ie:Ie.apply(null,arguments)},$t=e=>e&&"function"==typeof e.match;function Ut(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=>xe(t)&&t.type===e,n}function Pt(e){return"function"==typeof e&&"type"in e&&$t(e)}function Dt(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 Lt=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 Wt(e){return _e(e)?gt(e,(()=>{})):e}function Nt(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Kt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function qt(e,t,n){const o=Ft(e,t,n);return{detectMutations:()=>zt(e,t,o,n)}}function Ft(e,t=[],n,o="",r=new Set){const i={value:n};if(!e(n)&&!r.has(n)){r.add(n),i.children={};for(const r in n){const s=o?o+"."+r:r;t.length&&-1!==t.indexOf(s)||(i.children[r]=Ft(e,t,n[r],s))}}return i}function zt(e,t=[],n,o,r=!1,i=""){const s=n?n.value:void 0,a=s===o;if(r&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:i};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let r in c){const s=i?i+"."+r:r;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=zt(e,t,n.children[r],o[r],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function Bt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||me(e)}function Jt(e,t="",n=Bt,o,r=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),c=r.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(r.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Jt(l,a,n,o,r,i),s))return s}return i&&Ht(e)&&i.add(e),!1}function Ht(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Ht(t))return!1;return!0}function Vt(e){return"boolean"==typeof e}var Zt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:r=!0}=e??{};let i=new Lt;if(t&&(Vt(t)?i.push(Tt):i.push(_t(t.extraArgument))),n){let e={};Vt(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,o,r){return JSON.stringify(e,n(t,r),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(r,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,r):o.push(r),~n.indexOf(i)&&(i=t.call(this,r,i))}else n.push(i);return null==e?i:e.call(this,r,i)}},{isImmutable:o=Kt,ignoredPaths:r,warnAfter:i=32}=e;const s=qt.bind(null,o,r);return({getState:e})=>{let n,o=e(),r=s(o);return a=>c=>{const l=Dt(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(c);return l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(o){let e={};Vt(o)||(e=o),i.push(function(e={}){{const{isSerializable:t=Bt,getEntries:n,ignoredActions:o=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!xe(u))return l(u);const h=l(u),p=Dt(s,"SerializableStateInvariantMiddleware");return c||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=Jt(u,"",t,n,r,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=Jt(e.getState(),"",t,n,i,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(r){let e={};Vt(r)||(e=r),i.unshift(function(e={}){const{isActionCreator:t=Pt}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return i},Xt=e=>t=>{setTimeout(t,e)},Yt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Xt(10),Gt=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Lt(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let r=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Yt:"callback"===e.type?e.queueNotification:Xt(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>r&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return r=!e?.meta?.RTK_autoBatch,i=!r,i&&(s||(s=!0,c(l))),o.dispatch(e)}finally{r=!0}}})})("object"==typeof n?n:void 0)),o};function Qt(e){const t=Zt(),{reducer:n,middleware:o,devTools:r=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!me(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=Se(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=Ie;r&&(l=Mt({trace:!0,..."object"==typeof r&&r}));const d=function(...e){return t=>(n,o)=>{const r=t(n,o);let i=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:r.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=Ie(...a)(r.dispatch),{...r,dispatch:i}}}(...c),u=Gt(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 be(a,i,l(...h))}function en(e){const t={},n=[];let o;const r={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,r},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),r},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,r}};return e(r),[t,n,o]}function tn(...e){return t=>e.some((e=>((e,t)=>$t(e)?e.match(t):e(t))(e,t)))}var nn=["name","message","stack","code"],on=class{constructor(e,t){this.payload=e,this.meta=t}_type},rn=class{constructor(e,t){this.payload=e,this.meta=t}_type},sn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of nn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},an=(()=>{function e(e,t,n){const o=Ut(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),r=Ut(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=Ut(e+"/rejected",((e,t,o,r,i)=>({payload:r,error:(n&&n.serializeError||sn)(e||"Rejected"),meta:{...i||{},arg:o,requestId:t,rejectedWithValue:!!r,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||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(r(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 on(e,t),fulfillWithValue:(e,t)=>new rn(e,t)})).then((t=>{if(t instanceof on)throw t;return t instanceof rn?o(t.payload,l,e,t.meta):o(t,l,e)}))])}catch(t){p=t instanceof on?i(null,l,e,t.payload,t.meta):i(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,arg:e,unwrap:()=>p.then(cn)})}}),{pending:r,rejected:i,fulfilled:o,settled:tn(i,o),typePrefix:e})}return e.withTypes=()=>e,e})();function cn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var ln=Symbol.for("rtk-slice-createasyncthunk");function dn(e,t){return`${e}/${t}`}function un(e,t,n,o){function r(r,...i){let s=n.call(e,r);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return r.unwrapped=t,r}var hn=function({creators:e}={}){const t=e?.asyncThunk?.[ln];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const r=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(r),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?en(e.extraReducers):[e.extraReducers],r={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,r,i]=en(t);if(function(e){return"function"==typeof e}(e))n=()=>Wt(e());else{const t=Wt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...r.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(Te(e)){const o=n(e,t);return void 0===o?e:o}if(_e(e))return gt(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in r)e.addCase(t,r[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}i.forEach((o=>{const i=r[o],s={reducerName:o,type:dn(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,r){let i,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=o.reducer,s=o.prepare}else i=o;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?Ut(e,s):Ut(e))}(s,i,a):function({type:e,reducerName:t},n,o,r){if(!r)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:d}=n,u=r(e,i,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||pn,pending:a||pn,rejected:c||pn,settled:l||pn})}(s,i,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=Nt(d,this,{insert:()=>new WeakMap});return Nt(n,t,{insert:()=>{const n={};for(const[o,r]of Object.entries(e.selectors??{}))n[o]=un(this,r,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 pn(){}var fn="listenerMiddleware";Ut(`${fn}/add`),Ut(`${fn}/removeAll`),Ut(`${fn}/remove`);const gn=e=>u((t=>{const n=hn(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(w)(t)){constructor(...e){super(...e);const t=Qt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),r=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{cn(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},i=Object.keys(o).reduce(((e,t)=>(e[t]=r(o[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),vn=u((e=>class extends(w(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}})),mn=u((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),yn=e=>e.selectedAccessKeysIds,wn=e=>e.notifications,bn=Rt((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}))))),kn=Rt(yn,bn,((e,t)=>t.filter((t=>e.includes(t.id))))),Sn=Rt(yn,(e=>!!e.length)),In=Rt(kn,(e=>e.every((e=>e.editable)))),xn=Rt(In,Sn,((e,t)=>e&&t));Rt(yn,(e=>1===e.length));const On=Rt(kn,(e=>1===e.length?e[0].name:`${e.length} access keys`)),jn=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)}))}))},Cn=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}}),Rn=({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)})}}),An=an("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),En=jn(An)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},Cn((e=>e.createAccessKey)),Rn({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>`}})),Tn={action:An,reducer:En},_n=an("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),Mn=jn(_n)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},Cn((e=>e.deleteAccessKey)),Rn({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"]}`})),$n={action:_n,reducer:Mn},Un=an("accessKeys/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.accesskey.search(Object.assign(Object.assign({},o),e))})),Pn=jn(Un)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},Cn((e=>e.accessKeysList))),Dn={action:Un,reducer:Pn},Ln=an("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),Wn=jn(Ln)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},Cn((e=>e.activateAccessKey)),Rn({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"]}`})),Nn={action:Ln,reducer:Wn},Kn=an("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),qn=jn(Kn)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},Cn((e=>e.deactivateAccessKey)),Rn({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"]}`})),Fn={action:Kn,reducer:qn},zn=an("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),Bn={action:zn,reducer:jn(zn)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},Cn((e=>e.tenantRoles)))},Jn={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},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]};class Hn extends Error{}function Vn(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 Zn(e,t){if("string"!=typeof e)throw new Hn("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 Hn(`Invalid token specified: missing part #${n+1}`);let r;try{r=Vn(o)}catch(e){throw new Hn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new Hn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Hn.prototype.name="InvalidTokenError";var Xn={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",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 Yn="<region>",Gn=`https://api.${Yn}descope.com`,Qn=6e5,eo="dct",to=()=>{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")}},no=[521,524],oo=e=>async(...t)=>{let n=await e(...t);no.includes(n.status)&&(n=await e(...t),n.retries=1);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let ro;const io=()=>{if(ro)return ro;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 ro=`${t}-${n}`,ro};var so,ao;(ao=so||(so={})).get="GET",ao.delete="DELETE",ao.post="POST",ao.put="PUT",ao.patch="PATCH";const co=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(Yn,r?r+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{i=`${i}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return i},lo=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),uo={"Content-Type":"application/json"},ho=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},po=(e,t)=>{const n={"x-descope-sdk-session-id":io(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.47.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},fo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var go=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:r,hooks:i,cookiePolicy:s,fetch:a})=>{const c=e||Gn,l=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>to().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await oo(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return to().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:oo(n)})(r,a),d=async e=>{var r;const a=(null==i?void 0:i.beforeRequest)?i.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:lo(ho(t,g),po(t,o),(null==n?void 0:n.baseHeaders)||{},fo(v)?uo:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const y=await l(co({path:d,baseUrl:c,queryParams:p,projectId:t}),m);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(e,null==y?void 0:y.clone()),null==i?void 0:i.transformResponse){const e=await y.json(),t=((null===(r=y.headers)||void 0===r?void 0:r.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}return y};return{get:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:so.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:so.post,token:r}),patch:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:so.patch,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:so.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:so.delete,token:o}),hooks:i,buildUrl:(e,n)=>co({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 r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=r.length&&(await Promise.allSettled(null==r?void 0:r.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},vo=429;function mo(e,t,n){var o;let r=yo(e);if(t){if(!(null==r?void 0:r.tenants)&&(null==r?void 0:r[eo])===t)return(null==r?void 0:r[n])||[];r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]}const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function yo(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Zn(e)}function wo(e){const{exp:t}=yo(e);return(new Date).getTime()/1e3>t}function bo(e){let t=yo(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function ko(e,t){return mo(e,t,"permissions")}function So(e,t){return mo(e,t,"roles")}const Io=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function xo(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=i:(r.error=i,o.status===vo&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}function Oo(e){var t;return(null===(t=yo(e))||void 0===t?void 0:t[eo])||""}const jo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Co=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},Ro=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Ao=e=>t=>e.test(t),Eo=Ao(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),To=Ao(/^\+[1-9]{1}[0-9]{3,14}$/),_o=jo(Eo,'"{val}" is not a valid email'),Mo=jo(To,'"{val}" is not a valid phone number'),$o=jo((e=>e.length>=1),"Minimum length is 1");const Uo=jo((e=>"string"==typeof e),"Input is not a string"),Po=jo((e=>Array.isArray(e)),"Input is not an array"),Do=jo((e=>"boolean"==typeof e),"Input is not a boolean"),Lo=jo((e=>void 0===e),"Input is defined"),Wo=Co([Uo(),Lo()],"Input is not a string or undefined"),No=Co([Po(),Do()],"Input is not an array or boolean"),Ko=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Ro(...e).validate(n[t]))),t(...n)),qo=e=>[Uo(`"${e}" must be a string`)],Fo=e=>[Wo(`"${e}" must be string or undefined`)],zo=e=>[Uo(`"${e}" must be a string`),$o(`"${e}" must not be empty`)],Bo=e=>[Uo(`"${e}" must be a string`),_o()],Jo=e=>[Uo(`"${e}" must be a string`),Mo()],Ho=Ko(zo("accessKey")),Vo=e=>({exchange:Ho(((t,n)=>xo(e.post(Xn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Zo=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const s=i[r];i[r]=n(s)})),e),Xo=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Qn,Qn)});var Yo,Go;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(Yo||(Yo={})),function(e){e.email="email"}(Go||(Go={}));const Qo=Object.assign(Object.assign({},Yo),Go);var er;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(er||(er={}));const tr=zo("loginId"),nr=Ko(zo("token")),or=Ko(tr),rr=Ko(zo("pendingRef")),ir=Ko(tr,Bo("email")),sr=e=>({verify:nr((t=>xo(e.post(Xn.enchantedLink.verify,{token:t})))),signIn:or(((t,n,o,r)=>xo(e.post(Io(Xn.enchantedLink.signIn,Qo.email),{loginId:t,URI:n,loginOptions:o},{token:r})))),signUpOrIn:or(((t,n,o)=>xo(e.post(Io(Xn.enchantedLink.signUpOrIn,Qo.email),{loginId:t,URI:n,loginOptions:o})))),signUp:or(((t,n,o,r)=>xo(e.post(Io(Xn.enchantedLink.signUp,Qo.email),{loginId:t,URI:n,user:o,loginOptions:r})))),waitForSession:rr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=Xo(n);let s;const a=setInterval((async()=>{const n=await e.post(Xn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ir(((t,n,o,r,i)=>xo(e.post(Xn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),ar=Ko(zo("flowId")),cr=Ko(zo("executionId"),zo("stepId"),zo("interactionId")),lr=e=>({start:ar(((t,n,o,r,i,s,a)=>xo(e.post(Xn.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,componentsVersion:i,flowVersions:s,input:a})))),next:cr(((t,n,o,r,i,s)=>xo(e.post(Xn.flow.next,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:s}))))}),dr=zo("loginId"),ur=Ko(zo("token")),hr=Ko(dr),pr=Ko(dr,Jo("phone")),fr=Ko(dr,Bo("email")),gr=Object.keys(Qo).filter((e=>e!==Yo.voice)),vr=e=>({verify:ur((t=>xo(e.post(Xn.magicLink.verify,{token:t})))),signIn:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:hr(((t,o,r,i)=>xo(e.post(Io(Xn.magicLink.signIn,n),{loginId:t,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:hr(((t,o,r,i)=>xo(e.post(Io(Xn.magicLink.signUp,n),{loginId:t,URI:o,user:r,loginOptions:i}))))})),{}),signUpOrIn:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:hr(((t,o,r)=>xo(e.post(Io(Xn.magicLink.signUpOrIn,n),{loginId:t,URI:o,loginOptions:r}))))})),{}),update:{email:fr(((t,n,o,r,i)=>xo(e.post(Xn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(Yo).filter((e=>e!==Yo.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pr(((t,o,r,i,s)=>xo(e.post(Io(Xn.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:r},s),{token:i}))))})),{})}});var mr;!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"}(mr||(mr={}));const yr=Ko(zo("code")),wr=e=>({start:Object.assign(((t,n,o,r,i)=>xo(e.post(Xn.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),i&&{loginHint:i}),token:r}))),Object.keys(mr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r,i)=>xo(e.post(Xn.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),i&&{loginHint:i}),token:r}))})),{})),exchange:yr((t=>xo(e.post(Xn.oauth.exchange,{code:t})))),startNative:(t,n,o)=>xo(e.post(Xn.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,r,i)=>xo(e.post(Xn.oauth.finishNative,{provider:t,stateId:n,user:o,code:r,idToken:i})),getOneTapClientId:t=>xo(e.get(Xn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,r)=>xo(e.post(Xn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r})),exchangeOneTapIDToken:(t,n,o,r)=>xo(e.post(Xn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r}))}),br=zo("appId"),kr=Ko(br),Sr=e=>({connect:kr(((t,n,o)=>{const r=null==n?void 0:n.tenantId,i=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,xo(e.post(Xn.outbound.connect,{appId:t,tenantId:r,tenantLevel:i,options:n},{token:o}))}))}),Ir=zo("loginId"),xr=Ko(Ir,zo("code")),Or=Ko(Ir),jr=Ko(Ir,Jo("phone")),Cr=Ko(Ir,Bo("email")),Rr=e=>({verify:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:xr(((t,o)=>xo(e.post(Io(Xn.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Or(((t,o,r)=>xo(e.post(Io(Xn.otp.signIn,n),{loginId:t,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Or(((t,o,r)=>xo(e.post(Io(Xn.otp.signUp,n),{loginId:t,user:o,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Or(((t,o)=>xo(e.post(Io(Xn.otp.signUpOrIn,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:Cr(((t,n,o,r)=>xo(e.post(Xn.otp.update.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(Yo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jr(((t,o,r,i)=>xo(e.post(Io(Xn.otp.update.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),Ar=Ko(zo("tenant")),Er=Ko(zo("code")),Tr=e=>({start:Ar(((t,n,o,r,i)=>xo(e.post(Xn.saml.start,o||{},Object.assign({queryParams:Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),i&&{ssoId:i})},r&&{token:r}))))),exchange:Er((t=>xo(e.post(Xn.saml.exchange,{code:t}))))}),_r=zo("loginId"),Mr=Ko(_r,zo("code")),$r=Ko(_r),Ur=Ko(_r),Pr=e=>({signUp:$r(((t,n)=>xo(e.post(Xn.totp.signUp,{loginId:t,user:n})))),verify:Mr(((t,n,o,r)=>xo(e.post(Xn.totp.verify,{loginId:t,code:n,loginOptions:o},{token:r})))),update:Ur(((t,n)=>xo(e.post(Xn.totp.update,{loginId:t},{token:n}))))}),Dr=zo("loginId"),Lr=zo("newPassword"),Wr=Ko(Dr,zo("password")),Nr=Ko(Dr),Kr=Ko(Dr,Lr),qr=Ko(Dr,zo("oldPassword"),Lr),Fr=e=>({signUp:Wr(((t,n,o,r)=>xo(e.post(Xn.password.signUp,{loginId:t,password:n,user:o,loginOptions:r})))),signIn:Wr(((t,n,o)=>xo(e.post(Xn.password.signIn,{loginId:t,password:n,loginOptions:o})))),sendReset:Nr(((t,n,o)=>xo(e.post(Xn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Kr(((t,n,o)=>xo(e.post(Xn.password.update,{loginId:t,newPassword:n},{token:o})))),replace:qr(((t,n,o)=>xo(e.post(Xn.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>xo(e.get(Xn.password.policy))}),zr=qo("loginId"),Br=zo("loginId"),Jr=zo("origin"),Hr=Ko(Br,Jr,zo("name")),Vr=Ko(Br,Jr),Zr=Ko(zr,Jr),Xr=Ko(Br,Jr,Fo("token")),Yr=Ko(zo("transactionId"),zo("response")),Gr=e=>({signUp:{start:Hr(((t,n,o,r)=>xo(e.post(Xn.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,passkeyOptions:r})))),finish:Yr(((t,n)=>xo(e.post(Xn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Zr(((t,n,o,r,i)=>xo(e.post(Xn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i},{token:r})))),finish:Yr(((t,n)=>xo(e.post(Xn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Vr(((t,n,o)=>xo(e.post(Xn.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:o}))))},update:{start:Xr(((t,n,o,r)=>xo(e.post(Xn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:r},{token:o})))),finish:Yr(((t,n)=>xo(e.post(Xn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Qr=qo("loginId"),ei=Ko(Qr),ti=Ko(zo("pendingRef")),ni=e=>({signUpOrIn:ei(((t,n)=>xo(e.post(Xn.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:ei(((t,n,o)=>xo(e.post(Xn.notp.signUp,{loginId:t,user:n,loginOptions:o})))),signIn:ei(((t,n,o)=>xo(e.post(Xn.notp.signIn,{loginId:t,loginOptions:n},{token:o})))),waitForSession:ti(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=Xo(n);let s;const a=setInterval((async()=>{const n=await e.post(Xn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),oi=Ko(zo("token")),ri=Ko(Fo("token"));var ii,si=Ko([(ii=zo("projectId"),jo(((e,t)=>n=>Ro(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let r=0,i=e===Object(e)?e:void 0;for(;null!=i&&r<o;)i=i[n[r++]];return r&&r===o&&void 0!==i?i:void 0})(n,e)))("projectId",ii))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:r,baseHeaders:i={},refreshCookieName:s,fetch:a}=e;return c=go({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:r,baseConfig:{baseHeaders:i},refreshCookieName:s,fetch:a}),{accessKey:Vo(c),otp:Rr(c),magicLink:vr(c),enchantedLink:sr(c),oauth:wr(c),outbound:Sr(c),saml:Tr(c),totp:Pr(c),notp:ni(c),webauthn:Gr(c),password:Fr(c),flow:lr(c),refresh:ri(((e,t,n)=>{const o={};return n&&(o.externalToken=n),xo(c.post(Xn.refresh,o,{token:e,queryParams:t}))})),selectTenant:Ko([Uo("tenantId")],[Wo('"token" must be string or undefined')])(((e,t)=>xo(c.post(Xn.selectTenant,{tenant:e},{token:t})))),logout:ri((e=>xo(c.post(Xn.logout,{},{token:e})))),logoutAll:ri((e=>xo(c.post(Xn.logoutAll,{},{token:e})))),me:ri((e=>xo(c.get(Xn.me,{token:e})))),myTenants:Ko([No('"tenants" must a string array or a boolean')],[Wo('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,xo(c.post(Xn.myTenants,n,{token:t}))})),history:ri((e=>xo(c.get(Xn.history,{token:e})))),isJwtExpired:oi(wo),getTenants:oi(bo),getJwtPermissions:oi(ko),getJwtRoles:oi(So),getCurrentTenant:oi(Oo),httpClient:c};var c})),ai=Object.assign(si,{DeliveryMethods:Qo});
6
- /*! js-cookie v3.0.5 | MIT */function ci(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var li=function e(t,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=ci({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",ci({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,ci({},this.attributes,t))},withConverter:function(t){return e(ci({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var di={default:"endpoint"},ui="Blocked by CSP",hi="The endpoint parameter is not a valid URL",pi="Failed to load the JS script of the agent",fi="9319";function gi(e,t){var n,o,r,i,s,a=[],c=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),i=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},r=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===ui||s===hi)n.exclude(),i=0;else if(s===fi)n.exclude();else if(s===pi){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!r.has(c)&&(r.add(c),i=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=i?i:e.getTime()+o()-Date.now()]}]),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})},r=t(e);return r.then((function(){return o()}),o),r.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,r=t[0],i=t[1];return(o=i,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(r)}))}))};return u(l).then((function(e){return[e,a]}))}var vi="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",mi=vi;function yi(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:vi,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 gi(e,wi)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===fi?new Error(pi):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 wi(e){return function(e,t,n){var o,r=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=t,a())};r.addEventListener(i,s);var a=function(){return r.removeEventListener(i,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(hi);var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(pi))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)}),(function(){throw new Error(ui)})).then(bi)}function bi(){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(fi);return n}const ki=e=>{try{return Zn(e).exp}catch(e){return null}},Si=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ki(n)},Ii=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?ki(o):void 0)},xi=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Oi=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(e=>{const{access_token:n,id_token:o,refresh_token:r,refresh_expire_in:i}=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||r,sessionExpiration:e.sessionExpiration||Ii(e),cookieExpiration:e.cookieExpiration||Si(e)},s)})((null==n?void 0:n.authInfo)||n||{})},ji=async e=>{const t=await Oi(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Ci="undefined"!=typeof localStorage,Ri=(e,t)=>Ci&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Ai=e=>Ci&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Ei=e=>Ci&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Ti=(...e)=>{console.debug(...e)},_i="3.2.0",Mi="undefined"!=typeof window,$i=Math.pow(2,31)-1,Ui=`https://descopecdn.com/npm/oidc-client-ts@${_i}/dist/browser/oidc-client-ts.min.js`,Pi=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${_i}/dist/browser/oidc-client-ts.min.js`,Di="DS",Li="DSR",Wi="DSI";function Ni(e=""){return Ai(`${e}${Li}`)||""}function Ki(e=""){return li.get(Di)||Ai(`${e}${Di}`)||""}function qi(e=""){return Ai(`${e}${Wi}`)||""}function Fi(e=""){Ei(`${e}${Li}`),Ei(`${e}${Di}`),Ei(`${e}${Wi}`),li.remove(Di)}const zi=Mi&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Bi="vsid",Ji="vrid",Hi=(e=!1)=>{const t=localStorage.getItem("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Vi=async(e,t=zi)=>{try{if(Hi())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=r.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=yi({apiKey:e,endpoint:[o.toString(),di],scriptUrlPattern:[i,mi]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Bi]:e,[Ji]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Zi=e=>{const t=Hi(!0);return t&&e.body&&(e.body.fpData=t),e},Xi="descopeFlowNonce",Yi="X-Descope-Flow-Nonce",Gi="/v1/flow/start",Qi="/v1/flow/next",es=(e,t=Xi)=>`${t}${e}`,ts=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},ns=e=>{var t;return e.path===Qi&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ts(e.body.executionId):null},os="dls_last_user_login_id",rs="dls_last_user_display_name",is=()=>Ai(os),ss=()=>Ai(rs),as=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=is(),i=ss();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await e(...t)};function cs(){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 ls(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=gs(n.publicKey.challenge),n.publicKey.user.id=gs(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=gs(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:vs(n.rawId),type:n.type,response:{attestationObject:vs(n.response.attestationObject),clientDataJSON:vs(n.response.clientDataJSON)}});var n}async function ds(e){const t=ps(e);return fs(await navigator.credentials.get(t))}async function us(e,t){const n=ps(e);return n.signal=t.signal,n.mediation="conditional",fs(await navigator.credentials.get(n))}async function hs(e=!1){if(!Mi)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function ps(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=gs(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=gs(e.id)})),n}function fs(e){return JSON.stringify({id:e.id,rawId:vs(e.rawId),type:e.type,response:{authenticatorData:vs(e.response.authenticatorData),clientDataJSON:vs(e.response.clientDataJSON),signature:vs(e.response.signature),userHandle:e.response.userHandle?vs(e.response.userHandle):void 0}})}function gs(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function vs(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ms,ys=(ms=e=>({async signUp(t,n,o){const r=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await ls(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,i)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const r=await ds(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,r)},async signUpOrIn(t,n){var o;const r=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!r.ok)return r;if(null===(o=r.data)||void 0===o?void 0:o.create){const t=await ls(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,t)}{const t=await ds(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,t)}},async update(t,n,o){const r=await e.webauthn.update.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await ls(r.data.options);return await e.webauthn.update.finish(r.data.transactionId,i)},helpers:{create:ls,get:ds,isSupported:hs,conditional:us}}),(...e)=>{const t=ms(...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 ws="/fedcm/config",bs=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function ks(e,t){var n;try{await Ss(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Ss(e,t){var n,o;const r=await async function(e,t="google",n,o,r){const i=bs(),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:i,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:i})),s.prompt((e=>{var t,n;if(r&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==r||r(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(!r.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+r.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(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+r.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var Is=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await hs(),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 xs;const Os=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const r=t();if(r)return n(r);const i=e.shift(),s=document.createElement("script");s.src=i,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)})(i),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",(()=>{Os(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),js=(e,t,n)=>{const o=async()=>{let o,r;return o&&r||({client:o,stateUserKey:r}=await(async(e,t,n)=>{xs||(xs=(async()=>{try{return require("oidc-client-ts")}catch(e){return Os([Ui,Pi],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:r}=await xs;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const i=t,s=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",c=`${i}_user`;let l=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(l=`${l}/${n.applicationId}`);const d={authority:l,client_id:t,redirect_uri:s,response_type:"code",scope:a,stateStore:new r({store:window.localStorage,prefix:i}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new o(d),stateUserKey:c}})(e,t,n)),{client:o,stateUserKey:r}},r=async(t="")=>{var n;const{client:r,stateUserKey:i}=await o(),s=await r.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)))),window.localStorage.setItem(i,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(e={},t=!1)=>{const{client:n}=await o(),r=await n.createSigninRequest(e),{url:i}=r;return t||(window.location.href=i),{ok:!0,data:r}},finishLogin:r,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await r(e)},refreshToken:async t=>{var n;const{client:r,stateUserKey:i}=await o(),s=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(i);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 r.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:r}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||qi(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const i=await n.createSignoutRequest(e),{url:s}=i;return window.localStorage.removeItem(r),t||window.location.replace(s),i}}},Cs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:r}=n,i=t(n,["fpKey","fpLoad"]);return Mi?(o&&r&&Vi(o).catch((()=>null)),e(xi(i,{beforeRequest:Zi}))):e(i)}),(e=>n=>{var{autoRefresh:o}=n,r=t(n,["autoRefresh"]);if(!o||"undefined"!=typeof window&&window.descopeBridge)return e(r);const{clearAllTimers:i,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;Mi&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&a&&new Date>a&&(Ti("Expiration time passed, refreshing session"),l.refresh(Ni()||c))}));const l=e(xi(r,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:r}=await Oi(t);if(401===(null==t?void 0:t.status))Ti("Received 401, canceling all timers"),i();else if(n||r){if(a=((e,t)=>{if(t)return new Date(1e3*t);Ti("Could not extract expiration time from session token, trying to decode the token");try{const t=Zn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,r),!a)return void Ti("Could not extract expiration time from session token");c=o;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>$i&&(Ti(`Timeout is too large (${t}ms), setting it to ${$i}ms`),t=$i),t})(a);if(i(),e<=2e4)return void Ti("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Ti(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Ti("Refreshing session due to timer"),l.refresh(Ni()||o)}),e)}}}));return Zo(l,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Ti("Clearing all timers"),i(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.34.3"},t.baseHeaders)}))),(e=>t=>{const n=cs(),o=cs(),r=cs(),i=e(xi(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))o.pub(null),r.pub(null),n.pub(null);else{const e=await ji(t);e&&r.pub(e);const{sessionJwt:i,sessionExpiration:s}=await Oi(t);i&&o.pub(i),(s||i)&&n.pub(s||42)}}})),s=Zo(i,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const i=await e(...t);return o.pub(null),r.pub(null),n.pub(null),i}));return Object.assign(s,{onSessionTokenChange:o.sub,onUserChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:o=!0,nonceStoragePrefix:r=Xi}=n,i=t(n,["enableFlowNonce","nonceStoragePrefix"]);return o?(((e=Xi)=>{try{if(!Ci)return;for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(n&&n.startsWith(e)){const t=Ai(n);if(t)try{JSON.parse(t).expiry<Date.now()&&Ei(n)}catch(e){Ei(n)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}})(r),e(xi(i,{afterRequest:async(e,t)=>{if(e.path!==Gi&&e.path!==Qi)return;const{nonce:n,executionId:o}=await(async(e,t)=>{try{const n=t.headers.get(Yi);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=ns(e)),{nonce:n,executionId:ts(o)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&o&&((e,t,n,o=Xi)=>{try{const r=es(e,o),i=n?172800:10800,s={value:t,expiry:Date.now()+1e3*i,isStart:n};Ri(r,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(o,n,e.path===Gi,r)},beforeRequest:e=>{if(e.path===Qi){const t=ns(e);if(t){const n=((e,t=Xi)=>{try{const n=es(e,t),o=Ai(n);if(!o)return null;const r=JSON.parse(o);return r.expiry<Date.now()?(((e,t=Xi)=>{try{const n=es(e,t);Ei(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):r.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,r);n&&(e.headers=e.headers||{},e.headers[Yi]=n)}}return e}}))):e(i)}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(i),{getLastUserLoginId:is,getLastUserDisplayName:ss});const s=e(xi(i,{afterRequest:async(e,t)=>{var n;const o=await ji(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((e=>{Ri(os,e)})(r),(e=>{Ri(rs,e)})(i))}}));let a=Zo(s,["flow.start"],as);return a=Zo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(Ei(os),Ei(rs)),o})(r)),Object.assign(a,{getLastUserLoginId:is,getLastUserDisplayName:ss})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:r,storagePrefix:i}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!Mi)return e(s);const a=e(xi(s,{beforeRequest:(c=i,e=>Object.assign(e,{token:e.token||Ni(c)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||Fi(i):((e={},t=!1,n="")=>{var o;const{sessionJwt:r,refreshJwt:i}=e;if(i&&Ri(`${n}${Li}`,i),r)if(t){const n=t.sameSite||"Strict",i=null===(o=t.secure)||void 0===o||o;!function(e,t,n){if(t){const{cookieDomain:o,cookiePath:r,cookieSameSite:i,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);li.set(e,t,{path:r,domain:l?o:void 0,expires:c,sameSite:i,secure:a})}}(Di,r,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i}))}else Ri(`${n}${Di}`,r);e.idToken&&Ri(`${n}${Wi}`,e.idToken)})(await Oi(t),r,i)}}));var c;const l=Zo(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const o=await t(...n);return Fi(e),o})(i));return Object.assign(l,{getRefreshToken:()=>Ni(i),getSessionToken:()=>Ki(i),getIdToken:()=>qi(i)})}))((e=>{const t=ai(e),n=js(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async o=>{var r;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()}})}const i=Ki(),s=Ni();let a="";if(e.getExternalToken)try{a=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){Ti("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:i?"t":"f",dcr:s?"t":"f"},a)},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:Is(t),webauthn:ys(t),fedcm:(o=t,r=e.projectId,{onetap:{requestExchangeCode(e){ks(o,e)},requestAuthentication(e){ks(o,e)}},async oneTap(e,t,n,r,i){await Ss(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:r,onDismissed:i})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(r+ws),clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(i.token)},isSupported:()=>Mi&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(r+ws);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!i&&!!i.token}catch(e){return!1}}}),oidc:n});var o,r})),Rs={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"},As={roles:"/v1/mgmt/role/all"},Es=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)})),Ts=(...e)=>n(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((n=>{const o=[],r=(new Date).getTime()/1e3+2592e3,i=new Date(r).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:r,expireTimeFormatted:i,createdTime:r,createdTimeFormatted:i,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,r;return e.desc?null===(r=n[e.field])||void 0===r?void 0:r.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()))))}))})),_s=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:n,permittedIps:o},r){const i=Math.random().toString(10).substring(15);return new Promise((s=>{s({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${i}`,name:e||`Access Key ${i}`,createdBy:n||`User ${i}`,editable:!0,expireTime:r,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:o,status:"active",clientId:`Client ID ${i}`,boundUserId:n||`User ${i}`}})}))})),Ms=()=>n(void 0,void 0,void 0,(function*(){})),$s=()=>n(void 0,void 0,void 0,(function*(){})),Us=()=>n(void 0,void 0,void 0,(function*(){})),Ps=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})})),Ds=({httpClient:e,tenant:t,mock:o})=>({search:(...r)=>n(void 0,[...r],void 0,(function*({page:n,limit:r=1e4,text:i,sort:s}={}){if(o)return Ts({page:n,limit:r,text:i,sort:s});const a=yield e.post(Rs.search,{limit:r,page:n,text:i,sort:s},{queryParams:{tenant:t}});yield Es(a);return(yield a.json()).keys})),deleteBatch:r=>n(void 0,void 0,void 0,(function*(){if(o)return Us();const n=yield e.post(Rs.deleteBatch,{ids:r},{queryParams:{tenant:t}});return yield Es(n),n.json()})),create:r=>n(void 0,[r],void 0,(function*({name:n,expiration:r,roleNames:i,userId:s,permittedIps:a}){const c=new Date;c.setDate(c.getDate()+ +r);const l="0"===r[0]?0:Math.floor(c.getTime()/1e3);if(o)return _s({name:n,expiration:r,roleNames:i,userId:s,permittedIps:a},l);const d=yield e.post(Rs.create,{name:n,expireTime:l,roleNames:i,userId:s,permittedIps:a},{queryParams:{tenant:t}});yield Es(d);return yield d.json()})),activate:r=>n(void 0,void 0,void 0,(function*(){if(o)return Ms();const n=yield e.post(Rs.activate,{ids:r},{queryParams:{tenant:t}});yield Es(n);return yield n.json()})),deactivate:r=>n(void 0,void 0,void 0,(function*(){if(o)return $s();const n=yield e.post(Rs.deactivate,{ids:r},{queryParams:{tenant:t}});yield Es(n);return yield n.json()}))}),Ls=({httpClient:e,tenant:t,mock:o})=>({getTenantRoles:()=>n(void 0,void 0,void 0,(function*(){if(o)return Ps(t);const n=yield e.get(As.roles,{queryParams:{tenant:t}});return yield Es(n),n.json()}))}),Ws=u((e=>{var t,s,a,c;const l=i(j,x,w,C,mn,O({tenant:O.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"),r(this,s,((e,t,n,o)=>{const r=Cs(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.5.6"}}));return{accesskey:Ds({httpClient:r.httpClient,tenant:t,mock:n}),tenant:Ls({httpClient:r.httpClient,tenant:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},c})),Ns=u((e=>{const t=i(gn({name:"widget",initialState:Jn,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Tn.reducer(e),$n.reducer(e),Dn.reducer(e),Nn.reducer(e),Fn.reducer(e),Bn.reducer(e)},asyncActions:{searchAccessKeys:Dn.action,createAccessKey:Tn.action,activateAccessKeys:Nn.action,deactivateAccessKeys:Fn.action,deleteAccessKeys:$n.action,getTenantRoles:Bn.action}}),I,w,Ws)(e);return class extends t{constructor(...e){super(...e),this.state=Jn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ks=u((e=>{const t=i(T,O({"widget-id":O.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){const t=yield this.fetchStaticResource(`access-key-management-widget/${this.widgetId}/${e}`,"text");return null==t?void 0:t.body}))}}})),qs=u((e=>{var t,r,a;return a=class extends(i(w,I,q,V,Ks,Ns)(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",r).call(this),this.actions.searchAccessKeys(),this.actions.getTenantRoles()]),this.onWidgetRootReady()}))}},t=new WeakSet,r=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})),Fs=u((e=>{var t,r,s,a,l;return l=class extends(i(Ns,w,qs)(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",r).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,bn(this.state)),this.subscribe(o(this,s,"f").bind(this),bn)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,r=function(){var e;this.accessKeysTable=new ne(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})),zs=u((e=>{var t,r,a;return a=class extends(i(Ns,le,w,qs)(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",r).call(this)}))}},t=new WeakSet,r=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 Q((()=>{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 Q((()=>{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=kn(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const o=new ae(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=On(this.state);o.text=`Activate ${e}?`}}))},a})),Bs=u((e=>{var t,r,s,a;return a=class extends(i(w,qs,Ns,zs)(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",r).call(this),this.subscribe(o(this,s,"f").bind(this),xn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.activateButton=new Q(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})),Js=u((e=>{var t,r,a;return a=class extends(i(Ns,le,vn,w,qs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=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 Q((()=>{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})),Hs=u((e=>{var t,a,c,l,d;return d=class extends(i(Ns,le,vn,w,qs,Js)(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 Q((()=>{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 Q((()=>{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())}})))),r(this,a,new ie((()=>{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})),Vs=u((e=>{var t,r,s;return s=class extends(i(w,Hs,qs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){var e;this.createButton=new Q(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})),Zs=u((e=>{var t,r,a;return a=class extends(i(Ns,le,w,qs)(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",r).call(this)}))}},t=new WeakSet,r=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 Q((()=>{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 Q((()=>{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=kn(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const o=new ae(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=On(this.state);o.text=`Deactivate ${e}?`}}))},a})),Xs=u((e=>{var t,r,s,a;return a=class extends(i(w,qs,Ns,Zs)(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",r).call(this),this.subscribe(o(this,s,"f").bind(this),xn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.deactivateButton=new Q(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})),Ys=u((e=>{var t,r,a;return a=class extends(i(Ns,le,w,qs)(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",r).call(this)}))}},t=new WeakSet,r=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 Q((()=>{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 Q((()=>{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=kn(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const o=new ae(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=On(this.state);o.text=`Delete ${e}?`}}))},a})),Gs=u((e=>{var t,r,s,a;return a=class extends(i(w,qs,Ns,Ys)(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",r).call(this),this.subscribe(o(this,s,"f").bind(this),xn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.deleteButton=new Q(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})),Qs=u((e=>{var t,r,s,a;return a=class extends(i(w,qs,Ns)(e)){constructor(){super(...arguments),t.add(this),r.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)}))}},r=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new ce(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(o(this,r,"f"))},a}));const ea={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},ta=u((e=>{var t,r,s,a,l;return l=class extends(i(w,Ns,ue,I)(e)){constructor(){super(...arguments),t.add(this),a.set(this,c((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const i=o(this,t,"m",s).call(this,e);i.setContent(o(this,t,"m",r).call(this,{type:e,msg:n})),i.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),wn)}))}},a=new WeakMap,t=new WeakSet,r=function({type:e,msg:t}){const n=ea[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})),na=u((e=>class extends(i($,pe,Fs,Vs,Gs,Qs,Bs,Xs,ta)(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)}))}})),oa=i((e=>class extends(na(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",oa);const ra=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var ia,sa,aa,ca,la,da,ua,ha,pa,fa;const ga=document.createElement("template");ga.innerHTML=`\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;const va=i(B)(HTMLElement);class ma extends va{constructor(){var e;super(),ia.add(this),sa.set(this,new m({messages:[]})),aa.set(this,void 0),ca.set(this,void 0),la.set(this,void 0),da.set(this,{resize:o(this,ia,"m",fa).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(ga.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'),r(this,aa,this.shadowRoot.querySelector(".debugger"),"f"),r(this,ca,o(this,aa,"f").querySelector(".content"),"f"),r(this,la,o(this,aa,"f").querySelector(".header"),"f")}updateData(e){o(this,sa,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=ra(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,aa,"f"),o(this,la,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,da,"f").resize),(e=o(this,aa,"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,aa,"f").onresize=o(this,ia,"m",pa).bind(this),o(this,sa,"f").subscribe(o(this,ia,"m",ua).bind(this))}disconnectedCallback(){o(this,sa,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,da,"f").resize)}}sa=new WeakMap,aa=new WeakMap,ca=new WeakMap,la=new WeakMap,da=new WeakMap,ia=new WeakSet,ua=function(e){o(this,ia,"m",ha).call(this,e),o(this,ia,"m",pa).call(this)},ha=function(e){o(this,ca,"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("")},pa=function(){o(this,ca,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,r=n.clientHeight>20;o||r?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},fa=function(){const[e,t]=ra(o(this,aa,"f"),Number.parseInt(o(this,aa,"f").style.left,10),Number.parseInt(o(this,aa,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,aa,"f").style.top=`${t}px`,o(this,aa,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ma);var ya=Object.freeze({__proto__:null,default:ma});return oa}();
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 r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function r(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,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,r)=>{var i;return`${t}${o}${(null===(i=null==n?void 0:n[r])||void 0===i?void 0:i[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=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 h,p,f,g;function v(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!v(i,s))return!1}else if(i!==s)return!1}return!0}let m=class{constructor(e={},{forceUpdate:t=!1}={}){h.set(this,void 0),p.set(this,{}),f.set(this,0),g.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,h,"f")):e,n=Object.assign(Object.assign({},o(this,h,"f")),t);if(o(this,g,"f")||!v(o(this,h,"f"),n)){const e=o(this,h,"f");r(this,h,n,"f"),Object.freeze(o(this,h,"f")),setTimeout((()=>{Object.values(o(this,p,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},r(this,h,e,"f"),r(this,g,t,"f")}get current(){return Object.assign({},o(this,h,"f"))}subscribe(e){return r(this,f,o(this,f,"f")+1,"f"),o(this,p,"f")[o(this,f,"f")]=e,o(this,f,"f").toString()}unsubscribe(e){const t=!!o(this,p,"f")[e];return t&&delete o(this,p,"f")[e],t}unsubscribeAll(){return r(this,p,{},"f"),!0}};h=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap;const y=["error","warn","info","debug"],w=u((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",i).call(this,console))}set logger(e){r(this,n,o(this,t,"m",i).call(this,e||console),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return y.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})),b="undefined"!=typeof localStorage,k=b&&localStorage.getItem("base.content.url")||"",S=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,I=u((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(r(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),x=u((e=>{var t,n;const r=i(w,I)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,r;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,r=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>r(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&r(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const r=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(r,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),O=e=>t=>{var n,r,s;const a=i(w,I,x)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,o(this,n,"m",r).bind(this))}async init(){var e;c.forEach((e=>o(this,n,"m",r).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,r=function(t,n){const o=e[t],r="function"==typeof o?o(t,n):o;r&&this.logger.error(r)},s};O.missingAttrValidator=S;const j=u((e=>{const t=i(O({"project-id":S}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),C=u((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),R="Trying the next fallback URL...",A=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)}};function E({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o="https://static.descope.com/pages"}){const r=new URL(o);return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,n,t),r.baseUrl=o,r}const T=u((e=>{var t,n,s,a,c;const l=i(w,j,C)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0)}async fetchStaticResource(e,n){const i=o(this,t,"m",a).call(this,e),c=Array.isArray(i)?e=>{if(e!==i.length-1){const{baseUrl:t}=i[e];r(this,s,t,"f")}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const r=Array.isArray(e)?e:[e];for(let e=0;e<r.length;e++){const i=r[e],s=e===r.length-1;try{const r=await A(i.toString(),t,{logger:n});if(r.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${i}`),r;const a=`Error fetching URL ${i} [${r.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${R}`)}catch(e){const t=`Error fetching URL ${i} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${R}`)}}})(i,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(e){const t=k||this.baseStaticUrl;if(t)return E({projectId:this.projectId,filename:e,baseUrl:t});const i=o(this,n,"f")!==this.baseUrl,a=i&&!!this.baseUrl;i&&(r(this,n,this.baseUrl,"f"),r(this,s,void 0,"f"));const c=E({projectId:this.projectId,filename:e,baseUrl:o(this,s,"f")});if(!a)return c;return[E({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),c]},c})),_=u((e=>{var t,n;const r=i(O({"project-id":S}))(e);return n=class extends r{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})),M=u((e=>{var t,n,s,a,c;const l=i(T,_,I)(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")||r(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){r(this,s,void 0,"f")},c})),$=u((e=>{var t,n,s,a,c,l,d;return d=class extends(i(I,w)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,r)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,r),"debug"===e&&o(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var r;null===(r=super.onLogEvent)||void 0===r||r.call(this,e,n),"error"===e&&o(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),r(this,n,null,"f")},a=async function(){r(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return ya})),document.body.appendChild(o(this,n,"f"))},c=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},l=function(e,t){var r;e&&(null===(r=o(this,n,"f"))||void 0===r||r.updateData({title:e,description:t}))},d})),U=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],P=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()}`},D=(e,t)=>new Promise(((n,o)=>{const r=(e=>{const t=document.createElement("script");return t.id=e,t})(e);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),n(r)},r.src=t.toString(),document.body.appendChild(r)})),L=e=>"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)}))})),W=u((e=>{const t=i(w)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[]){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"`),(async(e,t)=>{for(const o of e){const{id:e,url:r}=o,i=(n=e,document.querySelector(`script#${n}`));if(i)try{return await L(i),o}catch(e){t(o,!0)}else try{return await D(e,r),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="")=>e.reduce(((e,r)=>{const i=r;if(!i)return e;let s;try{s=new URL(i)}catch(e){throw new Error(`Invalid URL: ${i}`)}return"/"!==s.pathname||(s.pathname=`/npm/${t}@${n}/${o}`),[...e,{url:s,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${P(s)}`}]}),[]))([...o,this.baseCdnUrl,...U],e,t,n),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),N="base.ui.components.url",K=b&&localStorage.getItem(N),q=u((e=>{var t,n,s,a,c,l;const d=i(w,M,W)(e);return l=class extends d{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get descopeUi(){return o(this,s,"f")||r(this,s,o(this,t,"m",c).call(this),"f"),o(this,s,"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",a).call(this,e))))}},s=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},a=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{return await this.injectNpmLib("@descope/web-components-ui",await o(this,t,"m",n).call(this),"dist/umd/index.js",[K]),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},l})),F=u((e=>{var t,n,r;const s=i(I,x)(e);return r=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(){window.DESCOPE_NONCE=this.nonce},r}));class z{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 B=u((e=>{const t=i(F)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new z(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}}})),J="content-root",H="root",V=u((e=>{const t=i(B)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${H}">\n <div id="${J}"></div>\n </div>\n `,this.injectStyle(`\n #${H}, #${J} {\n height: 100%;\n }\n #${H} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(J),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(H)}}})),Z="descope-modal";var X,Y;let G=class{constructor(e,t){X.set(this,void 0),this.nodeName="",r(this,X,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,X,"f"))}get ele(){var e,t;const n="function"==typeof o(this,X,"f")?o(this,X,"f").call(this):o(this,X,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}};X=new WeakMap;let Q=class extends G{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 ee=/^descope-grid-([^-]+)-column$/,te={text:class extends G{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 G{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 ne=class extends G{constructor(){super(...arguments),this.nodeName="descope-grid",Y.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=ee.exec(t.localName))||void 0===n?void 0:n[1],r=te[o];return r?(e.push(new r(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const r=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);a(r,this.ele.columns)||(this.ele.columns=r,null===(n=o(this,Y,"f"))||void 0===n||n.call(this,r))}onColumnsChange(e){r(this,Y,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var oe;Y=new WeakMap;let re=class extends G{constructor(){super(...arguments),oe.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,oe,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,oe,"f").content.cloneNode(!0)))}setContent(e){r(this,oe,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};oe=new WeakMap;let ie=class extends G{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}},se=class extends G{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()}},ae=class extends G{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)}},ce=class extends G{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 le=u((e=>{var t,n;const r=i(I,V,q)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends re{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Z);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([Z]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),de="descope-notification",ue=u((e=>{var t,n;const r=i(I,V,q)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends se{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(de);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([de])}},t=new WeakMap,n})),he=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',pe=u((e=>{var t,n,s,a,c,l,d,u,h,p,f,g,v,m;const y=i(O({theme:he}),T,I,q,M,V,x,B)(e);return m=class extends y{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{o(this,t,"m",g).call(this),o(this,v,"f").call(this,"os"===this.getAttribute("theme"))})),v.set(this,(e=>{var n,r,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(r=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===r?void 0:r[s])||void 0===i||i.call(r,"change",(()=>o(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,f,"f").call(this),await Promise.all([o(this,t,"m",l).call(this),o(this,t,"m",d).call(this)]),this.observeAttributes(["theme"],o(this,f,"f")),this.observeAttributes(["style-id"],(()=>{r(this,s,null,"f"),o(this,t,"m",h).call(this),o(this,t,"m",l).call(this),o(this,t,"m",d).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(N))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(N),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},c=function(){return o(this,s,"f")||(r(this,s,o(this,t,"m",a).call(this),"f"),o(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,s,"f")},l=async function(){var e,i;const s=await o(this,t,"a",c);s&&(o(this,n,"f")||r(this,n,this.injectStyle(""),"f"),o(this,n,"f").replaceSync(((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||"")))},d=async function(){var e,n;const r=await o(this,t,"a",c);if(!r)return;const i=await this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components,dark:null===(n=null==r?void 0:r.dark)||void 0===n?void 0:n.components})},u=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],r=null==n?void 0:n.cssTemplate,i=o||r;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},h=async function(){const e=await o(this,t,"m",u).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")},p=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){o(this,t,"m",h).call(this),o(this,t,"m",p).call(this)},m}));var fe=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ge=()=>Math.random().toString(36).substring(7).split("").join("."),ve={INIT:`@@redux/INIT${ge()}`,REPLACE:`@@redux/REPLACE${ge()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ge()}`};function me(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 ye(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 we(e){let t=typeof e;return t=ye(e),t}function be(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${we(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: '${we(n)}'`);return n(be)(e,t)}let o=e,r=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function 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 r}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${we(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function h(e){if(!me(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${we(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: '${we(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,r=o(r,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}h({type:ve.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: '${we(e)}`);o=e,h({type:ve.REPLACE})},[fe]: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: '${we(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[fe](){return this}}}}}function ke(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Se(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const r=t[o];void 0===e[r]&&ke(`No reducer provided for key "${r}"`),"function"==typeof e[r]&&(n[r]=e[r])}const o=Object.keys(n);let r,i;r={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:ve.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:ve.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 '${ve.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;{const o=function(e,t,n,o){const r=Object.keys(t),i=n&&n.type===ve.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!me(e))return`The ${i} has unexpected type of "${we(e)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===ve.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${r.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,r);o&&ke(o)}let s=!1;const a={};for(let r=0;r<o.length;r++){const i=o[r],c=n[i],l=e[i],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 "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=d,s=s||d!==l}return s=s||o.length!==Object.keys(e).length,s?a:e}}function Ie(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function xe(e){return me(e)&&"type"in e&&"string"==typeof e.type}var Oe=Symbol.for("immer-nothing"),je=Symbol.for("immer-draftable"),Ce=Symbol.for("immer-state"),Re=[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 Ae(e,...t){{const n=Re[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Ee=Object.getPrototypeOf;function Te(e){return!!e&&!!e[Ce]}function _e(e){return!!e&&($e(e)||Array.isArray(e)||!!e[je]||!!e.constructor?.[je]||We(e)||Ne(e))}var Me=Object.prototype.constructor.toString();function $e(e){if(!e||"object"!=typeof e)return!1;const t=Ee(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Me}function Ue(e,t){0===Pe(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Pe(e){const t=e[Ce];return t?t.type_:Array.isArray(e)?1:We(e)?2:Ne(e)?3:0}function De(e,t){return 2===Pe(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Le(e,t,n){const o=Pe(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function We(e){return e instanceof Map}function Ne(e){return e instanceof Set}function Ke(e){return e.copy_||e.base_}function qe(e,t){if(We(e))return new Map(e);if(Ne(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&$e(e)){if(!Ee(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ce];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const r=o[t],i=n[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[r]})}return Object.create(Ee(e),n)}function Fe(e,t=!1){return Be(e)||Te(e)||!_e(e)||(Pe(e)>1&&(e.set=e.add=e.clear=e.delete=ze),Object.freeze(e),t&&Ue(e,((e,t)=>Fe(t,!0)))),e}function ze(){Ae(2)}function Be(e){return Object.isFrozen(e)}var Je,He={};function Ve(e){const t=He[e];return t||Ae(0,e),t}function Ze(){return Je}function Xe(e,t){t&&(Ve("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ye(e){Ge(e),e.drafts_.forEach(et),e.drafts_=null}function Ge(e){e===Je&&(Je=e.parent_)}function Qe(e){return Je={drafts_:[],parent_:Je,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function et(e){const t=e[Ce];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function tt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ce].modified_&&(Ye(t),Ae(4)),_e(e)&&(e=nt(t,e),t.parent_||rt(t,e)),t.patches_&&Ve("Patches").generateReplacementPatches_(n[Ce].base_,e,t.patches_,t.inversePatches_)):e=nt(t,n,[]),Ye(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Oe?e:void 0}function nt(e,t,n){if(Be(t))return t;const o=t[Ce];if(!o)return Ue(t,((r,i)=>ot(e,o,t,r,i,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return rt(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let r=t,i=!1;3===o.type_&&(r=new Set(t),t.clear(),i=!0),Ue(r,((r,s)=>ot(e,o,t,r,s,n,i))),rt(e,t,!1),n&&e.patches_&&Ve("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function ot(e,t,n,o,r,i,s){if(r===n&&Ae(5),Te(r)){const s=nt(e,r,i&&t&&3!==t.type_&&!De(t.assigned_,o)?i.concat(o):void 0);if(Le(n,o,s),!Te(s))return;e.canAutoFreeze_=!1}else s&&n.add(r);if(_e(r)&&!Be(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;nt(e,r),t&&t.scope_.parent_||rt(e,r)}}function rt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Fe(t,n)}var it={get(e,t){if(t===Ce)return e;const n=Ke(e);if(!De(n,t))return function(e,t,n){const o=ct(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_||!_e(o)?o:o===at(e.base_,t)?(dt(e),e.copy_[t]=ut(o,e)):o},has:(e,t)=>t in Ke(e),ownKeys:e=>Reflect.ownKeys(Ke(e)),set(e,t,n){const o=ct(Ke(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=at(Ke(e),t),r=o?.[Ce];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||De(e.base_,t)))return!0;dt(e),lt(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!==at(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,dt(e),lt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ke(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Ae(11)},getPrototypeOf:e=>Ee(e.base_),setPrototypeOf(){Ae(12)}},st={};function at(e,t){const n=e[Ce];return(n?Ke(n):e)[t]}function ct(e,t){if(!(t in e))return;let n=Ee(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ee(n)}}function lt(e){e.modified_||(e.modified_=!0,e.parent_&&lt(e.parent_))}function dt(e){e.copy_||(e.copy_=qe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ue(it,((e,t)=>{st[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),st.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Ae(13),st.set.call(this,e,t,void 0)},st.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Ae(14),it.set.call(this,e[0],t,n,e[0])};function ut(e,t){const n=We(e)?Ve("MapSet").proxyMap_(e,t):Ne(e)?Ve("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Ze(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=it;n&&(r=[o],i=st);const{revoke:s,proxy:a}=Proxy.revocable(r,i);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Ze()).drafts_.push(n),n}function ht(e){return Te(e)||Ae(10,e),pt(e)}function pt(e){if(!_e(e)||Be(e))return e;const t=e[Ce];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 Ue(n,((e,t)=>{Le(n,e,pt(t))})),t&&(t.finalized_=!1),n}var ft=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...r){return o.produce(e,(e=>t.call(this,e,...r)))}}let o;if("function"!=typeof t&&Ae(6),void 0!==n&&"function"!=typeof n&&Ae(7),_e(e)){const r=Qe(this),i=ut(e,void 0);let s=!0;try{o=t(i),s=!1}finally{s?Ye(r):Ge(r)}return Xe(r,n),tt(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Oe&&(o=void 0),this.autoFreeze_&&Fe(o,!0),n){const t=[],r=[];Ve("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}Ae(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const r=this.produce(e,t,((e,t)=>{n=e,o=t}));return[r,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){_e(e)||Ae(8),Te(e)&&(e=ht(e));const t=Qe(this),n=ut(e,void 0);return n[Ce].isManual_=!0,Ge(t),n}finishDraft(e,t){const n=e&&e[Ce];n&&n.isManual_||Ae(9);const{scope_:o}=n;return Xe(o,t),tt(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Ve("Patches").applyPatches_;return Te(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},gt=ft.produce;ft.produceWithPatches.bind(ft),ft.setAutoFreeze.bind(ft),ft.setUseStrictShallowCopy.bind(ft),ft.applyPatches.bind(ft),ft.createDraft.bind(ft),ft.finishDraft.bind(ft);var vt=(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})}}},mt=(e,t,n)=>{const{memoize:o,memoizeOptions:r}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...r);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},yt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var wt=e=>Array.isArray(e)?e:[e];function bt(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 kt(e,t){const n=[],{length:o}=e;for(let r=0;r<o;r++)n.push(e[r].apply(null,t));return n}var St="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},It=0,xt=1;function Ot(){return{s:It,v:void 0,o:null,p:null}}function jt(e,t={}){let n=Ot();const{resultEqualityCheck:o}=t;let r,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=Ot(),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=Ot(),e.set(n,t)):t=o}}const a=t;let c;if(t.s===xt)c=t.v;else if(c=e.apply(null,arguments),i++,o){const e=r?.deref?.()??r;null!=e&&o(e,c)&&(c=e,0!==i&&i--);r="object"==typeof c&&null!==c||"function"==typeof c?new St(c):c}return a.s=xt,a.v=c,c}return s.clearCache=()=>{n=Ot(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function Ct(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,r=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:d=jt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=wt(l),f=wt(u),g=bt(e),v=c((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){r++;const e=kt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...yt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:vt},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:mt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=kt(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:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:c,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Rt=Ct(jt),At=Object.assign(((e,t=Rt)=>{!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:()=>At});function Et(e){return({dispatch:t,getState:n})=>o=>r=>"function"==typeof r?r(t,n,e):o(r)}var Tt=Et(),_t=Et;((...e)=>{const t=Ct(...e)})(jt);var Mt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ie:Ie.apply(null,arguments)},$t=e=>e&&"function"==typeof e.match;function Ut(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=>xe(t)&&t.type===e,n}function Pt(e){return"function"==typeof e&&"type"in e&&$t(e)}function Dt(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 Lt=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 Wt(e){return _e(e)?gt(e,(()=>{})):e}function Nt(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Kt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function qt(e,t,n){const o=Ft(e,t,n);return{detectMutations:()=>zt(e,t,o,n)}}function Ft(e,t=[],n,o="",r=new Set){const i={value:n};if(!e(n)&&!r.has(n)){r.add(n),i.children={};for(const r in n){const s=o?o+"."+r:r;t.length&&-1!==t.indexOf(s)||(i.children[r]=Ft(e,t,n[r],s))}}return i}function zt(e,t=[],n,o,r=!1,i=""){const s=n?n.value:void 0,a=s===o;if(r&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:i};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let r in c){const s=i?i+"."+r:r;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=zt(e,t,n.children[r],o[r],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function Bt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||me(e)}function Jt(e,t="",n=Bt,o,r=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),c=r.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(r.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Jt(l,a,n,o,r,i),s))return s}return i&&Ht(e)&&i.add(e),!1}function Ht(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Ht(t))return!1;return!0}function Vt(e){return"boolean"==typeof e}var Zt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:r=!0}=e??{};let i=new Lt;if(t&&(Vt(t)?i.push(Tt):i.push(_t(t.extraArgument))),n){let e={};Vt(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,o,r){return JSON.stringify(e,n(t,r),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(r,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,r):o.push(r),~n.indexOf(i)&&(i=t.call(this,r,i))}else n.push(i);return null==e?i:e.call(this,r,i)}},{isImmutable:o=Kt,ignoredPaths:r,warnAfter:i=32}=e;const s=qt.bind(null,o,r);return({getState:e})=>{let n,o=e(),r=s(o);return a=>c=>{const l=Dt(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(c);return l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(o){let e={};Vt(o)||(e=o),i.push(function(e={}){{const{isSerializable:t=Bt,getEntries:n,ignoredActions:o=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!xe(u))return l(u);const h=l(u),p=Dt(s,"SerializableStateInvariantMiddleware");return c||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=Jt(u,"",t,n,r,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=Jt(e.getState(),"",t,n,i,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(r){let e={};Vt(r)||(e=r),i.unshift(function(e={}){const{isActionCreator:t=Pt}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return i},Xt=e=>t=>{setTimeout(t,e)},Yt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Xt(10),Gt=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Lt(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let r=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Yt:"callback"===e.type?e.queueNotification:Xt(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>r&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return r=!e?.meta?.RTK_autoBatch,i=!r,i&&(s||(s=!0,c(l))),o.dispatch(e)}finally{r=!0}}})})("object"==typeof n?n:void 0)),o};function Qt(e){const t=Zt(),{reducer:n,middleware:o,devTools:r=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!me(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=Se(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=Ie;r&&(l=Mt({trace:!0,..."object"==typeof r&&r}));const d=function(...e){return t=>(n,o)=>{const r=t(n,o);let i=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:r.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=Ie(...a)(r.dispatch),{...r,dispatch:i}}}(...c),u=Gt(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 be(a,i,l(...h))}function en(e){const t={},n=[];let o;const r={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,r},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),r},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,r}};return e(r),[t,n,o]}function tn(...e){return t=>e.some((e=>((e,t)=>$t(e)?e.match(t):e(t))(e,t)))}var nn=["name","message","stack","code"],on=class{constructor(e,t){this.payload=e,this.meta=t}_type},rn=class{constructor(e,t){this.payload=e,this.meta=t}_type},sn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of nn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},an=(()=>{function e(e,t,n){const o=Ut(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),r=Ut(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=Ut(e+"/rejected",((e,t,o,r,i)=>({payload:r,error:(n&&n.serializeError||sn)(e||"Rejected"),meta:{...i||{},arg:o,requestId:t,rejectedWithValue:!!r,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||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(r(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 on(e,t),fulfillWithValue:(e,t)=>new rn(e,t)})).then((t=>{if(t instanceof on)throw t;return t instanceof rn?o(t.payload,l,e,t.meta):o(t,l,e)}))])}catch(t){p=t instanceof on?i(null,l,e,t.payload,t.meta):i(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,arg:e,unwrap:()=>p.then(cn)})}}),{pending:r,rejected:i,fulfilled:o,settled:tn(i,o),typePrefix:e})}return e.withTypes=()=>e,e})();function cn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var ln=Symbol.for("rtk-slice-createasyncthunk");function dn(e,t){return`${e}/${t}`}function un(e,t,n,o){function r(r,...i){let s=n.call(e,r);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return r.unwrapped=t,r}var hn=function({creators:e}={}){const t=e?.asyncThunk?.[ln];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const r=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(r),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?en(e.extraReducers):[e.extraReducers],r={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,r,i]=en(t);if(function(e){return"function"==typeof e}(e))n=()=>Wt(e());else{const t=Wt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...r.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(Te(e)){const o=n(e,t);return void 0===o?e:o}if(_e(e))return gt(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in r)e.addCase(t,r[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}i.forEach((o=>{const i=r[o],s={reducerName:o,type:dn(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,r){let i,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=o.reducer,s=o.prepare}else i=o;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?Ut(e,s):Ut(e))}(s,i,a):function({type:e,reducerName:t},n,o,r){if(!r)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:d}=n,u=r(e,i,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||pn,pending:a||pn,rejected:c||pn,settled:l||pn})}(s,i,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=Nt(d,this,{insert:()=>new WeakMap});return Nt(n,t,{insert:()=>{const n={};for(const[o,r]of Object.entries(e.selectors??{}))n[o]=un(this,r,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 pn(){}var fn="listenerMiddleware";Ut(`${fn}/add`),Ut(`${fn}/removeAll`),Ut(`${fn}/remove`);const gn=e=>u((t=>{const n=hn(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(w)(t)){constructor(...e){super(...e);const t=Qt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),r=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{cn(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},i=Object.keys(o).reduce(((e,t)=>(e[t]=r(o[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),vn=u((e=>class extends(w(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}})),mn=u((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),yn=e=>e.selectedAccessKeysIds,wn=e=>e.notifications,bn=Rt((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}))))),kn=Rt(yn,bn,((e,t)=>t.filter((t=>e.includes(t.id))))),Sn=Rt(yn,(e=>!!e.length)),In=Rt(kn,(e=>e.every((e=>e.editable)))),xn=Rt(In,Sn,((e,t)=>e&&t));Rt(yn,(e=>1===e.length));const On=Rt(kn,(e=>1===e.length?e[0].name:`${e.length} access keys`)),jn=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)}))}))},Cn=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}}),Rn=({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)})}}),An=an("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),En=jn(An)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},Cn((e=>e.createAccessKey)),Rn({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>`}})),Tn={action:An,reducer:En},_n=an("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),Mn=jn(_n)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},Cn((e=>e.deleteAccessKey)),Rn({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"]}`})),$n={action:_n,reducer:Mn},Un=an("accessKeys/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.accesskey.search(Object.assign(Object.assign({},o),e))})),Pn=jn(Un)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},Cn((e=>e.accessKeysList))),Dn={action:Un,reducer:Pn},Ln=an("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),Wn=jn(Ln)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},Cn((e=>e.activateAccessKey)),Rn({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"]}`})),Nn={action:Ln,reducer:Wn},Kn=an("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),qn=jn(Kn)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},Cn((e=>e.deactivateAccessKey)),Rn({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"]}`})),Fn={action:Kn,reducer:qn},zn=an("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),Bn={action:zn,reducer:jn(zn)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},Cn((e=>e.tenantRoles)))},Jn={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},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]};class Hn extends Error{}function Vn(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 Zn(e,t){if("string"!=typeof e)throw new Hn("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 Hn(`Invalid token specified: missing part #${n+1}`);let r;try{r=Vn(o)}catch(e){throw new Hn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new Hn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Hn.prototype.name="InvalidTokenError";var Xn={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const Yn="<region>",Gn=`https://api.${Yn}descope.com`,Qn=6e5,eo="dct",to=()=>{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")}},no=[521,524],oo=e=>async(...t)=>{let n=await e(...t);no.includes(n.status)&&(n=await e(...t),n.retries=1);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let ro;const io=()=>{if(ro)return ro;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 ro=`${t}-${n}`,ro};var so,ao;(ao=so||(so={})).get="GET",ao.delete="DELETE",ao.post="POST",ao.put="PUT",ao.patch="PATCH";const co=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(Yn,r?r+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{i=`${i}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return i},lo=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),uo={"Content-Type":"application/json"},ho=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},po=(e,t)=>{const n={"x-descope-sdk-session-id":io(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.49.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},fo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var go=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:r,hooks:i,cookiePolicy:s,fetch:a})=>{const c=e||Gn,l=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>to().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await oo(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return to().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:oo(n)})(r,a),d=async e=>{var r;const a=(null==i?void 0:i.beforeRequest)?i.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:lo(ho(t,g),po(t,o),(null==n?void 0:n.baseHeaders)||{},fo(v)?uo:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const y=await l(co({path:d,baseUrl:c,queryParams:p,projectId:t}),m);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(e,null==y?void 0:y.clone()),null==i?void 0:i.transformResponse){const e=await y.json(),t=((null===(r=y.headers)||void 0===r?void 0:r.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}return y};return{get:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:so.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:so.post,token:r}),patch:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:so.patch,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:so.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:so.delete,token:o}),hooks:i,buildUrl:(e,n)=>co({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 r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=r.length&&(await Promise.allSettled(null==r?void 0:r.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},vo=429;function mo(e,t,n){var o;let r=yo(e);if(t){if(!(null==r?void 0:r.tenants)&&(null==r?void 0:r[eo])===t)return(null==r?void 0:r[n])||[];r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]}const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function yo(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Zn(e)}function wo(e){const{exp:t}=yo(e);return(new Date).getTime()/1e3>t}function bo(e){let t=yo(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function ko(e,t){return mo(e,t,"permissions")}function So(e,t){return mo(e,t,"roles")}const Io=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function xo(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=i:(r.error=i,o.status===vo&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}function Oo(e){var t;return(null===(t=yo(e))||void 0===t?void 0:t[eo])||""}const jo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Co=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},Ro=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Ao=e=>t=>e.test(t),Eo=Ao(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),To=Ao(/^\+[1-9]{1}[0-9]{3,14}$/),_o=jo(Eo,'"{val}" is not a valid email'),Mo=jo(To,'"{val}" is not a valid phone number'),$o=jo((e=>e.length>=1),"Minimum length is 1");const Uo=jo((e=>"string"==typeof e),"Input is not a string"),Po=jo((e=>Array.isArray(e)),"Input is not an array"),Do=jo((e=>"boolean"==typeof e),"Input is not a boolean"),Lo=jo((e=>void 0===e),"Input is defined"),Wo=Co([Uo(),Lo()],"Input is not a string or undefined"),No=Co([Po(),Do()],"Input is not an array or boolean"),Ko=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Ro(...e).validate(n[t]))),t(...n)),qo=e=>[Uo(`"${e}" must be a string`)],Fo=e=>[Wo(`"${e}" must be string or undefined`)],zo=e=>[Uo(`"${e}" must be a string`),$o(`"${e}" must not be empty`)],Bo=e=>[Uo(`"${e}" must be a string`),_o()],Jo=e=>[Uo(`"${e}" must be a string`),Mo()],Ho=Ko(zo("accessKey")),Vo=e=>({exchange:Ho(((t,n)=>xo(e.post(Xn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Zo=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const s=i[r];i[r]=n(s)})),e),Xo=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Qn,Qn)});var Yo,Go;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(Yo||(Yo={})),function(e){e.email="email"}(Go||(Go={}));const Qo=Object.assign(Object.assign({},Yo),Go);var er;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(er||(er={}));const tr=zo("loginId"),nr=Ko(zo("token")),or=Ko(tr),rr=Ko(zo("pendingRef")),ir=Ko(tr,Bo("email")),sr=e=>({verify:nr((t=>xo(e.post(Xn.enchantedLink.verify,{token:t})))),signIn:or(((t,n,o,r)=>xo(e.post(Io(Xn.enchantedLink.signIn,Qo.email),{loginId:t,URI:n,loginOptions:o},{token:r})))),signUpOrIn:or(((t,n,o)=>xo(e.post(Io(Xn.enchantedLink.signUpOrIn,Qo.email),{loginId:t,URI:n,loginOptions:o})))),signUp:or(((t,n,o,r)=>xo(e.post(Io(Xn.enchantedLink.signUp,Qo.email),{loginId:t,URI:n,user:o,loginOptions:r})))),waitForSession:rr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=Xo(n);let s;const a=setInterval((async()=>{const n=await e.post(Xn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ir(((t,n,o,r,i)=>xo(e.post(Xn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),ar=Ko(zo("flowId")),cr=Ko(zo("executionId"),zo("stepId"),zo("interactionId")),lr=e=>({start:ar(((t,n,o,r,i,s,a)=>xo(e.post(Xn.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,componentsVersion:i,flowVersions:s,input:a})))),next:cr(((t,n,o,r,i,s)=>xo(e.post(Xn.flow.next,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:s}))))}),dr=zo("loginId"),ur=Ko(zo("token")),hr=Ko(dr),pr=Ko(dr,Jo("phone")),fr=Ko(dr,Bo("email")),gr=Object.keys(Qo).filter((e=>e!==Yo.voice)),vr=e=>({verify:ur((t=>xo(e.post(Xn.magicLink.verify,{token:t})))),signIn:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:hr(((t,o,r,i)=>xo(e.post(Io(Xn.magicLink.signIn,n),{loginId:t,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:hr(((t,o,r,i)=>xo(e.post(Io(Xn.magicLink.signUp,n),{loginId:t,URI:o,user:r,loginOptions:i}))))})),{}),signUpOrIn:gr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:hr(((t,o,r)=>xo(e.post(Io(Xn.magicLink.signUpOrIn,n),{loginId:t,URI:o,loginOptions:r}))))})),{}),update:{email:fr(((t,n,o,r,i)=>xo(e.post(Xn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(Yo).filter((e=>e!==Yo.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:pr(((t,o,r,i,s)=>xo(e.post(Io(Xn.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:r},s),{token:i}))))})),{})}});var mr;!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"}(mr||(mr={}));const yr=Ko(zo("code")),wr=e=>({start:Object.assign(((t,n,o,r,i)=>xo(e.post(Xn.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),i&&{loginHint:i}),token:r}))),Object.keys(mr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r,i)=>xo(e.post(Xn.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),i&&{loginHint:i}),token:r}))})),{})),exchange:yr((t=>xo(e.post(Xn.oauth.exchange,{code:t})))),startNative:(t,n,o)=>xo(e.post(Xn.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,r,i)=>xo(e.post(Xn.oauth.finishNative,{provider:t,stateId:n,user:o,code:r,idToken:i})),getOneTapClientId:t=>xo(e.get(Xn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,r)=>xo(e.post(Xn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r})),exchangeOneTapIDToken:(t,n,o,r)=>xo(e.post(Xn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r}))}),br=zo("appId"),kr=Ko(br),Sr=e=>({connect:kr(((t,n,o)=>{const r=null==n?void 0:n.tenantId,i=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,xo(e.post(Xn.outbound.connect,{appId:t,tenantId:r,tenantLevel:i,options:n},{token:o}))}))}),Ir=zo("loginId"),xr=Ko(Ir,zo("code")),Or=Ko(Ir),jr=Ko(Ir,Jo("phone")),Cr=Ko(Ir,Bo("email")),Rr=e=>({verify:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:xr(((t,o)=>xo(e.post(Io(Xn.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Or(((t,o,r)=>xo(e.post(Io(Xn.otp.signIn,n),{loginId:t,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Or(((t,o,r)=>xo(e.post(Io(Xn.otp.signUp,n),{loginId:t,user:o,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Qo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Or(((t,o)=>xo(e.post(Io(Xn.otp.signUpOrIn,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:Cr(((t,n,o,r)=>xo(e.post(Xn.otp.update.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(Yo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jr(((t,o,r,i)=>xo(e.post(Io(Xn.otp.update.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),Ar=Ko(zo("tenant")),Er=Ko(zo("code")),Tr=e=>({start:Ar(((t,n,o,r,i,s,a)=>xo(e.post(Xn.saml.start,o||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),i&&{ssoId:i}),s&&{forceAuthn:"true"}),a&&{loginHint:a})},r&&{token:r}))))),exchange:Er((t=>xo(e.post(Xn.saml.exchange,{code:t}))))}),_r=zo("loginId"),Mr=Ko(_r,zo("code")),$r=Ko(_r),Ur=Ko(_r),Pr=e=>({signUp:$r(((t,n)=>xo(e.post(Xn.totp.signUp,{loginId:t,user:n})))),verify:Mr(((t,n,o,r)=>xo(e.post(Xn.totp.verify,{loginId:t,code:n,loginOptions:o},{token:r})))),update:Ur(((t,n)=>xo(e.post(Xn.totp.update,{loginId:t},{token:n}))))}),Dr=zo("loginId"),Lr=zo("newPassword"),Wr=Ko(Dr,zo("password")),Nr=Ko(Dr),Kr=Ko(Dr,Lr),qr=Ko(Dr,zo("oldPassword"),Lr),Fr=e=>({signUp:Wr(((t,n,o,r)=>xo(e.post(Xn.password.signUp,{loginId:t,password:n,user:o,loginOptions:r})))),signIn:Wr(((t,n,o)=>xo(e.post(Xn.password.signIn,{loginId:t,password:n,loginOptions:o})))),sendReset:Nr(((t,n,o)=>xo(e.post(Xn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Kr(((t,n,o)=>xo(e.post(Xn.password.update,{loginId:t,newPassword:n},{token:o})))),replace:qr(((t,n,o)=>xo(e.post(Xn.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>xo(e.get(Xn.password.policy))}),zr=qo("loginId"),Br=zo("loginId"),Jr=zo("origin"),Hr=Ko(Br,Jr,zo("name")),Vr=Ko(Br,Jr),Zr=Ko(zr,Jr),Xr=Ko(Br,Jr,Fo("token")),Yr=Ko(zo("transactionId"),zo("response")),Gr=e=>({signUp:{start:Hr(((t,n,o,r)=>xo(e.post(Xn.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,passkeyOptions:r})))),finish:Yr(((t,n)=>xo(e.post(Xn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Zr(((t,n,o,r,i)=>xo(e.post(Xn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i},{token:r})))),finish:Yr(((t,n)=>xo(e.post(Xn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Vr(((t,n,o)=>xo(e.post(Xn.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:o}))))},update:{start:Xr(((t,n,o,r)=>xo(e.post(Xn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:r},{token:o})))),finish:Yr(((t,n)=>xo(e.post(Xn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Qr=qo("loginId"),ei=Ko(Qr),ti=Ko(zo("pendingRef")),ni=e=>({signUpOrIn:ei(((t,n)=>xo(e.post(Xn.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:ei(((t,n,o)=>xo(e.post(Xn.notp.signUp,{loginId:t,user:n,loginOptions:o})))),signIn:ei(((t,n,o)=>xo(e.post(Xn.notp.signIn,{loginId:t,loginOptions:n},{token:o})))),waitForSession:ti(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=Xo(n);let s;const a=setInterval((async()=>{const n=await e.post(Xn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(xo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),oi=Ko(zo("token")),ri=Ko(Fo("token"));var ii,si=Ko([(ii=zo("projectId"),jo(((e,t)=>n=>Ro(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let r=0,i=e===Object(e)?e:void 0;for(;null!=i&&r<o;)i=i[n[r++]];return r&&r===o&&void 0!==i?i:void 0})(n,e)))("projectId",ii))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:r,baseHeaders:i={},refreshCookieName:s,fetch:a}=e;return c=go({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:r,baseConfig:{baseHeaders:i},refreshCookieName:s,fetch:a}),{accessKey:Vo(c),otp:Rr(c),magicLink:vr(c),enchantedLink:sr(c),oauth:wr(c),outbound:Sr(c),saml:Tr(c),totp:Pr(c),notp:ni(c),webauthn:Gr(c),password:Fr(c),flow:lr(c),refresh:ri(((e,t,n,o)=>{const r={};n&&(r.externalToken=n);const i=o?Xn.tryRefresh:Xn.refresh;return xo(c.post(i,r,{token:e,queryParams:t}))})),selectTenant:Ko([Uo("tenantId")],[Wo('"token" must be string or undefined')])(((e,t)=>xo(c.post(Xn.selectTenant,{tenant:e},{token:t})))),logout:ri((e=>xo(c.post(Xn.logout,{},{token:e})))),logoutAll:ri((e=>xo(c.post(Xn.logoutAll,{},{token:e})))),me:ri((e=>xo(c.get(Xn.me,{token:e})))),myTenants:Ko([No('"tenants" must a string array or a boolean')],[Wo('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,xo(c.post(Xn.myTenants,n,{token:t}))})),history:ri((e=>xo(c.get(Xn.history,{token:e})))),isJwtExpired:oi(wo),getTenants:oi(bo),getJwtPermissions:oi(ko),getJwtRoles:oi(So),getCurrentTenant:oi(Oo),httpClient:c};var c})),ai=Object.assign(si,{DeliveryMethods:Qo});
6
+ /*! js-cookie v3.0.5 | MIT */function ci(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var li=function e(t,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=ci({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",ci({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,ci({},this.attributes,t))},withConverter:function(t){return e(ci({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var di={default:"endpoint"},ui="Blocked by CSP",hi="The endpoint parameter is not a valid URL",pi="Failed to load the JS script of the agent",fi="9319";function gi(e,t){var n,o,r,i,s,a=[],c=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),i=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},r=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===ui||s===hi)n.exclude(),i=0;else if(s===fi)n.exclude();else if(s===pi){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!r.has(c)&&(r.add(c),i=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=i?i:e.getTime()+o()-Date.now()]}]),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})},r=t(e);return r.then((function(){return o()}),o),r.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,r=t[0],i=t[1];return(o=i,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(r)}))}))};return u(l).then((function(e){return[e,a]}))}var vi="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",mi=vi;function yi(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:vi,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 gi(e,wi)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===fi?new Error(pi):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 wi(e){return function(e,t,n){var o,r=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=t,a())};r.addEventListener(i,s);var a=function(){return r.removeEventListener(i,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(hi);var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(pi))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)}),(function(){throw new Error(ui)})).then(bi)}function bi(){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(fi);return n}const ki=e=>{try{return Zn(e).exp}catch(e){return null}},Si=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ki(n)},Ii=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?ki(o):void 0)},xi=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Oi=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(e=>{const{access_token:n,id_token:o,refresh_token:r,refresh_expire_in:i}=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||r,sessionExpiration:e.sessionExpiration||Ii(e),cookieExpiration:e.cookieExpiration||Si(e)},s)})((null==n?void 0:n.authInfo)||n||{})},ji=async e=>{const t=await Oi(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Ci="undefined"!=typeof localStorage,Ri=(e,t)=>Ci&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Ai=e=>Ci&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Ei=e=>Ci&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Ti=(...e)=>{console.debug(...e)},_i="3.2.0",Mi="undefined"!=typeof window,$i=Math.pow(2,31)-1,Ui=`https://descopecdn.com/npm/oidc-client-ts@${_i}/dist/browser/oidc-client-ts.min.js`,Pi=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${_i}/dist/browser/oidc-client-ts.min.js`,Di="DS",Li="DSR",Wi="DSI";function Ni(e=""){return Ai(`${e}${Li}`)||""}function Ki(e=""){return li.get(Di)||Ai(`${e}${Di}`)||""}function qi(e=""){return Ai(`${e}${Wi}`)||""}function Fi(e=""){Ei(`${e}${Li}`),Ei(`${e}${Di}`),Ei(`${e}${Wi}`),li.remove(Di)}const zi=Mi&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Bi="vsid",Ji="vrid",Hi=(e=!1)=>{const t=localStorage.getItem("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Vi=async(e,t=zi)=>{try{if(Hi())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=r.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=yi({apiKey:e,endpoint:[o.toString(),di],scriptUrlPattern:[i,mi]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Bi]:e,[Ji]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Zi=e=>{const t=Hi(!0);return t&&e.body&&(e.body.fpData=t),e},Xi="descopeFlowNonce",Yi="X-Descope-Flow-Nonce",Gi="/v1/flow/start",Qi="/v1/flow/next",es=(e,t=Xi)=>`${t}${e}`,ts=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},ns=e=>{var t;return e.path===Qi&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ts(e.body.executionId):null},os="dls_last_user_login_id",rs="dls_last_user_display_name",is=()=>Ai(os),ss=()=>Ai(rs),as=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=is(),i=ss();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await e(...t)};function cs(){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 ls(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=gs(n.publicKey.challenge),n.publicKey.user.id=gs(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=gs(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:vs(n.rawId),type:n.type,response:{attestationObject:vs(n.response.attestationObject),clientDataJSON:vs(n.response.clientDataJSON)}});var n}async function ds(e){const t=ps(e);return fs(await navigator.credentials.get(t))}async function us(e,t){const n=ps(e);return n.signal=t.signal,n.mediation="conditional",fs(await navigator.credentials.get(n))}async function hs(e=!1){if(!Mi)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function ps(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=gs(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=gs(e.id)})),n}function fs(e){return JSON.stringify({id:e.id,rawId:vs(e.rawId),type:e.type,response:{authenticatorData:vs(e.response.authenticatorData),clientDataJSON:vs(e.response.clientDataJSON),signature:vs(e.response.signature),userHandle:e.response.userHandle?vs(e.response.userHandle):void 0}})}function gs(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function vs(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ms,ys=(ms=e=>({async signUp(t,n,o){const r=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await ls(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,i)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const r=await ds(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,r)},async signUpOrIn(t,n){var o;const r=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!r.ok)return r;if(null===(o=r.data)||void 0===o?void 0:o.create){const t=await ls(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,t)}{const t=await ds(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,t)}},async update(t,n,o){const r=await e.webauthn.update.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await ls(r.data.options);return await e.webauthn.update.finish(r.data.transactionId,i)},helpers:{create:ls,get:ds,isSupported:hs,conditional:us}}),(...e)=>{const t=ms(...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 ws="/fedcm/config",bs=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function ks(e,t){var n;try{await Ss(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Ss(e,t){var n,o;const r=await async function(e,t="google",n,o,r){const i=bs(),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:i,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:i})),s.prompt((e=>{var t,n;if(r&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==r||r(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(!r.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+r.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(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+r.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var Is=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await hs(),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 xs;const Os=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const r=t();if(r)return n(r);const i=e.shift(),s=document.createElement("script");s.src=i,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)})(i),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",(()=>{Os(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),js=(e,t,n)=>{const o=async()=>{let o,r;return o&&r||({client:o,stateUserKey:r}=await(async(e,t,n)=>{xs||(xs=(async()=>{try{return require("oidc-client-ts")}catch(e){return Os([Ui,Pi],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:r}=await xs;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const i=t,s=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",c=`${i}_user`;let l=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(l=`${l}/${n.applicationId}`);const d={authority:l,client_id:t,redirect_uri:s,response_type:"code",scope:a,stateStore:new r({store:window.localStorage,prefix:i}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new o(d),stateUserKey:c}})(e,t,n)),{client:o,stateUserKey:r}},r=async(t="")=>{var n;const{client:r,stateUserKey:i}=await o(),s=await r.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)))),window.localStorage.setItem(i,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(e={},t=!1)=>{const{client:n}=await o(),r=await n.createSigninRequest(e),{url:i}=r;return t||(window.location.href=i),{ok:!0,data:r}},finishLogin:r,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await r(e)},refreshToken:async t=>{var n;const{client:r,stateUserKey:i}=await o(),s=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(i);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 r.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:r}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||qi(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const i=await n.createSignoutRequest(e),{url:s}=i;return window.localStorage.removeItem(r),t||window.location.replace(s),i}}},Cs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:r}=n,i=t(n,["fpKey","fpLoad"]);return Mi?(o&&r&&Vi(o).catch((()=>null)),e(xi(i,{beforeRequest:Zi}))):e(i)}),(e=>n=>{var{autoRefresh:o}=n,r=t(n,["autoRefresh"]);if(!o||"undefined"!=typeof window&&window.descopeBridge)return e(r);const{clearAllTimers:i,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;Mi&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&a&&new Date>a&&(Ti("Expiration time passed, refreshing session"),l.refresh(Ni()||c))}));const l=e(xi(r,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:r}=await Oi(t);if(401===(null==t?void 0:t.status))Ti("Received 401, canceling all timers"),i();else if(n||r){if(a=((e,t)=>{if(t)return new Date(1e3*t);Ti("Could not extract expiration time from session token, trying to decode the token");try{const t=Zn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,r),!a)return void Ti("Could not extract expiration time from session token");c=o;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>$i&&(Ti(`Timeout is too large (${t}ms), setting it to ${$i}ms`),t=$i),t})(a);if(i(),e<=2e4)return void Ti("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Ti(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Ti("Refreshing session due to timer"),l.refresh(Ni()||o)}),e)}}}));return Zo(l,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Ti("Clearing all timers"),i(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.35.1"},t.baseHeaders)}))),(e=>t=>{const n=cs(),o=cs(),r=cs(),i=e(xi(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))o.pub(null),r.pub(null),n.pub(null);else{const e=await ji(t);e&&r.pub(e);const{sessionJwt:i,sessionExpiration:s}=await Oi(t);i&&o.pub(i),(s||i)&&n.pub(s||42)}}})),s=Zo(i,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const i=await e(...t);return o.pub(null),r.pub(null),n.pub(null),i}));return Object.assign(s,{onSessionTokenChange:o.sub,onUserChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:o=!0,nonceStoragePrefix:r=Xi}=n,i=t(n,["enableFlowNonce","nonceStoragePrefix"]);return o?(((e=Xi)=>{try{if(!Ci)return;for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(n&&n.startsWith(e)){const t=Ai(n);if(t)try{JSON.parse(t).expiry<Date.now()&&Ei(n)}catch(e){Ei(n)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}})(r),e(xi(i,{afterRequest:async(e,t)=>{if(e.path!==Gi&&e.path!==Qi)return;const{nonce:n,executionId:o}=await(async(e,t)=>{try{const n=t.headers.get(Yi);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=ns(e)),{nonce:n,executionId:ts(o)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&o&&((e,t,n,o=Xi)=>{try{const r=es(e,o),i=n?172800:10800,s={value:t,expiry:Date.now()+1e3*i,isStart:n};Ri(r,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(o,n,e.path===Gi,r)},beforeRequest:e=>{if(e.path===Qi){const t=ns(e);if(t){const n=((e,t=Xi)=>{try{const n=es(e,t),o=Ai(n);if(!o)return null;const r=JSON.parse(o);return r.expiry<Date.now()?(((e,t=Xi)=>{try{const n=es(e,t);Ei(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):r.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,r);n&&(e.headers=e.headers||{},e.headers[Yi]=n)}}return e}}))):e(i)}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(i),{getLastUserLoginId:is,getLastUserDisplayName:ss});const s=e(xi(i,{afterRequest:async(e,t)=>{var n;const o=await ji(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((e=>{Ri(os,e)})(r),(e=>{Ri(rs,e)})(i))}}));let a=Zo(s,["flow.start"],as);return a=Zo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(Ei(os),Ei(rs)),o})(r)),Object.assign(a,{getLastUserLoginId:is,getLastUserDisplayName:ss})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:r,storagePrefix:i}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!Mi)return e(s);const a=e(xi(s,{beforeRequest:(c=i,e=>Object.assign(e,{token:e.token||Ni(c)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||Fi(i):((e={},t=!1,n="")=>{var o;const{sessionJwt:r,refreshJwt:i}=e;if(i&&Ri(`${n}${Li}`,i),r)if(t){const n=t.sameSite||"Strict",i=null===(o=t.secure)||void 0===o||o;!function(e,t,n){if(t){const{cookieDomain:o,cookiePath:r,cookieSameSite:i,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);li.set(e,t,{path:r,domain:l?o:void 0,expires:c,sameSite:i,secure:a})}}(Di,r,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i}))}else Ri(`${n}${Di}`,r);e.idToken&&Ri(`${n}${Wi}`,e.idToken)})(await Oi(t),r,i)}}));var c;const l=Zo(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const o=await t(...n);return Fi(e),o})(i));return Object.assign(l,{getRefreshToken:()=>Ni(i),getSessionToken:()=>Ki(i),getIdToken:()=>qi(i)})}))((e=>{const t=ai(e),n=js(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,r)=>{var i;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()}})}const s=Ki(),a=Ni();let c="";if(e.getExternalToken)try{c=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){Ti("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},c,r)},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:Is(t),webauthn:ys(t),fedcm:(o=t,r=e.projectId,{onetap:{requestExchangeCode(e){ks(o,e)},requestAuthentication(e){ks(o,e)}},async oneTap(e,t,n,r,i){await Ss(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:r,onDismissed:i})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(r+ws),clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(i.token)},isSupported:()=>Mi&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(r+ws);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!i&&!!i.token}catch(e){return!1}}}),oidc:n});var o,r})),Rs={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"},As={roles:"/v1/mgmt/role/all"},Es=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)})),Ts=(...e)=>n(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((n=>{const o=[],r=(new Date).getTime()/1e3+2592e3,i=new Date(r).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:r,expireTimeFormatted:i,createdTime:r,createdTimeFormatted:i,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,r;return e.desc?null===(r=n[e.field])||void 0===r?void 0:r.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()))))}))})),_s=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:n,permittedIps:o},r){const i=Math.random().toString(10).substring(15);return new Promise((s=>{s({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${i}`,name:e||`Access Key ${i}`,createdBy:n||`User ${i}`,editable:!0,expireTime:r,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:o,status:"active",clientId:`Client ID ${i}`,boundUserId:n||`User ${i}`}})}))})),Ms=()=>n(void 0,void 0,void 0,(function*(){})),$s=()=>n(void 0,void 0,void 0,(function*(){})),Us=()=>n(void 0,void 0,void 0,(function*(){})),Ps=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})})),Ds=({httpClient:e,tenant:t,mock:o})=>({search:(...r)=>n(void 0,[...r],void 0,(function*({page:n,limit:r=1e4,text:i,sort:s}={}){if(o)return Ts({page:n,limit:r,text:i,sort:s});const a=yield e.post(Rs.search,{limit:r,page:n,text:i,sort:s},{queryParams:{tenant:t}});yield Es(a);return(yield a.json()).keys})),deleteBatch:r=>n(void 0,void 0,void 0,(function*(){if(o)return Us();const n=yield e.post(Rs.deleteBatch,{ids:r},{queryParams:{tenant:t}});return yield Es(n),n.json()})),create:r=>n(void 0,[r],void 0,(function*({name:n,expiration:r,roleNames:i,userId:s,permittedIps:a}){const c=new Date;c.setDate(c.getDate()+ +r);const l="0"===r[0]?0:Math.floor(c.getTime()/1e3);if(o)return _s({name:n,expiration:r,roleNames:i,userId:s,permittedIps:a},l);const d=yield e.post(Rs.create,{name:n,expireTime:l,roleNames:i,userId:s,permittedIps:a},{queryParams:{tenant:t}});yield Es(d);return yield d.json()})),activate:r=>n(void 0,void 0,void 0,(function*(){if(o)return Ms();const n=yield e.post(Rs.activate,{ids:r},{queryParams:{tenant:t}});yield Es(n);return yield n.json()})),deactivate:r=>n(void 0,void 0,void 0,(function*(){if(o)return $s();const n=yield e.post(Rs.deactivate,{ids:r},{queryParams:{tenant:t}});yield Es(n);return yield n.json()}))}),Ls=({httpClient:e,tenant:t,mock:o})=>({getTenantRoles:()=>n(void 0,void 0,void 0,(function*(){if(o)return Ps(t);const n=yield e.get(As.roles,{queryParams:{tenant:t}});return yield Es(n),n.json()}))}),Ws=u((e=>{var t,s,a,c;const l=i(j,x,w,C,mn,O({tenant:O.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"),r(this,s,((e,t,n,o)=>{const r=Cs(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.5.8"}}));return{accesskey:Ds({httpClient:r.httpClient,tenant:t,mock:n}),tenant:Ls({httpClient:r.httpClient,tenant:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},c})),Ns=u((e=>{const t=i(gn({name:"widget",initialState:Jn,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Tn.reducer(e),$n.reducer(e),Dn.reducer(e),Nn.reducer(e),Fn.reducer(e),Bn.reducer(e)},asyncActions:{searchAccessKeys:Dn.action,createAccessKey:Tn.action,activateAccessKeys:Nn.action,deactivateAccessKeys:Fn.action,deleteAccessKeys:$n.action,getTenantRoles:Bn.action}}),I,w,Ws)(e);return class extends t{constructor(...e){super(...e),this.state=Jn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ks=u((e=>{const t=i(T,O({"widget-id":O.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){const t=yield this.fetchStaticResource(`access-key-management-widget/${this.widgetId}/${e}`,"text");return null==t?void 0:t.body}))}}})),qs=u((e=>{var t,r,a;return a=class extends(i(w,I,q,V,Ks,Ns)(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",r).call(this),this.actions.searchAccessKeys(),this.actions.getTenantRoles()]),this.onWidgetRootReady()}))}},t=new WeakSet,r=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})),Fs=u((e=>{var t,r,s,a,l;return l=class extends(i(Ns,w,qs)(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",r).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,bn(this.state)),this.subscribe(o(this,s,"f").bind(this),bn)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,r=function(){var e;this.accessKeysTable=new ne(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})),zs=u((e=>{var t,r,a;return a=class extends(i(Ns,le,w,qs)(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",r).call(this)}))}},t=new WeakSet,r=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 Q((()=>{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 Q((()=>{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=kn(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const o=new ae(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=On(this.state);o.text=`Activate ${e}?`}}))},a})),Bs=u((e=>{var t,r,s,a;return a=class extends(i(w,qs,Ns,zs)(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",r).call(this),this.subscribe(o(this,s,"f").bind(this),xn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.activateButton=new Q(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})),Js=u((e=>{var t,r,a;return a=class extends(i(Ns,le,vn,w,qs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=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 Q((()=>{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})),Hs=u((e=>{var t,a,c,l,d;return d=class extends(i(Ns,le,vn,w,qs,Js)(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 Q((()=>{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 Q((()=>{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())}})))),r(this,a,new ie((()=>{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})),Vs=u((e=>{var t,r,s;return s=class extends(i(w,Hs,qs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){var e;this.createButton=new Q(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})),Zs=u((e=>{var t,r,a;return a=class extends(i(Ns,le,w,qs)(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",r).call(this)}))}},t=new WeakSet,r=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 Q((()=>{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 Q((()=>{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=kn(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const o=new ae(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=On(this.state);o.text=`Deactivate ${e}?`}}))},a})),Xs=u((e=>{var t,r,s,a;return a=class extends(i(w,qs,Ns,Zs)(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",r).call(this),this.subscribe(o(this,s,"f").bind(this),xn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.deactivateButton=new Q(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})),Ys=u((e=>{var t,r,a;return a=class extends(i(Ns,le,w,qs)(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",r).call(this)}))}},t=new WeakSet,r=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 Q((()=>{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 Q((()=>{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=kn(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const o=new ae(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=On(this.state);o.text=`Delete ${e}?`}}))},a})),Gs=u((e=>{var t,r,s,a;return a=class extends(i(w,qs,Ns,Ys)(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",r).call(this),this.subscribe(o(this,s,"f").bind(this),xn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.deleteButton=new Q(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})),Qs=u((e=>{var t,r,s,a;return a=class extends(i(w,qs,Ns)(e)){constructor(){super(...arguments),t.add(this),r.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)}))}},r=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new ce(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(o(this,r,"f"))},a}));const ea={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},ta=u((e=>{var t,r,s,a,l;return l=class extends(i(w,Ns,ue,I)(e)){constructor(){super(...arguments),t.add(this),a.set(this,c((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const i=o(this,t,"m",s).call(this,e);i.setContent(o(this,t,"m",r).call(this,{type:e,msg:n})),i.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),wn)}))}},a=new WeakMap,t=new WeakSet,r=function({type:e,msg:t}){const n=ea[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})),na=u((e=>class extends(i($,pe,Fs,Vs,Gs,Qs,Bs,Xs,ta)(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)}))}})),oa=i((e=>class extends(na(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",oa);const ra=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var ia,sa,aa,ca,la,da,ua,ha,pa,fa;const ga=document.createElement("template");ga.innerHTML=`\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;const va=i(B)(HTMLElement);class ma extends va{constructor(){var e;super(),ia.add(this),sa.set(this,new m({messages:[]})),aa.set(this,void 0),ca.set(this,void 0),la.set(this,void 0),da.set(this,{resize:o(this,ia,"m",fa).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(ga.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'),r(this,aa,this.shadowRoot.querySelector(".debugger"),"f"),r(this,ca,o(this,aa,"f").querySelector(".content"),"f"),r(this,la,o(this,aa,"f").querySelector(".header"),"f")}updateData(e){o(this,sa,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=ra(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,aa,"f"),o(this,la,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,da,"f").resize),(e=o(this,aa,"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,aa,"f").onresize=o(this,ia,"m",pa).bind(this),o(this,sa,"f").subscribe(o(this,ia,"m",ua).bind(this))}disconnectedCallback(){o(this,sa,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,da,"f").resize)}}sa=new WeakMap,aa=new WeakMap,ca=new WeakMap,la=new WeakMap,da=new WeakMap,ia=new WeakSet,ua=function(e){o(this,ia,"m",ha).call(this,e),o(this,ia,"m",pa).call(this)},ha=function(e){o(this,ca,"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("")},pa=function(){o(this,ca,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,r=n.clientHeight>20;o||r?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},fa=function(){const[e,t]=ra(o(this,aa,"f"),Number.parseInt(o(this,aa,"f").style.left,10),Number.parseInt(o(this,aa,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,aa,"f").style.top=`${t}px`,o(this,aa,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ma);var ya=Object.freeze({__proto__:null,default:ma});return oa}();
7
7
  //# sourceMappingURL=index.js.map