@descope/user-management-widget 0.0.7 → 0.0.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.
@@ -1,3 +1,3 @@
1
- // @descope/user-management-widget v0.0.7
1
+ // @descope/user-management-widget v0.0.8
2
2
  import{__classPrivateFieldGet as e,__classPrivateFieldSet as t}from"tslib";var n,s,i,o;function l(e,t){const n=Object.getOwnPropertyNames(e),s=Object.getOwnPropertyNames(t);if(n.length!==s.length)return!1;for(let s=0;s<n.length;s+=1){const i=n[s],o=e[i],r=t[i];if(null===o||null===r){if(o!==r)return!1}else if("object"==typeof o&&"object"==typeof r){if(!l(o,r))return!1}else if(o!==r)return!1}return!0}class r{constructor(r={},{updateOnlyOnChange:a=!0}={}){n.set(this,void 0),s.set(this,{}),i.set(this,0),o.set(this,!1),this.update=i=>{const r="function"==typeof i?i(e(this,n,"f")):i,a=Object.assign(Object.assign({},e(this,n,"f")),r);if(!e(this,o,"f")||!l(e(this,n,"f"),a)){const i=e(this,n,"f");t(this,n,a,"f"),Object.freeze(e(this,n,"f")),setTimeout((()=>{Object.values(e(this,s,"f")).forEach((e=>e(a,i,((e,t)=>n=>e[n]!==t[n])(a,i))))}),0)}},t(this,n,r,"f"),t(this,o,a,"f")}get current(){return Object.assign({},e(this,n,"f"))}subscribe(n){return t(this,i,e(this,i,"f")+1,"f"),e(this,s,"f")[e(this,i,"f")]=n,e(this,i,"f").toString()}unsubscribe(t){const n=!!e(this,s,"f")[t];return n&&delete e(this,s,"f")[t],n}unsubscribeAll(){return t(this,s,{},"f"),!0}}n=new WeakMap,s=new WeakMap,i=new WeakMap,o=new WeakMap;const a=(e,t,n,s={})=>{var i,o,l,r;return[Math.min(Math.max(t,("all"===s.left?e.offsetWidth:null!==(i=s.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(o=s.right)&&void 0!==o?o:0)),Math.min(Math.max(n,("all"===s.top?e.offsetHeight:null!==(l=s.top)&&void 0!==l?l:0)-e.offsetHeight),window.innerHeight-("all"===s.bottom?e.offsetHeight:null!==(r=s.bottom)&&void 0!==r?r:0))]};var d,c,h,f,p,g,u,m,b,v;const x=document.createElement("template");x.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class w extends HTMLElement{constructor(){var n;super(),d.add(this),c.set(this,new r({messages:[]})),h.set(this,void 0),f.set(this,void 0),p.set(this,void 0),g.set(this,{resize:e(this,d,"m",v).bind(this)}),this.attachShadow({mode:"open"}),null===(n=this.shadowRoot)||void 0===n||n.appendChild(x.content.cloneNode(!0)),t(this,h,this.shadowRoot.querySelector(".debugger"),"f"),t(this,f,e(this,h,"f").querySelector(".content"),"f"),t(this,p,e(this,h,"f").querySelector(".header"),"f")}updateData(t){e(this,c,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((e,t,n)=>{let s=0,i=0,o=0,l=0;function r(t){t.preventDefault(),s=o-t.clientX,i=l-t.clientY,o=t.clientX,l=t.clientY;const[r,d]=a(e,e.offsetLeft-s,e.offsetTop-i,n);e.style.top=`${d}px`,e.style.left=`${r}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),o=e.clientX,l=e.clientY,document.onmouseup=d,document.onmousemove=r}t?t.onmousedown=c:e.onmousedown=c})(e(this,h,"f"),e(this,p,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",e(this,g,"f").resize),(t=e(this,h,"f")).onmousemove=e=>{var n;const s=e.target;(s.w&&s.w!==s.offsetWidth||s.h&&s.h!==s.offsetHeight)&&(null===(n=t.onresize)||void 0===n||n.call(t,e)),s.w=s.offsetWidth,s.h=s.offsetHeight},e(this,h,"f").onresize=e(this,d,"m",b).bind(this),e(this,c,"f").subscribe(e(this,d,"m",u).bind(this))}disconnectedCallback(){e(this,c,"f").unsubscribeAll(),window.removeEventListener("resize",e(this,g,"f").resize)}}c=new WeakMap,h=new WeakMap,f=new WeakMap,p=new WeakMap,g=new WeakMap,d=new WeakSet,u=function(t){e(this,d,"m",m).call(this,t),e(this,d,"m",b).call(this)},m=function(t){e(this,f,"f").innerHTML=t.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("")},b=function(){e(this,f,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),s=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;s||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},v=function(){const[t,n]=a(e(this,h,"f"),Number.parseInt(e(this,h,"f").style.left,10),Number.parseInt(e(this,h,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});e(this,h,"f").style.top=`${n}px`,e(this,h,"f").style.left=`${t}px`},customElements.define("descope-debugger",w);export{w as default};
3
3
  //# sourceMappingURL=debugger-wc-6f11e405.js.map
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- // @descope/user-management-widget v0.0.7
1
+ // @descope/user-management-widget v0.0.8
2
2
  import{__classPrivateFieldGet as e,__classPrivateFieldSet as t,__awaiter as s}from"tslib";import{createSlice as i,configureStore as n,unwrapResult as o,createAsyncThunk as r}from"@reduxjs/toolkit";import{createSelector as a}from"reselect";import d from"@descope/web-js-sdk";function l(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const c=e=>{const t=Symbol((e=>{const t=e.toString();let s=0;for(let e=0;e<t.length;e++)s=(s<<5)-s+t.charCodeAt(e),s&=s;return s.toString(16)})(e));return s=>{if(s[t])return s;const i=e(s);return i[t]=!0,i}},u=c((i=>{var n,o;return o=class extends i{constructor(){super(...arguments),n.set(this,!0)}connectedCallback(){var s,i;null===(s=super.connectedCallback)||void 0===s||s.call(this),(null===(i=this.shadowRoot)||void 0===i?void 0:i.isConnected)&&e(this,n,"f")&&(t(this,n,!1,"f"),this.init())}init(){return s(this,void 0,void 0,(function*(){}))}},n=new WeakMap,o})),h=["error","warn","info","debug"],g=c((s=>{var i,n,o,r;return r=class extends s{constructor(){super(...arguments),i.add(this),n.set(this,e(this,i,"m",o).call(this,console))}set logger(s){t(this,n,e(this,i,"m",o).call(this,s),"f")}get logger(){return e(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,i=new WeakSet,o=function(e){return h.reduce(((t,s)=>(t[s]=(...t)=>{var i;this.onLogEvent(s,t),null===(i=e[s])||void 0===i||i.call(e,...t)},t)),{})},r})),v=c((i=>{var n,o,r,a,d,c,h;return h=class extends(l(u,g)(i)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),this.attributeChangedCallback=(t,s,i)=>{var o;null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,t,s,i),"debug"===t&&e(this,n,"m",d).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(t,s){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,t,s),"error"===t&&e(this,n,"m",c).call(this,s[0]||"Error",s[1])}init(){const t=Object.create(null,{init:{get:()=>super.init}});var i;return s(this,void 0,void 0,(function*(){yield null===(i=t.init)||void 0===i?void 0:i.call(this),e(this,n,"m",d).call(this)}))}},o=new WeakMap,n=new WeakSet,r=function(){var s;null===(s=e(this,o,"f"))||void 0===s||s.remove(),t(this,o,null,"f")},a=function(){return s(this,void 0,void 0,(function*(){t(this,o,document.createElement("descope-debugger"),"f"),Object.assign(e(this,o,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-6f11e405.js"),document.body.appendChild(e(this,o,"f"))}))},d=function(){this.debug?e(this,n,"m",a).call(this):e(this,n,"m",r).call(this)},c=function(t,s){var i;t&&(null===(i=e(this,o,"f"))||void 0===i||i.updateData({title:t,description:s}))},h})),m=e=>{let t,s;return(...i)=>{return t&&(o=i,(n=t).length===o.length&&n.every(((e,t)=>e===o[t])))||(t=i,s=e(...i)),s;var n,o}},p=e=>(t,...s)=>t.reduce(((t,i,n)=>{var o;return`${t}${i}${(null===(o=null==s?void 0:s[n])||void 0===o?void 0:o[e>1?1:0])||""}`}),""),f=(e,t=500)=>{let s;return function(...i){clearTimeout(s),s=setTimeout((()=>e.apply(this,i)),t)}},b="undefined"!=typeof localStorage,y=b&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",w=(e,t)=>!t&&`${e} cannot be empty`,x=c((t=>{var i,n;const o=l(g,u)(t);return n=class extends o{constructor(){super(...arguments),i.set(this,{})}init(){const t=Object.create(null,{init:{get:()=>super.init}});var n;return s(this,void 0,void 0,(function*(){var s,o;yield null===(n=t.init)||void 0===n?void 0:n.call(this),s=this,o=t=>{var s;null===(s=e(this,i,"f")[t])||void 0===s||s.forEach((e=>{e(t,this.getAttribute(t))}))},Array.from(s.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(s,{attributes:!0})}))}observeAttribute(t,s){e(this,i,"f")[t]||(e(this,i,"f")[t]=[]);const n=e(this,i,"f")[t].push(s);return()=>e(this,i,"f")[t].splice(n,1)}observeAttributes(e,t){const s=e.reduce(((e,s)=>(e.push(this.observeAttribute(s,t)),e)),[]);return()=>s.forEach((e=>e()))}},i=new WeakMap,n})),C=t=>i=>{var n,o,r;const a=l(g,u,x)(i),d=Object.keys(t);return r=class extends a{constructor(...t){super(...t),n.add(this),this.observeAttributes(d,e(this,n,"m",o).bind(this))}init(){const t=Object.create(null,{init:{get:()=>super.init}});var i;return s(this,void 0,void 0,(function*(){yield null===(i=t.init)||void 0===i?void 0:i.call(this),d.forEach((t=>e(this,n,"m",o).call(this,t,this.getAttribute(t))))}))}},n=new WeakSet,o=function(e,s){const i=t[e],n="function"==typeof i?i(e,s):i;n&&this.logger.error(n)},r},k=c((e=>{const t=l(C({"project-id":w}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}}));const j=c((e=>{const t=l(g,k)(e);return class extends t{fetchStaticResource(e,t){return s(this,void 0,void 0,(function*(){const s=function(e,t,s="v2-beta"){const i=new URL(y);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,s,t),i.toString()}(this.projectId,e),i=yield fetch(s,{cache:"default"});return i.ok||this.logger.error(`Error fetching URL ${s} [${i.status}]`),{body:yield i[t](),headers:Object.fromEntries(i.headers.entries())}}))}}})),U=c((i=>{var n,o,r;const a=l(j)(i);return r=class extends a{constructor(){super(...arguments),n.set(this,void 0),o.set(this,(()=>s(this,void 0,void 0,(function*(){try{const{body:e,headers:t}=yield this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))))}get config(){return e(this,n,"f")||t(this,n,e(this,o,"f").call(this),"f"),e(this,n,"f")}},n=new WeakMap,o=new WeakMap,r})),M="load-descope-ui-script",R="base.ui.components.url",E=b&&localStorage.getItem(R)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",S=b&&localStorage.getItem(R)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",I=e=>{const t=document.createElement("script");return t.id=e,t},L=(e,t)=>e.replace("<version>",t),W=c((i=>{var n,o,r,a,d,c,u,h,v,m,p,f;const b=l(g,U)(i);return f=class extends b{constructor(){super(...arguments),n.add(this),o.set(this,Symbol("errorCbs")),r.set(this,Symbol("loadCbs")),v.set(this,void 0)}get descopeUi(){return e(this,v,"f")||t(this,v,e(this,n,"m",p).call(this),"f"),e(this,v,"f")}loadDescopeUiComponents(t){return s(this,void 0,void 0,(function*(){const s=Array.isArray(t)?t:(i=t,[...Array.from(i.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)]);var i;return Promise.all(s.map((t=>e(this,n,"m",m).call(this,t))))}))}},o=new WeakMap,r=new WeakMap,v=new WeakMap,n=new WeakSet,a=function(){var e;return s(this,void 0,void 0,(function*(){const t=yield this.config,s=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return s?this.logger.debug(`Got component version "${s}"`):this.logger.error("Could not get components version"),s}))},d=function(t){const s=e(this,o,"f"),i=e(this,r,"f");t[s]=[],t[i]=[],Object.defineProperty(t,"onerror",{set(e){t[s].push(e)}}),Object.defineProperty(t,"onload",{set(e){t[i].push(e)}})},c=function(t,i){return s(this,void 0,void 0,(function*(){this.logger.debug("Trying to load DescopeUI from a fallback URL");const s=I("load-descope-ui-fallback-script");document.body.append(s),s.addEventListener("error",(()=>{t.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${s.src}"`)))})),s.addEventListener("load",(()=>{i.forEach((e=>e()))})),s.src=L(S,yield e(this,n,"m",a).call(this))}))},u=function(t){t.addEventListener("error",(()=>{t[e(this,o,"f")].forEach((e=>e(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${t.src}"`))),e(this,n,"m",c).call(this,t[e(this,o,"f")],t[e(this,r,"f")])})),t.addEventListener("load",(()=>{t[e(this,r,"f")].forEach((e=>e()))}))},h=function(){return s(this,void 0,void 0,(function*(){if(document.getElementById(M))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const t=I(M);document.body.append(t),e(this,n,"m",d).call(this,t),e(this,n,"m",u).call(this,t),t.src=L(E,yield e(this,n,"m",a).call(this))}return document.getElementById(M)}))},m=function(e){return s(this,void 0,void 0,(function*(){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=yield this.descopeUi;if(t[e])try{return yield 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(", ")}"`)}))},p=function(){return new Promise((t=>{globalThis.DescopeUI&&t(globalThis.DescopeUI),e(this,n,"m",h).call(this).then((e=>{e.onerror=this.logger.error,e.onload=()=>{this.logger.debug("DescopeUI was loaded"),t(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&t(globalThis.DescopeUI)}))}))}))},f})),O="content-root",A="root",D=c((e=>class extends e{constructor(...e){var t,s;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${A}, #${O} {\n height: 100%;\n }\n </style>\n <div id="${A}">\n <div id="${O}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(O),this.rootElement=null===(s=this.shadowRoot)||void 0===s?void 0:s.getElementById(A)}})),N=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',$=c((i=>{var n,o,r,a,d,c,h,g,v;const m=l(C({theme:N}),j,u,W,U,D)(i);return v=class extends m{constructor(){super(...arguments),n.add(this),o.set(this,void 0)}get theme(){var e,t;const s=this.getAttribute("theme");if("os"===s){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 s||"light"}init(){const t=Object.create(null,{init:{get:()=>super.init}});var i;return s(this,void 0,void 0,(function*(){yield null===(i=t.init)||void 0===i?void 0:i.call(this),e(this,n,"m",d).call(this),e(this,n,"m",c).call(this),e(this,n,"m",h).call(this),e(this,n,"m",g).call(this)}))}},o=new WeakMap,n=new WeakSet,r=function(){return s(this,void 0,void 0,(function*(){try{const{body:e}=yield this.fetchStaticResource("theme.json","json");return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},a=function(){return e(this,o,"f")||(t(this,o,e(this,n,"m",r).call(this),"f"),e(this,o,"f").then((e=>this.logger.debug("Fetched theme",e)))),e(this,o,"f")},d=function(){var t,i;return s(this,void 0,void 0,(function*(){const s=yield e(this,n,"a",a);if(!s)return;const o=document.createElement("style");o.innerText=((null===(t=null==s?void 0:s.light)||void 0===t?void 0:t.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||""),this.shadowRoot.appendChild(o)}))},c=function(){var t,i;return s(this,void 0,void 0,(function*(){const s=Object.assign({},yield e(this,n,"a",a));if(!s)return;const o=yield this.descopeUi;(null==o?void 0:o.componentsThemeManager)&&(o.componentsThemeManager.themes={light:null===(t=null==s?void 0:s.light)||void 0===t?void 0:t.components,dark:null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.components})}))},h=function(){var e,t;return s(this,void 0,void 0,(function*(){const{projectConfig:s}=yield this.config,i=null===(t=null===(e=null==s?void 0:s.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;i&&Object.values(i).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))}))}))},g=function(){return s(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},v}));var T;class P{constructor(e,s){T.set(this,void 0),this.nodeName="",t(this,T,e,"f"),this.logger=s.logger}get ele(){var t,s;const i="function"==typeof e(this,T,"f")?e(this,T,"f").call(this):e(this,T,"f");return i?(null==i?void 0:i.localName)!==this.nodeName?(null===(s=this.logger)||void 0===s||s.debug(`node name do not match, expected "${this.nodeName}", received "${i.localName}" `,Error()),null):i:(null===(t=this.logger)||void 0===t||t.debug("no element for driver ",this.constructor.name,new Error),null)}}T=new WeakMap;class z extends P{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 F=e=>{const t=document.createElement("template");return t.innerHTML=e,t},B=c((e=>class extends(l(g)(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,s;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(s=e.checkValidity)||void 0===s?void 0:s.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=>{e.value=t[e.getAttribute("name")]}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value=""}))}})),q="descope-modal";var H;class V extends P{constructor(){super(...arguments),H.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)}open(){var e,t;null===(e=this.beforeOpen)||void 0===e||e.call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var t;this.ele&&(this.ele.innerHTML=""),e(this,H,"f")&&(null===(t=this.ele)||void 0===t||t.append(e(this,H,"f").content.cloneNode(!0)))}setContent(e){t(this,H,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}H=new WeakMap;const Z=c((t=>{var i,n;const o=l(u,D,W)(t);return n=class extends o{constructor(){super(...arguments),i.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends V{setContent(t){e(t),super.setContent(t)}}})())}createModal(t){const s=((e={})=>{const t=document.createElement(q);return Object.keys(e).forEach((s=>{t.setAttribute(s,e[s])})),t})(Object.assign(Object.assign({},{}),t));return this.rootElement.append(s),new(e(this,i,"f"))(s,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return s(this,void 0,void 0,(function*(){this.loadDescopeUiComponents([q]),yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}},i=new WeakMap,n}));const G=e=>c((t=>{const r=i(e),a=Object.assign(Object.assign({},r.actions),e.asyncActions);return class extends(l(g)(t)){constructor(...e){super(...e);const t=n({reducer:r.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>(...i)=>s(this,void 0,void 0,(function*(){const s=yield t.dispatch(e(...i));try{o(s)}catch(e){this.logger.error(e.message,s.type,e.stack)}return s})),d=Object.keys(a).reduce(((e,t)=>(e[t]=i(a[t]),e)),{});this.actions=d,this.subscribe=(e,s=(e=>e))=>t.subscribe((()=>e(s(t.getState()))))}}})),J=e=>(...t)=>s=>{s.addCase(e.pending,((e,s)=>{t.forEach((({onPending:t})=>{null==t||t(e,s)}))})),s.addCase(e.fulfilled,((e,s)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,s)}))})),s.addCase(e.rejected,((e,s)=>{t.forEach((({onRejected:t})=>{null==t||t(e,s)}))}))},K=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,s)=>{e(t).loading=!1,e(t).error=s.error}}),Q=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,s)=>{t&&e.notifications.push({type:"success",msg:t(s)})},onRejected:(t,s)=>{e&&t.notifications.push({type:"error",msg:e(s)})}}),X=r("users/create",((e,{extra:{api:t}})=>t.user.create(e))),Y=J(X)({onFulfilled:(e,t)=>{e.usersList.data.unshift(t.payload)}},K((e=>e.createUser)),Q({getSuccessMsg:()=>"User created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),_={action:X,reducer:Y},ee=r("users/delete",((e,{extra:{api:t}})=>t.user.deleteBatch(e))),te=J(ee)({onFulfilled:(e,t)=>{e.usersList.data=e.usersList.data.filter((e=>!t.meta.arg.includes(e.userId))),e.selectedUsersLoginIds=[]}},K((e=>e.deleteUser)),Q({getSuccessMsg:e=>p(e.meta.arg.length)`${["",e.meta.arg.length]} ${["U","u"]}ser${["","s"]} deleted successfully`,getErrorMsg:e=>p(e.meta.arg.length)`Failed to delete user${["","s"]}`})),se={action:ee,reducer:te},ie=r("users/expirePassword",((e,{extra:{api:t}})=>t.user.expirePassword(e))),ne={action:ie,reducer:J(ie)(K((e=>e.expireUserPassword)))},oe=r("users/getCustomAttributes",((e,{extra:{api:t}})=>t.user.getCustomAttributes())),re=J(oe)({onFulfilled:(e,t)=>{e.customAttributes.data=t.payload}},K((e=>e.customAttributes)),K((e=>e.customAttributes))),ae={action:oe,reducer:re},de={enabled:"active"},le=e=>e.selectedUsersLoginIds,ce=e=>e.notifications,ue=a((e=>e.usersList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{status:de[e.status]||e.status}))))),he=a(ue,le,((e,t)=>e.filter((e=>t.includes(e.loginIds))).map((e=>e.userId)))),ge=a(le,ue,((e,t)=>t.filter((t=>e.includes(t.loginIds))))),ve=a(le,(e=>!!e.length)),me=a(ge,(e=>1===e.length?e[0].email:`${e.length} users`)),pe=r("users/search",((e,{extra:{api:t},getState:s})=>{const i=s().searchParams;return t.user.search(Object.assign(Object.assign({},i),e))})),fe={action:pe,reducer:J(pe)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.usersList.data=t.payload}},K((e=>e.usersList)))},be={usersList:{data:[],loading:!1,error:null},createUser:{loading:!1,error:null},deleteUser:{loading:!1,error:null},expireUserPassword:{loading:!1,error:null},customAttributes:{loading:!1,error:null,data:{}},searchParams:{text:"",sort:[]},selectedUsersLoginIds:[],notifications:[]},ye={search:"/v1/mgmt/user/search",deleteBatch:"/v1/mgmt/user/delete/batch",create:"/v1/mgmt/user/create",expirePassword:"/v1/mgmt/user/password/expire",customAttributes:"/v1/mgmt/user/customattributes"},we=e=>s(void 0,void 0,void 0,(function*(){const t=yield e.text(),s=JSON.parse(t);if(!e.ok){const t=`${s.errorDescription}${s.errorMessage?`: ${s.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(s),e.text=()=>Promise.resolve(t)})),xe=({httpClient:e,tenant:t})=>({search:({page:i,limit:n=1e4,customAttributes:o,statuses:r,emails:a,phones:d,text:l,sort:c}={})=>s(void 0,void 0,void 0,(function*(){const s=yield e.post(ye.search,{limit:n,page:i,withTestUser:!1,customAttributes:o,statuses:r,emails:a,phones:d,text:l,sort:c},{queryParams:{tenant:t}});yield we(s);return(yield s.json()).users})),deleteBatch:i=>s(void 0,void 0,void 0,(function*(){const s=yield e.post(ye.deleteBatch,{userIds:i},{queryParams:{tenant:t}});return yield we(s),s.json()})),create:({loginId:i,email:n,phone:o,displayName:r,roles:a,customAttributes:d,picture:l,verifiedEmail:c,verifiedPhone:u,givenName:h,middleName:g,familyName:v,additionalLoginIds:m,sendSMS:p,sendMail:f,inviteUrl:b,invite:y})=>s(void 0,void 0,void 0,(function*(){const s=yield e.post(ye.create,{loginId:i,email:n,phone:o,displayName:r,givenName:h,middleName:g,familyName:v,roleNames:a,userTenants:[{tenantId:t}],customAttributes:d,picture:l,verifiedEmail:c,verifiedPhone:u,additionalLoginIds:m,sendSMS:p,sendMail:f,inviteUrl:b,invite:y},{queryParams:{tenant:t}});yield we(s);return(yield s.json()).user})),expirePassword:i=>s(void 0,void 0,void 0,(function*(){const s=yield e.post(ye.expirePassword,{loginId:i[0]},{queryParams:{tenant:t}});return yield we(s),s.json()})),getCustomAttributes:()=>s(void 0,void 0,void 0,(function*(){const s=yield e.get(ye.customAttributes,{queryParams:{tenant:t}});return yield we(s),s.json()}))}),Ce=c((i=>{var n,o,r,a;const c=l(k,x,g,C({tenant:w}))(i);return a=class extends c{constructor(){super(...arguments),n.add(this),o.set(this,void 0)}get baseUrl(){return this.getAttribute("base-url")}get tenant(){return this.getAttribute("tenant")}get api(){return e(this,o,"f")||e(this,n,"m",r).call(this),e(this,o,"f")}init(){const t=Object.create(null,{init:{get:()=>super.init}});var i;return s(this,void 0,void 0,(function*(){yield null===(i=t.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{e(this,o,"f")&&e(this,n,"m",r).call(this)}))}))}},o=new WeakMap,n=new WeakSet,r=function(){this.logger.debug("creating an sdk instance"),t(this,o,((e,t)=>{const s=d(Object.assign(Object.assign({},e),{persistTokens:!0}));return{user:xe({httpClient:s.httpClient,tenant:t})}})({projectId:this.projectId,baseUrl:this.baseUrl},this.tenant),"f")},a})),ke=c((e=>{const t=l(G({name:"widget",initialState:be,reducers:{setSelectedUsersIds:(e,{payload:t})=>{e.selectedUsersLoginIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{_.reducer(e),se.reducer(e),fe.reducer(e),ne.reducer(e),ae.reducer(e)},asyncActions:{searchUsers:fe.action,createUser:_.action,deleteUsers:se.action,expireUserPassword:ne.action,getCustomAttributes:ae.action}}),u,g,Ce)(e);return class extends t{constructor(...e){super(...e),this.state=be,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}}));const je=c((t=>{var i,n,o;return o=class extends(l(g,u,W,D)(t)){constructor(){super(...arguments),i.add(this)}onWidgetRootReady(){return s(this,void 0,void 0,(function*(){}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});var o;return s(this,void 0,void 0,(function*(){yield null===(o=t.init)||void 0===o?void 0:o.call(this),e(this,i,"m",n).call(this)}))}},i=new WeakSet,n=function(){return s(this,void 0,void 0,(function*(){const e=F('\n<descope-container\n direction="column"\n space-between="md"\n st-horizontal-padding="1rem"\n st-vertical-padding="1rem"\n st-align-items="safe center"\n st-gap="1rem"\n>\n <descope-container\n direction="row"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-align-items="safe center"\n st-gap="0rem"\n st-justify-content="space-between"\n >\n <descope-text-field data-testid="search-input" data-id="search-input" placeholder="Search" size="sm" bordered="true"></descope-text-field>\n\n <descope-container\n direction="row"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-justify-content="flex-end"\n st-gap="0.5em"\n st-host-width="auto"\n >\n <descope-button data-testid="delete-users-trigger" data-id="delete-users" mode="primary" variant="outline" size="sm">Delete</descope-button>\n <descope-button data-testid="create-user-trigger" data-id="create-user" mode="primary" variant="contained" size="sm">+ User</descope-button>\n </descope-container>\n </descope-container>\n <descope-grid\n data-id="users-table"\n size="sm"\n column-reordering-allowed\n st-host-height="300px"\n style="width: 100%"\n >\n <descope-grid-selection-column frozen auto-width></descope-grid-selection-column>\n <descope-grid-text-column path="loginIds" header="Login ID" resizable></descope-grid-text-column>\n <descope-grid-text-column sortable="true" path="name" header="Name" resizable></descope-grid-text-column>\n <descope-grid-custom-column sortable="true" path="status" header="Status" resizable>\n <descope-badge mode="default" pattern="invited" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n <descope-badge mode="primary" pattern="active" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n <descope-badge mode="error" pattern="disabled" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n </descope-grid-custom-column>\n <descope-grid-text-column sortable="true" path="email" header="Email" resizable></descope-grid-text-column>\n <descope-grid-text-column sortable="true" path="phone" header="Phone" resizable></descope-grid-text-column>\n </descope-grid>\n </descope-container>\n');yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0)),this.onWidgetRootReady()}))},o})),Ue=c((t=>{var i,n,o;return o=class extends(l(ke,Z,B,g,je)(t)){constructor(){super(...arguments),i.add(this)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return s(this,void 0,void 0,(function*(){yield null===(o=t.onWidgetRootReady)||void 0===o?void 0:o.call(this),e(this,i,"m",n).call(this)}))}},i=new WeakSet,n=function(){return s(this,void 0,void 0,(function*(){this.createUserModal=this.createModal(),this.createUserModal.setContent(F('\n<descope-container\n direction="column"\n st-justify-content="safe center"\n st-gap="1rem"\n st-host-width="100%"\n st-background-color="none"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-border-radius="sm"\n>\n <descope-text variant="subtitle1" mode="surface">New User</descope-text>\n <descope-text-field name="loginId" label="Login ID" bordered="true" required="true" size="sm"></descope-text-field>\n <descope-email-field name="email" label="Email" bordered="true"></descope-email-field>\n <descope-text-field name="displayName" label="Name" bordered="true"></descope-text-field>\n <descope-phone-field name="phone" label="Phone" bordered="true"></descope-phone-field>\n\n <descope-container\n direction="row"\n st-justify-content="flex-end"\n st-gap="1rem"\n st-host-width="100%"\n st-horizontal-padding="0.75rem"\n st-vertical-padding="0.75rem"\n st-background-color="none"\n >\n <descope-button data-testid="create-user-modal-cancel" data-id="modal-cancel" mode="primary" variant="link" size="sm">Cancel</descope-button>\n <descope-button data-testid="create-user-modal-submit" data-id="modal-submit" mode="primary" variant="contained" size="sm">Create</descope-button>\n </descope-container>\n</descope-container>\n'));const e=new z((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});e.onClick((()=>this.createUserModal.close()));const t=new z((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});t.onClick((()=>s(this,void 0,void 0,(function*(){this.validateForm(this.createUserModal.ele)&&(this.actions.createUser(Object.assign(Object.assign({},this.getFormData(this.createUserModal.ele)),{invite:!0,verifiedEmail:!0,verifiedPhone:!0})),this.createUserModal.close(),this.resetFormData(this.createUserModal.ele))}))))}))},o})),Me=c((t=>{var i,n,o;return o=class extends(l(g,Ue,je)(t)){constructor(){super(...arguments),i.add(this)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return s(this,void 0,void 0,(function*(){yield null===(o=t.onWidgetRootReady)||void 0===o?void 0:o.call(this),e(this,i,"m",n).call(this)}))}},i=new WeakSet,n=function(){var e;this.createButton=new z(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-user"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createUserModal.open()))},o}));class Re extends P{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)}}const Ee=c((t=>{var i,n,o;return o=class extends(l(ke,Z,g,je)(t)){constructor(){super(...arguments),i.add(this)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return s(this,void 0,void 0,(function*(){yield null===(o=t.onWidgetRootReady)||void 0===o?void 0:o.call(this),yield e(this,i,"m",n).call(this)}))}},i=new WeakSet,n=function(){var e;return s(this,void 0,void 0,(function*(){this.deleteUsersModal=this.createModal(),this.deleteUsersModal.setContent(F('\n<descope-container\n direction="column"\n st-justify-content="safe center"\n st-gap="1rem"\n st-host-width="100%"\n st-background-color="none"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-border-radius="sm"\n data-testid="delete-users-modal"\n>\n <descope-text variant="subtitle1" mode="surface">Delete Users</descope-text>\n <descope-text data-id="body-text" variant="body1" mode="surface">Delete user</descope-text>\n\n <descope-container \n direction="row"\n st-justify-content="flex-end"\n st-gap="1rem"\n st-host-width="100%"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-background-color="none"\n >\n <descope-button data-testid="delete-users-modal-cancel" data-id="modal-cancel" mode="primary" variant="link" size="md">Cancel</descope-button>\n <descope-button data-testid="delete-users-modal-submit" data-id="modal-submit" mode="error" variant="contained" size="md">Delete</descope-button>\n </descope-container>\n</descope-container>\n'));const t=new z((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteUsersModal.close()));const s=new z((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});s.onClick((()=>{const e=he(this.state);this.actions.deleteUsers(e),this.deleteUsersModal.close()}));const i=new Re(null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteUsersModal.beforeOpen=()=>{const e=me(this.state);i.text=`Delete ${e}?`}}))},o})),Se=c((t=>{var i,n,o,r;return r=class extends(l(g,je,ke,Ee)(t)){constructor(){super(...arguments),i.add(this),o.set(this,m((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var r;return s(this,void 0,void 0,(function*(){yield null===(r=t.onWidgetRootReady)||void 0===r?void 0:r.call(this),e(this,i,"m",n).call(this),this.subscribe(e(this,o,"f").bind(this),ve)}))}},o=new WeakMap,i=new WeakSet,n=function(){var e;this.deleteButton=new z(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-users"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteUsersModal.open()}))},r}));class Ie extends P{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)}}const Le=c((t=>{var i,n,o,r;return r=class extends(l(g,je,ke)(t)){constructor(){super(...arguments),i.add(this),n.set(this,f((()=>{this.actions.searchUsers({text:this.searchInput.value})})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var n;return s(this,void 0,void 0,(function*(){yield null===(n=t.onWidgetRootReady)||void 0===n?void 0:n.call(this),e(this,i,"m",o).call(this)}))}},n=new WeakMap,i=new WeakSet,o=function(){var t;this.searchInput=new Ie(null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(e(this,n,"f"))},r})),We="descope-notification";class Oe extends P{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()}}const Ae=c((t=>{var i,n;const o=l(u,D,W)(t);return n=class extends o{constructor(){super(...arguments),i.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Oe{setContent(t){const s="string"==typeof t?F(t):t;e(s),super.setContent(s)}}})())}createNotification(t){const s=((e={})=>{const t=document.createElement(We);return Object.keys(e).forEach((s=>{t.setAttribute(s,e[s])})),t})(Object.assign(Object.assign({},{}),t));return this.rootElement.append(s),new(e(this,i,"f"))(s,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return s(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.loadDescopeUiComponents([We])}))}},i=new WeakMap,n}));const De={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="white"/>\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="#FFDFDD"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Ne=c((t=>{var i,n,o,r,a;return a=class extends(l(g,ke,Ae,u)(t)){constructor(){super(...arguments),i.add(this),r.set(this,m((t=>{t.length&&(t.forEach((({type:t,msg:s})=>{const r=e(this,i,"m",o).call(this,t);r.setContent(e(this,i,"m",n).call(this,{type:t,msg:s})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const t=Object.create(null,{init:{get:()=>super.init}});var i;return s(this,void 0,void 0,(function*(){yield null===(i=t.init)||void 0===i?void 0:i.call(this),this.subscribe(e(this,r,"f").bind(this),ce)}))}},r=new WeakMap,i=new WeakSet,n=function({type:e,msg:t}){const s=De[e],i=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="white"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==s?void 0:s.outerHTML)||""}${t}${i.outerHTML}`},o=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},a}));const $e=/^descope-grid-([^-]+)-column$/,Te={text:class extends P{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 P{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)}}}};class Pe extends P{constructor(){super(...arguments),this.nodeName="descope-grid"}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 s;const i=null===(s=$e.exec(t.localName))||void 0===s?void 0:s[1],n=Te[i];return n?(e.push(new n(t,{logger:this.logger})),e):e}),[]):[]}}const ze=c((t=>{var i,n,o,r,a;return a=class extends(l(ke,g,je)(t)){constructor(){super(...arguments),i.add(this),o.set(this,m((e=>{this.usersTable.data=e}))),r.set(this,f(((e,t)=>{const s=[],{value:i}=t;if(i){const t=e.path;s.push({field:t,desc:"desc"===i})}this.actions.searchUsers({sort:s})})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var a;return s(this,void 0,void 0,(function*(){yield null===(a=t.onWidgetRootReady)||void 0===a?void 0:a.call(this),e(this,i,"m",n).call(this),this.usersTable.columns.forEach((t=>{t.onSortDirectionChange((t=>{e(this,r,"f").call(this,t.target,t.detail)}))})),e(this,o,"f").call(this,ue(this.state)),this.subscribe(e(this,o,"f").bind(this),ue)}))}},o=new WeakMap,r=new WeakMap,i=new WeakSet,n=function(){var e;this.usersTable=new Pe(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="users-table"]'),{logger:this.logger}),this.usersTable.onSelectedItemsChange((e=>{this.actions.setSelectedUsersIds(e.detail.value.map((({loginIds:e})=>e)))}))},a})),Fe=c((e=>class extends(l(v,$,ze,Me,Se,Le,Ne)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return s(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.actions.searchUsers()}))}})),Be=l((e=>class extends(l(Fe)(e)){}))(HTMLElement);customElements.define("descope-user-management-widget",Be);export{Be as default};
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // @descope/user-management-widget v0.0.7
2
- !function(){"use strict";function e(...e){return t=>e.reduce(((e,t)=>t(e)),t)}var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function r(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function o(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function i(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;const s=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 r=e(n);return r[t]=!0,r}},a=s((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}init(){return r(this,void 0,void 0,(function*(){}))}},t=new WeakMap,n})),c=["error","warn","info","debug"],l=s((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,console))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return c.reduce(((t,n)=>(t[n]=(...t)=>{var r;this.onLogEvent(n,t),null===(r=e[n])||void 0===r||r.call(e,...t)},t)),{})},s})),u=s((t=>{var n,s,c,u,d,h,p;return p=class extends(e(a,l)(t)){constructor(){super(...arguments),n.add(this),s.set(this,void 0),this.attributeChangedCallback=(e,t,r)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,t,r),"debug"===e&&o(this,n,"m",d).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,t){var r;null===(r=super.onLogEvent)||void 0===r||r.call(this,e,t),"error"===e&&o(this,n,"m",h).call(this,t[0]||"Error",t[1])}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),o(this,n,"m",d).call(this)}))}},s=new WeakMap,n=new WeakSet,c=function(){var e;null===(e=o(this,s,"f"))||void 0===e||e.remove(),i(this,s,null,"f")},u=function(){return r(this,void 0,void 0,(function*(){i(this,s,document.createElement("descope-debugger"),"f"),Object.assign(o(this,s,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return ja})),document.body.appendChild(o(this,s,"f"))}))},d=function(){this.debug?o(this,n,"m",u).call(this):o(this,n,"m",c).call(this)},h=function(e,t){var n;e&&(null===(n=o(this,s,"f"))||void 0===n||n.updateData({title:e,description:t}))},p})),d=e=>{let t,n;return(...r)=>{return t&&(i=r,(o=t).length===i.length&&o.every(((e,t)=>e===i[t])))||(t=r,n=e(...r)),n;var o,i}},h=e=>(t,...n)=>t.reduce(((t,r,o)=>{var i;return`${t}${r}${(null===(i=null==n?void 0:n[o])||void 0===i?void 0:i[e>1?1:0])||""}`}),""),p=(e,t=500)=>{let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},f="undefined"!=typeof localStorage,g=f&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",m=(e,t)=>!t&&`${e} cannot be empty`,v=s((t=>{var n,i;const s=e(l,a)(t);return i=class extends s{constructor(){super(...arguments),n.set(this,{})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){var r,i;yield null===(t=e.init)||void 0===t?void 0:t.call(this),r=this,i=e=>{var t;null===(t=o(this,n,"f")[e])||void 0===t||t.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(r.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(r,{attributes:!0})}))}observeAttribute(e,t){o(this,n,"f")[e]||(o(this,n,"f")[e]=[]);const r=o(this,n,"f")[e].push(t);return()=>o(this,n,"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()))}},n=new WeakMap,i})),y=t=>n=>{var i,s,c;const u=e(l,a,v)(n),d=Object.keys(t);return c=class extends u{constructor(...e){super(...e),i.add(this),this.observeAttributes(d,o(this,i,"m",s).bind(this))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),d.forEach((e=>o(this,i,"m",s).call(this,e,this.getAttribute(e))))}))}},i=new WeakSet,s=function(e,n){const r=t[e],o="function"==typeof r?r(e,n):r;o&&this.logger.error(o)},c},b=s((t=>{const n=e(y({"project-id":m}))(t);return class extends n{get projectId(){return this.getAttribute("project-id")}}}));const w=s((t=>{const n=e(l,b)(t);return class extends n{fetchStaticResource(e,t){return r(this,void 0,void 0,(function*(){const n=function(e,t,n="v2-beta"){const r=new URL(g);return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,n,t),r.toString()}(this.projectId,e),r=yield fetch(n,{cache:"default"});return r.ok||this.logger.error(`Error fetching URL ${n} [${r.status}]`),{body:yield r[t](),headers:Object.fromEntries(r.headers.entries())}}))}}})),k=s((t=>{var n,s,a;const c=e(w)(t);return a=class extends c{constructor(){super(...arguments),n.set(this,void 0),s.set(this,(()=>r(this,void 0,void 0,(function*(){try{const{body:e,headers:t}=yield this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))))}get config(){return o(this,n,"f")||i(this,n,o(this,s,"f").call(this),"f"),o(this,n,"f")}},n=new WeakMap,s=new WeakMap,a})),j="load-descope-ui-script",x="base.ui.components.url",O=f&&localStorage.getItem(x)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",I=f&&localStorage.getItem(x)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",S=e=>{const t=document.createElement("script");return t.id=e,t},C=(e,t)=>e.replace("<version>",t),_=s((t=>{var n,s,a,c,u,d,h,p,f,g,m,v;const y=e(l,k)(t);return v=class extends y{constructor(){super(...arguments),n.add(this),s.set(this,Symbol("errorCbs")),a.set(this,Symbol("loadCbs")),f.set(this,void 0)}get descopeUi(){return o(this,f,"f")||i(this,f,o(this,n,"m",m).call(this),"f"),o(this,f,"f")}loadDescopeUiComponents(e){return r(this,void 0,void 0,(function*(){const t=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(t.map((e=>o(this,n,"m",g).call(this,e))))}))}},s=new WeakMap,a=new WeakMap,f=new WeakMap,n=new WeakSet,c=function(){var e;return r(this,void 0,void 0,(function*(){const t=yield 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}))},u=function(e){const t=o(this,s,"f"),n=o(this,a,"f");e[t]=[],e[n]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[n].push(t)}})},d=function(e,t){return r(this,void 0,void 0,(function*(){this.logger.debug("Trying to load DescopeUI from a fallback URL");const r=S("load-descope-ui-fallback-script");document.body.append(r),r.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${r.src}"`)))})),r.addEventListener("load",(()=>{t.forEach((e=>e()))})),r.src=C(I,yield o(this,n,"m",c).call(this))}))},h=function(e){e.addEventListener("error",(()=>{e[o(this,s,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),o(this,n,"m",d).call(this,e[o(this,s,"f")],e[o(this,a,"f")])})),e.addEventListener("load",(()=>{e[o(this,a,"f")].forEach((e=>e()))}))},p=function(){return r(this,void 0,void 0,(function*(){if(document.getElementById(j))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=S(j);document.body.append(e),o(this,n,"m",u).call(this,e),o(this,n,"m",h).call(this,e),e.src=C(O,yield o(this,n,"m",c).call(this))}return document.getElementById(j)}))},g=function(e){return r(this,void 0,void 0,(function*(){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=yield this.descopeUi;if(t[e])try{return yield 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(", ")}"`)}))},m=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),o(this,n,"m",p).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},v})),E="content-root",R="root",P=s((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${R}, #${E} {\n height: 100%;\n }\n </style>\n <div id="${R}">\n <div id="${E}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(E),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(R)}})),A=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',M=s((t=>{var n,s,c,l,u,d,h,p,f;const g=e(y({theme:A}),w,a,_,k,P)(t);return f=class extends g{constructor(){super(...arguments),n.add(this),s.set(this,void 0)}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"}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),o(this,n,"m",u).call(this),o(this,n,"m",d).call(this),o(this,n,"m",h).call(this),o(this,n,"m",p).call(this)}))}},s=new WeakMap,n=new WeakSet,c=function(){return r(this,void 0,void 0,(function*(){try{const{body:e}=yield this.fetchStaticResource("theme.json","json");return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},l=function(){return o(this,s,"f")||(i(this,s,o(this,n,"m",c).call(this),"f"),o(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,s,"f")},u=function(){var e,t;return r(this,void 0,void 0,(function*(){const r=yield o(this,n,"a",l);if(!r)return;const i=document.createElement("style");i.innerText=((null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.globals)||"")+((null===(t=null==r?void 0:r.dark)||void 0===t?void 0:t.globals)||""),this.shadowRoot.appendChild(i)}))},d=function(){var e,t;return r(this,void 0,void 0,(function*(){const r=Object.assign({},yield o(this,n,"a",l));if(!r)return;const i=yield 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===(t=null==r?void 0:r.dark)||void 0===t?void 0:t.components})}))},h=function(){var e,t;return r(this,void 0,void 0,(function*(){const{projectConfig:n}=yield this.config,r=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;r&&Object.values(r).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))}))}))},p=function(){return r(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},f}));var U;class T{constructor(e,t){U.set(this,void 0),this.nodeName="",i(this,U,e,"f"),this.logger=t.logger}get ele(){var e,t;const n="function"==typeof o(this,U,"f")?o(this,U,"f").call(this):o(this,U,"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("no element for driver ",this.constructor.name,new Error),null)}}U=new WeakMap;class $ extends T{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 D=e=>{const t=document.createElement("template");return t.innerHTML=e,t},L=s((t=>class extends(e(l)(t)){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=>{e.value=t[e.getAttribute("name")]}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value=""}))}})),N="descope-modal";var z;class W extends T{constructor(){super(...arguments),z.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)}open(){var e,t;null===(e=this.beforeOpen)||void 0===e||e.call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,z,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,z,"f").content.cloneNode(!0)))}setContent(e){i(this,z,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}z=new WeakMap;const F=s((t=>{var n,i;const s=e(a,P,_)(t);return i=class extends s{constructor(){super(...arguments),n.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends W{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const t=((e={})=>{const t=document.createElement(N);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(t),new(o(this,n,"f"))(t,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){this.loadDescopeUiComponents([N]),yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}},n=new WeakMap,i}));var q=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),B=()=>Math.random().toString(36).substring(7).split("").join("."),H={INIT:`@@redux/INIT${B()}`,REPLACE:`@@redux/REPLACE${B()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${B()}`};function J(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 K(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 V(e){let t=typeof e;return t=K(e),t}function Z(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${V(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: '${V(n)}'`);return n(Z)(e,t)}let r=e,o=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function u(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function d(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${V(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(!J(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${V(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: '${V(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,o=r(o,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}h({type:H.INIT});return{dispatch:h,subscribe:d,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${V(e)}`);r=e,h({type:H.REPLACE})},[q]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${V(t)}'`);function n(){const e=t;e.next&&e.next(u())}n();return{unsubscribe:e(n)}},[q](){return this}}}}}function Y(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function X(e){const t=Object.keys(e),n={};for(let r=0;r<t.length;r++){const o=t[r];void 0===e[o]&&Y(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const r=Object.keys(n);let o,i;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:H.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:H.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 '${H.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 r=function(e,t,n,r){const o=Object.keys(t),i=n&&n.type===H.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!J(e))return`The ${i} has unexpected type of "${V(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!r[e]));return s.forEach((e=>{r[e]=!0})),n&&n.type===H.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: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);r&&Y(r)}let s=!1;const a={};for(let o=0;o<r.length;o++){const i=r[o],c=n[i],l=e[i],u=c(l,t);if(void 0===u){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=u,s=s||u!==l}return s=s||r.length!==Object.keys(e).length,s?a:e}}function G(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Q(e){return J(e)&&"type"in e&&"string"==typeof e.type}var ee=Symbol.for("immer-nothing"),te=Symbol.for("immer-draftable"),ne=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 oe(e,...t){{const n=re[e],r="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}}var ie=Object.getPrototypeOf;function se(e){return!!e&&!!e[ne]}function ae(e){return!!e&&(le(e)||Array.isArray(e)||!!e[te]||!!e.constructor?.[te]||fe(e)||ge(e))}var ce=Object.prototype.constructor.toString();function le(e){if(!e||"object"!=typeof e)return!1;const t=ie(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)===ce}function ue(e,t){0===de(e)?Object.entries(e).forEach((([n,r])=>{t(n,r,e)})):e.forEach(((n,r)=>t(r,n,e)))}function de(e){const t=e[ne];return t?t.type_:Array.isArray(e)?1:fe(e)?2:ge(e)?3:0}function he(e,t){return 2===de(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function pe(e,t,n){const r=de(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function fe(e){return e instanceof Map}function ge(e){return e instanceof Set}function me(e){return e.copy_||e.base_}function ve(e,t){if(fe(e))return new Map(e);if(ge(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&le(e)){if(!ie(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[ne];let r=Reflect.ownKeys(n);for(let t=0;t<r.length;t++){const o=r[t],i=n[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(ie(e),n)}function ye(e,t=!1){return we(e)||se(e)||!ae(e)||(de(e)>1&&(e.set=e.add=e.clear=e.delete=be),Object.freeze(e),t&&ue(e,((e,t)=>ye(t,!0)))),e}function be(){oe(2)}function we(e){return Object.isFrozen(e)}var ke,je={};function xe(e){const t=je[e];return t||oe(0,e),t}function Oe(){return ke}function Ie(e,t){t&&(xe("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Se(e){Ce(e),e.drafts_.forEach(Ee),e.drafts_=null}function Ce(e){e===ke&&(ke=e.parent_)}function _e(e){return ke={drafts_:[],parent_:ke,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ee(e){const t=e[ne];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Re(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[ne].modified_&&(Se(t),oe(4)),ae(e)&&(e=Pe(t,e),t.parent_||Me(t,e)),t.patches_&&xe("Patches").generateReplacementPatches_(n[ne].base_,e,t.patches_,t.inversePatches_)):e=Pe(t,n,[]),Se(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ee?e:void 0}function Pe(e,t,n){if(we(t))return t;const r=t[ne];if(!r)return ue(t,((o,i)=>Ae(e,r,t,o,i,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return Me(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let o=t,i=!1;3===r.type_&&(o=new Set(t),t.clear(),i=!0),ue(o,((o,s)=>Ae(e,r,t,o,s,n,i))),Me(e,t,!1),n&&e.patches_&&xe("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Ae(e,t,n,r,o,i,s){if(o===n&&oe(5),se(o)){const s=Pe(e,o,i&&t&&3!==t.type_&&!he(t.assigned_,r)?i.concat(r):void 0);if(pe(n,r,s),!se(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(ae(o)&&!we(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Pe(e,o),t&&t.scope_.parent_||Me(e,o)}}function Me(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ye(t,n)}var Ue={get(e,t){if(t===ne)return e;const n=me(e);if(!he(n,t))return function(e,t,n){const r=De(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!ae(r)?r:r===$e(e.base_,t)?(Ne(e),e.copy_[t]=ze(r,e)):r},has:(e,t)=>t in me(e),ownKeys:e=>Reflect.ownKeys(me(e)),set(e,t,n){const r=De(me(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=$e(me(e),t),o=r?.[ne];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,r)&&(void 0!==n||he(e.base_,t)))return!0;Ne(e),Le(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!==$e(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Ne(e),Le(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=me(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){oe(11)},getPrototypeOf:e=>ie(e.base_),setPrototypeOf(){oe(12)}},Te={};function $e(e,t){const n=e[ne];return(n?me(n):e)[t]}function De(e,t){if(!(t in e))return;let n=ie(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=ie(n)}}function Le(e){e.modified_||(e.modified_=!0,e.parent_&&Le(e.parent_))}function Ne(e){e.copy_||(e.copy_=ve(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ue(Ue,((e,t)=>{Te[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Te.deleteProperty=function(e,t){return isNaN(parseInt(t))&&oe(13),Te.set.call(this,e,t,void 0)},Te.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&oe(14),Ue.set.call(this,e[0],t,n,e[0])};function ze(e,t){const n=fe(e)?xe("MapSet").proxyMap_(e,t):ge(e)?xe("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Oe(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=Ue;n&&(o=[r],i=Te);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}(e,t);return(t?t.scope_:Oe()).drafts_.push(n),n}function We(e){return se(e)||oe(10,e),Fe(e)}function Fe(e){if(!ae(e)||we(e))return e;const t=e[ne];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=ve(e,t.scope_.immer_.useStrictShallowCopy_)}else n=ve(e,!0);return ue(n,((e,t)=>{pe(n,e,Fe(t))})),t&&(t.finalized_=!1),n}var qe=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 r=this;return function(e=n,...o){return r.produce(e,(e=>t.call(this,e,...o)))}}let r;if("function"!=typeof t&&oe(6),void 0!==n&&"function"!=typeof n&&oe(7),ae(e)){const o=_e(this),i=ze(e,void 0);let s=!0;try{r=t(i),s=!1}finally{s?Se(o):Ce(o)}return Ie(o,n),Re(r,o)}if(!e||"object"!=typeof e){if(r=t(e),void 0===r&&(r=e),r===ee&&(r=void 0),this.autoFreeze_&&ye(r,!0),n){const t=[],o=[];xe("Patches").generateReplacementPatches_(e,r,t,o),n(t,o)}return r}oe(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;const o=this.produce(e,t,((e,t)=>{n=e,r=t}));return[o,n,r]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ae(e)||oe(8),se(e)&&(e=We(e));const t=_e(this),n=ze(e,void 0);return n[ne].isManual_=!0,Ce(t),n}finishDraft(e,t){const n=e&&e[ne];n&&n.isManual_||oe(9);const{scope_:r}=n;return Ie(r,t),Re(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=xe("Patches").applyPatches_;return se(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},Be=qe.produce;qe.produceWithPatches.bind(qe),qe.setAutoFreeze.bind(qe),qe.setUseStrictShallowCopy.bind(qe),qe.applyPatches.bind(qe),qe.createDraft.bind(qe),qe.finishDraft.bind(qe);var He=e=>{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})}},Je=(e,t,n)=>{const{memoize:r,memoizeOptions:o}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=r((()=>({})),...o);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})}},Ke={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Ve=e=>Array.isArray(e)?e:[e];function Ze(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 Ye(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var Xe="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Ge=0,Qe=1;function et(){return{s:Ge,v:void 0,o:null,p:null}}function tt(e,t={}){let n=et();const{resultEqualityCheck:r}=t;let o,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 r=e.get(n);void 0===r?(t=et(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=et(),e.set(n,t)):t=r}}const a=t;let c;if(t.s===Qe?c=t.v:(c=e.apply(null,arguments),i++),a.s=Qe,r){const e=o?.deref()??o;null!=e&&r(e,c)&&(c=e,0!==i&&i--);o="object"==typeof c&&null!==c||"function"==typeof c?new Xe(c):c}return a.v=c,c}return s.clearCache=()=>{n=et(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function nt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e;return(...e)=>{let t,r=0,o=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:u=tt,argsMemoizeOptions:d=[],devModeChecks:h={}}=a,p=Ve(l),f=Ve(d),g=Ze(e),m=c((function(){return r++,s.apply(null,arguments)}),...p);let v=!0;const y=u((function(){o++;const e=Ye(g,arguments);{const{identityFunctionCheck:t,inputStabilityCheck:n}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...Ke,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:He},inputStabilityCheck:{shouldRun:"always"===r||"once"===r&&e,run:Je}}})(v,h);if(t.shouldRun&&t.run(s),n.shouldRun){const t=Ye(g,arguments);n.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}v&&(v=!1)}return t=m.apply(null,e),t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:m,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:c,argsMemoize:u})}}var rt=nt(tt);function ot(e){return({dispatch:t,getState:n})=>r=>o=>"function"==typeof o?o(t,n,e):r(o)}var it=ot(),st=ot;((...e)=>{const t=nt(...e)})(tt);var at="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?G:G.apply(null,arguments)},ct=e=>e&&"function"==typeof e.match;function lt(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw new Error("prepareAction did not return an object");return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Q(t)&&t.type===e,n}function ut(e){return"function"==typeof e&&"type"in e&&ct(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 ht=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 pt(e){return ae(e)?Be(e,(()=>{})):e}function ft(e,t,n){if(e.has(t)){let r=e.get(t);return n.update&&(r=n.update(r,t,e),e.set(t,r)),r}if(!n.insert)throw new Error("No insert provided for key not already in map");const r=n.insert(t,e);return e.set(t,r),r}function gt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function mt(e,t,n){const r=vt(e,t,n);return{detectMutations:()=>yt(e,t,r,n)}}function vt(e,t=[],n,r="",o=new Set){const i={value:n};if(!e(n)&&!o.has(n)){o.add(n),i.children={};for(const o in n){const s=r?r+"."+o:o;t.length&&-1!==t.indexOf(s)||(i.children[o]=vt(e,t,n[o],s))}}return i}function yt(e,t=[],n,r,o=!1,i=""){const s=n?n.value:void 0,a=s===r;if(o&&!a&&!Number.isNaN(r))return{wasMutated:!0,path:i};if(e(s)||e(r))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in r)c[e]=!0;const l=t.length>0;for(let o in c){const s=i?i+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=yt(e,t,n.children[o],r[o],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)||J(e)}function wt(e,t="",n=bt,r,o=[],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!=r?r(e):Object.entries(e),c=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=wt(l,a,n,r,o,i),s))return s}return i&&kt(e)&&i.add(e),!1}function kt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!kt(t))return!1;return!0}function jt(e){return"boolean"==typeof e}var xt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:o=!0}=e??{};let i=new ht;if(t&&(jt(t)?i.push(it):i.push(st(t.extraArgument))),n){let e={};jt(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,r,o){return JSON.stringify(e,n(t,o),r)},n=function(e,t){let n=[],r=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+r.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?r.splice(s,1/0,o):r.push(o),~n.indexOf(i)&&(i=t.call(this,o,i))}else n.push(i);return null==e?i:e.call(this,o,i)}},{isImmutable:r=gt,ignoredPaths:o,warnAfter:i=32}=e;const s=mt.bind(null,r,o);return({getState:e})=>{let n,r=e(),o=s(r);return a=>c=>{const l=dt(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const u=a(c);return l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),u}}}}(e))}if(r){let e={};jt(r)||(e=r),i.push(function(e={}){{const{isSerializable:t=bt,getEntries:n,ignoredActions:r=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,u=!l&&WeakSet?new WeakSet:void 0;return e=>l=>d=>{if(!Q(d))return l(d);const h=l(d),p=dt(s,"SerializableStateInvariantMiddleware");return c||r.length&&-1!==r.indexOf(d.type)||p.measureTime((()=>{const e=wt(d,"",t,n,o,u);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",d,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const r=wt(e.getState(),"",t,n,i,u);if(r){const{keyPath:e,value:t}=r;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${d.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};jt(o)||(e=o),i.unshift(function(e={}){const{isActionCreator:t=ut}=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},Ot=e=>t=>{setTimeout(t,e)},It="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Ot(10),St=e=>function(t){const{autoBatch:n=!0}=t??{};let r=new ht(e);return n&&r.push(((e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let o=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?It:"callback"===e.type?e.queueNotification:Ot(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},r,{subscribe(e){const t=r.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,i=!o,i&&(s||(s=!0,c(l))),r.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),r};function Ct(e){const t=xt(),{reducer:n,middleware:r,devTools:o=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!J(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=X(n)}if(r&&"function"!=typeof r)throw new Error("`middleware` field must be a callback");if("function"==typeof r){if(c=r(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=G;o&&(l=at({trace:!0,..."object"==typeof o&&o}));const u=function(...e){return t=>(n,r)=>{const o=t(n,r);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:o.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=G(...a)(o.dispatch),{...o,dispatch:i}}}(...c),d=St(u);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(d):d();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(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Z(a,i,l(...h))}function _t(e){const t={},n=[];let r;const o={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(r)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,o},addMatcher(e,t){if(r)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(r)throw new Error("`builder.addDefaultCase` can only be called once");return r=e,o}};return e(o),[t,n,r]}function Et(...e){return t=>e.some((e=>((e,t)=>ct(e)?e.match(t):e(t))(e,t)))}var Rt=["name","message","stack","code"],Pt=class{constructor(e,t){this.payload=e,this.meta=t}_type},At=class{constructor(e,t){this.payload=e,this.meta=t}_type},Mt=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Rt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},Ut=(()=>{function e(e,t,n){const r=lt(e+"/fulfilled",((e,t,n,r)=>({payload:e,meta:{...r||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=lt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=lt(e+"/rejected",((e,t,r,o,i)=>({payload:o,error:(n&&n.serializeError||Mt)(e||"Rejected"),meta:{...i||{},arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),u=new AbortController;let d;function h(e){d=e,u.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||u.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>u.signal.addEventListener("abort",(()=>t({name:"AbortError",message:d||"Aborted"})))));s(o(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:u.signal,abort:h,rejectWithValue:(e,t)=>new Pt(e,t),fulfillWithValue:(e,t)=>new At(e,t)})).then((t=>{if(t instanceof Pt)throw t;return t instanceof At?r(t.payload,l,e,t.meta):r(t,l,e)}))])}catch(t){p=t instanceof Pt?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(Tt)})}}),{pending:o,rejected:i,fulfilled:r,settled:Et(i,r),typePrefix:e})}return e.withTypes=()=>e,e})();function Tt(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var $t=Symbol.for("rtk-slice-createasyncthunk");function Dt(e,t){return`${e}/${t}`}function Lt(e,t,n,r){function o(o,...i){let s=n.call(e,o);if(void 0===s){if(!r)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return o.unwrapped=t,o}var Nt=function({creators:e}={}){const t=e?.asyncThunk?.[$t];return function(e){const{name:n,reducerPath:r=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function 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=[],r]="function"==typeof e.extraReducers?_t(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[r,o,i]=_t(t);if(function(e){return"function"==typeof e}(e))n=()=>pt(e());else{const t=pt(e);n=()=>t}function s(e=n(),t){let s=[r[t.type],...o.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(se(e)){const r=n(e,t);return void 0===r?e:r}if(ae(e))return Be(e,(e=>n(e,t)));{const r=n(e,t);if(void 0===r){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return r}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)}))}i.forEach((r=>{const i=o[r],s={reducerName:r,type:Dt(n,r),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},r,o){let i,s;if("reducer"in r){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(r))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=r.reducer,s=r.prepare}else i=r;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?lt(e,s):lt(e))}(s,i,a):function({type:e,reducerName:t},n,r,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:u}=n,d=o(e,i,u);r.exposeAction(t,d),s&&r.addCase(d.fulfilled,s);a&&r.addCase(d.pending,a);c&&r.addCase(d.rejected,c);l&&r.addMatcher(d.settled,l);r.exposeCaseReducer(t,{fulfilled:s||zt,pending:a||zt,rejected:c||zt,settled:l||zt})}(s,i,a,t)}));const l=e=>e,u=new WeakMap;let d;const h={name:n,reducerPath:r,reducer:(e,t)=>(d||(d=c()),d(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(d||(d=c()),d.getInitialState()),getSelectors(t=l){const n=ft(u,this,{insert:()=>new WeakMap});return ft(n,t,{insert:()=>{const n={};for(const[r,o]of Object.entries(e.selectors??{}))n[r]=Lt(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const r=t??this.reducerPath;return e.inject({reducerPath:r,reducer:this.reducer},n),{...this,reducerPath:r}}};return h}}();function zt(){}var Wt="listenerMiddleware";lt(`${Wt}/add`),lt(`${Wt}/removeAll`),lt(`${Wt}/remove`);const Ft=t=>s((n=>{const o=Nt(t),i=Object.assign(Object.assign({},o.actions),t.asyncActions);return class extends(e(l)(n)){constructor(...e){super(...e);const t=Ct({reducer:o.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),n=e=>(...n)=>r(this,void 0,void 0,(function*(){const r=yield t.dispatch(e(...n));try{Tt(r)}catch(e){this.logger.error(e.message,r.type,e.stack)}return r})),s=Object.keys(i).reduce(((e,t)=>(e[t]=n(i[t]),e)),{});this.actions=s,this.subscribe=(e,n=(e=>e))=>t.subscribe((()=>e(n(t.getState()))))}}})),qt=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Bt=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}}),Ht=({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)})}}),Jt=Ut("users/create",((e,{extra:{api:t}})=>t.user.create(e))),Kt=qt(Jt)({onFulfilled:(e,t)=>{e.usersList.data.unshift(t.payload)}},Bt((e=>e.createUser)),Ht({getSuccessMsg:()=>"User created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Vt={action:Jt,reducer:Kt},Zt=Ut("users/delete",((e,{extra:{api:t}})=>t.user.deleteBatch(e))),Yt=qt(Zt)({onFulfilled:(e,t)=>{e.usersList.data=e.usersList.data.filter((e=>!t.meta.arg.includes(e.userId))),e.selectedUsersLoginIds=[]}},Bt((e=>e.deleteUser)),Ht({getSuccessMsg:e=>h(e.meta.arg.length)`${["",e.meta.arg.length]} ${["U","u"]}ser${["","s"]} deleted successfully`,getErrorMsg:e=>h(e.meta.arg.length)`Failed to delete user${["","s"]}`})),Xt={action:Zt,reducer:Yt},Gt=Ut("users/expirePassword",((e,{extra:{api:t}})=>t.user.expirePassword(e))),Qt={action:Gt,reducer:qt(Gt)(Bt((e=>e.expireUserPassword)))},en=Ut("users/getCustomAttributes",((e,{extra:{api:t}})=>t.user.getCustomAttributes())),tn=qt(en)({onFulfilled:(e,t)=>{e.customAttributes.data=t.payload}},Bt((e=>e.customAttributes)),Bt((e=>e.customAttributes))),nn={action:en,reducer:tn},rn={enabled:"active"},on=e=>e.selectedUsersLoginIds,sn=e=>e.notifications,an=rt((e=>e.usersList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{status:rn[e.status]||e.status}))))),cn=rt(an,on,((e,t)=>e.filter((e=>t.includes(e.loginIds))).map((e=>e.userId)))),ln=rt(on,an,((e,t)=>t.filter((t=>e.includes(t.loginIds))))),un=rt(on,(e=>!!e.length)),dn=rt(ln,(e=>1===e.length?e[0].email:`${e.length} users`)),hn=Ut("users/search",((e,{extra:{api:t},getState:n})=>{const r=n().searchParams;return t.user.search(Object.assign(Object.assign({},r),e))})),pn={action:hn,reducer:qt(hn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.usersList.data=t.payload}},Bt((e=>e.usersList)))},fn={usersList:{data:[],loading:!1,error:null},createUser:{loading:!1,error:null},deleteUser:{loading:!1,error:null},expireUserPassword:{loading:!1,error:null},customAttributes:{loading:!1,error:null,data:{}},searchParams:{text:"",sort:[]},selectedUsersLoginIds:[],notifications:[]};function gn(e){this.message=e}gn.prototype=new Error,gn.prototype.name="InvalidCharacterError";var mn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new gn("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,i=0,s="";r=t.charAt(i++);~r&&(n=o%4?64*n+r:r,o++%4)?s+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function vn(e){this.message=e}function yn(e,t){if("string"!=typeof e)throw new vn("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(mn(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return mn(t)}}(e.split(".")[n]))}catch(e){throw new vn("Invalid token specified: "+e.message)}}vn.prototype=new Error,vn.prototype.name="InvalidTokenError";var bn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function wn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kn="__lodash_hash_undefined__",jn=1/0,xn="[object Function]",On="[object GeneratorFunction]",In="[object Symbol]",Sn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Cn=/^\w*$/,_n=/^\./,En=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Rn=/\\(\\)?/g,Pn=/^\[object .+?Constructor\]$/,An="object"==typeof bn&&bn&&bn.Object===Object&&bn,Mn="object"==typeof self&&self&&self.Object===Object&&self,Un=An||Mn||Function("return this")();var Tn,$n=Array.prototype,Dn=Function.prototype,Ln=Object.prototype,Nn=Un["__core-js_shared__"],zn=(Tn=/[^.]+$/.exec(Nn&&Nn.keys&&Nn.keys.IE_PROTO||""))?"Symbol(src)_1."+Tn:"",Wn=Dn.toString,Fn=Ln.hasOwnProperty,qn=Ln.toString,Bn=RegExp("^"+Wn.call(Fn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hn=Un.Symbol,Jn=$n.splice,Kn=or(Un,"Map"),Vn=or(Object,"create"),Zn=Hn?Hn.prototype:void 0,Yn=Zn?Zn.toString:void 0;function Xn(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Gn(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Qn(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function er(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function tr(e,t){var n;t=function(e,t){if(cr(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||ur(e))return!0;return Cn.test(e)||!Sn.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:cr(n=t)?n:ir(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[sr(t[r++])];return r&&r==o?e:void 0}function nr(e){if(!lr(e)||(t=e,zn&&zn in t))return!1;var t,n=function(e){var t=lr(e)?qn.call(e):"";return t==xn||t==On}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Bn:Pn;return n.test(function(e){if(null!=e){try{return Wn.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function rr(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function or(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return nr(n)?n:void 0}Xn.prototype.clear=function(){this.__data__=Vn?Vn(null):{}},Xn.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Xn.prototype.get=function(e){var t=this.__data__;if(Vn){var n=t[e];return n===kn?void 0:n}return Fn.call(t,e)?t[e]:void 0},Xn.prototype.has=function(e){var t=this.__data__;return Vn?void 0!==t[e]:Fn.call(t,e)},Xn.prototype.set=function(e,t){return this.__data__[e]=Vn&&void 0===t?kn:t,this},Gn.prototype.clear=function(){this.__data__=[]},Gn.prototype.delete=function(e){var t=this.__data__,n=er(t,e);return!(n<0)&&(n==t.length-1?t.pop():Jn.call(t,n,1),!0)},Gn.prototype.get=function(e){var t=this.__data__,n=er(t,e);return n<0?void 0:t[n][1]},Gn.prototype.has=function(e){return er(this.__data__,e)>-1},Gn.prototype.set=function(e,t){var n=this.__data__,r=er(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Qn.prototype.clear=function(){this.__data__={hash:new Xn,map:new(Kn||Gn),string:new Xn}},Qn.prototype.delete=function(e){return rr(this,e).delete(e)},Qn.prototype.get=function(e){return rr(this,e).get(e)},Qn.prototype.has=function(e){return rr(this,e).has(e)},Qn.prototype.set=function(e,t){return rr(this,e).set(e,t),this};var ir=ar((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ur(e))return Yn?Yn.call(e):"";var t=e+"";return"0"==t&&1/e==-jn?"-0":t}(t);var n=[];return _n.test(e)&&n.push(""),e.replace(En,(function(e,t,r,o){n.push(r?o.replace(Rn,"$1"):t||e)})),n}));function sr(e){if("string"==typeof e||ur(e))return e;var t=e+"";return"0"==t&&1/e==-jn?"-0":t}function ar(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(ar.Cache||Qn),n}ar.Cache=Qn;var cr=Array.isArray;function lr(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ur(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&qn.call(e)==In}var dr=wn((function(e,t,n){var r=null==e?void 0:tr(e,t);return void 0===r?n:r})),hr="/v1/auth/accesskey/exchange",pr="/v1/auth/otp/verify",fr="/v1/auth/otp/signin",gr="/v1/auth/otp/signup",mr={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},vr="/v1/auth/otp/signup-in",yr="/v1/auth/magiclink/verify",br="/v1/auth/magiclink/signin",wr="/v1/auth/magiclink/signup",kr={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},jr="/v1/auth/magiclink/signup-in",xr="/v1/auth/enchantedlink/verify",Or="/v1/auth/enchantedlink/signin",Ir="/v1/auth/enchantedlink/signup",Sr="/v1/auth/enchantedlink/pending-session",Cr={email:"/v1/auth/enchantedlink/update/email"},_r="/v1/auth/enchantedlink/signup-in",Er="/v1/auth/oauth/authorize",Rr="/v1/auth/oauth/exchange",Pr="/v1/auth/saml/authorize",Ar="/v1/auth/saml/exchange",Mr="/v1/auth/totp/verify",Ur="/v1/auth/totp/signup",Tr="/v1/auth/totp/update",$r={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Dr={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Lr={start:"/v1/auth/webauthn/signup-in/start"},Nr={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},zr="/v1/auth/password/signup",Wr="/v1/auth/password/signin",Fr="/v1/auth/password/reset",qr="/v1/auth/password/update",Br="/v1/auth/password/replace",Hr="/v1/auth/password/policy",Jr="/v1/auth/refresh",Kr="/v1/auth/tenant/select",Vr="/v1/auth/logout",Zr="/v1/auth/logoutall",Yr="/v1/auth/me",Xr="/v1/auth/me/history",Gr="/v1/flow/start",Qr="/v1/flow/next";const eo="<region>",to=`https://api.${eo}descope.com`,no=6e5,ro=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};var oo;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(oo||(oo={}));const io=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,r])=>(e[n]=r,e)),e),e}),{})),so=e=>void 0===e?void 0:JSON.stringify(e),ao=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},co=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:o,cookiePolicy:i,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),r=await n.text();return n.text=()=>Promise.resolve(r),n.json=()=>Promise.resolve(JSON.parse(r)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>ro().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await n(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return ro().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n})(r,s),c=async r=>{const s=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:l,headers:u,queryParams:d,method:h,token:p}=s,f={headers:io(ao(t,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.9.0"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:so(l)};null!==i&&(f.credentials=i||"include");const g=await a((({path:e,baseUrl:t,queryParams:n,projectId:r})=>{const o=r.slice(1,-27);t=t.replace(eo,o?o+".":"");const i=new URL(e,t);return n&&(i.search=new URLSearchParams(n).toString()),i})({path:c,baseUrl:e,queryParams:d,projectId:t}),f);return(null==o?void 0:o.afterRequest)&&await o.afterRequest(r,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:r}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:oo.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>c({path:e,headers:n,queryParams:r,body:t,method:oo.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>c({path:e,headers:n,queryParams:r,body:t,method:oo.put,token:o}),delete:(e,{headers:t,queryParams:n,token:r}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:oo.delete,token:r}),hooks:o}};var lo=429;function uo(e,t,n){var r;let o=ho(e);t&&(o=null===(r=null==o?void 0:o.tenants)||void 0===r?void 0:r[t]);const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function ho(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return yn(e)}function po(e){const{exp:t}=ho(e);return(new Date).getTime()/1e3>t}function fo(e){let t=ho(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function go(e,t){return uo(e,t,"permissions")}function mo(e,t){return uo(e,t,"roles")}const vo=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function yo(e,t){var n;const r=await e,o={code:r.status,ok:r.ok,response:r},i=await r.clone().json();return r.ok?o.data=t?t(i):i:(o.error=i,r.status===lo&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=r.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const bo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),wo=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ko=e=>t=>e.test(t),jo=ko(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),xo=ko(/^\+[1-9]{1}[0-9]{3,14}$/),Oo=bo(jo,'"{val}" is not a valid email'),Io=bo(xo,'"{val}" is not a valid phone number'),So=bo((1,e=>e.length>=1),"Minimum length is 1");const Co=bo((e=>"string"==typeof e),"Input is not a string"),_o=bo((e=>void 0===e),"Input is defined"),Eo=(Ro=[Co(),_o()],"Input is not a string or undefined",(e="Input is not a string or undefined")=>t=>{const n=Ro.filter((e=>e(t)));return!(n.length<Ro.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var Ro;const Po=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>wo(...e).validate(n[t]))),t(...n)),Ao=e=>[Co(`"${e}" must be a string`),So(`"${e}" must not be empty`)],Mo=e=>[Co(`"${e}" must be a string`),Oo()],Uo=e=>[Co(`"${e}" must be a string`),Io()],To=Po(Ao("accessKey")),$o=e=>({exchange:To((t=>yo(e.post(hr,{},{token:t}))))});var Do,Lo;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Do||(Do={})),function(e){e.email="email"}(Lo||(Lo={}));const No=Object.assign(Object.assign({},Do),Lo);var zo;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(zo||(zo={}));const Wo=Ao("loginId"),Fo=Po(Ao("token")),qo=Po(Wo),Bo=Po(Ao("pendingRef")),Ho=Po(Wo,Mo("email")),Jo=e=>({verify:Fo((t=>yo(e.post(xr,{token:t})))),signIn:qo(((t,n,r,o)=>yo(e.post(vo(Or,No.email),{loginId:t,URI:n,loginOptions:r},{token:o})))),signUpOrIn:qo(((t,n,r)=>yo(e.post(vo(_r,No.email),{loginId:t,URI:n,loginOptions:r})))),signUp:qo(((t,n,r,o)=>yo(e.post(vo(Ir,No.email),{loginId:t,URI:n,user:r,loginOptions:o})))),waitForSession:Bo(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||no,no)}))(n);let s;const a=setInterval((async()=>{const n=await e.post(Sr,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(yo(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:Ho(((t,n,r,o,i)=>yo(e.post(Cr.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o}))))}}),Ko=Po(Ao("flowId")),Vo=Po(Ao("executionId"),Ao("stepId"),Ao("interactionId")),Zo=e=>({start:Ko(((t,n,r,o,i,s,a)=>yo(e.post(Gr,{flowId:t,options:n,conditionInteractionId:r,interactionId:o,version:i,componentsVersion:s,input:a})))),next:Vo(((t,n,r,o,i,s)=>yo(e.post(Qr,{executionId:t,stepId:n,interactionId:r,version:o,componentsVersion:i,input:s}))))}),Yo=Ao("loginId"),Xo=Po(Ao("token")),Go=Po(Yo),Qo=Po(Yo,Uo("phone")),ei=Po(Yo,Mo("email")),ti=e=>({verify:Xo((t=>yo(e.post(yr,{token:t})))),signIn:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Go(((t,r,o,i)=>yo(e.post(vo(br,n),{loginId:t,URI:r,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Go(((t,r,o,i)=>yo(e.post(vo(wr,n),{loginId:t,URI:r,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Go(((t,r,o)=>yo(e.post(vo(jr,n),{loginId:t,URI:r,loginOptions:o}))))})),{}),update:{email:ei(((t,n,r,o,i)=>yo(e.post(kr.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o})))),phone:Object.keys(Do).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qo(((t,r,o,i,s)=>yo(e.post(vo(kr.phone,n),Object.assign({loginId:t,phone:r,URI:o},s),{token:i}))))})),{})}});var ni;!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"}(ni||(ni={}));const ri=Po(Ao("code")),oi=e=>({start:Object.assign(((t,n,r,o)=>yo(e.post(Er,r||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:o}))),Object.keys(ni).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,r,o)=>yo(e.post(Er,r||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:o}))})),{})),exchange:ri((t=>yo(e.post(Rr,{code:t}))))}),ii=Ao("loginId"),si=Po(ii,Ao("code")),ai=Po(ii),ci=Po(ii,Uo("phone")),li=Po(ii,Mo("email")),ui=e=>({verify:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:si(((t,r)=>yo(e.post(vo(pr,n),{code:r,loginId:t}))))})),{}),signIn:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ai(((t,r,o)=>yo(e.post(vo(fr,n),{loginId:t,loginOptions:r},{token:o}))))})),{}),signUp:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ai(((t,r,o)=>yo(e.post(vo(gr,n),{loginId:t,user:r,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ai(((t,r)=>yo(e.post(vo(vr,n),{loginId:t,loginOptions:r}))))})),{}),update:{email:li(((t,n,r,o)=>yo(e.post(mr.email,Object.assign({loginId:t,email:n},o),{token:r})))),phone:Object.keys(Do).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ci(((t,r,o,i)=>yo(e.post(vo(mr.phone,n),Object.assign({loginId:t,phone:r},i),{token:o}))))})),{})}}),di=Po(Ao("tenant")),hi=Po(Ao("code")),pi=e=>({start:di(((t,n,r,o)=>yo(e.post(Pr,r||{},{queryParams:{tenant:t,redirectURL:n},token:o})))),exchange:hi((t=>yo(e.post(Ar,{code:t}))))}),fi=Ao("loginId"),gi=Po(fi,Ao("code")),mi=Po(fi),vi=Po(fi),yi=e=>({signUp:mi(((t,n)=>yo(e.post(Ur,{loginId:t,user:n})))),verify:gi(((t,n,r,o)=>yo(e.post(Mr,{loginId:t,code:n,loginOptions:r},{token:o})))),update:vi(((t,n)=>yo(e.post(Tr,{loginId:t},{token:n}))))}),bi=Ao("loginId"),wi=Ao("newPassword"),ki=Po(bi,Ao("password")),ji=Po(bi),xi=Po(bi,wi),Oi=Po(bi,Ao("oldPassword"),wi),Ii=e=>({signUp:ki(((t,n,r)=>yo(e.post(zr,{loginId:t,password:n,user:r})))),signIn:ki(((t,n)=>yo(e.post(Wr,{loginId:t,password:n})))),sendReset:ji(((t,n,r)=>yo(e.post(Fr,{loginId:t,redirectUrl:n,templateOptions:r})))),update:xi(((t,n,r)=>yo(e.post(qr,{loginId:t,newPassword:n},{token:r})))),replace:Oi(((t,n,r)=>yo(e.post(Br,{loginId:t,oldPassword:n,newPassword:r})))),policy:()=>yo(e.get(Hr))}),Si=[Co('"loginId" must be a string')],Ci=Ao("loginId"),_i=Ao("origin"),Ei=Po(Ci,_i,Ao("name")),Ri=Po(Ci,_i),Pi=Po(Si,_i),Ai=Po(Ci,_i,Ao("token")),Mi=Po(Ao("transactionId"),Ao("response")),Ui=e=>({signUp:{start:Ei(((t,n,r)=>yo(e.post($r.start,{user:{loginId:t,name:r},origin:n})))),finish:Mi(((t,n)=>yo(e.post($r.finish,{transactionId:t,response:n}))))},signIn:{start:Pi(((t,n,r,o)=>yo(e.post(Dr.start,{loginId:t,origin:n,loginOptions:r},{token:o})))),finish:Mi(((t,n)=>yo(e.post(Dr.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ri(((t,n)=>yo(e.post(Lr.start,{loginId:t,origin:n}))))},update:{start:Ai(((t,n,r)=>yo(e.post(Nr.start,{loginId:t,origin:n},{token:r})))),finish:Mi(((t,n)=>yo(e.post(Nr.finish,{transactionId:t,response:n}))))}}),Ti=Po(Ao("token")),$i=Po([Eo('"token" must be string or undefined')]);var Di,Li=Po([("projectId",Di=Ao("projectId"),bo(((e,t)=>n=>wo(...t).validate(dr(n,e)))("projectId",Di))())])((e=>{var t,n;const r=[].concat((null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest)||[]),o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o,baseHeaders:i={},fetch:s})=>{return a=co({baseUrl:n||to,projectId:e,logger:t,hooks:r,cookiePolicy:o,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:$o(a),otp:ui(a),magicLink:ti(a),enchantedLink:Jo(a),oauth:oi(a),saml:pi(a),totp:yi(a),webauthn:Ui(a),password:Ii(a),flow:Zo(a),refresh:$i((e=>yo(a.post(Jr,{},{token:e})))),selectTenant:Po([Co("tenantId")],[Eo('"token" must be string or undefined')])(((e,t)=>yo(a.post(Kr,{tenant:e},{token:t})))),logout:$i((e=>yo(a.post(Vr,{},{token:e})))),logoutAll:$i((e=>yo(a.post(Zr,{},{token:e})))),me:$i((e=>yo(a.get(Yr,{token:e})))),history:$i((e=>yo(a.get(Xr,{token:e})))),isJwtExpired:Ti(po),getTenants:Ti(fo),getJwtPermissions:Ti(go),getJwtRoles:Ti(mo),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:e=>null==r?void 0:r.reduce(((e,t)=>t(e)),e),afterRequest:async(t,n)=>{(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))}}}))}));const Ni=(e,t,n)=>(t.forEach((t=>{const r=t.split(".");let o=r.shift(),i=e;for(;r.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=r.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const s=i[o];i[o]=n(s)})),e);var zi=Object.assign(Li,{DeliveryMethods:No});var Wi="Blocked by CSP",Fi="9319";function qi(e,t){var n=[];return function(e,t){var n,r,o=(r=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],e,!0),{current:function(){return r[0]},postpone:function(){var e=r.shift();void 0!==e&&r.push(e)},exclude:function(){r.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=o.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(e,n){return t(e).catch((function(e){if(n+1>=5)throw e;!function(e){if(!(e instanceof Error))return!1;var t=e.message;return t===Wi||t===Fi}(e)?o.postpone():o.exclude();var t,r=o.current();if(void 0===r)throw e;return(t=i(),new Promise((function(e){return setTimeout(e,t)}))).then((function(){return a(r,n+1)}))}))};return a(s,0)}(e,(function(e){var r=new Date,o=function(t){return n.push({url:e,startedAt:r,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i})).then((function(e){return[e,{attempts:n}]}))}var Bi="Failed to load the JS script of the agent";function Hi(e){var r;e.scriptUrlPattern;var o=e.token,i=e.apiKey,s=void 0===i?o:i,a=n(e,["scriptUrlPattern","token","apiKey"]),c=null!==(r=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(e,"scriptUrlPattern"))&&void 0!==r?r:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";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.8.5"):e}))}(String(e),t)}))}(c,s);return qi(e,Ji).catch(Vi)})).then((function(e){var n=e[0],r=e[1];return n.load(t(t({},a),{ldi:r}))}))}function Ji(e){return function(e,t,n,r){var o,i=document,s="securitypolicyviolation",a=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,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(c(),o)return function(){throw new Error(Wi)}();throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(Bi))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)})).then(Ki)}function Ki(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Fi);return n}function Vi(e){throw e instanceof Error&&e.message===Fi?new Error(Bi):e}
3
- /*! js-cookie v3.0.5 | MIT */function Zi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var Yi=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=Zi({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in o)o[s]&&(i+="; "+s,!0!==o[s]&&(i+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+i}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(r[a]=t.read(s,a),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",Zi({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Zi({},this.attributes,t))},withConverter:function(t){return e(Zi({},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:"/"});const Xi=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,r)=>{var o;return n[r]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[r])||[]).concat((null==t?void 0:t[r])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Gi=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},Qi=async e=>{const t=await Gi(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},es="undefined"!=typeof localStorage,ts=(e,t)=>es&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),ns=e=>es&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),rs=e=>es&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),os=(...e)=>{console.debug(...e)},is="undefined"!=typeof window,ss=Math.pow(2,31)-1,as=is&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",cs=(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},ls=e=>{const t=cs(!0);return t&&e.body&&(e.body.fpData=t),e},us="dls_last_user_login_id",ds="dls_last_user_display_name",hs=()=>ns(us),ps=()=>ns(ds),fs=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,r={}]=t,o=hs(),i=ps();return o&&(null!==(n=r.lastAuth)&&void 0!==n||(r.lastAuth={}),r.lastAuth.loginId=o,r.lastAuth.name=i),await e(...t)},gs=e=>async(...t)=>{const n=await e(...t);return rs(us),rs(ds),n};function ms(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const vs="DS",ys="DSR";function bs(e=""){return ns(`${e}${ys}`)||""}function ws(e=""){rs(`${e}${ys}`),rs(`${e}${vs}`),Yi.remove(vs)}async function ks(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Cs(n.publicKey.challenge),n.publicKey.user.id=Cs(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Cs(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:_s(n.rawId),type:n.type,response:{attestationObject:_s(n.response.attestationObject),clientDataJSON:_s(n.response.clientDataJSON)}});var n}async function js(e){const t=Is(e);return Ss(await navigator.credentials.get(t))}async function xs(e,t){const n=Is(e);return n.signal=t.signal,n.mediation="conditional",Ss(await navigator.credentials.get(n))}async function Os(e=!1){if(!is)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 Is(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Cs(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Cs(e.id)})),n}function Ss(e){return JSON.stringify({id:e.id,rawId:_s(e.rawId),type:e.type,response:{authenticatorData:_s(e.response.authenticatorData),clientDataJSON:_s(e.response.clientDataJSON),signature:_s(e.response.signature),userHandle:e.response.userHandle?_s(e.response.userHandle):void 0}})}function Cs(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function _s(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Es,Rs=(Es=e=>({async signUp(t,n){const r=await e.webauthn.signUp.start(t,window.location.origin,n);if(!r.ok)return r;const o=await ks(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,o)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const r=await js(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,r)},async signUpOrIn(t){var n;const r=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!r.ok)return r;if(null===(n=r.data)||void 0===n?void 0:n.create){const t=await ks(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,t)}{const t=await js(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,t)}},async update(t,n){const r=await e.webauthn.update.start(t,window.location.origin,n);if(!r.ok)return r;const o=await ks(r.data.options);return await e.webauthn.update.finish(r.data.transactionId,o)},helpers:{create:ks,get:js,isSupported:Os,conditional:xs}}),(...e)=>{const t=Es(...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}),Ps=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Os(),r=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=r,e.flow.start(...t)}});const As=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var{fpKey:r,fpLoad:o}=t,i=n(t,["fpKey","fpLoad"]);return is?(r&&o&&(async e=>{try{if(cs())return;const t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=Hi({apiKey:e,endpoint:as}),r=await n,{requestId:o}=await r.get({linkedId:t}),i=((e,t)=>({vsid:e,vrid:t}))(t,o);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(t))})(i)}catch(e){global.FB_DEBUG&&console.error(e)}})(r).catch((()=>null)),e(Xi(i,{beforeRequest:ls}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),e(i))}),(e=>t=>{var{autoRefresh:r}=t,o=n(t,["autoRefresh"]);if(!r)return e(o);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;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(os("Expiration time passed, refreshing session"),l.refresh(c))}));const l=e(Xi(o,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:r}=await Gi(t);if(401===(null==t?void 0:t.status))os("Received 401, canceling all timers"),i();else if(r){a=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(r),c=n;let e=((o=a)?o.getTime()-(new Date).getTime():0)-2e4;e>ss&&(os(`Timeout is too large (${e}ms), setting it to ${ss}ms`),e=ss),i();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});os(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{os("Refreshing session due to timer"),l.refresh(n)}),e)}var o}}));return Ni(l,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return os("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.9.4"},t.baseHeaders)}))),(e=>t=>{const n=ms(),r=ms(),o=e(Xi(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),r.pub(null);else{const e=await Qi(t);e&&r.pub(e);const{sessionJwt:o}=await Gi(t);o&&n.pub(o)}}})),i=Ni(o,["logout","logoutAll"],(e=>async(...t)=>{const o=await e(...t);return n.pub(null),r.pub(null),o}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:r.sub})}),(e=>t=>{const n=e(Xi(t,{afterRequest:async(e,t)=>{var n;const r=await Qi(t),o=null===(n=null==r?void 0:r.loginIds)||void 0===n?void 0:n[0],i=null==r?void 0:r.name;o&&((e=>{ts(us,e)})(o),(e=>{ts(ds,e)})(i))}}));let r=Ni(n,["flow.start"],fs);return r=Ni(r,["logout","logoutAll"],gs),Object.assign(r,{getLastUserLoginId:hs,getLastUserDisplayName:ps})}),(e=>t=>{var{persistTokens:r,sessionTokenViaCookie:o,storagePrefix:i}=t,s=n(t,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!r||!is)return r&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),e(s);const a=e(Xi(s,{beforeRequest:(c=i,e=>Object.assign(e,{token:e.token||bs(c)})),afterRequest:async(e,t)=>{401===(null==t?void 0:t.status)?ws(i):((e={},t,r)=>{var{refreshJwt:o,sessionJwt:i}=e,s=n(e,["refreshJwt","sessionJwt"]);void 0===t&&(t=!1),void 0===r&&(r=""),o&&ts(`${r}${ys}`,o),i&&(t?function(e,t,{cookiePath:n,cookieDomain:r,cookieExpiration:o}){if(t){const i=new Date(1e3*o),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(r);Yi.set(e,t,{path:n,domain:s?r:void 0,expires:i,sameSite:"Strict",secure:!0})}}(vs,i,s):ts(`${r}${vs}`,i))})(await Gi(t),o,i)}}));var c;const l=Ni(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const r=await t(...n);return ws(e),r})(i));return Object.assign(l,{getRefreshToken:()=>bs(i),getSessionToken:()=>function(e=""){return Yi.get(vs)||ns(`${e}${vs}`)||""}(i)})}))(((...e)=>{const t=zi(...e);return Object.assign(Object.assign({},t),{flow:Ps(t),webauthn:Rs(t)})})),Ms={search:"/v1/mgmt/user/search",deleteBatch:"/v1/mgmt/user/delete/batch",create:"/v1/mgmt/user/create",expirePassword:"/v1/mgmt/user/password/expire",customAttributes:"/v1/mgmt/user/customattributes"},Us=e=>r(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=({httpClient:e,tenant:t})=>({search:({page:n,limit:o=1e4,customAttributes:i,statuses:s,emails:a,phones:c,text:l,sort:u}={})=>r(void 0,void 0,void 0,(function*(){const r=yield e.post(Ms.search,{limit:o,page:n,withTestUser:!1,customAttributes:i,statuses:s,emails:a,phones:c,text:l,sort:u},{queryParams:{tenant:t}});yield Us(r);return(yield r.json()).users})),deleteBatch:n=>r(void 0,void 0,void 0,(function*(){const r=yield e.post(Ms.deleteBatch,{userIds:n},{queryParams:{tenant:t}});return yield Us(r),r.json()})),create:({loginId:n,email:o,phone:i,displayName:s,roles:a,customAttributes:c,picture:l,verifiedEmail:u,verifiedPhone:d,givenName:h,middleName:p,familyName:f,additionalLoginIds:g,sendSMS:m,sendMail:v,inviteUrl:y,invite:b})=>r(void 0,void 0,void 0,(function*(){const r=yield e.post(Ms.create,{loginId:n,email:o,phone:i,displayName:s,givenName:h,middleName:p,familyName:f,roleNames:a,userTenants:[{tenantId:t}],customAttributes:c,picture:l,verifiedEmail:u,verifiedPhone:d,additionalLoginIds:g,sendSMS:m,sendMail:v,inviteUrl:y,invite:b},{queryParams:{tenant:t}});yield Us(r);return(yield r.json()).user})),expirePassword:n=>r(void 0,void 0,void 0,(function*(){const r=yield e.post(Ms.expirePassword,{loginId:n[0]},{queryParams:{tenant:t}});return yield Us(r),r.json()})),getCustomAttributes:()=>r(void 0,void 0,void 0,(function*(){const n=yield e.get(Ms.customAttributes,{queryParams:{tenant:t}});return yield Us(n),n.json()}))}),$s=s((t=>{var n,s,a,c;const u=e(b,v,l,y({tenant:m}))(t);return c=class extends u{constructor(){super(...arguments),n.add(this),s.set(this,void 0)}get baseUrl(){return this.getAttribute("base-url")}get tenant(){return this.getAttribute("tenant")}get api(){return o(this,s,"f")||o(this,n,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{o(this,s,"f")&&o(this,n,"m",a).call(this)}))}))}},s=new WeakMap,n=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t)=>{const n=As(Object.assign(Object.assign({},e),{persistTokens:!0}));return{user:Ts({httpClient:n.httpClient,tenant:t})}})({projectId:this.projectId,baseUrl:this.baseUrl},this.tenant),"f")},c})),Ds=s((t=>{const n=e(Ft({name:"widget",initialState:fn,reducers:{setSelectedUsersIds:(e,{payload:t})=>{e.selectedUsersLoginIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Vt.reducer(e),Xt.reducer(e),pn.reducer(e),Qt.reducer(e),nn.reducer(e)},asyncActions:{searchUsers:pn.action,createUser:Vt.action,deleteUsers:Xt.action,expireUserPassword:Qt.action,getCustomAttributes:nn.action}}),a,l,$s)(t);return class extends n{constructor(...e){super(...e),this.state=fn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}}));const Ls=s((t=>{var n,i,s;return s=class extends(e(l,a,_,P)(t)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){return r(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this)}))}},n=new WeakSet,i=function(){return r(this,void 0,void 0,(function*(){const e=D('\n<descope-container\n direction="column"\n space-between="md"\n st-horizontal-padding="1rem"\n st-vertical-padding="1rem"\n st-align-items="safe center"\n st-gap="1rem"\n>\n <descope-container\n direction="row"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-align-items="safe center"\n st-gap="0rem"\n st-justify-content="space-between"\n >\n <descope-text-field data-testid="search-input" data-id="search-input" placeholder="Search" size="sm" bordered="true"></descope-text-field>\n\n <descope-container\n direction="row"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-justify-content="flex-end"\n st-gap="0.5em"\n st-host-width="auto"\n >\n <descope-button data-testid="delete-users-trigger" data-id="delete-users" mode="primary" variant="outline" size="sm">Delete</descope-button>\n <descope-button data-testid="create-user-trigger" data-id="create-user" mode="primary" variant="contained" size="sm">+ User</descope-button>\n </descope-container>\n </descope-container>\n <descope-grid\n data-id="users-table"\n size="sm"\n column-reordering-allowed\n st-host-height="300px"\n style="width: 100%"\n >\n <descope-grid-selection-column frozen auto-width></descope-grid-selection-column>\n <descope-grid-text-column path="loginIds" header="Login ID" resizable></descope-grid-text-column>\n <descope-grid-text-column sortable="true" path="name" header="Name" resizable></descope-grid-text-column>\n <descope-grid-custom-column sortable="true" path="status" header="Status" resizable>\n <descope-badge mode="default" pattern="invited" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n <descope-badge mode="primary" pattern="active" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n <descope-badge mode="error" pattern="disabled" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n </descope-grid-custom-column>\n <descope-grid-text-column sortable="true" path="email" header="Email" resizable></descope-grid-text-column>\n <descope-grid-text-column sortable="true" path="phone" header="Phone" resizable></descope-grid-text-column>\n </descope-grid>\n </descope-container>\n');yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0)),this.onWidgetRootReady()}))},s})),Ns=s((t=>{var n,i,s;return s=class extends(e(Ds,F,L,l,Ls)(t)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this)}))}},n=new WeakSet,i=function(){return r(this,void 0,void 0,(function*(){this.createUserModal=this.createModal(),this.createUserModal.setContent(D('\n<descope-container\n direction="column"\n st-justify-content="safe center"\n st-gap="1rem"\n st-host-width="100%"\n st-background-color="none"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-border-radius="sm"\n>\n <descope-text variant="subtitle1" mode="surface">New User</descope-text>\n <descope-text-field name="loginId" label="Login ID" bordered="true" required="true" size="sm"></descope-text-field>\n <descope-email-field name="email" label="Email" bordered="true"></descope-email-field>\n <descope-text-field name="displayName" label="Name" bordered="true"></descope-text-field>\n <descope-phone-field name="phone" label="Phone" bordered="true"></descope-phone-field>\n\n <descope-container\n direction="row"\n st-justify-content="flex-end"\n st-gap="1rem"\n st-host-width="100%"\n st-horizontal-padding="0.75rem"\n st-vertical-padding="0.75rem"\n st-background-color="none"\n >\n <descope-button data-testid="create-user-modal-cancel" data-id="modal-cancel" mode="primary" variant="link" size="sm">Cancel</descope-button>\n <descope-button data-testid="create-user-modal-submit" data-id="modal-submit" mode="primary" variant="contained" size="sm">Create</descope-button>\n </descope-container>\n</descope-container>\n'));const e=new $((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});e.onClick((()=>this.createUserModal.close()));const t=new $((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});t.onClick((()=>r(this,void 0,void 0,(function*(){this.validateForm(this.createUserModal.ele)&&(this.actions.createUser(Object.assign(Object.assign({},this.getFormData(this.createUserModal.ele)),{invite:!0,verifiedEmail:!0,verifiedPhone:!0})),this.createUserModal.close(),this.resetFormData(this.createUserModal.ele))}))))}))},s})),zs=s((t=>{var n,i,s;return s=class extends(e(l,Ns,Ls)(t)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this)}))}},n=new WeakSet,i=function(){var e;this.createButton=new $(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-user"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createUserModal.open()))},s}));class Ws extends T{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)}}const Fs=s((t=>{var n,i,s;return s=class extends(e(Ds,F,l,Ls)(t)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),yield o(this,n,"m",i).call(this)}))}},n=new WeakSet,i=function(){var e;return r(this,void 0,void 0,(function*(){this.deleteUsersModal=this.createModal(),this.deleteUsersModal.setContent(D('\n<descope-container\n direction="column"\n st-justify-content="safe center"\n st-gap="1rem"\n st-host-width="100%"\n st-background-color="none"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-border-radius="sm"\n data-testid="delete-users-modal"\n>\n <descope-text variant="subtitle1" mode="surface">Delete Users</descope-text>\n <descope-text data-id="body-text" variant="body1" mode="surface">Delete user</descope-text>\n\n <descope-container \n direction="row"\n st-justify-content="flex-end"\n st-gap="1rem"\n st-host-width="100%"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-background-color="none"\n >\n <descope-button data-testid="delete-users-modal-cancel" data-id="modal-cancel" mode="primary" variant="link" size="md">Cancel</descope-button>\n <descope-button data-testid="delete-users-modal-submit" data-id="modal-submit" mode="error" variant="contained" size="md">Delete</descope-button>\n </descope-container>\n</descope-container>\n'));const t=new $((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteUsersModal.close()));const n=new $((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=cn(this.state);this.actions.deleteUsers(e),this.deleteUsersModal.close()}));const r=new Ws(null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteUsersModal.beforeOpen=()=>{const e=dn(this.state);r.text=`Delete ${e}?`}}))},s})),qs=s((t=>{var n,i,s,a;return a=class extends(e(l,Ls,Ds,Fs)(t)){constructor(){super(...arguments),n.add(this),s.set(this,d((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this),this.subscribe(o(this,s,"f").bind(this),un)}))}},s=new WeakMap,n=new WeakSet,i=function(){var e;this.deleteButton=new $(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-users"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteUsersModal.open()}))},a}));class Bs extends T{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)}}const Hs=s((t=>{var n,i,s,a;return a=class extends(e(l,Ls,Ds)(t)){constructor(){super(...arguments),n.add(this),i.set(this,p((()=>{this.actions.searchUsers({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",s).call(this)}))}},i=new WeakMap,n=new WeakSet,s=function(){var e;this.searchInput=new Bs(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(o(this,i,"f"))},a})),Js="descope-notification";class Ks extends T{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()}}const Vs=s((t=>{var n,i;const s=e(a,P,_)(t);return i=class extends s{constructor(){super(...arguments),n.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Ks{setContent(t){const n="string"==typeof t?D(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const t=((e={})=>{const t=document.createElement(Js);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(t),new(o(this,n,"f"))(t,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.loadDescopeUiComponents([Js])}))}},n=new WeakMap,i}));const Zs={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="white"/>\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="#FFDFDD"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Ys=s((t=>{var n,i,s,c,u;return u=class extends(e(l,Ds,Vs,a)(t)){constructor(){super(...arguments),n.add(this),c.set(this,d((e=>{e.length&&(e.forEach((({type:e,msg:t})=>{const r=o(this,n,"m",s).call(this,e);r.setContent(o(this,n,"m",i).call(this,{type:e,msg:t})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(o(this,c,"f").bind(this),sn)}))}},c=new WeakMap,n=new WeakSet,i=function({type:e,msg:t}){const n=Zs[e],r=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="white"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${r.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},u}));const Xs=/^descope-grid-([^-]+)-column$/,Gs={text:class extends T{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 T{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)}}}};class Qs extends T{constructor(){super(...arguments),this.nodeName="descope-grid"}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 r=null===(n=Xs.exec(t.localName))||void 0===n?void 0:n[1],o=Gs[r];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}}const ea=s((t=>{var n,i,s,a,c;return c=class extends(e(Ds,l,Ls)(t)){constructor(){super(...arguments),n.add(this),s.set(this,d((e=>{this.usersTable.data=e}))),a.set(this,p(((e,t)=>{const n=[],{value:r}=t;if(r){const t=e.path;n.push({field:t,desc:"desc"===r})}this.actions.searchUsers({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this),this.usersTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{o(this,a,"f").call(this,e.target,e.detail)}))})),o(this,s,"f").call(this,an(this.state)),this.subscribe(o(this,s,"f").bind(this),an)}))}},s=new WeakMap,a=new WeakMap,n=new WeakSet,i=function(){var e;this.usersTable=new Qs(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="users-table"]'),{logger:this.logger}),this.usersTable.onSelectedItemsChange((e=>{this.actions.setSelectedUsersIds(e.detail.value.map((({loginIds:e})=>e)))}))},c})),ta=s((t=>class extends(e(u,M,ea,zs,qs,Hs,Ys)(t)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.actions.searchUsers()}))}})),na=e((t=>class extends(e(ta)(t)){}))(HTMLElement);var ra,oa,ia,sa;customElements.define("descope-user-management-widget",na);function aa(e,t){const n=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r],i=e[o],s=t[o];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!aa(i,s))return!1}else if(i!==s)return!1}return!0}class ca{constructor(e={},{updateOnlyOnChange:t=!0}={}){ra.set(this,void 0),oa.set(this,{}),ia.set(this,0),sa.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,ra,"f")):e,n=Object.assign(Object.assign({},o(this,ra,"f")),t);if(!o(this,sa,"f")||!aa(o(this,ra,"f"),n)){const e=o(this,ra,"f");i(this,ra,n,"f"),Object.freeze(o(this,ra,"f")),setTimeout((()=>{Object.values(o(this,oa,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,ra,e,"f"),i(this,sa,t,"f")}get current(){return Object.assign({},o(this,ra,"f"))}subscribe(e){return i(this,ia,o(this,ia,"f")+1,"f"),o(this,oa,"f")[o(this,ia,"f")]=e,o(this,ia,"f").toString()}unsubscribe(e){const t=!!o(this,oa,"f")[e];return t&&delete o(this,oa,"f")[e],t}unsubscribeAll(){return i(this,oa,{},"f"),!0}}ra=new WeakMap,oa=new WeakMap,ia=new WeakMap,sa=new WeakMap;const la=(e,t,n,r={})=>{var o,i,s,a;return[Math.min(Math.max(t,("all"===r.left?e.offsetWidth:null!==(o=r.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===r.right?e.offsetWidth:null!==(i=r.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===r.top?e.offsetHeight:null!==(s=r.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===r.bottom?e.offsetHeight:null!==(a=r.bottom)&&void 0!==a?a:0))]};var ua,da,ha,pa,fa,ga,ma,va,ya,ba;const wa=document.createElement("template");wa.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class ka extends HTMLElement{constructor(){var e;super(),ua.add(this),da.set(this,new ca({messages:[]})),ha.set(this,void 0),pa.set(this,void 0),fa.set(this,void 0),ga.set(this,{resize:o(this,ua,"m",ba).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(wa.content.cloneNode(!0)),i(this,ha,this.shadowRoot.querySelector(".debugger"),"f"),i(this,pa,o(this,ha,"f").querySelector(".content"),"f"),i(this,fa,o(this,ha,"f").querySelector(".header"),"f")}updateData(e){o(this,da,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let r=0,o=0,i=0,s=0;function a(t){t.preventDefault(),r=i-t.clientX,o=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=la(e,e.offsetLeft-r,e.offsetTop-o,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,ha,"f"),o(this,fa,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ga,"f").resize),(e=o(this,ha,"f")).onmousemove=t=>{var n;const r=t.target;(r.w&&r.w!==r.offsetWidth||r.h&&r.h!==r.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),r.w=r.offsetWidth,r.h=r.offsetHeight},o(this,ha,"f").onresize=o(this,ua,"m",ya).bind(this),o(this,da,"f").subscribe(o(this,ua,"m",ma).bind(this))}disconnectedCallback(){o(this,da,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ga,"f").resize)}}da=new WeakMap,ha=new WeakMap,pa=new WeakMap,fa=new WeakMap,ga=new WeakMap,ua=new WeakSet,ma=function(e){o(this,ua,"m",va).call(this,e),o(this,ua,"m",ya).call(this)},va=function(e){o(this,pa,"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("")},ya=function(){o(this,pa,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),r=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;r||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},ba=function(){const[e,t]=la(o(this,ha,"f"),Number.parseInt(o(this,ha,"f").style.left,10),Number.parseInt(o(this,ha,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,ha,"f").style.top=`${t}px`,o(this,ha,"f").style.left=`${e}px`},customElements.define("descope-debugger",ka);var ja=Object.freeze({__proto__:null,default:ka})}();
1
+ // @descope/user-management-widget v0.0.8
2
+ !function(){"use strict";function e(...e){return t=>e.reduce(((e,t)=>t(e)),t)}var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function r(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function o(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function i(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;const s=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 r=e(n);return r[t]=!0,r}},a=s((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}init(){return r(this,void 0,void 0,(function*(){}))}},t=new WeakMap,n})),c=["error","warn","info","debug"],l=s((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,console))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return c.reduce(((t,n)=>(t[n]=(...t)=>{var r;this.onLogEvent(n,t),null===(r=e[n])||void 0===r||r.call(e,...t)},t)),{})},s})),u=s((t=>{var n,s,c,u,d,h,p;return p=class extends(e(a,l)(t)){constructor(){super(...arguments),n.add(this),s.set(this,void 0),this.attributeChangedCallback=(e,t,r)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,t,r),"debug"===e&&o(this,n,"m",d).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,t){var r;null===(r=super.onLogEvent)||void 0===r||r.call(this,e,t),"error"===e&&o(this,n,"m",h).call(this,t[0]||"Error",t[1])}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),o(this,n,"m",d).call(this)}))}},s=new WeakMap,n=new WeakSet,c=function(){var e;null===(e=o(this,s,"f"))||void 0===e||e.remove(),i(this,s,null,"f")},u=function(){return r(this,void 0,void 0,(function*(){i(this,s,document.createElement("descope-debugger"),"f"),Object.assign(o(this,s,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return ja})),document.body.appendChild(o(this,s,"f"))}))},d=function(){this.debug?o(this,n,"m",u).call(this):o(this,n,"m",c).call(this)},h=function(e,t){var n;e&&(null===(n=o(this,s,"f"))||void 0===n||n.updateData({title:e,description:t}))},p})),d=e=>{let t,n;return(...r)=>{return t&&(i=r,(o=t).length===i.length&&o.every(((e,t)=>e===i[t])))||(t=r,n=e(...r)),n;var o,i}},h=e=>(t,...n)=>t.reduce(((t,r,o)=>{var i;return`${t}${r}${(null===(i=null==n?void 0:n[o])||void 0===i?void 0:i[e>1?1:0])||""}`}),""),p=(e,t=500)=>{let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},f="undefined"!=typeof localStorage,g=f&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",m=(e,t)=>!t&&`${e} cannot be empty`,v=s((t=>{var n,i;const s=e(l,a)(t);return i=class extends s{constructor(){super(...arguments),n.set(this,{})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){var r,i;yield null===(t=e.init)||void 0===t?void 0:t.call(this),r=this,i=e=>{var t;null===(t=o(this,n,"f")[e])||void 0===t||t.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(r.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(r,{attributes:!0})}))}observeAttribute(e,t){o(this,n,"f")[e]||(o(this,n,"f")[e]=[]);const r=o(this,n,"f")[e].push(t);return()=>o(this,n,"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()))}},n=new WeakMap,i})),y=t=>n=>{var i,s,c;const u=e(l,a,v)(n),d=Object.keys(t);return c=class extends u{constructor(...e){super(...e),i.add(this),this.observeAttributes(d,o(this,i,"m",s).bind(this))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),d.forEach((e=>o(this,i,"m",s).call(this,e,this.getAttribute(e))))}))}},i=new WeakSet,s=function(e,n){const r=t[e],o="function"==typeof r?r(e,n):r;o&&this.logger.error(o)},c},b=s((t=>{const n=e(y({"project-id":m}))(t);return class extends n{get projectId(){return this.getAttribute("project-id")}}}));const w=s((t=>{const n=e(l,b)(t);return class extends n{fetchStaticResource(e,t){return r(this,void 0,void 0,(function*(){const n=function(e,t,n="v2-beta"){const r=new URL(g);return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,n,t),r.toString()}(this.projectId,e),r=yield fetch(n,{cache:"default"});return r.ok||this.logger.error(`Error fetching URL ${n} [${r.status}]`),{body:yield r[t](),headers:Object.fromEntries(r.headers.entries())}}))}}})),k=s((t=>{var n,s,a;const c=e(w)(t);return a=class extends c{constructor(){super(...arguments),n.set(this,void 0),s.set(this,(()=>r(this,void 0,void 0,(function*(){try{const{body:e,headers:t}=yield this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))))}get config(){return o(this,n,"f")||i(this,n,o(this,s,"f").call(this),"f"),o(this,n,"f")}},n=new WeakMap,s=new WeakMap,a})),j="load-descope-ui-script",x="base.ui.components.url",O=f&&localStorage.getItem(x)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",I=f&&localStorage.getItem(x)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",S=e=>{const t=document.createElement("script");return t.id=e,t},C=(e,t)=>e.replace("<version>",t),_=s((t=>{var n,s,a,c,u,d,h,p,f,g,m,v;const y=e(l,k)(t);return v=class extends y{constructor(){super(...arguments),n.add(this),s.set(this,Symbol("errorCbs")),a.set(this,Symbol("loadCbs")),f.set(this,void 0)}get descopeUi(){return o(this,f,"f")||i(this,f,o(this,n,"m",m).call(this),"f"),o(this,f,"f")}loadDescopeUiComponents(e){return r(this,void 0,void 0,(function*(){const t=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(t.map((e=>o(this,n,"m",g).call(this,e))))}))}},s=new WeakMap,a=new WeakMap,f=new WeakMap,n=new WeakSet,c=function(){var e;return r(this,void 0,void 0,(function*(){const t=yield 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}))},u=function(e){const t=o(this,s,"f"),n=o(this,a,"f");e[t]=[],e[n]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[n].push(t)}})},d=function(e,t){return r(this,void 0,void 0,(function*(){this.logger.debug("Trying to load DescopeUI from a fallback URL");const r=S("load-descope-ui-fallback-script");document.body.append(r),r.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${r.src}"`)))})),r.addEventListener("load",(()=>{t.forEach((e=>e()))})),r.src=C(I,yield o(this,n,"m",c).call(this))}))},h=function(e){e.addEventListener("error",(()=>{e[o(this,s,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),o(this,n,"m",d).call(this,e[o(this,s,"f")],e[o(this,a,"f")])})),e.addEventListener("load",(()=>{e[o(this,a,"f")].forEach((e=>e()))}))},p=function(){return r(this,void 0,void 0,(function*(){if(document.getElementById(j))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=S(j);document.body.append(e),o(this,n,"m",u).call(this,e),o(this,n,"m",h).call(this,e),e.src=C(O,yield o(this,n,"m",c).call(this))}return document.getElementById(j)}))},g=function(e){return r(this,void 0,void 0,(function*(){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=yield this.descopeUi;if(t[e])try{return yield 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(", ")}"`)}))},m=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),o(this,n,"m",p).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},v})),E="content-root",R="root",P=s((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${R}, #${E} {\n height: 100%;\n }\n </style>\n <div id="${R}">\n <div id="${E}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(E),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(R)}})),A=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',M=s((t=>{var n,s,c,l,u,d,h,p,f;const g=e(y({theme:A}),w,a,_,k,P)(t);return f=class extends g{constructor(){super(...arguments),n.add(this),s.set(this,void 0)}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"}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),o(this,n,"m",u).call(this),o(this,n,"m",d).call(this),o(this,n,"m",h).call(this),o(this,n,"m",p).call(this)}))}},s=new WeakMap,n=new WeakSet,c=function(){return r(this,void 0,void 0,(function*(){try{const{body:e}=yield this.fetchStaticResource("theme.json","json");return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},l=function(){return o(this,s,"f")||(i(this,s,o(this,n,"m",c).call(this),"f"),o(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,s,"f")},u=function(){var e,t;return r(this,void 0,void 0,(function*(){const r=yield o(this,n,"a",l);if(!r)return;const i=document.createElement("style");i.innerText=((null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.globals)||"")+((null===(t=null==r?void 0:r.dark)||void 0===t?void 0:t.globals)||""),this.shadowRoot.appendChild(i)}))},d=function(){var e,t;return r(this,void 0,void 0,(function*(){const r=Object.assign({},yield o(this,n,"a",l));if(!r)return;const i=yield 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===(t=null==r?void 0:r.dark)||void 0===t?void 0:t.components})}))},h=function(){var e,t;return r(this,void 0,void 0,(function*(){const{projectConfig:n}=yield this.config,r=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;r&&Object.values(r).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))}))}))},p=function(){return r(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},f}));var U;class T{constructor(e,t){U.set(this,void 0),this.nodeName="",i(this,U,e,"f"),this.logger=t.logger}get ele(){var e,t;const n="function"==typeof o(this,U,"f")?o(this,U,"f").call(this):o(this,U,"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("no element for driver ",this.constructor.name,new Error),null)}}U=new WeakMap;class $ extends T{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 D=e=>{const t=document.createElement("template");return t.innerHTML=e,t},L=s((t=>class extends(e(l)(t)){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=>{e.value=t[e.getAttribute("name")]}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value=""}))}})),N="descope-modal";var z;class W extends T{constructor(){super(...arguments),z.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)}open(){var e,t;null===(e=this.beforeOpen)||void 0===e||e.call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,z,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,z,"f").content.cloneNode(!0)))}setContent(e){i(this,z,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}z=new WeakMap;const F=s((t=>{var n,i;const s=e(a,P,_)(t);return i=class extends s{constructor(){super(...arguments),n.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends W{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const t=((e={})=>{const t=document.createElement(N);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(t),new(o(this,n,"f"))(t,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){this.loadDescopeUiComponents([N]),yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}},n=new WeakMap,i}));var q=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),B=()=>Math.random().toString(36).substring(7).split("").join("."),H={INIT:`@@redux/INIT${B()}`,REPLACE:`@@redux/REPLACE${B()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${B()}`};function J(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 K(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 V(e){let t=typeof e;return t=K(e),t}function Z(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${V(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: '${V(n)}'`);return n(Z)(e,t)}let r=e,o=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function u(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function d(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${V(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(!J(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${V(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: '${V(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,o=r(o,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}h({type:H.INIT});return{dispatch:h,subscribe:d,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${V(e)}`);r=e,h({type:H.REPLACE})},[q]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${V(t)}'`);function n(){const e=t;e.next&&e.next(u())}n();return{unsubscribe:e(n)}},[q](){return this}}}}}function Y(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function X(e){const t=Object.keys(e),n={};for(let r=0;r<t.length;r++){const o=t[r];void 0===e[o]&&Y(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const r=Object.keys(n);let o,i;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:H.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:H.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 '${H.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 r=function(e,t,n,r){const o=Object.keys(t),i=n&&n.type===H.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!J(e))return`The ${i} has unexpected type of "${V(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!r[e]));return s.forEach((e=>{r[e]=!0})),n&&n.type===H.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: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);r&&Y(r)}let s=!1;const a={};for(let o=0;o<r.length;o++){const i=r[o],c=n[i],l=e[i],u=c(l,t);if(void 0===u){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=u,s=s||u!==l}return s=s||r.length!==Object.keys(e).length,s?a:e}}function G(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Q(e){return J(e)&&"type"in e&&"string"==typeof e.type}var ee=Symbol.for("immer-nothing"),te=Symbol.for("immer-draftable"),ne=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 oe(e,...t){{const n=re[e],r="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}}var ie=Object.getPrototypeOf;function se(e){return!!e&&!!e[ne]}function ae(e){return!!e&&(le(e)||Array.isArray(e)||!!e[te]||!!e.constructor?.[te]||fe(e)||ge(e))}var ce=Object.prototype.constructor.toString();function le(e){if(!e||"object"!=typeof e)return!1;const t=ie(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)===ce}function ue(e,t){0===de(e)?Object.entries(e).forEach((([n,r])=>{t(n,r,e)})):e.forEach(((n,r)=>t(r,n,e)))}function de(e){const t=e[ne];return t?t.type_:Array.isArray(e)?1:fe(e)?2:ge(e)?3:0}function he(e,t){return 2===de(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function pe(e,t,n){const r=de(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function fe(e){return e instanceof Map}function ge(e){return e instanceof Set}function me(e){return e.copy_||e.base_}function ve(e,t){if(fe(e))return new Map(e);if(ge(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&le(e)){if(!ie(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[ne];let r=Reflect.ownKeys(n);for(let t=0;t<r.length;t++){const o=r[t],i=n[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(ie(e),n)}function ye(e,t=!1){return we(e)||se(e)||!ae(e)||(de(e)>1&&(e.set=e.add=e.clear=e.delete=be),Object.freeze(e),t&&ue(e,((e,t)=>ye(t,!0)))),e}function be(){oe(2)}function we(e){return Object.isFrozen(e)}var ke,je={};function xe(e){const t=je[e];return t||oe(0,e),t}function Oe(){return ke}function Ie(e,t){t&&(xe("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Se(e){Ce(e),e.drafts_.forEach(Ee),e.drafts_=null}function Ce(e){e===ke&&(ke=e.parent_)}function _e(e){return ke={drafts_:[],parent_:ke,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ee(e){const t=e[ne];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Re(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[ne].modified_&&(Se(t),oe(4)),ae(e)&&(e=Pe(t,e),t.parent_||Me(t,e)),t.patches_&&xe("Patches").generateReplacementPatches_(n[ne].base_,e,t.patches_,t.inversePatches_)):e=Pe(t,n,[]),Se(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ee?e:void 0}function Pe(e,t,n){if(we(t))return t;const r=t[ne];if(!r)return ue(t,((o,i)=>Ae(e,r,t,o,i,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return Me(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let o=t,i=!1;3===r.type_&&(o=new Set(t),t.clear(),i=!0),ue(o,((o,s)=>Ae(e,r,t,o,s,n,i))),Me(e,t,!1),n&&e.patches_&&xe("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Ae(e,t,n,r,o,i,s){if(o===n&&oe(5),se(o)){const s=Pe(e,o,i&&t&&3!==t.type_&&!he(t.assigned_,r)?i.concat(r):void 0);if(pe(n,r,s),!se(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(ae(o)&&!we(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Pe(e,o),t&&t.scope_.parent_||Me(e,o)}}function Me(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ye(t,n)}var Ue={get(e,t){if(t===ne)return e;const n=me(e);if(!he(n,t))return function(e,t,n){const r=De(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!ae(r)?r:r===$e(e.base_,t)?(Ne(e),e.copy_[t]=ze(r,e)):r},has:(e,t)=>t in me(e),ownKeys:e=>Reflect.ownKeys(me(e)),set(e,t,n){const r=De(me(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=$e(me(e),t),o=r?.[ne];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,r)&&(void 0!==n||he(e.base_,t)))return!0;Ne(e),Le(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!==$e(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Ne(e),Le(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=me(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){oe(11)},getPrototypeOf:e=>ie(e.base_),setPrototypeOf(){oe(12)}},Te={};function $e(e,t){const n=e[ne];return(n?me(n):e)[t]}function De(e,t){if(!(t in e))return;let n=ie(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=ie(n)}}function Le(e){e.modified_||(e.modified_=!0,e.parent_&&Le(e.parent_))}function Ne(e){e.copy_||(e.copy_=ve(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ue(Ue,((e,t)=>{Te[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Te.deleteProperty=function(e,t){return isNaN(parseInt(t))&&oe(13),Te.set.call(this,e,t,void 0)},Te.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&oe(14),Ue.set.call(this,e[0],t,n,e[0])};function ze(e,t){const n=fe(e)?xe("MapSet").proxyMap_(e,t):ge(e)?xe("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Oe(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=Ue;n&&(o=[r],i=Te);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}(e,t);return(t?t.scope_:Oe()).drafts_.push(n),n}function We(e){return se(e)||oe(10,e),Fe(e)}function Fe(e){if(!ae(e)||we(e))return e;const t=e[ne];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=ve(e,t.scope_.immer_.useStrictShallowCopy_)}else n=ve(e,!0);return ue(n,((e,t)=>{pe(n,e,Fe(t))})),t&&(t.finalized_=!1),n}var qe=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 r=this;return function(e=n,...o){return r.produce(e,(e=>t.call(this,e,...o)))}}let r;if("function"!=typeof t&&oe(6),void 0!==n&&"function"!=typeof n&&oe(7),ae(e)){const o=_e(this),i=ze(e,void 0);let s=!0;try{r=t(i),s=!1}finally{s?Se(o):Ce(o)}return Ie(o,n),Re(r,o)}if(!e||"object"!=typeof e){if(r=t(e),void 0===r&&(r=e),r===ee&&(r=void 0),this.autoFreeze_&&ye(r,!0),n){const t=[],o=[];xe("Patches").generateReplacementPatches_(e,r,t,o),n(t,o)}return r}oe(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;const o=this.produce(e,t,((e,t)=>{n=e,r=t}));return[o,n,r]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ae(e)||oe(8),se(e)&&(e=We(e));const t=_e(this),n=ze(e,void 0);return n[ne].isManual_=!0,Ce(t),n}finishDraft(e,t){const n=e&&e[ne];n&&n.isManual_||oe(9);const{scope_:r}=n;return Ie(r,t),Re(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=xe("Patches").applyPatches_;return se(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},Be=qe.produce;qe.produceWithPatches.bind(qe),qe.setAutoFreeze.bind(qe),qe.setUseStrictShallowCopy.bind(qe),qe.applyPatches.bind(qe),qe.createDraft.bind(qe),qe.finishDraft.bind(qe);var He=e=>{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})}},Je=(e,t,n)=>{const{memoize:r,memoizeOptions:o}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=r((()=>({})),...o);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})}},Ke={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Ve=e=>Array.isArray(e)?e:[e];function Ze(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 Ye(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var Xe="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Ge=0,Qe=1;function et(){return{s:Ge,v:void 0,o:null,p:null}}function tt(e,t={}){let n=et();const{resultEqualityCheck:r}=t;let o,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 r=e.get(n);void 0===r?(t=et(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=et(),e.set(n,t)):t=r}}const a=t;let c;if(t.s===Qe?c=t.v:(c=e.apply(null,arguments),i++),a.s=Qe,r){const e=o?.deref()??o;null!=e&&r(e,c)&&(c=e,0!==i&&i--);o="object"==typeof c&&null!==c||"function"==typeof c?new Xe(c):c}return a.v=c,c}return s.clearCache=()=>{n=et(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function nt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e;return(...e)=>{let t,r=0,o=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:u=tt,argsMemoizeOptions:d=[],devModeChecks:h={}}=a,p=Ve(l),f=Ve(d),g=Ze(e),m=c((function(){return r++,s.apply(null,arguments)}),...p);let v=!0;const y=u((function(){o++;const e=Ye(g,arguments);{const{identityFunctionCheck:t,inputStabilityCheck:n}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...Ke,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:He},inputStabilityCheck:{shouldRun:"always"===r||"once"===r&&e,run:Je}}})(v,h);if(t.shouldRun&&t.run(s),n.shouldRun){const t=Ye(g,arguments);n.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}v&&(v=!1)}return t=m.apply(null,e),t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:m,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:c,argsMemoize:u})}}var rt=nt(tt);function ot(e){return({dispatch:t,getState:n})=>r=>o=>"function"==typeof o?o(t,n,e):r(o)}var it=ot(),st=ot;((...e)=>{const t=nt(...e)})(tt);var at="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?G:G.apply(null,arguments)},ct=e=>e&&"function"==typeof e.match;function lt(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw new Error("prepareAction did not return an object");return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Q(t)&&t.type===e,n}function ut(e){return"function"==typeof e&&"type"in e&&ct(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 ht=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 pt(e){return ae(e)?Be(e,(()=>{})):e}function ft(e,t,n){if(e.has(t)){let r=e.get(t);return n.update&&(r=n.update(r,t,e),e.set(t,r)),r}if(!n.insert)throw new Error("No insert provided for key not already in map");const r=n.insert(t,e);return e.set(t,r),r}function gt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function mt(e,t,n){const r=vt(e,t,n);return{detectMutations:()=>yt(e,t,r,n)}}function vt(e,t=[],n,r="",o=new Set){const i={value:n};if(!e(n)&&!o.has(n)){o.add(n),i.children={};for(const o in n){const s=r?r+"."+o:o;t.length&&-1!==t.indexOf(s)||(i.children[o]=vt(e,t,n[o],s))}}return i}function yt(e,t=[],n,r,o=!1,i=""){const s=n?n.value:void 0,a=s===r;if(o&&!a&&!Number.isNaN(r))return{wasMutated:!0,path:i};if(e(s)||e(r))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in r)c[e]=!0;const l=t.length>0;for(let o in c){const s=i?i+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=yt(e,t,n.children[o],r[o],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)||J(e)}function wt(e,t="",n=bt,r,o=[],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!=r?r(e):Object.entries(e),c=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=wt(l,a,n,r,o,i),s))return s}return i&&kt(e)&&i.add(e),!1}function kt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!kt(t))return!1;return!0}function jt(e){return"boolean"==typeof e}var xt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:o=!0}=e??{};let i=new ht;if(t&&(jt(t)?i.push(it):i.push(st(t.extraArgument))),n){let e={};jt(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,r,o){return JSON.stringify(e,n(t,o),r)},n=function(e,t){let n=[],r=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+r.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?r.splice(s,1/0,o):r.push(o),~n.indexOf(i)&&(i=t.call(this,o,i))}else n.push(i);return null==e?i:e.call(this,o,i)}},{isImmutable:r=gt,ignoredPaths:o,warnAfter:i=32}=e;const s=mt.bind(null,r,o);return({getState:e})=>{let n,r=e(),o=s(r);return a=>c=>{const l=dt(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const u=a(c);return l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),u}}}}(e))}if(r){let e={};jt(r)||(e=r),i.push(function(e={}){{const{isSerializable:t=bt,getEntries:n,ignoredActions:r=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,u=!l&&WeakSet?new WeakSet:void 0;return e=>l=>d=>{if(!Q(d))return l(d);const h=l(d),p=dt(s,"SerializableStateInvariantMiddleware");return c||r.length&&-1!==r.indexOf(d.type)||p.measureTime((()=>{const e=wt(d,"",t,n,o,u);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",d,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const r=wt(e.getState(),"",t,n,i,u);if(r){const{keyPath:e,value:t}=r;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${d.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};jt(o)||(e=o),i.unshift(function(e={}){const{isActionCreator:t=ut}=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},Ot=e=>t=>{setTimeout(t,e)},It="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Ot(10),St=e=>function(t){const{autoBatch:n=!0}=t??{};let r=new ht(e);return n&&r.push(((e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let o=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?It:"callback"===e.type?e.queueNotification:Ot(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},r,{subscribe(e){const t=r.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,i=!o,i&&(s||(s=!0,c(l))),r.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),r};function Ct(e){const t=xt(),{reducer:n,middleware:r,devTools:o=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!J(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=X(n)}if(r&&"function"!=typeof r)throw new Error("`middleware` field must be a callback");if("function"==typeof r){if(c=r(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=G;o&&(l=at({trace:!0,..."object"==typeof o&&o}));const u=function(...e){return t=>(n,r)=>{const o=t(n,r);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:o.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=G(...a)(o.dispatch),{...o,dispatch:i}}}(...c),d=St(u);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(d):d();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(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Z(a,i,l(...h))}function _t(e){const t={},n=[];let r;const o={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(r)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,o},addMatcher(e,t){if(r)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(r)throw new Error("`builder.addDefaultCase` can only be called once");return r=e,o}};return e(o),[t,n,r]}function Et(...e){return t=>e.some((e=>((e,t)=>ct(e)?e.match(t):e(t))(e,t)))}var Rt=["name","message","stack","code"],Pt=class{constructor(e,t){this.payload=e,this.meta=t}_type},At=class{constructor(e,t){this.payload=e,this.meta=t}_type},Mt=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Rt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},Ut=(()=>{function e(e,t,n){const r=lt(e+"/fulfilled",((e,t,n,r)=>({payload:e,meta:{...r||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=lt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=lt(e+"/rejected",((e,t,r,o,i)=>({payload:o,error:(n&&n.serializeError||Mt)(e||"Rejected"),meta:{...i||{},arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),u=new AbortController;let d;function h(e){d=e,u.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||u.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>u.signal.addEventListener("abort",(()=>t({name:"AbortError",message:d||"Aborted"})))));s(o(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:u.signal,abort:h,rejectWithValue:(e,t)=>new Pt(e,t),fulfillWithValue:(e,t)=>new At(e,t)})).then((t=>{if(t instanceof Pt)throw t;return t instanceof At?r(t.payload,l,e,t.meta):r(t,l,e)}))])}catch(t){p=t instanceof Pt?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(Tt)})}}),{pending:o,rejected:i,fulfilled:r,settled:Et(i,r),typePrefix:e})}return e.withTypes=()=>e,e})();function Tt(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var $t=Symbol.for("rtk-slice-createasyncthunk");function Dt(e,t){return`${e}/${t}`}function Lt(e,t,n,r){function o(o,...i){let s=n.call(e,o);if(void 0===s){if(!r)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return o.unwrapped=t,o}var Nt=function({creators:e}={}){const t=e?.asyncThunk?.[$t];return function(e){const{name:n,reducerPath:r=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function 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=[],r]="function"==typeof e.extraReducers?_t(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[r,o,i]=_t(t);if(function(e){return"function"==typeof e}(e))n=()=>pt(e());else{const t=pt(e);n=()=>t}function s(e=n(),t){let s=[r[t.type],...o.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(se(e)){const r=n(e,t);return void 0===r?e:r}if(ae(e))return Be(e,(e=>n(e,t)));{const r=n(e,t);if(void 0===r){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return r}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)}))}i.forEach((r=>{const i=o[r],s={reducerName:r,type:Dt(n,r),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},r,o){let i,s;if("reducer"in r){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(r))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=r.reducer,s=r.prepare}else i=r;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?lt(e,s):lt(e))}(s,i,a):function({type:e,reducerName:t},n,r,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:u}=n,d=o(e,i,u);r.exposeAction(t,d),s&&r.addCase(d.fulfilled,s);a&&r.addCase(d.pending,a);c&&r.addCase(d.rejected,c);l&&r.addMatcher(d.settled,l);r.exposeCaseReducer(t,{fulfilled:s||zt,pending:a||zt,rejected:c||zt,settled:l||zt})}(s,i,a,t)}));const l=e=>e,u=new WeakMap;let d;const h={name:n,reducerPath:r,reducer:(e,t)=>(d||(d=c()),d(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(d||(d=c()),d.getInitialState()),getSelectors(t=l){const n=ft(u,this,{insert:()=>new WeakMap});return ft(n,t,{insert:()=>{const n={};for(const[r,o]of Object.entries(e.selectors??{}))n[r]=Lt(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const r=t??this.reducerPath;return e.inject({reducerPath:r,reducer:this.reducer},n),{...this,reducerPath:r}}};return h}}();function zt(){}var Wt="listenerMiddleware";lt(`${Wt}/add`),lt(`${Wt}/removeAll`),lt(`${Wt}/remove`);const Ft=t=>s((n=>{const o=Nt(t),i=Object.assign(Object.assign({},o.actions),t.asyncActions);return class extends(e(l)(n)){constructor(...e){super(...e);const t=Ct({reducer:o.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),n=e=>(...n)=>r(this,void 0,void 0,(function*(){const r=yield t.dispatch(e(...n));try{Tt(r)}catch(e){this.logger.error(e.message,r.type,e.stack)}return r})),s=Object.keys(i).reduce(((e,t)=>(e[t]=n(i[t]),e)),{});this.actions=s,this.subscribe=(e,n=(e=>e))=>t.subscribe((()=>e(n(t.getState()))))}}})),qt=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Bt=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}}),Ht=({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)})}}),Jt=Ut("users/create",((e,{extra:{api:t}})=>t.user.create(e))),Kt=qt(Jt)({onFulfilled:(e,t)=>{e.usersList.data.unshift(t.payload)}},Bt((e=>e.createUser)),Ht({getSuccessMsg:()=>"User created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Vt={action:Jt,reducer:Kt},Zt=Ut("users/delete",((e,{extra:{api:t}})=>t.user.deleteBatch(e))),Yt=qt(Zt)({onFulfilled:(e,t)=>{e.usersList.data=e.usersList.data.filter((e=>!t.meta.arg.includes(e.userId))),e.selectedUsersLoginIds=[]}},Bt((e=>e.deleteUser)),Ht({getSuccessMsg:e=>h(e.meta.arg.length)`${["",e.meta.arg.length]} ${["U","u"]}ser${["","s"]} deleted successfully`,getErrorMsg:e=>h(e.meta.arg.length)`Failed to delete user${["","s"]}`})),Xt={action:Zt,reducer:Yt},Gt=Ut("users/expirePassword",((e,{extra:{api:t}})=>t.user.expirePassword(e))),Qt={action:Gt,reducer:qt(Gt)(Bt((e=>e.expireUserPassword)))},en=Ut("users/getCustomAttributes",((e,{extra:{api:t}})=>t.user.getCustomAttributes())),tn=qt(en)({onFulfilled:(e,t)=>{e.customAttributes.data=t.payload}},Bt((e=>e.customAttributes)),Bt((e=>e.customAttributes))),nn={action:en,reducer:tn},rn={enabled:"active"},on=e=>e.selectedUsersLoginIds,sn=e=>e.notifications,an=rt((e=>e.usersList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{status:rn[e.status]||e.status}))))),cn=rt(an,on,((e,t)=>e.filter((e=>t.includes(e.loginIds))).map((e=>e.userId)))),ln=rt(on,an,((e,t)=>t.filter((t=>e.includes(t.loginIds))))),un=rt(on,(e=>!!e.length)),dn=rt(ln,(e=>1===e.length?e[0].email:`${e.length} users`)),hn=Ut("users/search",((e,{extra:{api:t},getState:n})=>{const r=n().searchParams;return t.user.search(Object.assign(Object.assign({},r),e))})),pn={action:hn,reducer:qt(hn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.usersList.data=t.payload}},Bt((e=>e.usersList)))},fn={usersList:{data:[],loading:!1,error:null},createUser:{loading:!1,error:null},deleteUser:{loading:!1,error:null},expireUserPassword:{loading:!1,error:null},customAttributes:{loading:!1,error:null,data:{}},searchParams:{text:"",sort:[]},selectedUsersLoginIds:[],notifications:[]};function gn(e){this.message=e}gn.prototype=new Error,gn.prototype.name="InvalidCharacterError";var mn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new gn("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,i=0,s="";r=t.charAt(i++);~r&&(n=o%4?64*n+r:r,o++%4)?s+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function vn(e){this.message=e}function yn(e,t){if("string"!=typeof e)throw new vn("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(mn(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return mn(t)}}(e.split(".")[n]))}catch(e){throw new vn("Invalid token specified: "+e.message)}}vn.prototype=new Error,vn.prototype.name="InvalidTokenError";var bn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function wn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kn="__lodash_hash_undefined__",jn=1/0,xn="[object Function]",On="[object GeneratorFunction]",In="[object Symbol]",Sn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Cn=/^\w*$/,_n=/^\./,En=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Rn=/\\(\\)?/g,Pn=/^\[object .+?Constructor\]$/,An="object"==typeof bn&&bn&&bn.Object===Object&&bn,Mn="object"==typeof self&&self&&self.Object===Object&&self,Un=An||Mn||Function("return this")();var Tn,$n=Array.prototype,Dn=Function.prototype,Ln=Object.prototype,Nn=Un["__core-js_shared__"],zn=(Tn=/[^.]+$/.exec(Nn&&Nn.keys&&Nn.keys.IE_PROTO||""))?"Symbol(src)_1."+Tn:"",Wn=Dn.toString,Fn=Ln.hasOwnProperty,qn=Ln.toString,Bn=RegExp("^"+Wn.call(Fn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hn=Un.Symbol,Jn=$n.splice,Kn=or(Un,"Map"),Vn=or(Object,"create"),Zn=Hn?Hn.prototype:void 0,Yn=Zn?Zn.toString:void 0;function Xn(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Gn(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Qn(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function er(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function tr(e,t){var n;t=function(e,t){if(cr(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||ur(e))return!0;return Cn.test(e)||!Sn.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:cr(n=t)?n:ir(n);for(var r=0,o=t.length;null!=e&&r<o;)e=e[sr(t[r++])];return r&&r==o?e:void 0}function nr(e){if(!lr(e)||(t=e,zn&&zn in t))return!1;var t,n=function(e){var t=lr(e)?qn.call(e):"";return t==xn||t==On}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Bn:Pn;return n.test(function(e){if(null!=e){try{return Wn.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function rr(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function or(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return nr(n)?n:void 0}Xn.prototype.clear=function(){this.__data__=Vn?Vn(null):{}},Xn.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Xn.prototype.get=function(e){var t=this.__data__;if(Vn){var n=t[e];return n===kn?void 0:n}return Fn.call(t,e)?t[e]:void 0},Xn.prototype.has=function(e){var t=this.__data__;return Vn?void 0!==t[e]:Fn.call(t,e)},Xn.prototype.set=function(e,t){return this.__data__[e]=Vn&&void 0===t?kn:t,this},Gn.prototype.clear=function(){this.__data__=[]},Gn.prototype.delete=function(e){var t=this.__data__,n=er(t,e);return!(n<0)&&(n==t.length-1?t.pop():Jn.call(t,n,1),!0)},Gn.prototype.get=function(e){var t=this.__data__,n=er(t,e);return n<0?void 0:t[n][1]},Gn.prototype.has=function(e){return er(this.__data__,e)>-1},Gn.prototype.set=function(e,t){var n=this.__data__,r=er(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Qn.prototype.clear=function(){this.__data__={hash:new Xn,map:new(Kn||Gn),string:new Xn}},Qn.prototype.delete=function(e){return rr(this,e).delete(e)},Qn.prototype.get=function(e){return rr(this,e).get(e)},Qn.prototype.has=function(e){return rr(this,e).has(e)},Qn.prototype.set=function(e,t){return rr(this,e).set(e,t),this};var ir=ar((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ur(e))return Yn?Yn.call(e):"";var t=e+"";return"0"==t&&1/e==-jn?"-0":t}(t);var n=[];return _n.test(e)&&n.push(""),e.replace(En,(function(e,t,r,o){n.push(r?o.replace(Rn,"$1"):t||e)})),n}));function sr(e){if("string"==typeof e||ur(e))return e;var t=e+"";return"0"==t&&1/e==-jn?"-0":t}function ar(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(ar.Cache||Qn),n}ar.Cache=Qn;var cr=Array.isArray;function lr(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ur(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&qn.call(e)==In}var dr=wn((function(e,t,n){var r=null==e?void 0:tr(e,t);return void 0===r?n:r})),hr="/v1/auth/accesskey/exchange",pr="/v1/auth/otp/verify",fr="/v1/auth/otp/signin",gr="/v1/auth/otp/signup",mr={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},vr="/v1/auth/otp/signup-in",yr="/v1/auth/magiclink/verify",br="/v1/auth/magiclink/signin",wr="/v1/auth/magiclink/signup",kr={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},jr="/v1/auth/magiclink/signup-in",xr="/v1/auth/enchantedlink/verify",Or="/v1/auth/enchantedlink/signin",Ir="/v1/auth/enchantedlink/signup",Sr="/v1/auth/enchantedlink/pending-session",Cr={email:"/v1/auth/enchantedlink/update/email"},_r="/v1/auth/enchantedlink/signup-in",Er="/v1/auth/oauth/authorize",Rr="/v1/auth/oauth/exchange",Pr="/v1/auth/saml/authorize",Ar="/v1/auth/saml/exchange",Mr="/v1/auth/totp/verify",Ur="/v1/auth/totp/signup",Tr="/v1/auth/totp/update",$r={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Dr={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Lr={start:"/v1/auth/webauthn/signup-in/start"},Nr={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},zr="/v1/auth/password/signup",Wr="/v1/auth/password/signin",Fr="/v1/auth/password/reset",qr="/v1/auth/password/update",Br="/v1/auth/password/replace",Hr="/v1/auth/password/policy",Jr="/v1/auth/refresh",Kr="/v1/auth/tenant/select",Vr="/v1/auth/logout",Zr="/v1/auth/logoutall",Yr="/v1/auth/me",Xr="/v1/auth/me/history",Gr="/v1/flow/start",Qr="/v1/flow/next";const eo="<region>",to=`https://api.${eo}descope.com`,no=6e5,ro=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};var oo;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(oo||(oo={}));const io=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,r])=>(e[n]=r,e)),e),e}),{})),so=e=>void 0===e?void 0:JSON.stringify(e),ao=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},co=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:o,cookiePolicy:i,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),r=await n.text();return n.text=()=>Promise.resolve(r),n.json=()=>Promise.resolve(JSON.parse(r)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>ro().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await n(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return ro().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n})(r,s),c=async r=>{const s=(null==o?void 0:o.beforeRequest)?o.beforeRequest(r):r,{path:c,body:l,headers:u,queryParams:d,method:h,token:p}=s,f={headers:io(ao(t,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.9.1"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:so(l)};null!==i&&(f.credentials=i||"include");const g=await a((({path:e,baseUrl:t,queryParams:n,projectId:r})=>{const o=r.slice(1,-27);t=t.replace(eo,o?o+".":"");const i=new URL(e,t);return n&&(i.search=new URLSearchParams(n).toString()),i})({path:c,baseUrl:e,queryParams:d,projectId:t}),f);return(null==o?void 0:o.afterRequest)&&await o.afterRequest(r,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:r}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:oo.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>c({path:e,headers:n,queryParams:r,body:t,method:oo.post,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>c({path:e,headers:n,queryParams:r,body:t,method:oo.put,token:o}),delete:(e,{headers:t,queryParams:n,token:r}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:oo.delete,token:r}),hooks:o}};var lo=429;function uo(e,t,n){var r;let o=ho(e);t&&(o=null===(r=null==o?void 0:o.tenants)||void 0===r?void 0:r[t]);const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function ho(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return yn(e)}function po(e){const{exp:t}=ho(e);return(new Date).getTime()/1e3>t}function fo(e){let t=ho(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function go(e,t){return uo(e,t,"permissions")}function mo(e,t){return uo(e,t,"roles")}const vo=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function yo(e,t){var n;const r=await e,o={code:r.status,ok:r.ok,response:r},i=await r.clone().json();return r.ok?o.data=t?t(i):i:(o.error=i,r.status===lo&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=r.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const bo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),wo=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ko=e=>t=>e.test(t),jo=ko(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),xo=ko(/^\+[1-9]{1}[0-9]{3,14}$/),Oo=bo(jo,'"{val}" is not a valid email'),Io=bo(xo,'"{val}" is not a valid phone number'),So=bo((1,e=>e.length>=1),"Minimum length is 1");const Co=bo((e=>"string"==typeof e),"Input is not a string"),_o=bo((e=>void 0===e),"Input is defined"),Eo=(Ro=[Co(),_o()],"Input is not a string or undefined",(e="Input is not a string or undefined")=>t=>{const n=Ro.filter((e=>e(t)));return!(n.length<Ro.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var Ro;const Po=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>wo(...e).validate(n[t]))),t(...n)),Ao=e=>[Co(`"${e}" must be a string`),So(`"${e}" must not be empty`)],Mo=e=>[Co(`"${e}" must be a string`),Oo()],Uo=e=>[Co(`"${e}" must be a string`),Io()],To=Po(Ao("accessKey")),$o=e=>({exchange:To((t=>yo(e.post(hr,{},{token:t}))))});var Do,Lo;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Do||(Do={})),function(e){e.email="email"}(Lo||(Lo={}));const No=Object.assign(Object.assign({},Do),Lo);var zo;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(zo||(zo={}));const Wo=Ao("loginId"),Fo=Po(Ao("token")),qo=Po(Wo),Bo=Po(Ao("pendingRef")),Ho=Po(Wo,Mo("email")),Jo=e=>({verify:Fo((t=>yo(e.post(xr,{token:t})))),signIn:qo(((t,n,r,o)=>yo(e.post(vo(Or,No.email),{loginId:t,URI:n,loginOptions:r},{token:o})))),signUpOrIn:qo(((t,n,r)=>yo(e.post(vo(_r,No.email),{loginId:t,URI:n,loginOptions:r})))),signUp:qo(((t,n,r,o)=>yo(e.post(vo(Ir,No.email),{loginId:t,URI:n,user:r,loginOptions:o})))),waitForSession:Bo(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||no,no)}))(n);let s;const a=setInterval((async()=>{const n=await e.post(Sr,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(yo(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:Ho(((t,n,r,o,i)=>yo(e.post(Cr.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o}))))}}),Ko=Po(Ao("flowId")),Vo=Po(Ao("executionId"),Ao("stepId"),Ao("interactionId")),Zo=e=>({start:Ko(((t,n,r,o,i,s,a)=>yo(e.post(Gr,{flowId:t,options:n,conditionInteractionId:r,interactionId:o,version:i,componentsVersion:s,input:a})))),next:Vo(((t,n,r,o,i,s)=>yo(e.post(Qr,{executionId:t,stepId:n,interactionId:r,version:o,componentsVersion:i,input:s}))))}),Yo=Ao("loginId"),Xo=Po(Ao("token")),Go=Po(Yo),Qo=Po(Yo,Uo("phone")),ei=Po(Yo,Mo("email")),ti=e=>({verify:Xo((t=>yo(e.post(yr,{token:t})))),signIn:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Go(((t,r,o,i)=>yo(e.post(vo(br,n),{loginId:t,URI:r,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Go(((t,r,o,i)=>yo(e.post(vo(wr,n),{loginId:t,URI:r,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Go(((t,r,o)=>yo(e.post(vo(jr,n),{loginId:t,URI:r,loginOptions:o}))))})),{}),update:{email:ei(((t,n,r,o,i)=>yo(e.post(kr.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o})))),phone:Object.keys(Do).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qo(((t,r,o,i,s)=>yo(e.post(vo(kr.phone,n),Object.assign({loginId:t,phone:r,URI:o},s),{token:i}))))})),{})}});var ni;!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"}(ni||(ni={}));const ri=Po(Ao("code")),oi=e=>({start:Object.assign(((t,n,r,o)=>yo(e.post(Er,r||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:o}))),Object.keys(ni).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,r,o)=>yo(e.post(Er,r||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:o}))})),{})),exchange:ri((t=>yo(e.post(Rr,{code:t}))))}),ii=Ao("loginId"),si=Po(ii,Ao("code")),ai=Po(ii),ci=Po(ii,Uo("phone")),li=Po(ii,Mo("email")),ui=e=>({verify:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:si(((t,r)=>yo(e.post(vo(pr,n),{code:r,loginId:t}))))})),{}),signIn:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ai(((t,r,o)=>yo(e.post(vo(fr,n),{loginId:t,loginOptions:r},{token:o}))))})),{}),signUp:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ai(((t,r,o)=>yo(e.post(vo(gr,n),{loginId:t,user:r,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(No).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ai(((t,r)=>yo(e.post(vo(vr,n),{loginId:t,loginOptions:r}))))})),{}),update:{email:li(((t,n,r,o)=>yo(e.post(mr.email,Object.assign({loginId:t,email:n},o),{token:r})))),phone:Object.keys(Do).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ci(((t,r,o,i)=>yo(e.post(vo(mr.phone,n),Object.assign({loginId:t,phone:r},i),{token:o}))))})),{})}}),di=Po(Ao("tenant")),hi=Po(Ao("code")),pi=e=>({start:di(((t,n,r,o)=>yo(e.post(Pr,r||{},{queryParams:{tenant:t,redirectURL:n},token:o})))),exchange:hi((t=>yo(e.post(Ar,{code:t}))))}),fi=Ao("loginId"),gi=Po(fi,Ao("code")),mi=Po(fi),vi=Po(fi),yi=e=>({signUp:mi(((t,n)=>yo(e.post(Ur,{loginId:t,user:n})))),verify:gi(((t,n,r,o)=>yo(e.post(Mr,{loginId:t,code:n,loginOptions:r},{token:o})))),update:vi(((t,n)=>yo(e.post(Tr,{loginId:t},{token:n}))))}),bi=Ao("loginId"),wi=Ao("newPassword"),ki=Po(bi,Ao("password")),ji=Po(bi),xi=Po(bi,wi),Oi=Po(bi,Ao("oldPassword"),wi),Ii=e=>({signUp:ki(((t,n,r)=>yo(e.post(zr,{loginId:t,password:n,user:r})))),signIn:ki(((t,n)=>yo(e.post(Wr,{loginId:t,password:n})))),sendReset:ji(((t,n,r)=>yo(e.post(Fr,{loginId:t,redirectUrl:n,templateOptions:r})))),update:xi(((t,n,r)=>yo(e.post(qr,{loginId:t,newPassword:n},{token:r})))),replace:Oi(((t,n,r)=>yo(e.post(Br,{loginId:t,oldPassword:n,newPassword:r})))),policy:()=>yo(e.get(Hr))}),Si=[Co('"loginId" must be a string')],Ci=Ao("loginId"),_i=Ao("origin"),Ei=Po(Ci,_i,Ao("name")),Ri=Po(Ci,_i),Pi=Po(Si,_i),Ai=Po(Ci,_i,Ao("token")),Mi=Po(Ao("transactionId"),Ao("response")),Ui=e=>({signUp:{start:Ei(((t,n,r)=>yo(e.post($r.start,{user:{loginId:t,name:r},origin:n})))),finish:Mi(((t,n)=>yo(e.post($r.finish,{transactionId:t,response:n}))))},signIn:{start:Pi(((t,n,r,o)=>yo(e.post(Dr.start,{loginId:t,origin:n,loginOptions:r},{token:o})))),finish:Mi(((t,n)=>yo(e.post(Dr.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ri(((t,n)=>yo(e.post(Lr.start,{loginId:t,origin:n}))))},update:{start:Ai(((t,n,r)=>yo(e.post(Nr.start,{loginId:t,origin:n},{token:r})))),finish:Mi(((t,n)=>yo(e.post(Nr.finish,{transactionId:t,response:n}))))}}),Ti=Po(Ao("token")),$i=Po([Eo('"token" must be string or undefined')]);var Di,Li=Po([("projectId",Di=Ao("projectId"),bo(((e,t)=>n=>wo(...t).validate(dr(n,e)))("projectId",Di))())])((e=>(({projectId:e,logger:t,baseUrl:n,hooks:r,cookiePolicy:o,baseHeaders:i={},fetch:s})=>{return a=co({baseUrl:n||to,projectId:e,logger:t,hooks:r,cookiePolicy:o,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:$o(a),otp:ui(a),magicLink:ti(a),enchantedLink:Jo(a),oauth:oi(a),saml:pi(a),totp:yi(a),webauthn:Ui(a),password:Ii(a),flow:Zo(a),refresh:$i((e=>yo(a.post(Jr,{},{token:e})))),selectTenant:Po([Co("tenantId")],[Eo('"token" must be string or undefined')])(((e,t)=>yo(a.post(Kr,{tenant:e},{token:t})))),logout:$i((e=>yo(a.post(Vr,{},{token:e})))),logoutAll:$i((e=>yo(a.post(Zr,{},{token:e})))),me:$i((e=>yo(a.get(Yr,{token:e})))),history:$i((e=>yo(a.get(Xr,{token:e})))),isJwtExpired:Ti(po),getTenants:Ti(fo),getJwtPermissions:Ti(go),getJwtRoles:Ti(mo),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const r=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==r?void 0:r.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var r;const o=[].concat((null===(r=e.hooks)||void 0===r?void 0:r.afterRequest)||[]);(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))}}}))));const Ni=(e,t,n)=>(t.forEach((t=>{const r=t.split(".");let o=r.shift(),i=e;for(;r.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=r.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const s=i[o];i[o]=n(s)})),e);var zi=Object.assign(Li,{DeliveryMethods:No});var Wi="Blocked by CSP",Fi="9319";function qi(e,t){var n=[];return function(e,t){var n,r,o=(r=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],e,!0),{current:function(){return r[0]},postpone:function(){var e=r.shift();void 0!==e&&r.push(e)},exclude:function(){r.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=o.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(e,n){return t(e).catch((function(e){if(n+1>=5)throw e;!function(e){if(!(e instanceof Error))return!1;var t=e.message;return t===Wi||t===Fi}(e)?o.postpone():o.exclude();var t,r=o.current();if(void 0===r)throw e;return(t=i(),new Promise((function(e){return setTimeout(e,t)}))).then((function(){return a(r,n+1)}))}))};return a(s,0)}(e,(function(e){var r=new Date,o=function(t){return n.push({url:e,startedAt:r,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i})).then((function(e){return[e,{attempts:n}]}))}var Bi="Failed to load the JS script of the agent";function Hi(e){var r;e.scriptUrlPattern;var o=e.token,i=e.apiKey,s=void 0===i?o:i,a=n(e,["scriptUrlPattern","token","apiKey"]),c=null!==(r=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(e,"scriptUrlPattern"))&&void 0!==r?r:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";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.8.5"):e}))}(String(e),t)}))}(c,s);return qi(e,Ji).catch(Vi)})).then((function(e){var n=e[0],r=e[1];return n.load(t(t({},a),{ldi:r}))}))}function Ji(e){return function(e,t,n,r){var o,i=document,s="securitypolicyviolation",a=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,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(c(),o)return function(){throw new Error(Wi)}();throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(Bi))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)})).then(Ki)}function Ki(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Fi);return n}function Vi(e){throw e instanceof Error&&e.message===Fi?new Error(Bi):e}
3
+ /*! js-cookie v3.0.5 | MIT */function Zi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var Yi=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=Zi({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in o)o[s]&&(i+="; "+s,!0!==o[s]&&(i+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+i}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(r[a]=t.read(s,a),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",Zi({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Zi({},this.attributes,t))},withConverter:function(t){return e(Zi({},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:"/"});const Xi=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,r)=>{var o;return n[r]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[r])||[]).concat((null==t?void 0:t[r])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Gi=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},Qi=async e=>{const t=await Gi(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},es="undefined"!=typeof localStorage,ts=(e,t)=>es&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),ns=e=>es&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),rs=e=>es&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),os=(...e)=>{console.debug(...e)},is="undefined"!=typeof window,ss=Math.pow(2,31)-1,as=is&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",cs=(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},ls=e=>{const t=cs(!0);return t&&e.body&&(e.body.fpData=t),e},us="dls_last_user_login_id",ds="dls_last_user_display_name",hs=()=>ns(us),ps=()=>ns(ds),fs=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,r={}]=t,o=hs(),i=ps();return o&&(null!==(n=r.lastAuth)&&void 0!==n||(r.lastAuth={}),r.lastAuth.loginId=o,r.lastAuth.name=i),await e(...t)},gs=e=>async(...t)=>{const n=await e(...t);return rs(us),rs(ds),n};function ms(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const vs="DS",ys="DSR";function bs(e=""){return ns(`${e}${ys}`)||""}function ws(e=""){rs(`${e}${ys}`),rs(`${e}${vs}`),Yi.remove(vs)}async function ks(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Cs(n.publicKey.challenge),n.publicKey.user.id=Cs(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Cs(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:_s(n.rawId),type:n.type,response:{attestationObject:_s(n.response.attestationObject),clientDataJSON:_s(n.response.clientDataJSON)}});var n}async function js(e){const t=Is(e);return Ss(await navigator.credentials.get(t))}async function xs(e,t){const n=Is(e);return n.signal=t.signal,n.mediation="conditional",Ss(await navigator.credentials.get(n))}async function Os(e=!1){if(!is)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 Is(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Cs(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Cs(e.id)})),n}function Ss(e){return JSON.stringify({id:e.id,rawId:_s(e.rawId),type:e.type,response:{authenticatorData:_s(e.response.authenticatorData),clientDataJSON:_s(e.response.clientDataJSON),signature:_s(e.response.signature),userHandle:e.response.userHandle?_s(e.response.userHandle):void 0}})}function Cs(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function _s(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Es,Rs=(Es=e=>({async signUp(t,n){const r=await e.webauthn.signUp.start(t,window.location.origin,n);if(!r.ok)return r;const o=await ks(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,o)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const r=await js(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,r)},async signUpOrIn(t){var n;const r=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!r.ok)return r;if(null===(n=r.data)||void 0===n?void 0:n.create){const t=await ks(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,t)}{const t=await js(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,t)}},async update(t,n){const r=await e.webauthn.update.start(t,window.location.origin,n);if(!r.ok)return r;const o=await ks(r.data.options);return await e.webauthn.update.finish(r.data.transactionId,o)},helpers:{create:ks,get:js,isSupported:Os,conditional:xs}}),(...e)=>{const t=Es(...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}),Ps=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Os(),r=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=r,e.flow.start(...t)}});const As=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var{fpKey:r,fpLoad:o}=t,i=n(t,["fpKey","fpLoad"]);return is?(r&&o&&(async e=>{try{if(cs())return;const t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=Hi({apiKey:e,endpoint:as}),r=await n,{requestId:o}=await r.get({linkedId:t}),i=((e,t)=>({vsid:e,vrid:t}))(t,o);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(t))})(i)}catch(e){global.FB_DEBUG&&console.error(e)}})(r).catch((()=>null)),e(Xi(i,{beforeRequest:ls}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),e(i))}),(e=>t=>{var{autoRefresh:r}=t,o=n(t,["autoRefresh"]);if(!r)return e(o);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;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(os("Expiration time passed, refreshing session"),l.refresh(c))}));const l=e(Xi(o,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:r}=await Gi(t);if(401===(null==t?void 0:t.status))os("Received 401, canceling all timers"),i();else if(r){a=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(r),c=n;let e=((o=a)?o.getTime()-(new Date).getTime():0)-2e4;e>ss&&(os(`Timeout is too large (${e}ms), setting it to ${ss}ms`),e=ss),i();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});os(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{os("Refreshing session due to timer"),l.refresh(n)}),e)}var o}}));return Ni(l,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return os("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.9.5"},t.baseHeaders)}))),(e=>t=>{const n=ms(),r=ms(),o=e(Xi(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),r.pub(null);else{const e=await Qi(t);e&&r.pub(e);const{sessionJwt:o}=await Gi(t);o&&n.pub(o)}}})),i=Ni(o,["logout","logoutAll"],(e=>async(...t)=>{const o=await e(...t);return n.pub(null),r.pub(null),o}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:r.sub})}),(e=>t=>{const n=e(Xi(t,{afterRequest:async(e,t)=>{var n;const r=await Qi(t),o=null===(n=null==r?void 0:r.loginIds)||void 0===n?void 0:n[0],i=null==r?void 0:r.name;o&&((e=>{ts(us,e)})(o),(e=>{ts(ds,e)})(i))}}));let r=Ni(n,["flow.start"],fs);return r=Ni(r,["logout","logoutAll"],gs),Object.assign(r,{getLastUserLoginId:hs,getLastUserDisplayName:ps})}),(e=>t=>{var{persistTokens:r,sessionTokenViaCookie:o,storagePrefix:i}=t,s=n(t,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!r||!is)return r&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),e(s);const a=e(Xi(s,{beforeRequest:(c=i,e=>Object.assign(e,{token:e.token||bs(c)})),afterRequest:async(e,t)=>{401===(null==t?void 0:t.status)?ws(i):((e={},t,r)=>{var{refreshJwt:o,sessionJwt:i}=e,s=n(e,["refreshJwt","sessionJwt"]);void 0===t&&(t=!1),void 0===r&&(r=""),o&&ts(`${r}${ys}`,o),i&&(t?function(e,t,{cookiePath:n,cookieDomain:r,cookieExpiration:o}){if(t){const i=new Date(1e3*o),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(r);Yi.set(e,t,{path:n,domain:s?r:void 0,expires:i,sameSite:"Strict",secure:!0})}}(vs,i,s):ts(`${r}${vs}`,i))})(await Gi(t),o,i)}}));var c;const l=Ni(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const r=await t(...n);return ws(e),r})(i));return Object.assign(l,{getRefreshToken:()=>bs(i),getSessionToken:()=>function(e=""){return Yi.get(vs)||ns(`${e}${vs}`)||""}(i)})}))(((...e)=>{const t=zi(...e);return Object.assign(Object.assign({},t),{flow:Ps(t),webauthn:Rs(t)})})),Ms={search:"/v1/mgmt/user/search",deleteBatch:"/v1/mgmt/user/delete/batch",create:"/v1/mgmt/user/create",expirePassword:"/v1/mgmt/user/password/expire",customAttributes:"/v1/mgmt/user/customattributes"},Us=e=>r(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=({httpClient:e,tenant:t})=>({search:({page:n,limit:o=1e4,customAttributes:i,statuses:s,emails:a,phones:c,text:l,sort:u}={})=>r(void 0,void 0,void 0,(function*(){const r=yield e.post(Ms.search,{limit:o,page:n,withTestUser:!1,customAttributes:i,statuses:s,emails:a,phones:c,text:l,sort:u},{queryParams:{tenant:t}});yield Us(r);return(yield r.json()).users})),deleteBatch:n=>r(void 0,void 0,void 0,(function*(){const r=yield e.post(Ms.deleteBatch,{userIds:n},{queryParams:{tenant:t}});return yield Us(r),r.json()})),create:({loginId:n,email:o,phone:i,displayName:s,roles:a,customAttributes:c,picture:l,verifiedEmail:u,verifiedPhone:d,givenName:h,middleName:p,familyName:f,additionalLoginIds:g,sendSMS:m,sendMail:v,inviteUrl:y,invite:b})=>r(void 0,void 0,void 0,(function*(){const r=yield e.post(Ms.create,{loginId:n,email:o,phone:i,displayName:s,givenName:h,middleName:p,familyName:f,roleNames:a,userTenants:[{tenantId:t}],customAttributes:c,picture:l,verifiedEmail:u,verifiedPhone:d,additionalLoginIds:g,sendSMS:m,sendMail:v,inviteUrl:y,invite:b},{queryParams:{tenant:t}});yield Us(r);return(yield r.json()).user})),expirePassword:n=>r(void 0,void 0,void 0,(function*(){const r=yield e.post(Ms.expirePassword,{loginId:n[0]},{queryParams:{tenant:t}});return yield Us(r),r.json()})),getCustomAttributes:()=>r(void 0,void 0,void 0,(function*(){const n=yield e.get(Ms.customAttributes,{queryParams:{tenant:t}});return yield Us(n),n.json()}))}),$s=s((t=>{var n,s,a,c;const u=e(b,v,l,y({tenant:m}))(t);return c=class extends u{constructor(){super(...arguments),n.add(this),s.set(this,void 0)}get baseUrl(){return this.getAttribute("base-url")}get tenant(){return this.getAttribute("tenant")}get api(){return o(this,s,"f")||o(this,n,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{o(this,s,"f")&&o(this,n,"m",a).call(this)}))}))}},s=new WeakMap,n=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t)=>{const n=As(Object.assign(Object.assign({},e),{persistTokens:!0}));return{user:Ts({httpClient:n.httpClient,tenant:t})}})({projectId:this.projectId,baseUrl:this.baseUrl},this.tenant),"f")},c})),Ds=s((t=>{const n=e(Ft({name:"widget",initialState:fn,reducers:{setSelectedUsersIds:(e,{payload:t})=>{e.selectedUsersLoginIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Vt.reducer(e),Xt.reducer(e),pn.reducer(e),Qt.reducer(e),nn.reducer(e)},asyncActions:{searchUsers:pn.action,createUser:Vt.action,deleteUsers:Xt.action,expireUserPassword:Qt.action,getCustomAttributes:nn.action}}),a,l,$s)(t);return class extends n{constructor(...e){super(...e),this.state=fn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}}));const Ls=s((t=>{var n,i,s;return s=class extends(e(l,a,_,P)(t)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){return r(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this)}))}},n=new WeakSet,i=function(){return r(this,void 0,void 0,(function*(){const e=D('\n<descope-container\n direction="column"\n space-between="md"\n st-horizontal-padding="1rem"\n st-vertical-padding="1rem"\n st-align-items="safe center"\n st-gap="1rem"\n>\n <descope-container\n direction="row"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-align-items="safe center"\n st-gap="0rem"\n st-justify-content="space-between"\n >\n <descope-text-field data-testid="search-input" data-id="search-input" placeholder="Search" size="sm" bordered="true"></descope-text-field>\n\n <descope-container\n direction="row"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-justify-content="flex-end"\n st-gap="0.5em"\n st-host-width="auto"\n >\n <descope-button data-testid="delete-users-trigger" data-id="delete-users" mode="primary" variant="outline" size="sm">Delete</descope-button>\n <descope-button data-testid="create-user-trigger" data-id="create-user" mode="primary" variant="contained" size="sm">+ User</descope-button>\n </descope-container>\n </descope-container>\n <descope-grid\n data-id="users-table"\n size="sm"\n column-reordering-allowed\n st-host-height="300px"\n style="width: 100%"\n >\n <descope-grid-selection-column frozen auto-width></descope-grid-selection-column>\n <descope-grid-text-column path="loginIds" header="Login ID" resizable></descope-grid-text-column>\n <descope-grid-text-column sortable="true" path="name" header="Name" resizable></descope-grid-text-column>\n <descope-grid-custom-column sortable="true" path="status" header="Status" resizable>\n <descope-badge mode="default" pattern="invited" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n <descope-badge mode="primary" pattern="active" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n <descope-badge mode="error" pattern="disabled" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n </descope-grid-custom-column>\n <descope-grid-text-column sortable="true" path="email" header="Email" resizable></descope-grid-text-column>\n <descope-grid-text-column sortable="true" path="phone" header="Phone" resizable></descope-grid-text-column>\n </descope-grid>\n </descope-container>\n');yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0)),this.onWidgetRootReady()}))},s})),Ns=s((t=>{var n,i,s;return s=class extends(e(Ds,F,L,l,Ls)(t)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this)}))}},n=new WeakSet,i=function(){return r(this,void 0,void 0,(function*(){this.createUserModal=this.createModal(),this.createUserModal.setContent(D('\n<descope-container\n direction="column"\n st-justify-content="safe center"\n st-gap="1rem"\n st-host-width="100%"\n st-background-color="none"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-border-radius="sm"\n>\n <descope-text variant="subtitle1" mode="surface">New User</descope-text>\n <descope-text-field name="loginId" label="Login ID" bordered="true" required="true" size="sm"></descope-text-field>\n <descope-email-field name="email" label="Email" bordered="true"></descope-email-field>\n <descope-text-field name="displayName" label="Name" bordered="true"></descope-text-field>\n <descope-phone-field name="phone" label="Phone" bordered="true"></descope-phone-field>\n\n <descope-container\n direction="row"\n st-justify-content="flex-end"\n st-gap="1rem"\n st-host-width="100%"\n st-horizontal-padding="0.75rem"\n st-vertical-padding="0.75rem"\n st-background-color="none"\n >\n <descope-button data-testid="create-user-modal-cancel" data-id="modal-cancel" mode="primary" variant="link" size="sm">Cancel</descope-button>\n <descope-button data-testid="create-user-modal-submit" data-id="modal-submit" mode="primary" variant="contained" size="sm">Create</descope-button>\n </descope-container>\n</descope-container>\n'));const e=new $((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});e.onClick((()=>this.createUserModal.close()));const t=new $((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});t.onClick((()=>r(this,void 0,void 0,(function*(){this.validateForm(this.createUserModal.ele)&&(this.actions.createUser(Object.assign(Object.assign({},this.getFormData(this.createUserModal.ele)),{invite:!0,verifiedEmail:!0,verifiedPhone:!0})),this.createUserModal.close(),this.resetFormData(this.createUserModal.ele))}))))}))},s})),zs=s((t=>{var n,i,s;return s=class extends(e(l,Ns,Ls)(t)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this)}))}},n=new WeakSet,i=function(){var e;this.createButton=new $(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-user"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createUserModal.open()))},s}));class Ws extends T{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)}}const Fs=s((t=>{var n,i,s;return s=class extends(e(Ds,F,l,Ls)(t)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),yield o(this,n,"m",i).call(this)}))}},n=new WeakSet,i=function(){var e;return r(this,void 0,void 0,(function*(){this.deleteUsersModal=this.createModal(),this.deleteUsersModal.setContent(D('\n<descope-container\n direction="column"\n st-justify-content="safe center"\n st-gap="1rem"\n st-host-width="100%"\n st-background-color="none"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-border-radius="sm"\n data-testid="delete-users-modal"\n>\n <descope-text variant="subtitle1" mode="surface">Delete Users</descope-text>\n <descope-text data-id="body-text" variant="body1" mode="surface">Delete user</descope-text>\n\n <descope-container \n direction="row"\n st-justify-content="flex-end"\n st-gap="1rem"\n st-host-width="100%"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-background-color="none"\n >\n <descope-button data-testid="delete-users-modal-cancel" data-id="modal-cancel" mode="primary" variant="link" size="md">Cancel</descope-button>\n <descope-button data-testid="delete-users-modal-submit" data-id="modal-submit" mode="error" variant="contained" size="md">Delete</descope-button>\n </descope-container>\n</descope-container>\n'));const t=new $((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteUsersModal.close()));const n=new $((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=cn(this.state);this.actions.deleteUsers(e),this.deleteUsersModal.close()}));const r=new Ws(null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteUsersModal.beforeOpen=()=>{const e=dn(this.state);r.text=`Delete ${e}?`}}))},s})),qs=s((t=>{var n,i,s,a;return a=class extends(e(l,Ls,Ds,Fs)(t)){constructor(){super(...arguments),n.add(this),s.set(this,d((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this),this.subscribe(o(this,s,"f").bind(this),un)}))}},s=new WeakMap,n=new WeakSet,i=function(){var e;this.deleteButton=new $(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-users"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteUsersModal.open()}))},a}));class Bs extends T{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)}}const Hs=s((t=>{var n,i,s,a;return a=class extends(e(l,Ls,Ds)(t)){constructor(){super(...arguments),n.add(this),i.set(this,p((()=>{this.actions.searchUsers({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",s).call(this)}))}},i=new WeakMap,n=new WeakSet,s=function(){var e;this.searchInput=new Bs(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(o(this,i,"f"))},a})),Js="descope-notification";class Ks extends T{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()}}const Vs=s((t=>{var n,i;const s=e(a,P,_)(t);return i=class extends s{constructor(){super(...arguments),n.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Ks{setContent(t){const n="string"==typeof t?D(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const t=((e={})=>{const t=document.createElement(Js);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(t),new(o(this,n,"f"))(t,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.loadDescopeUiComponents([Js])}))}},n=new WeakMap,i}));const Zs={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="white"/>\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="#FFDFDD"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Ys=s((t=>{var n,i,s,c,u;return u=class extends(e(l,Ds,Vs,a)(t)){constructor(){super(...arguments),n.add(this),c.set(this,d((e=>{e.length&&(e.forEach((({type:e,msg:t})=>{const r=o(this,n,"m",s).call(this,e);r.setContent(o(this,n,"m",i).call(this,{type:e,msg:t})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(o(this,c,"f").bind(this),sn)}))}},c=new WeakMap,n=new WeakSet,i=function({type:e,msg:t}){const n=Zs[e],r=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="white"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${r.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},u}));const Xs=/^descope-grid-([^-]+)-column$/,Gs={text:class extends T{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 T{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)}}}};class Qs extends T{constructor(){super(...arguments),this.nodeName="descope-grid"}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 r=null===(n=Xs.exec(t.localName))||void 0===n?void 0:n[1],o=Gs[r];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}}const ea=s((t=>{var n,i,s,a,c;return c=class extends(e(Ds,l,Ls)(t)){constructor(){super(...arguments),n.add(this),s.set(this,d((e=>{this.usersTable.data=e}))),a.set(this,p(((e,t)=>{const n=[],{value:r}=t;if(r){const t=e.path;n.push({field:t,desc:"desc"===r})}this.actions.searchUsers({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),o(this,n,"m",i).call(this),this.usersTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{o(this,a,"f").call(this,e.target,e.detail)}))})),o(this,s,"f").call(this,an(this.state)),this.subscribe(o(this,s,"f").bind(this),an)}))}},s=new WeakMap,a=new WeakMap,n=new WeakSet,i=function(){var e;this.usersTable=new Qs(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="users-table"]'),{logger:this.logger}),this.usersTable.onSelectedItemsChange((e=>{this.actions.setSelectedUsersIds(e.detail.value.map((({loginIds:e})=>e)))}))},c})),ta=s((t=>class extends(e(u,M,ea,zs,qs,Hs,Ys)(t)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.actions.searchUsers()}))}})),na=e((t=>class extends(e(ta)(t)){}))(HTMLElement);var ra,oa,ia,sa;customElements.define("descope-user-management-widget",na);function aa(e,t){const n=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r],i=e[o],s=t[o];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!aa(i,s))return!1}else if(i!==s)return!1}return!0}class ca{constructor(e={},{updateOnlyOnChange:t=!0}={}){ra.set(this,void 0),oa.set(this,{}),ia.set(this,0),sa.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,ra,"f")):e,n=Object.assign(Object.assign({},o(this,ra,"f")),t);if(!o(this,sa,"f")||!aa(o(this,ra,"f"),n)){const e=o(this,ra,"f");i(this,ra,n,"f"),Object.freeze(o(this,ra,"f")),setTimeout((()=>{Object.values(o(this,oa,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,ra,e,"f"),i(this,sa,t,"f")}get current(){return Object.assign({},o(this,ra,"f"))}subscribe(e){return i(this,ia,o(this,ia,"f")+1,"f"),o(this,oa,"f")[o(this,ia,"f")]=e,o(this,ia,"f").toString()}unsubscribe(e){const t=!!o(this,oa,"f")[e];return t&&delete o(this,oa,"f")[e],t}unsubscribeAll(){return i(this,oa,{},"f"),!0}}ra=new WeakMap,oa=new WeakMap,ia=new WeakMap,sa=new WeakMap;const la=(e,t,n,r={})=>{var o,i,s,a;return[Math.min(Math.max(t,("all"===r.left?e.offsetWidth:null!==(o=r.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===r.right?e.offsetWidth:null!==(i=r.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===r.top?e.offsetHeight:null!==(s=r.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===r.bottom?e.offsetHeight:null!==(a=r.bottom)&&void 0!==a?a:0))]};var ua,da,ha,pa,fa,ga,ma,va,ya,ba;const wa=document.createElement("template");wa.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class ka extends HTMLElement{constructor(){var e;super(),ua.add(this),da.set(this,new ca({messages:[]})),ha.set(this,void 0),pa.set(this,void 0),fa.set(this,void 0),ga.set(this,{resize:o(this,ua,"m",ba).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(wa.content.cloneNode(!0)),i(this,ha,this.shadowRoot.querySelector(".debugger"),"f"),i(this,pa,o(this,ha,"f").querySelector(".content"),"f"),i(this,fa,o(this,ha,"f").querySelector(".header"),"f")}updateData(e){o(this,da,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let r=0,o=0,i=0,s=0;function a(t){t.preventDefault(),r=i-t.clientX,o=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=la(e,e.offsetLeft-r,e.offsetTop-o,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,ha,"f"),o(this,fa,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ga,"f").resize),(e=o(this,ha,"f")).onmousemove=t=>{var n;const r=t.target;(r.w&&r.w!==r.offsetWidth||r.h&&r.h!==r.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),r.w=r.offsetWidth,r.h=r.offsetHeight},o(this,ha,"f").onresize=o(this,ua,"m",ya).bind(this),o(this,da,"f").subscribe(o(this,ua,"m",ma).bind(this))}disconnectedCallback(){o(this,da,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ga,"f").resize)}}da=new WeakMap,ha=new WeakMap,pa=new WeakMap,fa=new WeakMap,ga=new WeakMap,ua=new WeakSet,ma=function(e){o(this,ua,"m",va).call(this,e),o(this,ua,"m",ya).call(this)},va=function(e){o(this,pa,"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("")},ya=function(){o(this,pa,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),r=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;r||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},ba=function(){const[e,t]=la(o(this,ha,"f"),Number.parseInt(o(this,ha,"f").style.left,10),Number.parseInt(o(this,ha,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,ha,"f").style.top=`${t}px`,o(this,ha,"f").style.left=`${e}px`},customElements.define("descope-debugger",ka);var ja=Object.freeze({__proto__:null,default:ka})}();
4
4
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/user-management-widget",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/descope-js",
6
6
  "bugs": {
@@ -75,7 +75,7 @@
75
75
  "redux-thunk": "3.1.0",
76
76
  "reselect": "5.0.1",
77
77
  "tslib": "2.6.2",
78
- "@descope/web-js-sdk": "1.9.4"
78
+ "@descope/web-js-sdk": "1.9.5"
79
79
  },
80
80
  "overrides": {
81
81
  "terser": "5.21.0"