@descope/role-management-widget 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +2 -2
- package/dist/index.d.ts +56 -51
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/role-management-widget v0.7.
|
|
3
|
+
* @descope/role-management-widget v0.7.2
|
|
4
4
|
*/
|
|
5
|
-
this["descope-role-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function r(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),l=e=>{let t,n;return(...o)=>(t&&a(t,o)||(t=o,n=e(...o)),n)},c=e=>(t,...n)=>t.reduce(((t,o,r)=>{var i;return`${t}${o}${(null===(i=null==n?void 0:n[r])||void 0===i?void 0:i[e>1?1:0])||""}`}),""),d=(e,t=500)=>{let n;return function(...o){clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}},u=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const o=e(n);return o[t]=!0,o}};var h,p,f,g;function v(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!v(i,s))return!1}else if(i!==s)return!1}return!0}let m=class{constructor(e={},{forceUpdate:t=!1}={}){h.set(this,void 0),p.set(this,{}),f.set(this,0),g.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,h,"f")):e,n=Object.assign(Object.assign({},o(this,h,"f")),t);if(o(this,g,"f")||!v(o(this,h,"f"),n)){const e=o(this,h,"f");r(this,h,n,"f"),Object.freeze(o(this,h,"f")),setTimeout((()=>{Object.values(o(this,p,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},r(this,h,e,"f"),r(this,g,t,"f")}get current(){return Object.assign({},o(this,h,"f"))}subscribe(e){return r(this,f,o(this,f,"f")+1,"f"),o(this,p,"f")[o(this,f,"f")]=e,o(this,f,"f").toString()}unsubscribe(e){const t=!!o(this,p,"f")[e];return t&&delete o(this,p,"f")[e],t}unsubscribeAll(){return r(this,p,{},"f"),!0}};h=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap;const y=["error","warn","info","debug"],w={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},b=u((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",i).call(this,w))}set logger(e){r(this,n,o(this,t,"m",i).call(this,e||w),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return y.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),k="undefined"!=typeof localStorage,I="https://static.descope.com/pages",S="https://static2.descope.com/pages",O=k&&localStorage.getItem("base.content.url")||"",x=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,j=u((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(r(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),C=u((e=>{var t,n;const r=i(b,j)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,r;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,r=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>r(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&r(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const r=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(r,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),R=e=>t=>{var n,r,s;const a=i(b,j,C)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",r).bind(this))}async init(){var e;l.forEach((e=>o(this,n,"m",r).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,r=function(t,n){const o=e[t],r="function"==typeof o?o(t,n):o;r&&this.logger.error(r)},s};R.missingAttrValidator=x;const E=u((e=>{const t=i(R({"project-id":x}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),_=u((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),T="Trying the next fallback URL...",A=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(o){return null==n||n.debug(`Network error fetching URL ${e} [${o.message}], retrying...`),fetch(e,t)}};const $=u((e=>{var t,n,s,a,l,c,d;const u=i(b,E,_)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const i=o(this,t,"m",l).call(this,e),c=Array.isArray(i)?e=>{const{baseUrl:t}=i[e];r(this,s,t,"f");for(let t=0;t<e;t++){const e=i[t].baseUrl;o(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const r=Array.isArray(e)?e:[e];for(let e=0;e<r.length;e++){const i=r[e],s=e===r.length-1;try{const r=await A(i.toString(),t,{logger:n});if(r.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${i}`),r;const a=`Error fetching URL ${i} [${r.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${T}`)}catch(e){const t=`Error fetching URL ${i} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${T}`)}}})(i,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const i=O||this.baseStaticUrl;if(i)return o(this,t,"m",c).call(this,e,i);o(this,n,"f")!==this.baseUrl&&(r(this,n,this.baseUrl,"f"),r(this,s,void 0,"f"),o(this,a,"f").clear());const l=[];if(o(this,s,"f"))l.push(o(this,t,"m",c).call(this,e,o(this,s,"f"))),o(this,s,"f")===I&&l.push(o(this,t,"m",c).call(this,e,S));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&l.push(o(this,t,"m",c).call(this,e,n)),o(this,a,"f").has(I)||l.push(o(this,t,"m",c).call(this,e,I)),l.push(o(this,t,"m",c).call(this,e,S))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=I}){const r=new URL(o);return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,n,t),r.baseUrl=o,r}({projectId:this.projectId,filename:e,baseUrl:t})},d})),M=u((e=>{var t,n;const r=i(R({"project-id":x}))(e);return n=class extends r{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),P=u((e=>{var t,n,s,a,l;const c=i($,M,j)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",o(this,t,"m",n).bind(this))}get config(){return o(this,s,"f")||r(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){r(this,s,void 0,"f")},l})),U=u((e=>{var t,n,s,a,l,c,d;return d=class extends(i(j,b)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,r)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,r),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var r;null===(r=super.onLogEvent)||void 0===r||r.call(this,e,n),"error"===e&&o(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),r(this,n,null,"f")},a=async function(){r(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Na})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var r;e&&(null===(r=o(this,n,"f"))||void 0===r||r.updateData({title:e,description:t}))},d})),D=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],N=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},L=(e,t,n)=>new Promise(((o,r)=>{const i=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);i.onerror=e=>{i.setAttribute("status","error"),r(e)},i.onload=()=>{i.setAttribute("status","loaded"),o(i)},i.src=t.toString(),document.body.appendChild(i)})),W=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},F=u((e=>{const t=i(b)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[],r){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${r?" with SRI integrity check":""}`),(async(e,t)=>{for(const o of e){const{id:e,url:r,integrity:i}=o,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await W(s,i),o}catch(e){t(o,!0)}else try{return await L(e,r,i),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="",r)=>e.reduce(((e,i)=>{const s=i;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${o}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${N(a)}`};return r&&(l.integrity=r),[...e,l]}),[]))([...o,this.baseCdnUrl,...D],e,t,n,r),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),q="base.ui.components.url",z=k&&localStorage.getItem(q),B=u((e=>{var t,n,s,a,l,c,d;const u=i(b,P,F)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return o(this,a,"f")||r(this,a,o(this,t,"m",c).call(this),"f"),o(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await o(this,t,"m",n).call(this),r=await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[z],r),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),J=u((e=>{var t,n,r;const s=i(j,C)(e);return r=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",o(this,t,"m",n).bind(this)),o(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},r}));class V{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const H=u((e=>{const t=i(J)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new V(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const o=[...e.adoptedStyleSheets||[]];o[t?"unshift":"push"](n),e.adoptedStyleSheets=o}}return n}}})),K="content-root",Z="root",X=u((e=>{const t=i(H)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Z}">\n <div id="${K}"></div>\n </div>\n `,this.injectStyle(`\n #${Z}, #${K} {\n height: 100%;\n }\n #${Z} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(K),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Z)}}})),Y="descope-modal";var G,Q;let ee=class{constructor(e,t){G.set(this,void 0),this.nodeName="",r(this,G,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,G,"f"))}get ele(){var e,t;const n="function"==typeof o(this,G,"f")?o(this,G,"f").call(this):o(this,G,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};G=new WeakMap;let te=class extends ee{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 ne=/^descope-grid-([^-]+)-column$/,oe={text:class extends ee{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 ee{constructor(){super(...arguments),this.nodeName="descope-grid-custom-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}}};let re=class extends ee{constructor(){super(...arguments),this.nodeName="descope-grid",Q.set(this,void 0)}onSelectedItemsChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("selected-items-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get columns(){return this.ele?Array.from(this.ele.children).reduce(((e,t)=>{var n;const o=null===(n=ne.exec(t.localName))||void 0===n?void 0:n[1],r=oe[o];return r?(e.push(new r(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const r=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);r&&this.ele.columns&&(a(r,this.ele.columns)||(this.ele.columns=r,null===(n=o(this,Q,"f"))||void 0===n||n.call(this,r)))}onColumnsChange(e){r(this,Q,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var ie;Q=new WeakMap;let se=class extends ee{constructor(){super(...arguments),ie.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,ie,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,ie,"f").content.cloneNode(!0)))}setContent(e){r(this,ie,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};ie=new WeakMap;let ae=class extends ee{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}},le=class extends ee{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()}},ce=class extends ee{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)}},de=class extends ee{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const ue=u((e=>{var t,n;const r=i(j,X,B)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends se{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Y);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Y]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),he="descope-notification",pe=u((e=>{var t,n;const r=i(j,X,B)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends le{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(he);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([he])}},t=new WeakMap,n})),fe=(e,t,n="")=>Object.entries(e).reduce(((e,[o,r])=>{if(!/^[a-zA-Z0-9-]+$/.test(o))return t("Ignoring invalid override-css token path segment"),e;const i=n?`${n}-${o}`:o;if("object"==typeof r&&null!==r)return e+fe(r,t,i);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(r);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${i}:${s};`}),""),ge=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ve=u((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,y,w,b;const k=i(R({theme:ge}),$,j,B,P,X,C,H)(e);return b=class extends k{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),l.set(this,void 0),m.set(this,(()=>{o(this,t,"m",y).call(this),o(this,w,"f").call(this,"os"===this.getAttribute("theme"))})),w.set(this,(e=>{var n,r,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(r=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===r?void 0:r[s])||void 0===i||i.call(r,"change",(()=>o(this,t,"m",y).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,m,"f").call(this),await Promise.all([o(this,t,"m",u).call(this),o(this,t,"m",p).call(this)]),await o(this,t,"m",h).call(this),this.observeAttributes(["theme"],o(this,m,"f")),this.observeAttributes(["theme-override"],(()=>o(this,t,"m",h).call(this))),this.observeAttributes(["style-id"],(()=>{r(this,l,null,"f"),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",p).call(this)}))}},n=new WeakMap,s=new WeakMap,l=new WeakMap,m=new WeakMap,w=new WeakMap,t=new WeakSet,a=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,r,i,s,a;const l=null===(r=null===(o=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===o?void 0:o.colors)||void 0===r?void 0:r.primary,c=null===(a=null===(s=null===(i=e[t])||void 0===i?void 0:i.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${fe({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},c=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(q))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(q),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},d=function(){return o(this,l,"f")||(r(this,l,o(this,t,"m",c).call(this),"f"),o(this,l,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,l,"f")},u=async function(){var e,i;const s=await o(this,t,"a",d);s&&(o(this,n,"f")||r(this,n,this.injectStyle(""),"f"),o(this,n,"f").replaceSync(((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||"")))},h=async function(){var e;this.themeOverride?(o(this,s,"f")||r(this,s,this.injectStyle(""),"f"),o(this,s,"f").replaceSync(o(this,t,"m",a).call(this))):null===(e=o(this,s,"f"))||void 0===e||e.replaceSync("")},p=async function(){var e,n;const r=await o(this,t,"a",d);if(!r)return;const i=await this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components,dark:null===(n=null==r?void 0:r.dark)||void 0===n?void 0:n.components})},f=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],r=null==n?void 0:n.cssTemplate,i=o||r;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},g=async function(){const e=await o(this,t,"m",f).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},v=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},y=function(){o(this,t,"m",g).call(this),o(this,t,"m",v).call(this)},b}));var me=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ye=()=>Math.random().toString(36).substring(7).split("").join("."),we={INIT:`@@redux/INIT${ye()}`,REPLACE:`@@redux/REPLACE${ye()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ye()}`};function be(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 ke(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 Ie(e){let t=typeof e;return t=ke(e),t}function Se(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Ie(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: '${Ie(n)}'`);return n(Se)(e,t)}let o=e,r=t,i=new Map,s=i,a=0,l=!1;function c(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Ie(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),i=null}}}function h(e){if(!be(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Ie(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: '${Ie(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,r=o(r,e)}finally{l=!1}return(i=s).forEach((e=>{e()})),e}h({type:we.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${Ie(e)}`);o=e,h({type:we.REPLACE})},[me]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${Ie(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[me](){return this}}}}}function Oe(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function xe(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const r=t[o];void 0===e[r]&&Oe(`No reducer provided for key "${r}"`),"function"==typeof e[r]&&(n[r]=e[r])}const o=Object.keys(n);let r,i;r={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:we.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:we.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 '${we.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;{const o=function(e,t,n,o){const r=Object.keys(t),i=n&&n.type===we.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!be(e))return`The ${i} has unexpected type of "${Ie(e)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===we.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${r.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,r);o&&Oe(o)}let s=!1;const a={};for(let r=0;r<o.length;r++){const i=o[r],l=n[i],c=e[i],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=d,s=s||d!==c}return s=s||o.length!==Object.keys(e).length,s?a:e}}function je(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Ce(e){return be(e)&&"type"in e&&"string"==typeof e.type}var Re=Symbol.for("immer-nothing"),Ee=Symbol.for("immer-draftable"),_e=Symbol.for("immer-state"),Te=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function Ae(e,...t){{const n=Te[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var $e=Object.getPrototypeOf;function Me(e){return!!e&&!!e[_e]}function Pe(e){return!!e&&(De(e)||Array.isArray(e)||!!e[Ee]||!!e.constructor?.[Ee]||qe(e)||ze(e))}var Ue=Object.prototype.constructor.toString();function De(e){if(!e||"object"!=typeof e)return!1;const t=$e(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)===Ue}function Ne(e,t){0===Le(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Le(e){const t=e[_e];return t?t.type_:Array.isArray(e)?1:qe(e)?2:ze(e)?3:0}function We(e,t){return 2===Le(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Fe(e,t,n){const o=Le(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function qe(e){return e instanceof Map}function ze(e){return e instanceof Set}function Be(e){return e.copy_||e.base_}function Je(e,t){if(qe(e))return new Map(e);if(ze(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&De(e)){if(!$e(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[_e];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const r=o[t],i=n[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[r]})}return Object.create($e(e),n)}function Ve(e,t=!1){return Ke(e)||Me(e)||!Pe(e)||(Le(e)>1&&(e.set=e.add=e.clear=e.delete=He),Object.freeze(e),t&&Ne(e,((e,t)=>Ve(t,!0)))),e}function He(){Ae(2)}function Ke(e){return Object.isFrozen(e)}var Ze,Xe={};function Ye(e){const t=Xe[e];return t||Ae(0,e),t}function Ge(){return Ze}function Qe(e,t){t&&(Ye("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function et(e){tt(e),e.drafts_.forEach(ot),e.drafts_=null}function tt(e){e===Ze&&(Ze=e.parent_)}function nt(e){return Ze={drafts_:[],parent_:Ze,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ot(e){const t=e[_e];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function rt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[_e].modified_&&(et(t),Ae(4)),Pe(e)&&(e=it(t,e),t.parent_||at(t,e)),t.patches_&&Ye("Patches").generateReplacementPatches_(n[_e].base_,e,t.patches_,t.inversePatches_)):e=it(t,n,[]),et(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Re?e:void 0}function it(e,t,n){if(Ke(t))return t;const o=t[_e];if(!o)return Ne(t,((r,i)=>st(e,o,t,r,i,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return at(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let r=t,i=!1;3===o.type_&&(r=new Set(t),t.clear(),i=!0),Ne(r,((r,s)=>st(e,o,t,r,s,n,i))),at(e,t,!1),n&&e.patches_&&Ye("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function st(e,t,n,o,r,i,s){if(r===n&&Ae(5),Me(r)){const s=it(e,r,i&&t&&3!==t.type_&&!We(t.assigned_,o)?i.concat(o):void 0);if(Fe(n,o,s),!Me(s))return;e.canAutoFreeze_=!1}else s&&n.add(r);if(Pe(r)&&!Ke(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;it(e,r),t&&t.scope_.parent_||at(e,r)}}function at(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ve(t,n)}var lt={get(e,t){if(t===_e)return e;const n=Be(e);if(!We(n,t))return function(e,t,n){const o=ut(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!Pe(o)?o:o===dt(e.base_,t)?(pt(e),e.copy_[t]=ft(o,e)):o},has:(e,t)=>t in Be(e),ownKeys:e=>Reflect.ownKeys(Be(e)),set(e,t,n){const o=ut(Be(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=dt(Be(e),t),r=o?.[_e];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||We(e.base_,t)))return!0;pt(e),ht(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!==dt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,pt(e),ht(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Be(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Ae(11)},getPrototypeOf:e=>$e(e.base_),setPrototypeOf(){Ae(12)}},ct={};function dt(e,t){const n=e[_e];return(n?Be(n):e)[t]}function ut(e,t){if(!(t in e))return;let n=$e(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=$e(n)}}function ht(e){e.modified_||(e.modified_=!0,e.parent_&&ht(e.parent_))}function pt(e){e.copy_||(e.copy_=Je(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ne(lt,((e,t)=>{ct[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ct.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Ae(13),ct.set.call(this,e,t,void 0)},ct.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Ae(14),lt.set.call(this,e[0],t,n,e[0])};function ft(e,t){const n=qe(e)?Ye("MapSet").proxyMap_(e,t):ze(e)?Ye("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Ge(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=lt;n&&(r=[o],i=ct);const{revoke:s,proxy:a}=Proxy.revocable(r,i);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Ge()).drafts_.push(n),n}function gt(e){return Me(e)||Ae(10,e),vt(e)}function vt(e){if(!Pe(e)||Ke(e))return e;const t=e[_e];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Je(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Je(e,!0);return Ne(n,((e,t)=>{Fe(n,e,vt(t))})),t&&(t.finalized_=!1),n}var mt=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...r){return o.produce(e,(e=>t.call(this,e,...r)))}}let o;if("function"!=typeof t&&Ae(6),void 0!==n&&"function"!=typeof n&&Ae(7),Pe(e)){const r=nt(this),i=ft(e,void 0);let s=!0;try{o=t(i),s=!1}finally{s?et(r):tt(r)}return Qe(r,n),rt(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Re&&(o=void 0),this.autoFreeze_&&Ve(o,!0),n){const t=[],r=[];Ye("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}Ae(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const r=this.produce(e,t,((e,t)=>{n=e,o=t}));return[r,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Pe(e)||Ae(8),Me(e)&&(e=gt(e));const t=nt(this),n=ft(e,void 0);return n[_e].isManual_=!0,tt(t),n}finishDraft(e,t){const n=e&&e[_e];n&&n.isManual_||Ae(9);const{scope_:o}=n;return Qe(o,t),rt(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Ye("Patches").applyPatches_;return Me(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},yt=mt.produce;mt.produceWithPatches.bind(mt),mt.setAutoFreeze.bind(mt),mt.setUseStrictShallowCopy.bind(mt),mt.applyPatches.bind(mt),mt.createDraft.bind(mt),mt.finishDraft.bind(mt);var wt=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},bt=(e,t,n)=>{const{memoize:o,memoizeOptions:r}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...r);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},kt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var It=e=>Array.isArray(e)?e:[e];function St(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 Ot(e,t){const n=[],{length:o}=e;for(let r=0;r<o;r++)n.push(e[r].apply(null,t));return n}var xt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},jt=0,Ct=1;function Rt(){return{s:jt,v:void 0,o:null,p:null}}function Et(e,t={}){let n=Rt();const{resultEqualityCheck:o}=t;let r,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=Rt(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=Rt(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===Ct)l=t.v;else if(l=e.apply(null,arguments),i++,o){const e=r?.deref?.()??r;null!=e&&o(e,l)&&(l=e,0!==i&&i--);r="object"==typeof l&&null!==l||"function"==typeof l?new xt(l):l}return a.s=Ct,a.v=l,l}return s.clearCache=()=>{n=Rt(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function _t(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,r=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:l,memoizeOptions:c=[],argsMemoize:d=Et,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=It(c),f=It(u),g=St(e),v=l((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){r++;const e=Ot(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...kt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:wt},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:bt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=Ot(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Tt=_t(Et),At=Object.assign(((e,t=Tt)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})))}),{withTypes:()=>At});function $t(e){return({dispatch:t,getState:n})=>o=>r=>"function"==typeof r?r(t,n,e):o(r)}var Mt=$t(),Pt=$t;((...e)=>{const t=_t(...e)})(Et);var Ut="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?je:je.apply(null,arguments)},Dt=e=>e&&"function"==typeof e.match;function Nt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Ce(t)&&t.type===e,n}function Lt(e){return"function"==typeof e&&"type"in e&&Dt(e)}function Wt(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 Ft=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 qt(e){return Pe(e)?yt(e,(()=>{})):e}function zt(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Bt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Jt(e,t,n){const o=Vt(e,t,n);return{detectMutations:()=>Ht(e,t,o,n)}}function Vt(e,t=[],n,o="",r=new Set){const i={value:n};if(!e(n)&&!r.has(n)){r.add(n),i.children={};for(const r in n){const s=o?o+"."+r:r;t.length&&-1!==t.indexOf(s)||(i.children[r]=Vt(e,t,n[r],s))}}return i}function Ht(e,t=[],n,o,r=!1,i=""){const s=n?n.value:void 0,a=s===o;if(r&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:i};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let r in l){const s=i?i+"."+r:r;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Ht(e,t,n.children[r],o[r],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Kt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||be(e)}function Zt(e,t="",n=Kt,o,r=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),l=r.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(r.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Zt(c,a,n,o,r,i),s))return s}return i&&Xt(e)&&i.add(e),!1}function Xt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Xt(t))return!1;return!0}function Yt(e){return"boolean"==typeof e}var Gt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:r=!0}=e??{};let i=new Ft;if(t&&(Yt(t)?i.push(Mt):i.push(Pt(t.extraArgument))),n){let e={};Yt(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,o,r){return JSON.stringify(e,n(t,r),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(r,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,r):o.push(r),~n.indexOf(i)&&(i=t.call(this,r,i))}else n.push(i);return null==e?i:e.call(this,r,i)}},{isImmutable:o=Bt,ignoredPaths:r,warnAfter:i=32}=e;const s=Jt.bind(null,o,r);return({getState:e})=>{let n,o=e(),r=s(o);return a=>l=>{const c=Wt(i,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(o){let e={};Yt(o)||(e=o),i.push(function(e={}){{const{isSerializable:t=Kt,getEntries:n,ignoredActions:o=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!Ce(u))return c(u);const h=c(u),p=Wt(s,"SerializableStateInvariantMiddleware");return l||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=Zt(u,"",t,n,r,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const o=Zt(e.getState(),"",t,n,i,d);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(r){let e={};Yt(r)||(e=r),i.unshift(function(e={}){const{isActionCreator:t=Lt}=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},Qt=e=>t=>{setTimeout(t,e)},en="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Qt(10),tn=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Ft(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let r=!0,i=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?en:"callback"===e.type?e.queueNotification:Qt(e.timeout),c=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>r&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return r=!e?.meta?.RTK_autoBatch,i=!r,i&&(s||(s=!0,l(c))),o.dispatch(e)}finally{r=!0}}})})("object"==typeof n?n:void 0)),o};function nn(e){const t=Gt(),{reducer:n,middleware:o,devTools:r=!0,preloadedState:i,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!be(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=xe(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=je;r&&(c=Ut({trace:!0,..."object"==typeof r&&r}));const d=function(...e){return t=>(n,o)=>{const r=t(n,o);let i=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:r.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=je(...a)(r.dispatch),{...r,dispatch:i}}}(...l),u=tn(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Se(a,i,c(...h))}function on(e){const t={},n=[];let o;const r={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,r},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),r},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,r}};return e(r),[t,n,o]}function rn(...e){return t=>e.some((e=>((e,t)=>Dt(e)?e.match(t):e(t))(e,t)))}var sn=["name","message","stack","code"],an=class{constructor(e,t){this.payload=e,this.meta=t}_type},ln=class{constructor(e,t){this.payload=e,this.meta=t}_type},cn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of sn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},dn=(()=>{function e(e,t,n){const o=Nt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),r=Nt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=Nt(e+"/rejected",((e,t,o,r,i)=>({payload:r,error:(n&&n.serializeError||cn)(e||"Rejected"),meta:{...i||{},arg:o,requestId:t,rejectedWithValue:!!r,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let i=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(r(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new an(e,t),fulfillWithValue:(e,t)=>new ln(e,t)})).then((t=>{if(t instanceof an)throw t;return t instanceof ln?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof an?i(null,c,e,t.payload,t.meta):i(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(un)})}}),{pending:r,rejected:i,fulfilled:o,settled:rn(i,o),typePrefix:e})}return e.withTypes=()=>e,e})();function un(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var hn=Symbol.for("rtk-slice-createasyncthunk");function pn(e,t){return`${e}/${t}`}function fn(e,t,n,o){function r(r,...i){let s=n.call(e,r);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return r.unwrapped=t,r}var gn=function({creators:e}={}){const t=e?.asyncThunk?.[hn];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const r=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(r),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?on(e.extraReducers):[e.extraReducers],r={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,r,i]=on(t);if(function(e){return"function"==typeof e}(e))n=()=>qt(e());else{const t=qt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...r.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(Me(e)){const o=n(e,t);return void 0===o?e:o}if(Pe(e))return yt(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in r)e.addCase(t,r[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}i.forEach((o=>{const i=r[o],s={reducerName:o,type:pn(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,r){let i,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=o.reducer,s=o.prepare}else i=o;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?Nt(e,s):Nt(e))}(s,i,a):function({type:e,reducerName:t},n,o,r){if(!r)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=r(e,i,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.exposeCaseReducer(t,{fulfilled:s||vn,pending:a||vn,rejected:l||vn,settled:c||vn})}(s,i,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=zt(d,this,{insert:()=>new WeakMap});return zt(n,t,{insert:()=>{const n={};for(const[o,r]of Object.entries(e.selectors??{}))n[o]=fn(this,r,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function vn(){}var mn="listenerMiddleware";Nt(`${mn}/add`),Nt(`${mn}/removeAll`),Nt(`${mn}/remove`);const yn=e=>u((t=>{const n=gn(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(b)(t)){constructor(...e){super(...e);const t=nn({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),r=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{un(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},i=Object.keys(o).reduce(((e,t)=>(e[t]=r(o[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),wn=u((e=>class extends(b(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}})),bn=u((e=>{const t=i(R({"widget-id":x}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}}));u((e=>{const t=i(P,bn)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}}));const kn=u((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),In=e=>e.selectedRolesIds,Sn=e=>e.notifications,On=e=>e.tenantPermissions.data||[],xn=Tt((e=>e.rolesList.data),(e=>e.map((e=>{var t;return Object.assign(Object.assign({},e),{editable:0===(null===(t=null==e?void 0:e.tenantId)||void 0===t?void 0:t.length)?"no":"yes"})})))),jn=Tt(In,xn,((e,t)=>t.filter((t=>e.includes(t.name))))),Cn=Tt(In,(e=>!!e.length)),Rn=Tt(In,(e=>1===e.length)),En=Tt(jn,Rn,((e,t)=>t&&"yes"===e[0].editable)),_n=Tt(jn,(e=>1===e.length?e[0].name:`${e.length} roles`)),Tn=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)}))}))},An=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}}),$n=({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)})}}),Mn=dn("roles/create",((e,{extra:{api:t}})=>t.role.create(e))),Pn=Tn(Mn)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},An((e=>e.createRole)),$n({getSuccessMsg:()=>"Role created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Un={action:Mn,reducer:Pn},Dn=dn("roles/delete",((e,{extra:{api:t}})=>t.role.deleteBatch(e))),Nn=Tn(Dn)({onFulfilled:(e,t)=>{e.rolesList.data=e.rolesList.data.filter((e=>{var n;return 0===(null===(n=null==e?void 0:e.tenantId)||void 0===n?void 0:n.length)||!t.meta.arg.includes(e.name)})),e.selectedRolesIds=[]}},An((e=>e.deleteRole)),$n({getSuccessMsg:e=>c(e.meta.arg.length)`${["",e.meta.arg.length]} ${["R","r"]}ole${["","s"]} deleted successfully`,getErrorMsg:e=>c(e.meta.arg.length)`Failed to delete role${["","s"]}`})),Ln={action:Dn,reducer:Nn},Wn=dn("roles/duplicate",((e,{extra:{api:t}})=>t.role.create(e))),Fn=Tn(Wn)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},An((e=>e.duplicateRole)),$n({getSuccessMsg:()=>"Role duplicated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to duplicate role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),qn={action:Wn,reducer:Fn},zn=dn("roles/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.role.search(Object.assign(Object.assign({},o),e))})),Bn=Tn(zn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.rolesList.data=t.payload}},An((e=>e.rolesList))),Jn={action:zn,reducer:Bn},Vn=dn("roles/update",((e,{extra:{api:t}})=>t.role.update(e))),Hn=Tn(Vn)({onFulfilled:(e,t)=>{const n=e.rolesList.data.findIndex((e=>e.name===t.payload.oldName));-1!==n&&(e.rolesList.data[n]=t.payload)}},An((e=>e.updateRole)),$n({getSuccessMsg:()=>"Role updated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to update role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Kn={action:Vn,reducer:Hn},Zn=dn("tenant/getTenantPermissions",((e,{extra:{api:t}})=>t.tenant.getTenantPermissions())),Xn={action:Zn,reducer:Tn(Zn)({onFulfilled:(e,t)=>{e.tenantPermissions.data=t.payload.permissions}},An((e=>e.tenantPermissions)))},Yn={rolesList:{data:[],loading:!1,error:null},createRole:{loading:!1,error:null},duplicateRole:{loading:!1,error:null},updateRole:{loading:!1,error:null},deleteRole:{loading:!1,error:null},tenantPermissions:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedRolesIds:[],notifications:[]};class Gn extends Error{}function Qn(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function eo(e,t){if("string"!=typeof e)throw new Gn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,o=e.split(".")[n];if("string"!=typeof o)throw new Gn(`Invalid token specified: missing part #${n+1}`);let r;try{r=Qn(o)}catch(e){throw new Gn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new Gn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Gn.prototype.name="InvalidTokenError";var to={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const no="<region>",oo=`https://api.${no}descope.com`,ro=6e5,io="dct",so=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},ao=[503,521,522,524,530],lo=[100,5e3,5e3],co=e=>new Promise((t=>setTimeout(t,e))),uo=e=>async(...t)=>{let n=await e(...t),o=0;for(;ao.includes(n.status)&&o<lo.length;)await co(lo[o]),n=await e(...t),o++;o>0&&(n.retries=o);const r=await n.text();return n.text=()=>Promise.resolve(r),n.json=()=>Promise.resolve(JSON.parse(r)),n.clone=()=>n,n};let ho;const po=()=>{if(ho)return ho;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return ho=`${t}-${n}`,ho};var fo,go;(go=fo||(fo={})).get="GET",go.delete="DELETE",go.post="POST",go.put="PUT",go.patch="PATCH";const vo=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(no,r?r+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{i=`${i}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return i},mo=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),yo={"Content-Type":"application/json"},wo=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},bo=(e,t)=>{const n={"x-descope-sdk-session-id":po(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.62.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},ko=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var Io=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:r,hooks:i,cookiePolicy:s,fetch:a})=>{const l=e||oo,c=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>so().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await uo(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return so().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:uo(n)})(r,a),d=async e=>{var r;const a=(null==i?void 0:i.beforeRequest)?i.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:mo(wo(t,g),bo(t,o),(null==n?void 0:n.baseHeaders)||{},ko(v)?yo:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const y=await c(vo({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(e,null==y?void 0:y.clone()),null==i?void 0:i.transformResponse){const e=await y.json(),t=(w=(null===(r=y.headers)||void 0===r?void 0:r.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function o(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function r(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const i=n;let s,a,l=!1;for(;o();)if(","===e.charAt(n)){for(s=n,n+=1,o(),a=n;n<e.length&&r();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(i,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(i,e.length))}return t}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}var w;return y};return{get:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:fo.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:fo.post,token:r}),patch:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:fo.patch,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:fo.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:fo.delete,token:o}),hooks:i,buildUrl:(e,n)=>vo({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=r.length&&(await Promise.allSettled(null==r?void 0:r.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},So=429;function Oo(e,t,n){var o;let r=xo(e);if(t){if(!(null==r?void 0:r.tenants)&&(null==r?void 0:r[io])===t)return(null==r?void 0:r[n])||[];r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]}const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function xo(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return eo(e)}function jo(e){const{exp:t}=xo(e);return(new Date).getTime()/1e3>t}function Co(e){let t=xo(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Ro(e,t){return Oo(e,t,"permissions")}function Eo(e,t){return Oo(e,t,"roles")}const _o=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function To(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=i:(r.error=i,o.status===So&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}function Ao(e){var t;return(null===(t=xo(e))||void 0===t?void 0:t[io])||""}const $o=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Mo=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},Po=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Uo=e=>t=>e.test(t),Do=Uo(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),No=Uo(/^\+[1-9]{1}[0-9]{3,14}$/),Lo=$o(Do,'"{val}" is not a valid email'),Wo=$o(No,'"{val}" is not a valid phone number'),Fo=$o((e=>e.length>=1),"Minimum length is 1");const qo=$o((e=>"string"==typeof e),"Input is not a string"),zo=$o((e=>Array.isArray(e)),"Input is not an array"),Bo=$o((e=>"boolean"==typeof e),"Input is not a boolean"),Jo=$o((e=>void 0===e),"Input is defined"),Vo=Mo([qo(),Jo()],"Input is not a string or undefined"),Ho=Mo([zo(),Bo()],"Input is not an array or boolean"),Ko=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Po(...e).validate(n[t]))),t(...n)),Zo=e=>[qo(`"${e}" must be a string`)],Xo=e=>[Vo(`"${e}" must be string or undefined`)],Yo=e=>[qo(`"${e}" must be a string`),Fo(`"${e}" must not be empty`)],Go=e=>[qo(`"${e}" must be a string`),Lo()],Qo=e=>[qo(`"${e}" must be a string`),Wo()],er=Ko(Yo("accessKey")),tr=e=>({exchange:er(((t,n)=>To(e.post(to.accessKey.exchange,{loginOptions:n},{token:t}))))}),nr=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const s=i[r];i[r]=n(s)})),e),or=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||ro,ro)});var rr,ir;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(rr||(rr={})),function(e){e.email="email"}(ir||(ir={}));const sr=Object.assign(Object.assign({},rr),ir);var ar;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(ar||(ar={}));const lr=Yo("loginId"),cr=Ko(Yo("token")),dr=Ko(lr),ur=Ko(Yo("pendingRef")),hr=Ko(lr,Go("email")),pr=e=>({verify:cr((t=>To(e.post(to.enchantedLink.verify,{token:t})))),signIn:dr(((n,o,r={},i)=>{var{providerId:s}=r,a=t(r,["providerId"]);return To(e.post(_o(to.enchantedLink.signIn,sr.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:i}))})),signUpOrIn:dr(((n,o,r={})=>{var{providerId:i}=r,s=t(r,["providerId"]);return To(e.post(_o(to.enchantedLink.signUpOrIn,sr.email),{loginId:n,URI:o,loginOptions:s,providerId:i}))})),signUp:dr(((n,o,r,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return To(e.post(_o(to.enchantedLink.signUp,sr.email),{loginId:n,URI:o,user:r,loginOptions:a,providerId:s}))})),waitForSession:ur(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=or(n);let s;const a=setInterval((async()=>{const n=await e.post(to.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(To(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:hr(((t,n,o,r,i)=>To(e.post(to.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),fr=Ko(Yo("flowId")),gr=Ko(Yo("executionId"),Yo("stepId"),Yo("interactionId")),vr=e=>({start:fr(((t,n,o,r,i,s,a,l=!1)=>To(e.post(to.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,componentsVersion:i,flowVersions:s,input:a,isCustomScreen:l})))),next:gr(((t,n,o,r,i,s,a=!1)=>To(e.post(to.flow.next,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:s,isCustomScreen:a}))))}),mr=Yo("loginId"),yr=Ko(Yo("token")),wr=Ko(mr),br=Ko(mr,Qo("phone")),kr=Ko(mr,Go("email")),Ir=Object.keys(sr).filter((e=>e!==rr.voice&&e!==rr.im)),Sr=e=>({verify:yr((t=>To(e.post(to.magicLink.verify,{token:t})))),signIn:Ir.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:wr(((n,r,i={},s)=>{var{providerId:a}=i,l=t(i,["providerId"]);return To(e.post(_o(to.magicLink.signIn,o),{loginId:n,URI:r,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:Ir.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:wr(((n,r,i,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return To(e.post(_o(to.magicLink.signUp,o),{loginId:n,URI:r,user:i,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:Ir.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:wr(((n,r,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return To(e.post(_o(to.magicLink.signUpOrIn,o),{loginId:n,URI:r,loginOptions:a,providerId:s}))}))})),{}),update:{email:kr(((t,n,o,r,i)=>To(e.post(to.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(rr).filter((e=>e!==rr.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:br(((t,o,r,i,s)=>To(e.post(_o(to.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:r},s),{token:i}))))})),{})}});var Or;!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"}(Or||(Or={}));const xr=Ko(Yo("code")),jr=e=>({start:Object.assign(((t,n,o,r,i)=>To(e.post(to.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),i&&{loginHint:i}),token:r}))),Object.keys(Or).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r,i)=>To(e.post(to.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),i&&{loginHint:i}),token:r}))})),{})),exchange:xr((t=>To(e.post(to.oauth.exchange,{code:t})))),startNative:(t,n,o)=>To(e.post(to.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,r,i)=>To(e.post(to.oauth.finishNative,{provider:t,stateId:n,user:o,code:r,idToken:i})),getOneTapClientId:t=>To(e.get(to.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,r)=>To(e.post(to.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r})),exchangeOneTapIDToken:(t,n,o,r)=>To(e.post(to.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r}))}),Cr=Yo("appId"),Rr=Ko(Cr),Er=e=>({connect:Rr(((t,n,o)=>{const r=null==n?void 0:n.tenantId,i=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,To(e.post(to.outbound.connect,{appId:t,tenantId:r,tenantLevel:i,options:n},{token:o}))}))}),_r=Yo("loginId"),Tr=Ko(_r,Yo("code")),Ar=Ko(_r),$r=Ko(_r,Qo("phone")),Mr=Ko(_r,Go("email")),Pr=e=>({verify:Object.keys(sr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Tr(((t,o)=>To(e.post(_o(to.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(sr).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ar(((n,r={},i)=>{var{providerId:s}=r,a=t(r,["providerId"]);return To(e.post(_o(to.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:i}))}))})),{}),signUp:Object.keys(sr).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ar(((n,r,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return To(e.post(_o(to.otp.signUp,o),{loginId:n,user:r,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(sr).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ar(((n,r={})=>{var{providerId:i}=r,s=t(r,["providerId"]);return To(e.post(_o(to.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:i}))}))})),{}),update:{email:Mr(((t,n,o,r)=>To(e.post(to.otp.update.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(rr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:$r(((t,o,r,i)=>To(e.post(_o(to.otp.update.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),Ur=Ko(Yo("tenant")),Dr=Ko(Yo("code")),Nr=e=>({start:Ur(((t,n,o,r,i,s,a,l)=>To(e.post(to.saml.start,o||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),i&&{ssoId:i}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},r&&{token:r}))))),exchange:Dr((t=>To(e.post(to.saml.exchange,{code:t}))))}),Lr=Yo("loginId"),Wr=Ko(Lr,Yo("code")),Fr=Ko(Lr),qr=Ko(Lr),zr=e=>({signUp:Fr(((t,n)=>To(e.post(to.totp.signUp,{loginId:t,user:n})))),verify:Wr(((t,n,o,r)=>To(e.post(to.totp.verify,{loginId:t,code:n,loginOptions:o},{token:r})))),update:qr(((t,n)=>To(e.post(to.totp.update,{loginId:t},{token:n}))))}),Br=Yo("loginId"),Jr=Yo("newPassword"),Vr=Ko(Br,Yo("password")),Hr=Ko(Br),Kr=Ko(Br,Jr),Zr=Ko(Br,Yo("oldPassword"),Jr),Xr=e=>({signUp:Vr(((n,o,r,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return To(e.post(to.password.signUp,{loginId:n,password:o,user:r,loginOptions:a,providerId:s}))})),signIn:Vr(((n,o,r={})=>{var{providerId:i}=r,s=t(r,["providerId"]);return To(e.post(to.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:i}))})),sendReset:Hr(((t,n,o)=>To(e.post(to.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Kr(((t,n,o)=>To(e.post(to.password.update,{loginId:t,newPassword:n},{token:o})))),replace:Zr(((t,n,o)=>To(e.post(to.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>To(e.get(to.password.policy))}),Yr=Zo("loginId"),Gr=Yo("loginId"),Qr=Yo("origin"),ei=Ko(Gr,Qr,Yo("name")),ti=Ko(Gr,Qr),ni=Ko(Yr,Qr),oi=Ko(Gr,Qr,Xo("token")),ri=Ko(Yo("transactionId"),Yo("response")),ii=e=>({signUp:{start:ei(((t,n,o,r,i)=>To(e.post(to.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:i,passkeyOptions:r})))),finish:ri(((t,n)=>To(e.post(to.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:ni(((t,n,o,r,i)=>To(e.post(to.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i},{token:r})))),finish:ri(((t,n)=>To(e.post(to.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:ti(((t,n,o,r)=>To(e.post(to.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:r,passkeyOptions:o}))))},update:{start:oi(((t,n,o,r)=>To(e.post(to.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:r},{token:o})))),finish:ri(((t,n)=>To(e.post(to.webauthn.update.finish,{transactionId:t,response:n}))))}}),si=Zo("loginId"),ai=Ko(si),li=Ko(Yo("pendingRef")),ci=e=>({signUpOrIn:ai(((n,o={})=>{var{providerId:r}=o,i=t(o,["providerId"]);return To(e.post(to.notp.signUpOrIn,{loginId:n,loginOptions:i,providerId:r}))})),signUp:ai(((n,o,r={})=>{var{providerId:i}=r,s=t(r,["providerId"]);return To(e.post(to.notp.signUp,{loginId:n,user:o,providerId:i,loginOptions:s}))})),signIn:ai(((n,o={},r)=>{var{providerId:i}=o,s=t(o,["providerId"]);return To(e.post(to.notp.signIn,{loginId:n,loginOptions:s,providerId:i},{token:r}))})),waitForSession:li(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=or(n);let s;const a=setInterval((async()=>{const n=await e.post(to.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(To(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),di=Ko(Yo("token")),ui=Ko(Xo("token"));var hi,pi=Ko([(hi=Yo("projectId"),$o(((e,t)=>n=>Po(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let r=0,i=e===Object(e)?e:void 0;for(;null!=i&&r<o;)i=i[n[r++]];return r&&r===o&&void 0!==i?i:void 0})(n,e)))("projectId",hi))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:r,baseHeaders:i={},refreshCookieName:s,fetch:a}=e;return l=Io({baseUrl:o,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:r,baseConfig:{baseHeaders:i},refreshCookieName:s,fetch:a}),{accessKey:tr(l),otp:Pr(l),magicLink:Sr(l),enchantedLink:pr(l),oauth:jr(l),outbound:Er(l),saml:Nr(l),totp:zr(l),notp:ci(l),webauthn:ii(l),password:Xr(l),flow:vr(l),refresh:ui(((e,t,n,o)=>{const r={};n&&(r.externalToken=n);const i=o?to.tryRefresh:to.refresh;return To(l.post(i,r,{token:e,queryParams:t}))})),selectTenant:Ko([qo("tenantId")],[Vo('"token" must be string or undefined')])(((e,t)=>To(l.post(to.selectTenant,{tenant:e},{token:t})))),logout:ui((e=>To(l.post(to.logout,{},{token:e})))),logoutAll:ui((e=>To(l.post(to.logoutAll,{},{token:e})))),me:ui((e=>To(l.get(to.me,{token:e})))),myTenants:Ko([Ho('"tenants" must a string array or a boolean')],[Vo('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,To(l.post(to.myTenants,n,{token:t}))})),history:ui((e=>To(l.get(to.history,{token:e})))),isJwtExpired:di(jo),getTenants:di(Co),getJwtPermissions:di(Ro),getJwtRoles:di(Eo),getCurrentTenant:di(Ao),httpClient:l};var l})),fi=Object.assign(pi,{DeliveryMethods:sr});
|
|
6
|
-
/*! js-cookie v3.0.5 | MIT */function gi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var vi=function e(t,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=gi({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",gi({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,gi({},this.attributes,t))},withConverter:function(t){return e(gi({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var mi={default:"endpoint"},yi="Blocked by CSP",wi="The endpoint parameter is not a valid URL",bi="Failed to load the JS script of the agent",ki="9319";function Ii(e,t){var n,o,r,i,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),i=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},r=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===yi||s===wi)n.exclude(),i=0;else if(s===ki)n.exclude();else if(s===bi){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!r.has(l)&&(r.add(l),i=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=i?i:e.getTime()+o()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},r=t(e);return r.then((function(){return o()}),o),r.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,r=t[0],i=t[1];return(o=i,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(r)}))}))};return u(c).then((function(e){return[e,a]}))}var Si="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Oi=Si;function xi(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:Si,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return Ii(e,ji)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===ki?new Error(bi):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function ji(e){return function(e,t,n){var o,r=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=t,a())};r.addEventListener(i,s);var a=function(){return r.removeEventListener(i,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),o)return n(o);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(wi);var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(bi))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)}),(function(){throw new Error(yi)})).then(Ci)}function Ci(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(ki);return n}const Ri="3.2.0",Ei="undefined"!=typeof window,_i=Math.pow(2,31)-1,Ti=`https://descopecdn.com/npm/oidc-client-ts@${Ri}/dist/browser/oidc-client-ts.min.js`,Ai=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Ri}/dist/browser/oidc-client-ts.min.js`,$i=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Mi;const Pi=e=>{try{return eo(e).exp}catch(e){return null}},Ui=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Pi(n)},Di=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?Pi(o):void 0)},Ni=e=>{const{access_token:n,id_token:o,refresh_token:r,refresh_expire_in:i}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:o,refreshJwt:e.refreshJwt||r,sessionExpiration:e.sessionExpiration||Di(e),cookieExpiration:e.cookieExpiration||Ui(e)},s)},Li=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Wi=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return Ni(n)},Fi=()=>Ei&&!!window.descopeBridge,qi=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return $i.includes(n)},zi=void 0!==Mi||Ei&&void 0!==window.localStorage,Bi=(e,t)=>{var n,o;return null===(o=null===(n=Mi||Ei&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},Ji=e=>{var t,n;return null===(n=null===(t=Mi||Ei&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Vi=e=>{var t,n;return null===(n=null===(t=Mi||Ei&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},Hi=e=>{var t,n,o,r,i;return null!==(i=null!==(n=null===(t=null==Mi?void 0:Mi.key)||void 0===t?void 0:t.call(Mi,e))&&void 0!==n?n:Ei&&(null===(r=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===r?void 0:r.call(o,e)))&&void 0!==i?i:null},Ki=(...e)=>{console.debug(...e)},Zi=(...e)=>{console.warn(...e)},Xi=(e,t)=>{let n;var o;return t>0?(n=1e3*t,Ki(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>_i&&(Ki(`Timeout is too large (${n}ms), setting it to ${_i}ms`),n=_i),n},Yi="DS",Gi="DSR",Qi="DSI",es="DSRCN";function ts(e,t,n){if(t){const{cookieDomain:o,cookiePath:r,cookieSameSite:i,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=ns(o);vi.set(e,t,{path:r,domain:c?o:void 0,expires:l,sameSite:i,secure:a})}}function ns(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const os=e=>(null==e?void 0:e.cookieName)||Yi,rs=e=>(null==e?void 0:e.cookieName)||Gi;function is(e="",t){return vi.get(rs(t))||Ji(`${e}${Gi}`)||""}function ss(e="",t){return vi.get(os(t))||Ji(`${e}${Yi}`)||""}function as(e=""){return Ji(`${e}${Qi}`)||""}function ls(e="",t,n,o){Vi(`${e}${Gi}`),Vi(`${e}${Yi}`),Vi(`${e}${Qi}`),Vi(`${e}${es}`);const r=os(t);vi.remove(r,null==o?void 0:o.session);const i=rs(n);vi.remove(i,null==o?void 0:o.refresh)}const cs=(e,t,n)=>o=>{const r=Object.assign(o,{token:o.token||is(e,t)});if(!n){const t=function(e=""){return Ji(`${e}${es}`)}(e);t&&(r.headers=Object.assign(Object.assign({},r.headers||{}),{"x-descope-refresh-cookie-name":t}))}const i=function(e=""){return Ji(`${e}DTD`)||""}(e);return i&&(r.headers=Object.assign(Object.assign({},r.headers||{}),{"x-descope-trusted-device-token":i})),r},ds=Ei&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",us="vsid",hs="vrid",ps=(e=!1)=>{const t=Ji("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},fs=async(e,t=ds)=>{try{if(ps())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=r.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=xi({apiKey:e,endpoint:[o.toString(),mi],scriptUrlPattern:[i,Oi]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[us]:e,[hs]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Bi("fp",JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},gs=e=>{const t=ps(!0);return t&&e.body&&(e.body.fpData=t),e},vs="descopeFlowNonce",ms="X-Descope-Flow-Nonce",ys="/v1/flow/start",ws="/v1/flow/next",bs=(e,t=vs)=>`${t}${e}`,ks=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Is=e=>{var t;return e.path===ws&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ks(e.body.executionId):null},Ss="dls_last_user_login_id",Os="dls_last_user_display_name",xs=e=>Bi(Ss,e),js=()=>Ji(Ss),Cs=()=>Ji(Os),Rs=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=js(),i=Cs();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await e(...t)},Es="DSLI",_s=e=>async(...t)=>{const n=await e(...t);return Vi(Es),n};function Ts(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function As(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Ns(n.publicKey.challenge),n.publicKey.user.id=Ns(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Ns(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Ls(n.rawId),type:n.type,response:{attestationObject:Ls(n.response.attestationObject),clientDataJSON:Ls(n.response.clientDataJSON)}});var n}async function $s(e){const t=Us(e);return Ds(await navigator.credentials.get(t))}async function Ms(e,t){const n=Us(e);return n.signal=t.signal,n.mediation="conditional",Ds(await navigator.credentials.get(n))}async function Ps(e=!1){var t,n;if(!Ei)return Promise.resolve(!1);if(Fi()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function Us(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Ns(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Ns(e.id)})),n}function Ds(e){return JSON.stringify({id:e.id,rawId:Ls(e.rawId),type:e.type,response:{authenticatorData:Ls(e.response.authenticatorData),clientDataJSON:Ls(e.response.clientDataJSON),signature:Ls(e.response.signature),userHandle:e.response.userHandle?Ls(e.response.userHandle):void 0}})}function Ns(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ls(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ws,Fs=(Ws=e=>({async signUp(t,n,o){const r=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await As(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,i)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const r=await $s(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,r)},async signUpOrIn(t,n){var o;const r=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!r.ok)return r;if(null===(o=r.data)||void 0===o?void 0:o.create){const t=await As(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,t)}{const t=await $s(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,t)}},async update(t,n,o){const r=await e.webauthn.update.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await As(r.data.options);return await e.webauthn.update.finish(r.data.transactionId,i)},helpers:{create:As,get:$s,isSupported:Ps,conditional:Ms}}),(...e)=>{const t=Ws(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const qs="/fedcm/config",zs=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function Bs(e,t){var n;try{await Js(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Js(e,t){var n,o;const r=await async function(e,t="google",n,o,r){const i=zs(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:i,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:i})),s.prompt((e=>{var t,n;if(r&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==r||r(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!r.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+r.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+r.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var Vs=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Ps(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let Hs;const Ks=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const r=t();if(r)return n(r);const i=e.shift(),s=document.createElement("script");s.src=i,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(i),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Ks(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Zs=(e,t,n)=>{const o=async()=>{let o,r;return o&&r||({client:o,stateUserKey:r}=await(async(e,t,n)=>{Hs||(Hs=(async()=>{try{return require("oidc-client-ts")}catch(e){return Ks([Ti,Ai],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:r}=await Hs;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const i=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:i,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new r({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}})(e,t,n)),{client:o,stateUserKey:r}},r=async(t="")=>{var n;const{client:r,stateUserKey:i}=await o(),s=await r.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),Bi(i,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var r;const{client:i}=await o(),s=await i.createSigninRequest(t),{url:a}=s;return n||(await(null===(r=e.httpClient.hooks)||void 0===r?void 0:r.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:r,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await r(e)},refreshToken:async t=>{var n;const{client:r,stateUserKey:i}=await o(),s=(e=>{const t=Ji(e);return t?JSON.parse(t):null})(i);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await r.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:r}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||as(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const i=await n.createSignoutRequest(e),{url:s}=i;return Vi(r),t||window.location.replace(s),i}}},Xs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Mi=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:r}=n,i=t(n,["fpKey","fpLoad"]);return Ei?(o&&r&&fs(o).catch((()=>null)),e(Li(i,{beforeRequest:gs}))):e(i)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.50.1"},t.baseHeaders)}))),(e=>t=>{const n=Ts(),o=Ts(),r=Ts(),i=Ts(),s=e(Li(t,{afterRequest:async(e,t)=>{if(qi(e,t))Ki("Session invalidated, notifying subscribers with empty values"),o.pub(null),r.pub(null),n.pub(null),i.pub(null);else{const e=await(async e=>{const t=await Wi(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&r.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await Wi(t);s&&o.pub(s),l&&i.pub(l),(a||s)&&n.pub(a||42)}}})),a=nr(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return o.pub(null),r.pub(null),n.pub(null),i.pub(null),s}));return Object.assign(a,{onSessionTokenChange:o.sub,onUserChange:r.sub,onClaimsChange:i.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var o;const{enableFlowNonce:r=!0,nonceStoragePrefix:i=vs}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!r)return e(s);((e=vs)=>{try{if(!zi)return;for(let r=0;r<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==Mi?void 0:Mi.length)&&void 0!==t?t:Ei&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);r++){const t=Hi(r);if(t&&t.startsWith(e)){const n=Ji(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Vi(t)}catch(e){Vi(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(i);const a=e(Li(s,{afterRequest:async(e,t)=>{if(e.path!==ys&&e.path!==ws)return;const{nonce:n,executionId:o}=await(async(e,t)=>{try{const n=t.headers.get(ms);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Is(e)),{nonce:n,executionId:ks(o)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&o&&((e,t,n,o=vs)=>{try{const r=bs(e,o),i=n?172800:10800,s={value:t,expiry:Date.now()+1e3*i,isStart:n};Bi(r,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(o,n,e.path===ys,i)},beforeRequest:e=>{if(e.path===ws){const t=Is(e);if(t){const n=((e,t=vs)=>{try{const n=bs(e,t),o=Ji(n);if(!o)return null;const r=JSON.parse(o);return r.expiry<Date.now()?(((e,t=vs)=>{try{const n=bs(e,t);Vi(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):r.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,i);n&&(e.headers=e.headers||{},e.headers[ms]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let r;e=new Promise((e=>{r=e})),await o;try{return await t(...n)}finally{r()}}}return a}),(e=>t=>{const n=e(Li(t,{afterRequest:async(e,t)=>{if(qi(e,t))return void Vi(Es);const n=await Wi(t);(null==n?void 0:n.sessionExpiration)&&Bi(Es,String(n.sessionExpiration))}}));return nr(n,["logout","logoutAll","oidc.logout"],_s)}),(e=>n=>{var{autoRefresh:o}=n,r=t(n,["autoRefresh"]);const i=!!o,s="object"==typeof o&&(null==o?void 0:o.customActivityTracking);if(!i||Fi())return Object.assign(e(r),{markUserActive:()=>{Zi("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(Ki("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Ei&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(Ki("Expiration time passed, refreshing session"),f.refresh(is()||d))}));const f=e(Li(r,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:r,nextRefreshSeconds:i}=await Wi(t);if(qi(e,t))Ki("Session invalidated, canceling all timers"),a();else if(n||r){if(c=((e,t)=>{if(t)return new Date(1e3*t);Ki("Could not extract expiration time from session token, trying to decode the token");try{const t=eo(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,r),!c)return void Ki("Could not extract expiration time from session token");d=o,h=i>0;const e=Xi(c,i);if(a(),e<=2e4)return void Ki("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Ki(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Ei&&"hidden"===document.visibilityState)Ki("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return Ki("Skipping refresh due to timer - user is idle"),void(p=!0);Ki("Refreshing session due to timer"),f.refresh(is()||o)}}),e)}}}));return Object.assign(nr(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Ki("Clearing all timers"),a(),n})),{markUserActive:u?()=>{Ki("markUserActive() called"),h||Ki("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(Ki("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(is()||d))}:()=>{Zi("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(i),{getLastUserLoginId:js,getLastUserDisplayName:Cs});const s=e(Li(i,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:r}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=Ni((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;i?(xs(i),(e=>{Bi(Os,e)})(s)):(null==r?void 0:r.loginId)&&xs(r.loginId)}}));let a=nr(s,["flow.start"],Rs);return a=nr(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(Vi(Ss),Vi(Os)),o})(r)),Object.assign(a,{getLastUserLoginId:js,getLastUserDisplayName:Cs})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:r,refreshTokenViaCookie:i,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!Ei)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(Li(Object.assign({refreshCookieName:a},l),{beforeRequest:cs(s,i,a),afterRequest:async(e,t)=>{if(qi(e,t))Ki("Session invalidated, clearing persisted tokens"),ls(s,r,i,c);else{const e=await Wi(t);e.cookieName?Bi(`${s||""}${es}`,e.cookieName):e.refreshJwt&&Vi(`${s||""}${es}`);const n=((e={},t=!1,n="",o=!1)=>{var r,i,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(o){Vi(`${n}${Gi}`);const t=o.sameSite||"Strict",s=null===(r=o.secure)||void 0===r||r,a=null!==(i=o.domain)&&void 0!==i?i:e.cookieDomain,l=rs(o);s&&"https:"!==window.location.protocol&&Zi("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});ts(l,c,d);const h=ns(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=rs(o);vi.remove(e),Bi(`${n}${Gi}`,c)}if(l)if(t){const n=t.sameSite||"Strict",o=null===(s=t.secure)||void 0===s||s,r=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,i=os(t);o&&"https:"!==window.location.protocol&&Zi("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:r});ts(i,l,c);const d=ns(r);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?r:void 0}})}else Bi(`${n}${Yi}`,l);return e.idToken&&Bi(`${n}${Qi}`,e.idToken),d&&Bi(`${n}DTD`,d),u})(e,r,s,i);n&&(c=n)}}})),u=nr(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>r=>async(...i)=>{const s=await r(...i);return ls(e,t,n,null==o?void 0:o()),s})(s,r,i,(()=>c)));return Object.assign(u,{getRefreshToken:()=>is(s,i),getSessionToken:()=>ss(s,r),getIdToken:()=>as(s)})}))((e=>{const t=fi(e),n=Zs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,r)=>{var i;if(Fi())return Ki(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(r&&!Ji(Es)&&!Ji(Ss)&&!Ji("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=ss(),a=is();let l="";if(e.getExternalToken)try{l=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){Ki("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},l,r)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:Vs(t),webauthn:Fs(t),fedcm:(o=t,r=e.projectId,{onetap:{requestExchangeCode(e){Bs(o,e)},requestAuthentication(e){Bs(o,e)}},async oneTap(e,t,n,r,i){await Js(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:r,onDismissed:i})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(r+qs),clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(i.token)},isSupported:()=>Ei&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(r+qs);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!i&&!!i.token}catch(e){return!1}}}),oidc:n});var o,r})),Ys={search:"/v1/mgmt/role/search",deleteBatch:"/v1/mgmt/role/delete/batch",create:"/v1/mgmt/role/create",update:"/v1/mgmt/role/update"},Gs={permissions:"/v1/mgmt/permission/all"},Qs=e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),ea=(e,t)=>n(void 0,[e,t],void 0,(function*({text:e,sort:t},n){return new Promise((o=>{const r=[];for(let e=1;e<10;e+=1)r.push({name:`Role ${e}`,description:`Role description ${e}`,permissionNames:[`Permission ${e}`],createdTime:new Date,tenantId:n});t.forEach((e=>{r.sort(((t,n)=>{var o,r;return e.desc?null===(r=n[e.field])||void 0===r?void 0:r.localeCompare(t[e.field]):null===(o=t[e.field])||void 0===o?void 0:o.localeCompare(n[e.field])}))})),o(r.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()))))}))})),ta=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,description:t,permissionNames:n},o){return new Promise((r=>{r({name:e,description:t,permissionNames:n,createdTime:new Date,tenantId:o})}))})),na=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,newName:t,description:n,permissionNames:o},r){return new Promise((i=>{i({name:t,description:n,permissionNames:o,createdTime:new Date,oldName:e,tenantId:r})}))})),oa=()=>n(void 0,void 0,void 0,(function*(){})),ra=()=>new Promise((e=>{const t=[];for(let e=1;e<5;e+=1)t.push({name:`Permission ${e}`});e({permissions:t})})),ia=({httpClient:e,tenant:t,mock:o})=>({search:(...r)=>n(void 0,[...r],void 0,(function*({page:n,limit:r=1e4,text:i,sort:s}={}){if(o)return ea({page:n,limit:r,text:i,sort:s},t);const a=yield e.post(Ys.search,{limit:r,page:n,text:i,sort:s},{queryParams:{tenant:t}});yield Qs(a);return(yield a.json()).roles})),deleteBatch:r=>n(void 0,void 0,void 0,(function*(){if(o)return oa();const n=yield e.post(Ys.deleteBatch,{roleNames:r},{queryParams:{tenant:t}});return yield Qs(n),n.json()})),create:r=>n(void 0,[r],void 0,(function*({name:n,description:r,permissionNames:i}){if(o)return ta({name:n,description:r,permissionNames:i},t);const s=yield e.post(Ys.create,{name:n,description:r,permissionNames:i,tenantId:t},{queryParams:{tenant:t}});yield Qs(s);return yield s.json()})),update:r=>n(void 0,[r],void 0,(function*({name:n,newName:r,description:i,permissionNames:s}){if(o)return na({name:n,newName:r,description:i,permissionNames:s},t);const a=yield e.post(Ys.update,{name:n,newName:r,description:i,permissionNames:s,tenantId:t},{queryParams:{tenant:t}});yield Qs(a);const l=yield a.json();return l.oldName=n,l}))}),sa=({httpClient:e,tenant:t,mock:o})=>({getTenantPermissions:()=>n(void 0,void 0,void 0,(function*(){if(o)return ra();const n=yield e.get(Gs.permissions,{queryParams:{tenant:t}});return yield Qs(n),n.json()}))}),aa=u((e=>{var t,s,a,l;const c=i(E,C,b,_,kn,R({tenant:R.missingAttrValidator}))(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),r(this,s,((e,t,n,o)=>{const r=Xs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"role-management-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.7.0"}}));return{role:ia({httpClient:r.httpClient,tenant:t,mock:n}),tenant:sa({httpClient:r.httpClient,tenant:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},l})),la=u((e=>{const t=i(yn({name:"widget",initialState:Yn,reducers:{setSelectedRolesIds:(e,{payload:t})=>{e.selectedRolesIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Un.reducer(e),qn.reducer(e),Kn.reducer(e),Ln.reducer(e),Jn.reducer(e),Xn.reducer(e)},asyncActions:{searchRoles:Jn.action,createRole:Un.action,duplicateRole:qn.action,updateRole:Kn.action,deleteRoles:Ln.action,getTenantPermissions:Xn.action}}),j,b,aa)(e);return class extends t{constructor(...e){super(...e),this.state=Yn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),ca=u((e=>{const t=i($,R({"widget-id":R.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`role-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),da=u((e=>{var t,r,a;return a=class extends(i(b,j,B,X,ca,la)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([o(this,t,"m",r).call(this),this.actions.searchRoles(),this.actions.getTenantPermissions()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,r=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),ua=u((e=>{var t,a,l,c,d,u,h;return h=class extends(i(la,ue,wn,b,da)(e)){constructor(){super(...arguments),t.add(this),a.set(this,void 0),l.set(this,"create"),c.set(this,null),u.set(this,(()=>n(this,void 0,void 0,(function*(){var e;yield o(this,a,"f").setData(null===(e=On(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}openRoleModal(e="create",t){r(this,l,e,"f"),r(this,c,null!=t?t:null,"f"),this.roleFormModal.open()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",d).call(this)}))}},a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,t=new WeakSet,d=function(){return n(this,void 0,void 0,(function*(){this.roleFormModal=this.createModal(),this.roleFormModal.setContent(s(yield this.fetchWidgetPage("create-role-modal.html")));new te((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}));new te((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>n(this,void 0,void 0,(function*(){if(this.validateForm(this.roleFormModal.ele)){const e=this.getFormData(this.roleFormModal.ele);"duplicate"===o(this,l,"f")?this.actions.duplicateRole(Object.assign({},e)):this.actions.createRole(Object.assign({},e)),this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}})))),r(this,a,new ae((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),o(this,u,"f").call(this),this.roleFormModal.beforeOpen=()=>n(this,void 0,void 0,(function*(){yield o(this,u,"f").call(this),o(this,c,"f")&&(this.setFormData(this.roleFormModal.ele,o(this,c,"f")),r(this,c,null,"f"))}))}))},h})),ha=u((e=>{var t,r,s;return s=class extends(i(b,ua,da)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){var e;this.createButton=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-role"]'),{logger:this.logger}),this.createButton.onClick((()=>this.openRoleModal()))},s})),pa=u((e=>{var t,r,a;return a=class extends(i(la,ue,b,da)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){return n(this,void 0,void 0,(function*(){var e;this.deleteRolesModal=this.createModal(),this.deleteRolesModal.setContent(s(yield this.fetchWidgetPage("delete-roles-modal.html")));const t=new te((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteRolesModal.close()));const n=new te((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=jn(this.state);this.actions.deleteRoles(null==e?void 0:e.map((e=>e.name))),this.deleteRolesModal.close()}));const o=new ce(null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteRolesModal.beforeOpen=()=>{const e=_n(this.state);o.text=`Delete ${e}?`}}))},a})),fa=u((e=>{var t,r,s,a;return a=class extends(i(b,da,la,pa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.subscribe(o(this,s,"f").bind(this),Cn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.deleteButton=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-roles"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteRolesModal.open()}))},a})),ga=u((e=>{var t,r,s,a;return a=class extends(i(b,da,la,ua)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.duplicateButton.enable():this.duplicateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.subscribe(o(this,s,"f").bind(this),Rn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.duplicateButton=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="duplicate-role"]'),{logger:this.logger}),this.duplicateButton.disable(),this.duplicateButton.onClick((()=>{var e,t,n;const o=null===(e=jn(this.state))||void 0===e?void 0:e[0];o&&this.openRoleModal("duplicate",{name:`${o.name} Copy`,description:null!==(t=o.description)&&void 0!==t?t:"",permissionNames:null!==(n=o.permissionNames)&&void 0!==n?n:[]})}))},a})),va=u((e=>{var a,l,c,d,u,h,p,f;return f=class extends(i(la,ue,b,wn,da)(e)){constructor(){super(...arguments),a.add(this),l.set(this,void 0),u.set(this,(()=>n(this,void 0,void 0,(function*(){var e;yield o(this,l,"f").setData(null===(e=On(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),h.set(this,(()=>{var e;const t=null===(e=jn(this.state))||void 0===e?void 0:e[0],n={name:null==t?void 0:t.name,description:null==t?void 0:t.description,permissionNames:null==t?void 0:t.permissionNames};this.setFormData(this.editRoleModal.ele,n)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),yield o(this,a,"m",p).call(this)}))}},l=new WeakMap,u=new WeakMap,h=new WeakMap,a=new WeakSet,c=function(){new te((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editRoleModal.close()))},d=function(){new te((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{var e;if(this.validateForm(this.editRoleModal.ele)){const n=this.getFormData(this.editRoleModal.ele),{name:o}=n,r=t(n,["name"]),i=null===(e=jn(this.state))||void 0===e?void 0:e[0];this.actions.updateRole(Object.assign({newName:o,name:i.name},r)),this.editRoleModal.close(),this.resetFormData(this.editRoleModal.ele)}}))},p=function(){return n(this,void 0,void 0,(function*(){this.editRoleModal=this.createModal(),this.editRoleModal.setContent(s(yield this.fetchWidgetPage("edit-role-modal.html"))),o(this,a,"m",c).call(this),o(this,a,"m",d).call(this),r(this,l,new ae((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),this.editRoleModal.beforeOpen=()=>n(this,void 0,void 0,(function*(){yield o(this,u,"f").call(this),o(this,h,"f").call(this)}))}))},f})),ma=u((e=>{var t,r,s,a;return a=class extends(i(b,da,la,va,wn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.subscribe(o(this,s,"f").bind(this),En)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.editButton=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-role"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editRoleModal.open()}))},a})),ya=u((e=>{var t,r,s,a;return a=class extends(i(b,da,la)(e)){constructor(){super(...arguments),t.add(this),r.set(this,d((()=>{this.actions.searchRoles({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",s).call(this)}))}},r=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new de(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(o(this,r,"f"))},a}));const wa={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},ba=u((e=>{var t,r,s,a,c;return c=class extends(i(b,la,pe,j)(e)){constructor(){super(...arguments),t.add(this),a.set(this,l((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const i=o(this,t,"m",s).call(this,e);i.setContent(o(this,t,"m",r).call(this,{type:e,msg:n})),i.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(o(this,a,"f").bind(this),Sn)}))}},a=new WeakMap,t=new WeakSet,r=function({type:e,msg:t}){const n=wa[e],o=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${o.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},c})),ka=u((e=>{var t,r,s,a,c;return c=class extends(i(la,b,da)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{this.rolesTable.data=e}))),a.set(this,d(((e,t)=>{const n=[],{value:o}=t;if(o){const t=e.path;n.push({field:t,desc:"desc"===o})}this.actions.searchRoles({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{o(this,a,"f").call(this,e.target,e.detail)}))})),o(this,s,"f").call(this,xn(this.state)),this.subscribe(o(this,s,"f").bind(this),xn)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,r=function(){var e;this.rolesTable=new re(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-table"]'),{logger:this.logger}),this.rolesTable.onSelectedItemsChange((e=>{this.actions.setSelectedRolesIds(e.detail.value.map((({name:e})=>e)))}))},c})),Ia=u((e=>class extends(i(U,ve,ka,ha,fa,ga,ma,ya,ba)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Sa=i((e=>class extends(Ia(e)){}))(HTMLElement);customElements.define("descope-role-management-widget",Sa);const Oa=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var xa,ja,Ca,Ra,Ea,_a,Ta,Aa,$a,Ma;const Pa=document.createElement("template");Pa.innerHTML=`\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;const Ua=i(H)(HTMLElement);class Da extends Ua{constructor(){var e;super(),xa.add(this),ja.set(this,new m({messages:[]})),Ca.set(this,void 0),Ra.set(this,void 0),Ea.set(this,void 0),_a.set(this,{resize:o(this,xa,"m",Ma).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Pa.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),r(this,Ca,this.shadowRoot.querySelector(".debugger"),"f"),r(this,Ra,o(this,Ca,"f").querySelector(".content"),"f"),r(this,Ea,o(this,Ca,"f").querySelector(".header"),"f")}updateData(e){o(this,ja,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,l]=Oa(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(o(this,Ca,"f"),o(this,Ea,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,_a,"f").resize),(e=o(this,Ca,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,Ca,"f").onresize=o(this,xa,"m",$a).bind(this),o(this,ja,"f").subscribe(o(this,xa,"m",Ta).bind(this))}disconnectedCallback(){o(this,ja,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,_a,"f").resize)}}ja=new WeakMap,Ca=new WeakMap,Ra=new WeakMap,Ea=new WeakMap,_a=new WeakMap,xa=new WeakSet,Ta=function(e){o(this,xa,"m",Aa).call(this,e),o(this,xa,"m",$a).call(this)},Aa=function(e){o(this,Ra,"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("")},$a=function(){o(this,Ra,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,r=n.clientHeight>20;o||r?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Ma=function(){const[e,t]=Oa(o(this,Ca,"f"),Number.parseInt(o(this,Ca,"f").style.left,10),Number.parseInt(o(this,Ca,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Ca,"f").style.top=`${t}px`,o(this,Ca,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Da);var Na=Object.freeze({__proto__:null,default:Da});return Sa}();
|
|
5
|
+
this["descope-role-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function r(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),l=e=>{let t,n;return(...o)=>(t&&a(t,o)||(t=o,n=e(...o)),n)},c=e=>(t,...n)=>t.reduce(((t,o,r)=>{var i;return`${t}${o}${(null===(i=null==n?void 0:n[r])||void 0===i?void 0:i[e>1?1:0])||""}`}),""),d=(e,t=500)=>{let n;return function(...o){clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}},u=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const o=e(n);return o[t]=!0,o}};var h,p,f,g;function v(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!v(i,s))return!1}else if(i!==s)return!1}return!0}let m=class{constructor(e={},{forceUpdate:t=!1}={}){h.set(this,void 0),p.set(this,{}),f.set(this,0),g.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,h,"f")):e,n=Object.assign(Object.assign({},o(this,h,"f")),t);if(o(this,g,"f")||!v(o(this,h,"f"),n)){const e=o(this,h,"f");r(this,h,n,"f"),Object.freeze(o(this,h,"f")),setTimeout((()=>{Object.values(o(this,p,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},r(this,h,e,"f"),r(this,g,t,"f")}get current(){return Object.assign({},o(this,h,"f"))}subscribe(e){return r(this,f,o(this,f,"f")+1,"f"),o(this,p,"f")[o(this,f,"f")]=e,o(this,f,"f").toString()}unsubscribe(e){const t=!!o(this,p,"f")[e];return t&&delete o(this,p,"f")[e],t}unsubscribeAll(){return r(this,p,{},"f"),!0}};h=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap;const y=["error","warn","info","debug"],w={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},b=u((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",i).call(this,w))}set logger(e){r(this,n,o(this,t,"m",i).call(this,e||w),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return y.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),k="undefined"!=typeof localStorage,I="https://static.descope.com/pages",S="https://static2.descope.com/pages",O=k&&localStorage.getItem("base.content.url")||"",j=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,x=u((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(r(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),C=u((e=>{var t,n;const r=i(b,x)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,r;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,r=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>r(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&r(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const r=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(r,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),R=e=>t=>{var n,r,s;const a=i(b,x,C)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,o(this,n,"m",r).bind(this))}async init(){var e;l.forEach((e=>o(this,n,"m",r).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,r=function(t,n){const o=e[t],r="function"==typeof o?o(t,n):o;r&&this.logger.error(r)},s};R.missingAttrValidator=j;const E=u((e=>{const t=i(R({"project-id":j}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),_=u((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),T="Trying the next fallback URL...",A=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(o){return null==n||n.debug(`Network error fetching URL ${e} [${o.message}], retrying...`),fetch(e,t)}};const $=u((e=>{var t,n,s,a,l,c,d;const u=i(b,E,_)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const i=o(this,t,"m",l).call(this,e),c=Array.isArray(i)?e=>{const{baseUrl:t}=i[e];r(this,s,t,"f");for(let t=0;t<e;t++){const e=i[t].baseUrl;o(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o}={})=>{const r=Array.isArray(e)?e:[e];for(let e=0;e<r.length;e++){const i=r[e],s=e===r.length-1;try{const r=await A(i.toString(),t,{logger:n});if(r.ok)return null==o||o(e),null==n||n.debug(`Successfully fetched URL ${i}`),r;const a=`Error fetching URL ${i} [${r.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${T}`)}catch(e){const t=`Error fetching URL ${i} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${T}`)}}})(i,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const i=O||this.baseStaticUrl;if(i)return o(this,t,"m",c).call(this,e,i);o(this,n,"f")!==this.baseUrl&&(r(this,n,this.baseUrl,"f"),r(this,s,void 0,"f"),o(this,a,"f").clear());const l=[];if(o(this,s,"f"))l.push(o(this,t,"m",c).call(this,e,o(this,s,"f"))),o(this,s,"f")===I&&l.push(o(this,t,"m",c).call(this,e,S));else{const n=this.baseUrl+"/pages";this.baseUrl&&!o(this,a,"f").has(n)&&l.push(o(this,t,"m",c).call(this,e,n)),o(this,a,"f").has(I)||l.push(o(this,t,"m",c).call(this,e,I)),l.push(o(this,t,"m",c).call(this,e,S))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o=I}){const r=new URL(o);return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,n,t),r.baseUrl=o,r}({projectId:this.projectId,filename:e,baseUrl:t})},d})),M=u((e=>{var t,n;const r=i(R({"project-id":j}))(e);return n=class extends r{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),P=u((e=>{var t,n,s,a,l;const c=i($,M,x)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",o(this,t,"m",n).bind(this))}get config(){return o(this,s,"f")||r(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){r(this,s,void 0,"f")},l})),U=u((e=>{var t,n,s,a,l,c,d;return d=class extends(i(x,b)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,r)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,r),"debug"===e&&o(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var r;null===(r=super.onLogEvent)||void 0===r||r.call(this,e,n),"error"===e&&o(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),r(this,n,null,"f")},a=async function(){r(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Fa})),document.body.appendChild(o(this,n,"f"))},l=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},c=function(e,t){var r;e&&(null===(r=o(this,n,"f"))||void 0===r||r.updateData({title:e,description:t}))},d})),D=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],N=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},L=(e,t,n)=>new Promise(((o,r)=>{const i=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);i.onerror=e=>{i.setAttribute("status","error"),r(e)},i.onload=()=>{i.setAttribute("status","loaded"),o(i)},i.src=t.toString(),document.body.appendChild(i)})),W=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},F=u((e=>{const t=i(b)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",o=[],r){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${r?" with SRI integrity check":""}`),(async(e,t)=>{for(const o of e){const{id:e,url:r,integrity:i}=o,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await W(s,i),o}catch(e){t(o,!0)}else try{return await L(e,r,i),o}catch(e){t(o,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,o="",r)=>e.reduce(((e,i)=>{const s=i;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${o}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${N(a)}`};return r&&(l.integrity=r),[...e,l]}),[]))([...o,this.baseCdnUrl,...D],e,t,n,r),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),q="base.ui.components.url",z=k&&localStorage.getItem(q),B=u((e=>{var t,n,s,a,l,c,d;const u=i(b,P,F)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return o(this,a,"f")||r(this,a,o(this,t,"m",c).call(this),"f"),o(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await o(this,t,"m",n).call(this),r=await o(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[z],r),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),J=u((e=>{var t,n,r;const s=i(x,C)(e);return r=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",o(this,t,"m",n).bind(this)),o(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},r}));class V{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const H=u((e=>{const t=i(J)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new V(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const o=[...e.adoptedStyleSheets||[]];o[t?"unshift":"push"](n),e.adoptedStyleSheets=o}}return n}}})),K="content-root",Z="root",X=u((e=>{const t=i(H)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Z}">\n <div id="${K}"></div>\n </div>\n `,this.injectStyle(`\n #${Z}, #${K} {\n height: 100%;\n }\n #${Z} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(K),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Z)}}})),Y="descope-modal";var G,Q;let ee=class{constructor(e,t){G.set(this,void 0),this.nodeName="",r(this,G,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,G,"f"))}get ele(){var e,t;const n="function"==typeof o(this,G,"f")?o(this,G,"f").call(this):o(this,G,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};G=new WeakMap;let te=class extends ee{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 ne=/^descope-grid-([^-]+)-column$/,oe={text:class extends ee{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 ee{constructor(){super(...arguments),this.nodeName="descope-grid-custom-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}}};let re=class extends ee{constructor(){super(...arguments),this.nodeName="descope-grid",Q.set(this,void 0)}onSelectedItemsChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("selected-items-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get columns(){return this.ele?Array.from(this.ele.children).reduce(((e,t)=>{var n;const o=null===(n=ne.exec(t.localName))||void 0===n?void 0:n[1],r=oe[o];return r?(e.push(new r(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const r=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);r&&this.ele.columns&&(a(r,this.ele.columns)||(this.ele.columns=r,null===(n=o(this,Q,"f"))||void 0===n||n.call(this,r)))}onColumnsChange(e){r(this,Q,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var ie;Q=new WeakMap;let se=class extends ee{constructor(){super(...arguments),ie.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,ie,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,ie,"f").content.cloneNode(!0)))}setContent(e){r(this,ie,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};ie=new WeakMap;let ae=class extends ee{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}},le=class extends ee{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()}},ce=class extends ee{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)}},de=class extends ee{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const ue=u((e=>{var t,n;const r=i(x,X,B)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends se{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Y);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Y]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),he="descope-notification",pe=u((e=>{var t,n;const r=i(x,X,B)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends le{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(he);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([he])}},t=new WeakMap,n})),fe=(e,t,n="")=>Object.entries(e).reduce(((e,[o,r])=>{if(!/^[a-zA-Z0-9-]+$/.test(o))return t("Ignoring invalid override-css token path segment"),e;const i=n?`${n}-${o}`:o;if("object"==typeof r&&null!==r)return e+fe(r,t,i);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(r);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${i}:${s};`}),"");function ge(e,t){const n=Object.assign({},e);for(const[e,o]of Object.entries(t||{}))if(null!=o)if("object"==typeof o){if(0===Object.keys(o).length)continue;n[e]=ge(n[e]||{},o)}else n[e]="string"==typeof o?(n[e]||"")+o:o;return n}const ve=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",me=u((e=>{const t=i(R({tenant:ve}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),ye=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',we=u((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,y,w,b,k,I,S,O,j;const E=i(R({theme:ye}),me,$,x,B,P,X,C,H)(e);return j=class extends E{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),I.set(this,(()=>{o(this,t,"m",S).call(this),o(this,O,"f").call(this,"os"===this.getAttribute("theme"))})),O.set(this,(e=>{var n,r,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(r=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===r?void 0:r[s])||void 0===i||i.call(r,"change",(()=>o(this,t,"m",S).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,I,"f").call(this),await Promise.all([o(this,t,"m",p).call(this),o(this,t,"m",v).call(this),o(this,t,"m",y).call(this)]),o(this,t,"m",m).call(this),this.observeAttributes(["theme"],o(this,I,"f")),this.observeAttributes(["theme-override"],(()=>o(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{r(this,d,null,"f"),o(this,t,"m",v).call(this),o(this,t,"m",y).call(this)})),this.observeAttributes(["style-id"],(()=>{r(this,c,null,"f"),o(this,t,"m",b).call(this),o(this,t,"m",p).call(this),o(this,t,"m",y).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,I=new WeakMap,O=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,o,r,i,s,a;const l=null===(r=null===(o=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===o?void 0:o.colors)||void 0===r?void 0:r.primary,c=null===(a=null===(s=null===(i=e[t])||void 0===i?void 0:i.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${fe({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},u=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(q))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(q),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},h=function(){return o(this,c,"f")||(r(this,c,o(this,t,"m",u).call(this),"f"),o(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,c,"f")},p=async function(){var e,i;const s=await o(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||"");o(this,n,"f")?o(this,n,"f").replaceSync(a):r(this,n,this.injectStyle(a,{prepend:!0}),"f")},f=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.error("Cannot fetch tenant theme file","make sure that your tenantId, projectId & flowId are correct")}},g=function(){return o(this,d,"f")||r(this,d,o(this,t,"m",f).call(this),"f"),o(this,d,"f")},v=async function(){var e,n,i,a;if(!this.tenantId)return void(null===(e=o(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await o(this,t,"a",g);if(!l)return void(null===(n=o(this,s,"f"))||void 0===n||n.replaceSync(""));const c=((null===(i=l.light)||void 0===i?void 0:i.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");o(this,s,"f")?o(this,s,"f").replaceSync(c):r(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=o(this,a,"f"))||void 0===e||e.replaceSync(""));const n=o(this,t,"m",l).call(this);o(this,a,"f")?o(this,a,"f").replaceSync(n):r(this,a,this.injectStyle(n),"f")},y=async function(){var e,n,r,i;const s=await o(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await o(this,t,"a",g);a.componentsThemeManager.themes={light:ge((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==l?void 0:l.light)||void 0===n?void 0:n.components)||{}),dark:ge((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.components)||{},(null===(i=null==l?void 0:l.dark)||void 0===i?void 0:i.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],r=null==n?void 0:n.cssTemplate,i=o||r;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},b=async function(){const e=await o(this,t,"m",w).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},k=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},S=function(){o(this,t,"m",b).call(this),o(this,t,"m",k).call(this)},j}));var be=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ke=()=>Math.random().toString(36).substring(7).split("").join("."),Ie={INIT:`@@redux/INIT${ke()}`,REPLACE:`@@redux/REPLACE${ke()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ke()}`};function Se(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 Oe(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 je(e){let t=typeof e;return t=Oe(e),t}function xe(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${je(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: '${je(n)}'`);return n(xe)(e,t)}let o=e,r=t,i=new Map,s=i,a=0,l=!1;function c(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${je(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),i=null}}}function h(e){if(!Se(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${je(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: '${je(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,r=o(r,e)}finally{l=!1}return(i=s).forEach((e=>{e()})),e}h({type:Ie.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${je(e)}`);o=e,h({type:Ie.REPLACE})},[be]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${je(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[be](){return this}}}}}function Ce(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Re(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const r=t[o];void 0===e[r]&&Ce(`No reducer provided for key "${r}"`),"function"==typeof e[r]&&(n[r]=e[r])}const o=Object.keys(n);let r,i;r={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:Ie.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:Ie.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 '${Ie.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;{const o=function(e,t,n,o){const r=Object.keys(t),i=n&&n.type===Ie.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Se(e))return`The ${i} has unexpected type of "${je(e)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===Ie.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${r.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,r);o&&Ce(o)}let s=!1;const a={};for(let r=0;r<o.length;r++){const i=o[r],l=n[i],c=e[i],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=d,s=s||d!==c}return s=s||o.length!==Object.keys(e).length,s?a:e}}function Ee(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function _e(e){return Se(e)&&"type"in e&&"string"==typeof e.type}var Te=Symbol.for("immer-nothing"),Ae=Symbol.for("immer-draftable"),$e=Symbol.for("immer-state"),Me=[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 Pe(e,...t){{const n=Me[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Ue=Object.getPrototypeOf;function De(e){return!!e&&!!e[$e]}function Ne(e){return!!e&&(We(e)||Array.isArray(e)||!!e[Ae]||!!e.constructor?.[Ae]||Je(e)||Ve(e))}var Le=Object.prototype.constructor.toString();function We(e){if(!e||"object"!=typeof e)return!1;const t=Ue(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Le}function Fe(e,t){0===qe(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function qe(e){const t=e[$e];return t?t.type_:Array.isArray(e)?1:Je(e)?2:Ve(e)?3:0}function ze(e,t){return 2===qe(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Be(e,t,n){const o=qe(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function Je(e){return e instanceof Map}function Ve(e){return e instanceof Set}function He(e){return e.copy_||e.base_}function Ke(e,t){if(Je(e))return new Map(e);if(Ve(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&We(e)){if(!Ue(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[$e];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const r=o[t],i=n[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[r]})}return Object.create(Ue(e),n)}function Ze(e,t=!1){return Ye(e)||De(e)||!Ne(e)||(qe(e)>1&&(e.set=e.add=e.clear=e.delete=Xe),Object.freeze(e),t&&Fe(e,((e,t)=>Ze(t,!0)))),e}function Xe(){Pe(2)}function Ye(e){return Object.isFrozen(e)}var Ge,Qe={};function et(e){const t=Qe[e];return t||Pe(0,e),t}function tt(){return Ge}function nt(e,t){t&&(et("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ot(e){rt(e),e.drafts_.forEach(st),e.drafts_=null}function rt(e){e===Ge&&(Ge=e.parent_)}function it(e){return Ge={drafts_:[],parent_:Ge,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function st(e){const t=e[$e];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function at(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[$e].modified_&&(ot(t),Pe(4)),Ne(e)&&(e=lt(t,e),t.parent_||dt(t,e)),t.patches_&&et("Patches").generateReplacementPatches_(n[$e].base_,e,t.patches_,t.inversePatches_)):e=lt(t,n,[]),ot(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Te?e:void 0}function lt(e,t,n){if(Ye(t))return t;const o=t[$e];if(!o)return Fe(t,((r,i)=>ct(e,o,t,r,i,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return dt(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let r=t,i=!1;3===o.type_&&(r=new Set(t),t.clear(),i=!0),Fe(r,((r,s)=>ct(e,o,t,r,s,n,i))),dt(e,t,!1),n&&e.patches_&&et("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function ct(e,t,n,o,r,i,s){if(r===n&&Pe(5),De(r)){const s=lt(e,r,i&&t&&3!==t.type_&&!ze(t.assigned_,o)?i.concat(o):void 0);if(Be(n,o,s),!De(s))return;e.canAutoFreeze_=!1}else s&&n.add(r);if(Ne(r)&&!Ye(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;lt(e,r),t&&t.scope_.parent_||dt(e,r)}}function dt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ze(t,n)}var ut={get(e,t){if(t===$e)return e;const n=He(e);if(!ze(n,t))return function(e,t,n){const o=ft(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!Ne(o)?o:o===pt(e.base_,t)?(vt(e),e.copy_[t]=mt(o,e)):o},has:(e,t)=>t in He(e),ownKeys:e=>Reflect.ownKeys(He(e)),set(e,t,n){const o=ft(He(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=pt(He(e),t),r=o?.[$e];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||ze(e.base_,t)))return!0;vt(e),gt(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!==pt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,vt(e),gt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=He(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Pe(11)},getPrototypeOf:e=>Ue(e.base_),setPrototypeOf(){Pe(12)}},ht={};function pt(e,t){const n=e[$e];return(n?He(n):e)[t]}function ft(e,t){if(!(t in e))return;let n=Ue(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ue(n)}}function gt(e){e.modified_||(e.modified_=!0,e.parent_&>(e.parent_))}function vt(e){e.copy_||(e.copy_=Ke(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Fe(ut,((e,t)=>{ht[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ht.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Pe(13),ht.set.call(this,e,t,void 0)},ht.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Pe(14),ut.set.call(this,e[0],t,n,e[0])};function mt(e,t){const n=Je(e)?et("MapSet").proxyMap_(e,t):Ve(e)?et("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:tt(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=ut;n&&(r=[o],i=ht);const{revoke:s,proxy:a}=Proxy.revocable(r,i);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:tt()).drafts_.push(n),n}function yt(e){return De(e)||Pe(10,e),wt(e)}function wt(e){if(!Ne(e)||Ye(e))return e;const t=e[$e];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Ke(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Ke(e,!0);return Fe(n,((e,t)=>{Be(n,e,wt(t))})),t&&(t.finalized_=!1),n}var bt=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...r){return o.produce(e,(e=>t.call(this,e,...r)))}}let o;if("function"!=typeof t&&Pe(6),void 0!==n&&"function"!=typeof n&&Pe(7),Ne(e)){const r=it(this),i=mt(e,void 0);let s=!0;try{o=t(i),s=!1}finally{s?ot(r):rt(r)}return nt(r,n),at(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Te&&(o=void 0),this.autoFreeze_&&Ze(o,!0),n){const t=[],r=[];et("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}Pe(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const r=this.produce(e,t,((e,t)=>{n=e,o=t}));return[r,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Ne(e)||Pe(8),De(e)&&(e=yt(e));const t=it(this),n=mt(e,void 0);return n[$e].isManual_=!0,rt(t),n}finishDraft(e,t){const n=e&&e[$e];n&&n.isManual_||Pe(9);const{scope_:o}=n;return nt(o,t),at(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=et("Patches").applyPatches_;return De(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},kt=bt.produce;bt.produceWithPatches.bind(bt),bt.setAutoFreeze.bind(bt),bt.setUseStrictShallowCopy.bind(bt),bt.applyPatches.bind(bt),bt.createDraft.bind(bt),bt.finishDraft.bind(bt);var It=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},St=(e,t,n)=>{const{memoize:o,memoizeOptions:r}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...r);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},Ot={inputStabilityCheck:"once",identityFunctionCheck:"once"};var jt=e=>Array.isArray(e)?e:[e];function xt(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 Ct(e,t){const n=[],{length:o}=e;for(let r=0;r<o;r++)n.push(e[r].apply(null,t));return n}var Rt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Et=0,_t=1;function Tt(){return{s:Et,v:void 0,o:null,p:null}}function At(e,t={}){let n=Tt();const{resultEqualityCheck:o}=t;let r,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=Tt(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=Tt(),e.set(n,t)):t=o}}const a=t;let l;if(t.s===_t)l=t.v;else if(l=e.apply(null,arguments),i++,o){const e=r?.deref?.()??r;null!=e&&o(e,l)&&(l=e,0!==i&&i--);r="object"==typeof l&&null!==l||"function"==typeof l?new Rt(l):l}return a.s=_t,a.v=l,l}return s.clearCache=()=>{n=Tt(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function $t(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,r=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:l,memoizeOptions:c=[],argsMemoize:d=At,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=jt(c),f=jt(u),g=xt(e),v=l((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){r++;const e=Ct(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Ot,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:It},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:St}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=Ct(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:l,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Mt=$t(At),Pt=Object.assign(((e,t=Mt)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})))}),{withTypes:()=>Pt});function Ut(e){return({dispatch:t,getState:n})=>o=>r=>"function"==typeof r?r(t,n,e):o(r)}var Dt=Ut(),Nt=Ut;((...e)=>{const t=$t(...e)})(At);var Lt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ee:Ee.apply(null,arguments)},Wt=e=>e&&"function"==typeof e.match;function Ft(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>_e(t)&&t.type===e,n}function qt(e){return"function"==typeof e&&"type"in e&&Wt(e)}function zt(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 Bt=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 Jt(e){return Ne(e)?kt(e,(()=>{})):e}function Vt(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Ht(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Kt(e,t,n){const o=Zt(e,t,n);return{detectMutations:()=>Xt(e,t,o,n)}}function Zt(e,t=[],n,o="",r=new Set){const i={value:n};if(!e(n)&&!r.has(n)){r.add(n),i.children={};for(const r in n){const s=o?o+"."+r:r;t.length&&-1!==t.indexOf(s)||(i.children[r]=Zt(e,t,n[r],s))}}return i}function Xt(e,t=[],n,o,r=!1,i=""){const s=n?n.value:void 0,a=s===o;if(r&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:i};if(e(s)||e(o))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in o)l[e]=!0;const c=t.length>0;for(let r in l){const s=i?i+"."+r:r;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Xt(e,t,n.children[r],o[r],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Yt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Se(e)}function Gt(e,t="",n=Yt,o,r=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),l=r.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(r.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Gt(c,a,n,o,r,i),s))return s}return i&&Qt(e)&&i.add(e),!1}function Qt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Qt(t))return!1;return!0}function en(e){return"boolean"==typeof e}var tn=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:r=!0}=e??{};let i=new Bt;if(t&&(en(t)?i.push(Dt):i.push(Nt(t.extraArgument))),n){let e={};en(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,o,r){return JSON.stringify(e,n(t,r),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(r,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,r):o.push(r),~n.indexOf(i)&&(i=t.call(this,r,i))}else n.push(i);return null==e?i:e.call(this,r,i)}},{isImmutable:o=Ht,ignoredPaths:r,warnAfter:i=32}=e;const s=Kt.bind(null,o,r);return({getState:e})=>{let n,o=e(),r=s(o);return a=>l=>{const c=zt(i,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(o){let e={};en(o)||(e=o),i.push(function(e={}){{const{isSerializable:t=Yt,getEntries:n,ignoredActions:o=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!_e(u))return c(u);const h=c(u),p=zt(s,"SerializableStateInvariantMiddleware");return l||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=Gt(u,"",t,n,r,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const o=Gt(e.getState(),"",t,n,i,d);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(r){let e={};en(r)||(e=r),i.unshift(function(e={}){const{isActionCreator:t=qt}=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},nn=e=>t=>{setTimeout(t,e)},on="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:nn(10),rn=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Bt(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let r=!0,i=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?on:"callback"===e.type?e.queueNotification:nn(e.timeout),c=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>r&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return r=!e?.meta?.RTK_autoBatch,i=!r,i&&(s||(s=!0,l(c))),o.dispatch(e)}finally{r=!0}}})})("object"==typeof n?n:void 0)),o};function sn(e){const t=tn(),{reducer:n,middleware:o,devTools:r=!0,preloadedState:i,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!Se(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=Re(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(l=o(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=Ee;r&&(c=Lt({trace:!0,..."object"==typeof r&&r}));const d=function(...e){return t=>(n,o)=>{const r=t(n,o);let i=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:r.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=Ee(...a)(r.dispatch),{...r,dispatch:i}}}(...l),u=rn(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return xe(a,i,c(...h))}function an(e){const t={},n=[];let o;const r={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,r},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),r},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,r}};return e(r),[t,n,o]}function ln(...e){return t=>e.some((e=>((e,t)=>Wt(e)?e.match(t):e(t))(e,t)))}var cn=["name","message","stack","code"],dn=class{constructor(e,t){this.payload=e,this.meta=t}_type},un=class{constructor(e,t){this.payload=e,this.meta=t}_type},hn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of cn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},pn=(()=>{function e(e,t,n){const o=Ft(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),r=Ft(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=Ft(e+"/rejected",((e,t,o,r,i)=>({payload:r,error:(n&&n.serializeError||hn)(e||"Rejected"),meta:{...i||{},arg:o,requestId:t,rejectedWithValue:!!r,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let i=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(r(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new dn(e,t),fulfillWithValue:(e,t)=>new un(e,t)})).then((t=>{if(t instanceof dn)throw t;return t instanceof un?o(t.payload,c,e,t.meta):o(t,c,e)}))])}catch(t){p=t instanceof dn?i(null,c,e,t.payload,t.meta):i(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(fn)})}}),{pending:r,rejected:i,fulfilled:o,settled:ln(i,o),typePrefix:e})}return e.withTypes=()=>e,e})();function fn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var gn=Symbol.for("rtk-slice-createasyncthunk");function vn(e,t){return`${e}/${t}`}function mn(e,t,n,o){function r(r,...i){let s=n.call(e,r);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return r.unwrapped=t,r}var yn=function({creators:e}={}){const t=e?.asyncThunk?.[gn];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const r=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(r),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?an(e.extraReducers):[e.extraReducers],r={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,r,i]=an(t);if(function(e){return"function"==typeof e}(e))n=()=>Jt(e());else{const t=Jt(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...r.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(De(e)){const o=n(e,t);return void 0===o?e:o}if(Ne(e))return kt(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in r)e.addCase(t,r[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}i.forEach((o=>{const i=r[o],s={reducerName:o,type:vn(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,r){let i,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=o.reducer,s=o.prepare}else i=o;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?Ft(e,s):Ft(e))}(s,i,a):function({type:e,reducerName:t},n,o,r){if(!r)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=r(e,i,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);l&&o.addCase(u.rejected,l);c&&o.addMatcher(u.settled,c);o.exposeCaseReducer(t,{fulfilled:s||wn,pending:a||wn,rejected:l||wn,settled:c||wn})}(s,i,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=Vt(d,this,{insert:()=>new WeakMap});return Vt(n,t,{insert:()=>{const n={};for(const[o,r]of Object.entries(e.selectors??{}))n[o]=mn(this,r,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function wn(){}var bn="listenerMiddleware";Ft(`${bn}/add`),Ft(`${bn}/removeAll`),Ft(`${bn}/remove`);const kn=e=>u((t=>{const n=yn(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(b)(t)){constructor(...e){super(...e);const t=sn({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),r=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{fn(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},i=Object.keys(o).reduce(((e,t)=>(e[t]=r(o[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),In=u((e=>class extends(b(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}})),Sn=u((e=>{const t=i(R({"widget-id":j}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}}));u((e=>{const t=i(P,Sn)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}}));const On=u((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),jn=e=>e.selectedRolesIds,xn=e=>e.notifications,Cn=e=>e.tenantPermissions.data||[],Rn=Mt((e=>e.rolesList.data),(e=>e.map((e=>{var t;return Object.assign(Object.assign({},e),{editable:0===(null===(t=null==e?void 0:e.tenantId)||void 0===t?void 0:t.length)?"no":"yes"})})))),En=Mt(jn,Rn,((e,t)=>t.filter((t=>e.includes(t.name))))),_n=Mt(jn,(e=>!!e.length)),Tn=Mt(jn,(e=>1===e.length)),An=Mt(En,Tn,((e,t)=>t&&"yes"===e[0].editable)),$n=Mt(En,(e=>1===e.length?e[0].name:`${e.length} roles`)),Mn=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)}))}))},Pn=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}}),Un=({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)})}}),Dn=pn("roles/create",((e,{extra:{api:t}})=>t.role.create(e))),Nn=Mn(Dn)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Pn((e=>e.createRole)),Un({getSuccessMsg:()=>"Role created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Ln={action:Dn,reducer:Nn},Wn=pn("roles/delete",((e,{extra:{api:t}})=>t.role.deleteBatch(e))),Fn=Mn(Wn)({onFulfilled:(e,t)=>{e.rolesList.data=e.rolesList.data.filter((e=>{var n;return 0===(null===(n=null==e?void 0:e.tenantId)||void 0===n?void 0:n.length)||!t.meta.arg.includes(e.name)})),e.selectedRolesIds=[]}},Pn((e=>e.deleteRole)),Un({getSuccessMsg:e=>c(e.meta.arg.length)`${["",e.meta.arg.length]} ${["R","r"]}ole${["","s"]} deleted successfully`,getErrorMsg:e=>c(e.meta.arg.length)`Failed to delete role${["","s"]}`})),qn={action:Wn,reducer:Fn},zn=pn("roles/duplicate",((e,{extra:{api:t}})=>t.role.create(e))),Bn=Mn(zn)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Pn((e=>e.duplicateRole)),Un({getSuccessMsg:()=>"Role duplicated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to duplicate role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Jn={action:zn,reducer:Bn},Vn=pn("roles/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.role.search(Object.assign(Object.assign({},o),e))})),Hn=Mn(Vn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.rolesList.data=t.payload}},Pn((e=>e.rolesList))),Kn={action:Vn,reducer:Hn},Zn=pn("roles/update",((e,{extra:{api:t}})=>t.role.update(e))),Xn=Mn(Zn)({onFulfilled:(e,t)=>{const n=e.rolesList.data.findIndex((e=>e.name===t.payload.oldName));-1!==n&&(e.rolesList.data[n]=t.payload)}},Pn((e=>e.updateRole)),Un({getSuccessMsg:()=>"Role updated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to update role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Yn={action:Zn,reducer:Xn},Gn=pn("tenant/getTenantPermissions",((e,{extra:{api:t}})=>t.tenant.getTenantPermissions())),Qn={action:Gn,reducer:Mn(Gn)({onFulfilled:(e,t)=>{e.tenantPermissions.data=t.payload.permissions}},Pn((e=>e.tenantPermissions)))},eo={rolesList:{data:[],loading:!1,error:null},createRole:{loading:!1,error:null},duplicateRole:{loading:!1,error:null},updateRole:{loading:!1,error:null},deleteRole:{loading:!1,error:null},tenantPermissions:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedRolesIds:[],notifications:[]};class to extends Error{}function no(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function oo(e,t){if("string"!=typeof e)throw new to("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,o=e.split(".")[n];if("string"!=typeof o)throw new to(`Invalid token specified: missing part #${n+1}`);let r;try{r=no(o)}catch(e){throw new to(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new to(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}to.prototype.name="InvalidTokenError";var ro={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const io="<region>",so=`https://api.${io}descope.com`,ao=6e5,lo="dct",co=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},uo=[503,521,522,524,530],ho=[100,5e3,5e3],po=e=>new Promise((t=>setTimeout(t,e))),fo=e=>async function(...t){let n=await e(...t),o=0;for(;uo.includes(n.status)&&o<ho.length;)await po(ho[o]),n=await e(...t),o++;o>0&&(n.retries=o);const r=await n.text();return n.text=()=>Promise.resolve(r),n.json=()=>Promise.resolve(JSON.parse(r)),n.clone=()=>n,n};let go;const vo=()=>{if(go)return go;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return go=`${t}-${n}`,go};var mo,yo;(yo=mo||(mo={})).get="GET",yo.delete="DELETE",yo.post="POST",yo.put="PUT",yo.patch="PATCH";const wo=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(io,r?r+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{i=`${i}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return i},bo=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),ko={"Content-Type":"application/json"},Io=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},So=(e,t)=>{const n={"x-descope-sdk-session-id":vo(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.62.1","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Oo=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var jo=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:r,hooks:i,cookiePolicy:s,fetch:a})=>{const l=e||so,c=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async function(...t){if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>co().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await fo(n)(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return co().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(o)),o}:fo(n)})(r,a),d=async e=>{var r;const a=(null==i?void 0:i.beforeRequest)?i.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:bo(Io(t,g),So(t,o),(null==n?void 0:n.baseHeaders)||{},Oo(v)?ko:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const y=await c(wo({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(e,null==y?void 0:y.clone()),null==i?void 0:i.transformResponse){const e=await y.json(),t=(w=(null===(r=y.headers)||void 0===r?void 0:r.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function o(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function r(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const i=n;let s,a,l=!1;for(;o();)if(","===e.charAt(n)){for(s=n,n+=1,o(),a=n;n<e.length&&r();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(i,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(i,e.length))}return t}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}var w;return y};return{get:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:mo.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:mo.post,token:r}),patch:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:mo.patch,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>d({path:e,headers:n,queryParams:o,body:t,method:mo.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:mo.delete,token:o}),hooks:i,buildUrl:(e,n)=>wo({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=r.length&&(await Promise.allSettled(null==r?void 0:r.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},xo=429;function Co(e,t,n){var o;let r=Ro(e);if(t){if(!(null==r?void 0:r.tenants)&&(null==r?void 0:r[lo])===t)return(null==r?void 0:r[n])||[];r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]}const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function Ro(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return oo(e)}function Eo(e){const{exp:t}=Ro(e);return(new Date).getTime()/1e3>t}function _o(e){let t=Ro(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function To(e,t){return Co(e,t,"permissions")}function Ao(e,t){return Co(e,t,"roles")}const $o=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Mo(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=i:(r.error=i,o.status===xo&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}function Po(e){var t;return(null===(t=Ro(e))||void 0===t?void 0:t[lo])||""}const Uo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Do=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},No=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Lo=e=>t=>e.test(t),Wo=Lo(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Fo=Lo(/^\+[1-9]{1}[0-9]{3,14}$/),qo=Uo(Wo,'"{val}" is not a valid email'),zo=Uo(Fo,'"{val}" is not a valid phone number'),Bo=Uo((e=>e.length>=1),"Minimum length is 1");const Jo=Uo((e=>"string"==typeof e),"Input is not a string"),Vo=Uo((e=>Array.isArray(e)),"Input is not an array"),Ho=Uo((e=>"boolean"==typeof e),"Input is not a boolean"),Ko=Uo((e=>void 0===e),"Input is defined"),Zo=Do([Jo(),Ko()],"Input is not a string or undefined"),Xo=Do([Vo(),Ho()],"Input is not an array or boolean"),Yo=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>No(...e).validate(n[t]))),t(...n)),Go=e=>[Jo(`"${e}" must be a string`)],Qo=e=>[Zo(`"${e}" must be string or undefined`)],er=e=>[Jo(`"${e}" must be a string`),Bo(`"${e}" must not be empty`)],tr=e=>[Jo(`"${e}" must be a string`),qo()],nr=e=>[Jo(`"${e}" must be a string`),zo()],or=Yo(er("accessKey")),rr=e=>({exchange:or(((t,n)=>Mo(e.post(ro.accessKey.exchange,{loginOptions:n},{token:t}))))}),ir=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const s=i[r];i[r]=n(s)})),e),sr=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||ao,ao)});var ar,lr;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(ar||(ar={})),function(e){e.email="email"}(lr||(lr={}));const cr=Object.assign(Object.assign({},ar),lr);var dr;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(dr||(dr={}));const ur=er("loginId"),hr=Yo(er("token")),pr=Yo(ur),fr=Yo(er("pendingRef")),gr=Yo(ur,tr("email")),vr=e=>({verify:hr((t=>Mo(e.post(ro.enchantedLink.verify,{token:t})))),signIn:pr(((n,o,r={},i)=>{var{providerId:s}=r,a=t(r,["providerId"]);return Mo(e.post($o(ro.enchantedLink.signIn,cr.email),{loginId:n,URI:o,loginOptions:a,providerId:s},{token:i}))})),signUpOrIn:pr(((n,o,r={})=>{var{providerId:i}=r,s=t(r,["providerId"]);return Mo(e.post($o(ro.enchantedLink.signUpOrIn,cr.email),{loginId:n,URI:o,loginOptions:s,providerId:i}))})),signUp:pr(((n,o,r,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Mo(e.post($o(ro.enchantedLink.signUp,cr.email),{loginId:n,URI:o,user:r,loginOptions:a,providerId:s}))})),waitForSession:fr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=sr(n);let s;const a=setInterval((async()=>{const n=await e.post(ro.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Mo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:gr(((t,n,o,r,i)=>Mo(e.post(ro.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),mr=Yo(er("flowId")),yr=Yo(er("executionId"),er("stepId"),er("interactionId")),wr=e=>({start:mr(((t,n,o,r,i,s,a,l=!1)=>Mo(e.post(ro.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,componentsVersion:i,flowVersions:s,input:a,isCustomScreen:l})))),next:yr(((t,n,o,r,i,s,a=!1)=>Mo(e.post(ro.flow.next,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:s,isCustomScreen:a}))))}),br=er("loginId"),kr=Yo(er("token")),Ir=Yo(br),Sr=Yo(br,nr("phone")),Or=Yo(br,tr("email")),jr=Object.keys(cr).filter((e=>e!==ar.voice&&e!==ar.im)),xr=e=>({verify:kr((t=>Mo(e.post(ro.magicLink.verify,{token:t})))),signIn:jr.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ir(((n,r,i={},s)=>{var{providerId:a}=i,l=t(i,["providerId"]);return Mo(e.post($o(ro.magicLink.signIn,o),{loginId:n,URI:r,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:jr.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ir(((n,r,i,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Mo(e.post($o(ro.magicLink.signUp,o),{loginId:n,URI:r,user:i,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:jr.reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Ir(((n,r,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Mo(e.post($o(ro.magicLink.signUpOrIn,o),{loginId:n,URI:r,loginOptions:a,providerId:s}))}))})),{}),update:{email:Or(((t,n,o,r,i)=>Mo(e.post(ro.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(ar).filter((e=>e!==ar.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Sr(((t,o,r,i,s)=>Mo(e.post($o(ro.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:r},s),{token:i}))))})),{})}});var Cr;!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"}(Cr||(Cr={}));const Rr=Yo(er("code")),Er=e=>({start:Object.assign(((t,n,o,r,i)=>Mo(e.post(ro.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),i&&{loginHint:i}),token:r}))),Object.keys(Cr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r,i)=>Mo(e.post(ro.oauth.start,o||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),i&&{loginHint:i}),token:r}))})),{})),exchange:Rr((t=>Mo(e.post(ro.oauth.exchange,{code:t})))),startNative:(t,n,o)=>Mo(e.post(ro.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,r,i)=>Mo(e.post(ro.oauth.finishNative,{provider:t,stateId:n,user:o,code:r,idToken:i})),getOneTapClientId:t=>Mo(e.get(ro.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,r)=>Mo(e.post(ro.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r})),exchangeOneTapIDToken:(t,n,o,r)=>Mo(e.post(ro.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r}))}),_r=er("appId"),Tr=Yo(_r),Ar=e=>({connect:Tr(((t,n,o)=>{const r=null==n?void 0:n.tenantId,i=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Mo(e.post(ro.outbound.connect,{appId:t,tenantId:r,tenantLevel:i,options:n},{token:o}))}))}),$r=er("loginId"),Mr=Yo($r,er("code")),Pr=Yo($r),Ur=Yo($r,nr("phone")),Dr=Yo($r,tr("email")),Nr=e=>({verify:Object.keys(cr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Mr(((t,o)=>Mo(e.post($o(ro.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(cr).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pr(((n,r={},i)=>{var{providerId:s}=r,a=t(r,["providerId"]);return Mo(e.post($o(ro.otp.signIn,o),{loginId:n,loginOptions:a,providerId:s},{token:i}))}))})),{}),signUp:Object.keys(cr).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pr(((n,r,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Mo(e.post($o(ro.otp.signUp,o),{loginId:n,user:r,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(cr).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:Pr(((n,r={})=>{var{providerId:i}=r,s=t(r,["providerId"]);return Mo(e.post($o(ro.otp.signUpOrIn,o),{loginId:n,loginOptions:s,providerId:i}))}))})),{}),update:{email:Dr(((t,n,o,r)=>Mo(e.post(ro.otp.update.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(ar).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ur(((t,o,r,i)=>Mo(e.post($o(ro.otp.update.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),Lr=Yo(er("tenant")),Wr=Yo(er("code")),Fr=e=>({start:Lr(((t,n,o,r,i,s,a,l)=>Mo(e.post(ro.saml.start,o||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),i&&{ssoId:i}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},r&&{token:r}))))),exchange:Wr((t=>Mo(e.post(ro.saml.exchange,{code:t}))))}),qr=er("loginId"),zr=Yo(qr,er("code")),Br=Yo(qr),Jr=Yo(qr),Vr=e=>({signUp:Br(((t,n)=>Mo(e.post(ro.totp.signUp,{loginId:t,user:n})))),verify:zr(((t,n,o,r)=>Mo(e.post(ro.totp.verify,{loginId:t,code:n,loginOptions:o},{token:r})))),update:Jr(((t,n)=>Mo(e.post(ro.totp.update,{loginId:t},{token:n}))))}),Hr=er("loginId"),Kr=er("newPassword"),Zr=Yo(Hr,er("password")),Xr=Yo(Hr),Yr=Yo(Hr,Kr),Gr=Yo(Hr,er("oldPassword"),Kr),Qr=e=>({signUp:Zr(((n,o,r,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Mo(e.post(ro.password.signUp,{loginId:n,password:o,user:r,loginOptions:a,providerId:s}))})),signIn:Zr(((n,o,r={})=>{var{providerId:i}=r,s=t(r,["providerId"]);return Mo(e.post(ro.password.signIn,{loginId:n,password:o,loginOptions:s,providerId:i}))})),sendReset:Xr(((t,n,o)=>Mo(e.post(ro.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Yr(((t,n,o)=>Mo(e.post(ro.password.update,{loginId:t,newPassword:n},{token:o})))),replace:Gr(((t,n,o)=>Mo(e.post(ro.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>Mo(e.get(ro.password.policy))}),ei=Go("loginId"),ti=er("loginId"),ni=er("origin"),oi=Yo(ti,ni,er("name")),ri=Yo(ti,ni),ii=Yo(ei,ni),si=Yo(ti,ni,Qo("token")),ai=Yo(er("transactionId"),er("response")),li=e=>({signUp:{start:oi(((t,n,o,r,i)=>Mo(e.post(ro.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,loginOptions:i,passkeyOptions:r})))),finish:ai(((t,n)=>Mo(e.post(ro.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:ii(((t,n,o,r,i)=>Mo(e.post(ro.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i},{token:r})))),finish:ai(((t,n)=>Mo(e.post(ro.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:ri(((t,n,o,r)=>Mo(e.post(ro.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:r,passkeyOptions:o}))))},update:{start:si(((t,n,o,r)=>Mo(e.post(ro.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:r},{token:o})))),finish:ai(((t,n)=>Mo(e.post(ro.webauthn.update.finish,{transactionId:t,response:n}))))}}),ci=Go("loginId"),di=Yo(ci),ui=Yo(er("pendingRef")),hi=e=>({signUpOrIn:di(((n,o={})=>{var{providerId:r}=o,i=t(o,["providerId"]);return Mo(e.post(ro.notp.signUpOrIn,{loginId:n,loginOptions:i,providerId:r}))})),signUp:di(((n,o,r={})=>{var{providerId:i}=r,s=t(r,["providerId"]);return Mo(e.post(ro.notp.signUp,{loginId:n,user:o,providerId:i,loginOptions:s}))})),signIn:di(((n,o={},r)=>{var{providerId:i}=o,s=t(o,["providerId"]);return Mo(e.post(ro.notp.signIn,{loginId:n,loginOptions:s,providerId:i},{token:r}))})),waitForSession:ui(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=sr(n);let s;const a=setInterval((async()=>{const n=await e.post(ro.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Mo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),pi=Yo(er("token")),fi=Yo(Qo("token"));var gi,vi=Yo([(gi=er("projectId"),Uo(((e,t)=>n=>No(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let r=0,i=e===Object(e)?e:void 0;for(;null!=i&&r<o;)i=i[n[r++]];return r&&r===o&&void 0!==i?i:void 0})(n,e)))("projectId",gi))())])((e=>{const{projectId:t,logger:n,baseUrl:o,cookiePolicy:r,baseHeaders:i={},refreshCookieName:s,fetch:a}=e;return l=jo({baseUrl:o,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:r,baseConfig:{baseHeaders:i},refreshCookieName:s,fetch:a}),{accessKey:rr(l),otp:Nr(l),magicLink:xr(l),enchantedLink:vr(l),oauth:Er(l),outbound:Ar(l),saml:Fr(l),totp:Vr(l),notp:hi(l),webauthn:li(l),password:Qr(l),flow:wr(l),refresh:fi(((e,t,n,o)=>{const r={};n&&(r.externalToken=n);const i=o?ro.tryRefresh:ro.refresh;return Mo(l.post(i,r,{token:e,queryParams:t}))})),selectTenant:Yo([Jo("tenantId")],[Zo('"token" must be string or undefined')])(((e,t)=>Mo(l.post(ro.selectTenant,{tenant:e},{token:t})))),logout:fi((e=>Mo(l.post(ro.logout,{},{token:e})))),logoutAll:fi((e=>Mo(l.post(ro.logoutAll,{},{token:e})))),me:fi((e=>Mo(l.get(ro.me,{token:e})))),myTenants:Yo([Xo('"tenants" must a string array or a boolean')],[Zo('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Mo(l.post(ro.myTenants,n,{token:t}))})),history:fi((e=>Mo(l.get(ro.history,{token:e})))),isJwtExpired:pi(Eo),getTenants:pi(_o),getJwtPermissions:pi(To),getJwtRoles:pi(Ao),getCurrentTenant:pi(Po),httpClient:l};var l})),mi=Object.assign(vi,{DeliveryMethods:cr});
|
|
6
|
+
/*! js-cookie v3.0.5 | MIT */function yi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var wi=function e(t,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=yi({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",yi({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,yi({},this.attributes,t))},withConverter:function(t){return e(yi({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var bi={default:"endpoint"},ki="Blocked by CSP",Ii="The endpoint parameter is not a valid URL",Si="Failed to load the JS script of the agent",Oi="9319";function ji(e,t){var n,o,r,i,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),i=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},r=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===ki||s===Ii)n.exclude(),i=0;else if(s===Oi)n.exclude();else if(s===Si){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!r.has(l)&&(r.add(l),i=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=i?i:e.getTime()+o()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},r=t(e);return r.then((function(){return o()}),o),r.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,r=t[0],i=t[1];return(o=i,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(r)}))}))};return u(c).then((function(e){return[e,a]}))}var xi="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Ci=xi;function Ri(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:xi,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return ji(e,Ei)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Oi?new Error(Si):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function Ei(e){return function(e,t,n){var o,r=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=t,a())};r.addEventListener(i,s);var a=function(){return r.removeEventListener(i,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),o)return n(o);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(Ii);var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(Si))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)}),(function(){throw new Error(ki)})).then(_i)}function _i(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Oi);return n}const Ti="3.2.0",Ai="undefined"!=typeof window,$i=Math.pow(2,31)-1,Mi=`https://descopecdn.com/npm/oidc-client-ts@${Ti}/dist/browser/oidc-client-ts.min.js`,Pi=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Ti}/dist/browser/oidc-client-ts.min.js`,Ui=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Di;const Ni=e=>{try{return oo(e).exp}catch(e){return null}},Li=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Ni(n)},Wi=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?Ni(o):void 0)},Fi=e=>{const{access_token:n,id_token:o,refresh_token:r,refresh_expire_in:i}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:o,refreshJwt:e.refreshJwt||r,sessionExpiration:e.sessionExpiration||Wi(e),cookieExpiration:e.cookieExpiration||Li(e)},s)},qi=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},zi=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return Fi(n)},Bi=()=>Ai&&!!window.descopeBridge,Ji=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return Ui.includes(n)},Vi=void 0!==Di||Ai&&void 0!==window.localStorage,Hi=(e,t)=>{var n,o;return null===(o=null===(n=Di||Ai&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},Ki=e=>{var t,n;return null===(n=null===(t=Di||Ai&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Zi=e=>{var t,n;return null===(n=null===(t=Di||Ai&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},Xi=e=>{var t,n,o,r,i;return null!==(i=null!==(n=null===(t=null==Di?void 0:Di.key)||void 0===t?void 0:t.call(Di,e))&&void 0!==n?n:Ai&&(null===(r=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===r?void 0:r.call(o,e)))&&void 0!==i?i:null},Yi=(...e)=>{console.debug(...e)},Gi=(...e)=>{console.warn(...e)},Qi=(e,t)=>{let n;var o;return t>0?(n=1e3*t,Yi(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>$i&&(Yi(`Timeout is too large (${n}ms), setting it to ${$i}ms`),n=$i),n},es="DS",ts="DSR",ns="DSI",os="DSRCN";function rs(e,t,n){if(t){const{cookieDomain:o,cookiePath:r,cookieSameSite:i,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=is(o);wi.set(e,t,{path:r,domain:c?o:void 0,expires:l,sameSite:i,secure:a})}}function is(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const ss=e=>(null==e?void 0:e.cookieName)||es,as=e=>(null==e?void 0:e.cookieName)||ts;function ls(e="",t){return wi.get(as(t))||Ki(`${e}${ts}`)||""}function cs(e="",t){return wi.get(ss(t))||Ki(`${e}${es}`)||""}function ds(e=""){return Ki(`${e}${ns}`)||""}function us(e="",t,n,o){Zi(`${e}${ts}`),Zi(`${e}${es}`),Zi(`${e}${ns}`),Zi(`${e}${os}`);const r=ss(t);wi.remove(r,null==o?void 0:o.session);const i=as(n);wi.remove(i,null==o?void 0:o.refresh)}const hs=(e,t,n)=>o=>{const r=Object.assign(o,{token:o.token||ls(e,t)});if(!n){const t=function(e=""){return Ki(`${e}${os}`)}(e);t&&(r.headers=Object.assign(Object.assign({},r.headers||{}),{"x-descope-refresh-cookie-name":t}))}const i=function(e=""){return Ki(`${e}DTD`)||""}(e);return i&&(r.headers=Object.assign(Object.assign({},r.headers||{}),{"x-descope-trusted-device-token":i})),r},ps=Ai&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",fs="vsid",gs="vrid",vs=(e=!1)=>{const t=Ki("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},ms=async(e,t=ps)=>{try{if(vs())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=r.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Ri({apiKey:e,endpoint:[o.toString(),bi],scriptUrlPattern:[i,Ci]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[fs]:e,[gs]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Hi("fp",JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},ys=e=>{const t=vs(!0);return t&&e.body&&(e.body.fpData=t),e},ws="descopeFlowNonce",bs="X-Descope-Flow-Nonce",ks="/v1/flow/start",Is="/v1/flow/next",Ss=(e,t=ws)=>`${t}${e}`,Os=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},js=e=>{var t;return e.path===Is&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Os(e.body.executionId):null},xs="dls_last_user_login_id",Cs="dls_last_user_display_name",Rs=e=>Hi(xs,e),Es=()=>Ki(xs),_s=()=>Ki(Cs),Ts=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=Es(),i=_s();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await e(...t)},As="DSLI",$s=e=>async(...t)=>{const n=await e(...t);return Zi(As),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)}}}async function Ps(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Fs(n.publicKey.challenge),n.publicKey.user.id=Fs(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Fs(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:qs(n.rawId),type:n.type,response:{attestationObject:qs(n.response.attestationObject),clientDataJSON:qs(n.response.clientDataJSON)}});var n}async function Us(e){const t=Ls(e);return Ws(await navigator.credentials.get(t))}async function Ds(e,t){const n=Ls(e);return n.signal=t.signal,n.mediation="conditional",Ws(await navigator.credentials.get(n))}async function Ns(e=!1){var t,n;if(!Ai)return Promise.resolve(!1);if(Bi()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function Ls(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Fs(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Fs(e.id)})),n}function Ws(e){return JSON.stringify({id:e.id,rawId:qs(e.rawId),type:e.type,response:{authenticatorData:qs(e.response.authenticatorData),clientDataJSON:qs(e.response.clientDataJSON),signature:qs(e.response.signature),userHandle:e.response.userHandle?qs(e.response.userHandle):void 0}})}function Fs(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function qs(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var zs,Bs=(zs=e=>({async signUp(t,n,o){const r=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await Ps(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,i)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const r=await Us(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,r)},async signUpOrIn(t,n){var o;const r=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!r.ok)return r;if(null===(o=r.data)||void 0===o?void 0:o.create){const t=await Ps(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,t)}{const t=await Us(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,t)}},async update(t,n,o){const r=await e.webauthn.update.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await Ps(r.data.options);return await e.webauthn.update.finish(r.data.transactionId,i)},helpers:{create:Ps,get:Us,isSupported:Ns,conditional:Ds}}),(...e)=>{const t=zs(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const Js="/fedcm/config",Vs=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function Hs(e,t){var n;try{await Ks(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Ks(e,t){var n,o;const r=await async function(e,t="google",n,o,r){const i=Vs(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:i,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:i})),s.prompt((e=>{var t,n;if(r&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==r||r(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!r.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+r.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+r.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var Zs=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Ns(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let Xs;const Ys=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const r=t();if(r)return n(r);const i=e.shift(),s=document.createElement("script");s.src=i,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(i),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Ys(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Gs=(e,t,n)=>{const o=async()=>{let o,r;return o&&r||({client:o,stateUserKey:r}=await(async(e,t,n)=>{Xs||(Xs=(async()=>{try{return require("oidc-client-ts")}catch(e){return Ys([Mi,Pi],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:r}=await Xs;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const i=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:i,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new r({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}})(e,t,n)),{client:o,stateUserKey:r}},r=async(t="")=>{var n;const{client:r,stateUserKey:i}=await o(),s=await r.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),Hi(i,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var r;const{client:i}=await o(),s=await i.createSigninRequest(t),{url:a}=s;return n||(await(null===(r=e.httpClient.hooks)||void 0===r?void 0:r.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:r,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await r(e)},refreshToken:async t=>{var n;const{client:r,stateUserKey:i}=await o(),s=(e=>{const t=Ki(e);return t?JSON.parse(t):null})(i);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await r.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:r}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||ds(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const i=await n.createSignoutRequest(e),{url:s}=i;return Zi(r),t||window.location.replace(s),i}}},Qs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Di=n,e(t)}),(e=>n=>{var{fpKey:o,fpLoad:r}=n,i=t(n,["fpKey","fpLoad"]);return Ai?(o&&r&&ms(o).catch((()=>null)),e(qi(i,{beforeRequest:ys}))):e(i)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.50.2"},t.baseHeaders)}))),(e=>t=>{const n=Ms(),o=Ms(),r=Ms(),i=Ms(),s=e(qi(t,{afterRequest:async(e,t)=>{if(Ji(e,t))Yi("Session invalidated, notifying subscribers with empty values"),o.pub(null),r.pub(null),n.pub(null),i.pub(null);else{const e=await(async e=>{const t=await zi(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&r.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await zi(t);s&&o.pub(s),l&&i.pub(l),(a||s)&&n.pub(a||42)}}})),a=ir(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return o.pub(null),r.pub(null),n.pub(null),i.pub(null),s}));return Object.assign(a,{onSessionTokenChange:o.sub,onUserChange:r.sub,onClaimsChange:i.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var o;const{enableFlowNonce:r=!0,nonceStoragePrefix:i=ws}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!r)return e(s);((e=ws)=>{try{if(!Vi)return;for(let r=0;r<(void 0,n=void 0,void 0,null!==(o=null!==(t=null==Di?void 0:Di.length)&&void 0!==t?t:Ai&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);r++){const t=Xi(r);if(t&&t.startsWith(e)){const n=Ki(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Zi(t)}catch(e){Zi(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(i);const a=e(qi(s,{afterRequest:async(e,t)=>{if(e.path!==ks&&e.path!==Is)return;const{nonce:n,executionId:o}=await(async(e,t)=>{try{const n=t.headers.get(bs);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=js(e)),{nonce:n,executionId:Os(o)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&o&&((e,t,n,o=ws)=>{try{const r=Ss(e,o),i=n?172800:10800,s={value:t,expiry:Date.now()+1e3*i,isStart:n};Hi(r,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(o,n,e.path===ks,i)},beforeRequest:e=>{if(e.path===Is){const t=js(e);if(t){const n=((e,t=ws)=>{try{const n=Ss(e,t),o=Ki(n);if(!o)return null;const r=JSON.parse(o);return r.expiry<Date.now()?(((e,t=ws)=>{try{const n=Ss(e,t);Zi(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):r.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,i);n&&(e.headers=e.headers||{},e.headers[bs]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let r;e=new Promise((e=>{r=e})),await o;try{return await t(...n)}finally{r()}}}return a}),(e=>t=>{const n=e(qi(t,{afterRequest:async(e,t)=>{if(Ji(e,t))return void Zi(As);const n=await zi(t);(null==n?void 0:n.sessionExpiration)&&Hi(As,String(n.sessionExpiration))}}));return ir(n,["logout","logoutAll","oidc.logout"],$s)}),(e=>n=>{var{autoRefresh:o}=n,r=t(n,["autoRefresh"]);const i=!!o,s="object"==typeof o&&(null==o?void 0:o.customActivityTracking);if(!i||Bi())return Object.assign(e(r),{markUserActive:()=>{Gi("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(Yi("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Ai&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(Yi("Expiration time passed, refreshing session"),f.refresh(ls()||d))}));const f=e(qi(r,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:r,nextRefreshSeconds:i}=await zi(t);if(Ji(e,t))Yi("Session invalidated, canceling all timers"),a();else if(n||r){if(c=((e,t)=>{if(t)return new Date(1e3*t);Yi("Could not extract expiration time from session token, trying to decode the token");try{const t=oo(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,r),!c)return void Yi("Could not extract expiration time from session token");d=o,h=i>0;const e=Qi(c,i);if(a(),e<=2e4)return void Yi("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Yi(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Ai&&"hidden"===document.visibilityState)Yi("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return Yi("Skipping refresh due to timer - user is idle"),void(p=!0);Yi("Refreshing session due to timer"),f.refresh(ls()||o)}}),e)}}}));return Object.assign(ir(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Yi("Clearing all timers"),a(),n})),{markUserActive:u?()=>{Yi("markUserActive() called"),h||Yi("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(Yi("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(ls()||d))}:()=>{Gi("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(i),{getLastUserLoginId:Es,getLastUserDisplayName:_s});const s=e(qi(i,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:r}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=Fi((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;i?(Rs(i),(e=>{Hi(Cs,e)})(s)):(null==r?void 0:r.loginId)&&Rs(r.loginId)}}));let a=ir(s,["flow.start"],Ts);return a=ir(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(Zi(xs),Zi(Cs)),o})(r)),Object.assign(a,{getLastUserLoginId:Es,getLastUserDisplayName:_s})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:r,refreshTokenViaCookie:i,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!o||!Ai)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(qi(Object.assign({refreshCookieName:a},l),{beforeRequest:hs(s,i,a),afterRequest:async(e,t)=>{if(Ji(e,t))Yi("Session invalidated, clearing persisted tokens"),us(s,r,i,c);else{const e=await zi(t);e.cookieName?Hi(`${s||""}${os}`,e.cookieName):e.refreshJwt&&Zi(`${s||""}${os}`);const n=((e={},t=!1,n="",o=!1)=>{var r,i,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(o){Zi(`${n}${ts}`);const t=o.sameSite||"Strict",s=null===(r=o.secure)||void 0===r||r,a=null!==(i=o.domain)&&void 0!==i?i:e.cookieDomain,l=as(o);s&&"https:"!==window.location.protocol&&Gi("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});rs(l,c,d);const h=is(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=as(o);wi.remove(e),Hi(`${n}${ts}`,c)}if(l)if(t){const n=t.sameSite||"Strict",o=null===(s=t.secure)||void 0===s||s,r=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,i=ss(t);o&&"https:"!==window.location.protocol&&Gi("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:r});rs(i,l,c);const d=is(r);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?r:void 0}})}else Hi(`${n}${es}`,l);return e.idToken&&Hi(`${n}${ns}`,e.idToken),d&&Hi(`${n}DTD`,d),u})(e,r,s,i);n&&(c=n)}}})),u=ir(d,["logout","logoutAll","oidc.logout"],((e,t,n,o)=>r=>async(...i)=>{const s=await r(...i);return us(e,t,n,null==o?void 0:o()),s})(s,r,i,(()=>c)));return Object.assign(u,{getRefreshToken:()=>ls(s,i),getSessionToken:()=>cs(s,r),getIdToken:()=>ds(s)})}))((e=>{const t=mi(e),n=Gs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(o,r)=>{var i;if(Bi())return Yi(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(r&&!Ki(As)&&!Ki(xs)&&!Ki("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=cs(),a=ls();let l="";if(e.getExternalToken)try{l=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){Yi("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:s?"t":"f",dcr:a?"t":"f"},l,r)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:Zs(t),webauthn:Bs(t),fedcm:(o=t,r=e.projectId,{onetap:{requestExchangeCode(e){Hs(o,e)},requestAuthentication(e){Hs(o,e)}},async oneTap(e,t,n,r,i){await Ks(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:r,onDismissed:i})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(r+Js),clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(i.token)},isSupported:()=>Ai&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(r+Js);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!i&&!!i.token}catch(e){return!1}}}),oidc:n});var o,r})),ea={search:"/v1/mgmt/role/search",deleteBatch:"/v1/mgmt/role/delete/batch",create:"/v1/mgmt/role/create",update:"/v1/mgmt/role/update"},ta={permissions:"/v1/mgmt/permission/all"},na=e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),oa=(e,t)=>n(void 0,[e,t],void 0,(function*({text:e,sort:t},n){return new Promise((o=>{const r=[];for(let e=1;e<10;e+=1)r.push({name:`Role ${e}`,description:`Role description ${e}`,permissionNames:[`Permission ${e}`],createdTime:new Date,tenantId:n});t.forEach((e=>{r.sort(((t,n)=>{var o,r;return e.desc?null===(r=n[e.field])||void 0===r?void 0:r.localeCompare(t[e.field]):null===(o=t[e.field])||void 0===o?void 0:o.localeCompare(n[e.field])}))})),o(r.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()))))}))})),ra=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,description:t,permissionNames:n},o){return new Promise((r=>{r({name:e,description:t,permissionNames:n,createdTime:new Date,tenantId:o})}))})),ia=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,newName:t,description:n,permissionNames:o},r){return new Promise((i=>{i({name:t,description:n,permissionNames:o,createdTime:new Date,oldName:e,tenantId:r})}))})),sa=()=>n(void 0,void 0,void 0,(function*(){})),aa=()=>new Promise((e=>{const t=[];for(let e=1;e<5;e+=1)t.push({name:`Permission ${e}`});e({permissions:t})})),la=({httpClient:e,tenant:t,mock:o})=>({search:(...r)=>n(void 0,[...r],void 0,(function*({page:n,limit:r=1e4,text:i,sort:s}={}){if(o)return oa({page:n,limit:r,text:i,sort:s},t);const a=yield e.post(ea.search,{limit:r,page:n,text:i,sort:s},{queryParams:{tenant:t}});yield na(a);return(yield a.json()).roles})),deleteBatch:r=>n(void 0,void 0,void 0,(function*(){if(o)return sa();const n=yield e.post(ea.deleteBatch,{roleNames:r},{queryParams:{tenant:t}});return yield na(n),n.json()})),create:r=>n(void 0,[r],void 0,(function*({name:n,description:r,permissionNames:i}){if(o)return ra({name:n,description:r,permissionNames:i},t);const s=yield e.post(ea.create,{name:n,description:r,permissionNames:i,tenantId:t},{queryParams:{tenant:t}});yield na(s);return yield s.json()})),update:r=>n(void 0,[r],void 0,(function*({name:n,newName:r,description:i,permissionNames:s}){if(o)return ia({name:n,newName:r,description:i,permissionNames:s},t);const a=yield e.post(ea.update,{name:n,newName:r,description:i,permissionNames:s,tenantId:t},{queryParams:{tenant:t}});yield na(a);const l=yield a.json();return l.oldName=n,l}))}),ca=({httpClient:e,tenant:t,mock:o})=>({getTenantPermissions:()=>n(void 0,void 0,void 0,(function*(){if(o)return aa();const n=yield e.get(ta.permissions,{queryParams:{tenant:t}});return yield na(n),n.json()}))}),da=u((e=>{var t,s,a,l;const c=i(E,C,b,_,On,R({tenant:R.missingAttrValidator}))(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),r(this,s,((e,t,n,o)=>{const r=Qs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"role-management-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.7.2"}}));return{role:la({httpClient:r.httpClient,tenant:t,mock:n}),tenant:ca({httpClient:r.httpClient,tenant:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},l})),ua=u((e=>{const t=i(kn({name:"widget",initialState:eo,reducers:{setSelectedRolesIds:(e,{payload:t})=>{e.selectedRolesIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Ln.reducer(e),Jn.reducer(e),Yn.reducer(e),qn.reducer(e),Kn.reducer(e),Qn.reducer(e)},asyncActions:{searchRoles:Kn.action,createRole:Ln.action,duplicateRole:Jn.action,updateRole:Yn.action,deleteRoles:qn.action,getTenantPermissions:Qn.action}}),x,b,da)(e);return class extends t{constructor(...e){super(...e),this.state=eo,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),ha=u((e=>{const t=i($,R({"widget-id":R.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`role-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),pa=u((e=>{var t,r,a;return a=class extends(i(b,x,B,X,ha,ua)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([o(this,t,"m",r).call(this),this.actions.searchRoles(),this.actions.getTenantPermissions()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,r=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),fa=u((e=>{var t,a,l,c,d,u,h;return h=class extends(i(ua,ue,In,b,pa)(e)){constructor(){super(...arguments),t.add(this),a.set(this,void 0),l.set(this,"create"),c.set(this,null),u.set(this,(()=>n(this,void 0,void 0,(function*(){var e;yield o(this,a,"f").setData(null===(e=Cn(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}openRoleModal(e="create",t){r(this,l,e,"f"),r(this,c,null!=t?t:null,"f"),this.roleFormModal.open()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",d).call(this)}))}},a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,t=new WeakSet,d=function(){return n(this,void 0,void 0,(function*(){this.roleFormModal=this.createModal(),this.roleFormModal.setContent(s(yield this.fetchWidgetPage("create-role-modal.html")));new te((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}));new te((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>n(this,void 0,void 0,(function*(){if(this.validateForm(this.roleFormModal.ele)){const e=this.getFormData(this.roleFormModal.ele);"duplicate"===o(this,l,"f")?this.actions.duplicateRole(Object.assign({},e)):this.actions.createRole(Object.assign({},e)),this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}})))),r(this,a,new ae((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),o(this,u,"f").call(this),this.roleFormModal.beforeOpen=()=>n(this,void 0,void 0,(function*(){yield o(this,u,"f").call(this),o(this,c,"f")&&(this.setFormData(this.roleFormModal.ele,o(this,c,"f")),r(this,c,null,"f"))}))}))},h})),ga=u((e=>{var t,r,s;return s=class extends(i(b,fa,pa)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){var e;this.createButton=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-role"]'),{logger:this.logger}),this.createButton.onClick((()=>this.openRoleModal()))},s})),va=u((e=>{var t,r,a;return a=class extends(i(ua,ue,b,pa)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){return n(this,void 0,void 0,(function*(){var e;this.deleteRolesModal=this.createModal(),this.deleteRolesModal.setContent(s(yield this.fetchWidgetPage("delete-roles-modal.html")));const t=new te((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteRolesModal.close()));const n=new te((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=En(this.state);this.actions.deleteRoles(null==e?void 0:e.map((e=>e.name))),this.deleteRolesModal.close()}));const o=new ce(null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteRolesModal.beforeOpen=()=>{const e=$n(this.state);o.text=`Delete ${e}?`}}))},a})),ma=u((e=>{var t,r,s,a;return a=class extends(i(b,pa,ua,va)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.subscribe(o(this,s,"f").bind(this),_n)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.deleteButton=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-roles"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteRolesModal.open()}))},a})),ya=u((e=>{var t,r,s,a;return a=class extends(i(b,pa,ua,fa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.duplicateButton.enable():this.duplicateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.subscribe(o(this,s,"f").bind(this),Tn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.duplicateButton=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="duplicate-role"]'),{logger:this.logger}),this.duplicateButton.disable(),this.duplicateButton.onClick((()=>{var e,t,n;const o=null===(e=En(this.state))||void 0===e?void 0:e[0];o&&this.openRoleModal("duplicate",{name:`${o.name} Copy`,description:null!==(t=o.description)&&void 0!==t?t:"",permissionNames:null!==(n=o.permissionNames)&&void 0!==n?n:[]})}))},a})),wa=u((e=>{var a,l,c,d,u,h,p,f;return f=class extends(i(ua,ue,b,In,pa)(e)){constructor(){super(...arguments),a.add(this),l.set(this,void 0),u.set(this,(()=>n(this,void 0,void 0,(function*(){var e;yield o(this,l,"f").setData(null===(e=Cn(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),h.set(this,(()=>{var e;const t=null===(e=En(this.state))||void 0===e?void 0:e[0],n={name:null==t?void 0:t.name,description:null==t?void 0:t.description,permissionNames:null==t?void 0:t.permissionNames};this.setFormData(this.editRoleModal.ele,n)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),yield o(this,a,"m",p).call(this)}))}},l=new WeakMap,u=new WeakMap,h=new WeakMap,a=new WeakSet,c=function(){new te((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editRoleModal.close()))},d=function(){new te((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{var e;if(this.validateForm(this.editRoleModal.ele)){const n=this.getFormData(this.editRoleModal.ele),{name:o}=n,r=t(n,["name"]),i=null===(e=En(this.state))||void 0===e?void 0:e[0];this.actions.updateRole(Object.assign({newName:o,name:i.name},r)),this.editRoleModal.close(),this.resetFormData(this.editRoleModal.ele)}}))},p=function(){return n(this,void 0,void 0,(function*(){this.editRoleModal=this.createModal(),this.editRoleModal.setContent(s(yield this.fetchWidgetPage("edit-role-modal.html"))),o(this,a,"m",c).call(this),o(this,a,"m",d).call(this),r(this,l,new ae((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),this.editRoleModal.beforeOpen=()=>n(this,void 0,void 0,(function*(){yield o(this,u,"f").call(this),o(this,h,"f").call(this)}))}))},f})),ba=u((e=>{var t,r,s,a;return a=class extends(i(b,pa,ua,wa,In)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.subscribe(o(this,s,"f").bind(this),An)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.editButton=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-role"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editRoleModal.open()}))},a})),ka=u((e=>{var t,r,s,a;return a=class extends(i(b,pa,ua)(e)){constructor(){super(...arguments),t.add(this),r.set(this,d((()=>{this.actions.searchRoles({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",s).call(this)}))}},r=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new de(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(o(this,r,"f"))},a}));const Ia={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Sa=u((e=>{var t,r,s,a,c;return c=class extends(i(b,ua,pe,x)(e)){constructor(){super(...arguments),t.add(this),a.set(this,l((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const i=o(this,t,"m",s).call(this,e);i.setContent(o(this,t,"m",r).call(this,{type:e,msg:n})),i.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(o(this,a,"f").bind(this),xn)}))}},a=new WeakMap,t=new WeakSet,r=function({type:e,msg:t}){const n=Ia[e],o=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${o.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},c})),Oa=u((e=>{var t,r,s,a,c;return c=class extends(i(ua,b,pa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,l((e=>{this.rolesTable.data=e}))),a.set(this,d(((e,t)=>{const n=[],{value:o}=t;if(o){const t=e.path;n.push({field:t,desc:"desc"===o})}this.actions.searchRoles({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{o(this,a,"f").call(this,e.target,e.detail)}))})),o(this,s,"f").call(this,Rn(this.state)),this.subscribe(o(this,s,"f").bind(this),Rn)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,r=function(){var e;this.rolesTable=new re(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-table"]'),{logger:this.logger}),this.rolesTable.onSelectedItemsChange((e=>{this.actions.setSelectedRolesIds(e.detail.value.map((({name:e})=>e)))}))},c})),ja=u((e=>class extends(i(U,we,Oa,ga,ma,ya,ba,ka,Sa)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),xa=i((e=>class extends(ja(e)){}))(HTMLElement);customElements.define("descope-role-management-widget",xa);const Ca=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Ra,Ea,_a,Ta,Aa,$a,Ma,Pa,Ua,Da;const Na=document.createElement("template");Na.innerHTML=`\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;const La=i(H)(HTMLElement);class Wa extends La{constructor(){var e;super(),Ra.add(this),Ea.set(this,new m({messages:[]})),_a.set(this,void 0),Ta.set(this,void 0),Aa.set(this,void 0),$a.set(this,{resize:o(this,Ra,"m",Da).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Na.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),r(this,_a,this.shadowRoot.querySelector(".debugger"),"f"),r(this,Ta,o(this,_a,"f").querySelector(".content"),"f"),r(this,Aa,o(this,_a,"f").querySelector(".header"),"f")}updateData(e){o(this,Ea,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,l]=Ca(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(o(this,_a,"f"),o(this,Aa,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,$a,"f").resize),(e=o(this,_a,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,_a,"f").onresize=o(this,Ra,"m",Ua).bind(this),o(this,Ea,"f").subscribe(o(this,Ra,"m",Ma).bind(this))}disconnectedCallback(){o(this,Ea,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,$a,"f").resize)}}Ea=new WeakMap,_a=new WeakMap,Ta=new WeakMap,Aa=new WeakMap,$a=new WeakMap,Ra=new WeakSet,Ma=function(e){o(this,Ra,"m",Pa).call(this,e),o(this,Ra,"m",Ua).call(this)},Pa=function(e){o(this,Ta,"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("")},Ua=function(){o(this,Ta,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,r=n.clientHeight>20;o||r?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Da=function(){const[e,t]=Ca(o(this,_a,"f"),Number.parseInt(o(this,_a,"f").style.left,10),Number.parseInt(o(this,_a,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,_a,"f").style.top=`${t}px`,o(this,_a,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Wa);var Fa=Object.freeze({__proto__:null,default:Wa});return xa}();
|
|
7
7
|
//# sourceMappingURL=index.js.map
|