@descope/audit-management-widget 0.5.35 → 0.5.37
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.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/audit-management-widget v0.5.
|
|
3
|
+
* @descope/audit-management-widget v0.5.37
|
|
4
4
|
*/
|
|
5
|
-
this["descope-audit-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function r(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function o(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),c=(e,t=500)=>{let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},l=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const r=e(n);return r[t]=!0,r}};var u,d,h,p;function f(e,t){const n=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r],i=e[o],s=t[o];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!f(i,s))return!1}else if(i!==s)return!1}return!0}let g=class{constructor(e={},{forceUpdate:t=!1}={}){u.set(this,void 0),d.set(this,{}),h.set(this,0),p.set(this,!0),this.update=e=>{const t="function"==typeof e?e(r(this,u,"f")):e,n=Object.assign(Object.assign({},r(this,u,"f")),t);if(r(this,p,"f")||!f(r(this,u,"f"),n)){const e=r(this,u,"f");o(this,u,n,"f"),Object.freeze(r(this,u,"f")),setTimeout((()=>{Object.values(r(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,u,e,"f"),o(this,p,t,"f")}get current(){return Object.assign({},r(this,u,"f"))}subscribe(e){return o(this,h,r(this,h,"f")+1,"f"),r(this,d,"f")[r(this,h,"f")]=e,r(this,h,"f").toString()}unsubscribe(e){const t=!!r(this,d,"f")[e];return t&&delete r(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};u=new WeakMap,d=new WeakMap,h=new WeakMap,p=new WeakMap;const v=["error","warn","info","debug"],m={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},y=l((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,r(this,t,"m",i).call(this,m))}set logger(e){o(this,n,r(this,t,"m",i).call(this,e||m),"f")}get logger(){return r(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return v.reduce(((t,n)=>(t[n]=(...t)=>{var r;this.onLogEvent(n,t),null===(r=e[n])||void 0===r||r.call(e,...t)},t)),{})},s})),w="undefined"!=typeof localStorage,b="https://static.descope.com/pages",k="https://static2.descope.com/pages",I=w&&localStorage.getItem("base.content.url")||"",O=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,S=l((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)&&r(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),j=l((e=>{var t,n;const o=i(y,S)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=r(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){r(this,t,"f")[e]||(r(this,t,"f")[e]=[]);const o=r(this,t,"f")[e].push(n);return()=>r(this,t,"f")[e].splice(o,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})),x=e=>t=>{var n,o,s;const a=i(y,S,j)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,r(this,n,"m",o).bind(this))}async init(){var e;c.forEach((e=>r(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const r=e[t],o="function"==typeof r?r(t,n):r;o&&this.logger.error(o)},s};x.missingAttrValidator=O;const C=l((e=>{const t=i(x({"project-id":O}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),E=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),_="Trying the next fallback URL...",A=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(r){return null==n||n.debug(`Network error fetching URL ${e} [${r.message}], retrying...`),fetch(e,t)}};const T=l((e=>{var t,n,s,a,c,l,u;const d=i(y,C,E)(e);return u=class extends d{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=r(this,t,"m",c).call(this,e),l=Array.isArray(i)?e=>{const{baseUrl:t}=i[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=i[t].baseUrl;r(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:r}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const i=o[e],s=e===o.length-1;try{const o=await A(i.toString(),t,{logger:n});if(o.ok)return null==r||r(e),null==n||n.debug(`Successfully fetched URL ${i}`),o;const a=`Error fetching URL ${i} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${_}`)}catch(e){const t=`Error fetching URL ${i} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${_}`)}}})(i,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(e){const i=I||this.baseStaticUrl;if(i)return r(this,t,"m",l).call(this,e,i);r(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),r(this,a,"f").clear());const c=[];if(r(this,s,"f"))c.push(r(this,t,"m",l).call(this,e,r(this,s,"f"))),r(this,s,"f")===b&&c.push(r(this,t,"m",l).call(this,e,k));else{const n=this.baseUrl+"/pages";this.baseUrl&&!r(this,a,"f").has(n)&&c.push(r(this,t,"m",l).call(this,e,n)),r(this,a,"f").has(b)||c.push(r(this,t,"m",l).call(this,e,b)),c.push(r(this,t,"m",l).call(this,e,k))}return 1===c.length?c[0]:c},l=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:r=b}){const o=new URL(r);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=r,o}({projectId:this.projectId,filename:e,baseUrl:t})},u})),R=l((e=>{var t,n;const o=i(x({"project-id":O}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(r(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return r(this,t,"f").set(e,n),()=>{r(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(r(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!r(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=r(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),$=l((e=>{var t,n,s,a,c;const l=i(T,R,S)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",r(this,t,"m",n).bind(this))}get config(){return r(this,s,"f")||o(this,s,r(this,a,"f").call(this),"f"),r(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},c})),U=l((e=>{var t,n,s,a,c,l,u;return u=class extends(i(S,y)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,o),"debug"===e&&r(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&r(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),r(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=r(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(r(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return qs})),document.body.appendChild(r(this,n,"f"))},c=function(){this.debug?r(this,t,"m",a).call(this):r(this,t,"m",s).call(this)},l=function(e,t){var o;e&&(null===(o=r(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},u})),P=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],D=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(((r,o)=>{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"),o(e)},i.onload=()=>{i.setAttribute("status","loaded"),r(i)},i.src=t.toString(),document.body.appendChild(i)})),M=(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)}))}))},N=l((e=>{const t=i(y)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",r=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const r of e){const{id:e,url:o,integrity:i}=r,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await M(s,i),r}catch(e){t(r,!0)}else try{return await L(e,o,i),r}catch(e){t(r,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,r="",o)=>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}/${r}`);const c={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${D(a)}`};return o&&(c.integrity=o),[...e,c]}),[]))([...r,this.baseCdnUrl,...P],e,t,n,o),((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}"`)}))}}})),W="base.ui.components.url",q=w&&localStorage.getItem(W),F=l((e=>{var t,n,s,a,c,l,u;const d=i(y,$,N)(e);return u=class extends d{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return r(this,a,"f")||o(this,a,r(this,t,"m",l).call(this),"f"),r(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=>r(this,t,"m",c).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},c=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},l=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await r(this,t,"m",n).call(this),o=await r(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[q],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},u})),z=l((e=>{var t,n,o;const s=i(S,j)(e);return o=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",r(this,t,"m",n).bind(this)),r(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class J{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 V=l((e=>{const t=i(z)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new J(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const r=[...e.adoptedStyleSheets||[]];r[t?"unshift":"push"](n),e.adoptedStyleSheets=r}}return n}}})),H="content-root",K="root",B=l((e=>{const t=i(V)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${H}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${H} {\n height: 100%;\n }\n #${K} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(H),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),X="descope-modal";var Y,G;let Z=class{constructor(e,t){Y.set(this,void 0),this.nodeName="",o(this,Y,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const r="function"==typeof e?e():e;r&&(clearInterval(n),t(r))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(r(this,Y,"f"))}get ele(){var e,t;const n="function"==typeof r(this,Y,"f")?r(this,Y,"f").call(this):r(this,Y,"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}};Y=new WeakMap;const Q=/^descope-grid-([^-]+)-column$/,ee={text:class extends Z{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 Z{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 te=class extends Z{constructor(){super(...arguments),this.nodeName="descope-grid",G.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 r=null===(n=Q.exec(t.localName))||void 0===n?void 0:n[1],o=ee[r];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const o=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);o&&this.ele.columns&&(a(o,this.ele.columns)||(this.ele.columns=o,null===(n=r(this,G,"f"))||void 0===n||n.call(this,o)))}onColumnsChange(e){o(this,G,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var ne;G=new WeakMap;let re=class extends Z{constructor(){super(...arguments),ne.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=""),r(this,ne,"f")&&(null===(e=this.ele)||void 0===e||e.append(r(this,ne,"f").content.cloneNode(!0)))}setContent(e){o(this,ne,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};ne=new WeakMap;let oe=class extends Z{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()}},ie=class extends Z{constructor(){super(...arguments),this.nodeName="descope-combo-box"}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)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},se=class extends Z{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")}};l((e=>{var t,n;const o=i(S,B,F)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends re{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(X);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(r(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([X]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));const ae="descope-notification";l((e=>{var t,n;const o=i(S,B,F)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends oe{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ae);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(r(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([ae])}},t=new WeakMap,n}));const ce=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',le=l((e=>{var t,n,s,a,c,l,u,d,h,p,f,g,v,m;const y=i(x({theme:ce}),T,S,F,$,B,j,V)(e);return m=class extends y{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{r(this,t,"m",g).call(this),r(this,v,"f").call(this,"os"===this.getAttribute("theme"))})),v.set(this,(e=>{var n,o,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===i||i.call(o,"change",(()=>r(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),r(this,f,"f").call(this),await Promise.all([r(this,t,"m",l).call(this),r(this,t,"m",u).call(this)]),this.observeAttributes(["theme"],r(this,f,"f")),this.observeAttributes(["style-id"],(()=>{o(this,s,null,"f"),r(this,t,"m",h).call(this),r(this,t,"m",l).call(this),r(this,t,"m",u).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(W))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(W),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},c=function(){return r(this,s,"f")||(o(this,s,r(this,t,"m",a).call(this),"f"),r(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),r(this,s,"f")},l=async function(){var e,i;const s=await r(this,t,"a",c);s&&(r(this,n,"f")||o(this,n,this.injectStyle(""),"f"),r(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)||"")))},u=async function(){var e,n;const o=await r(this,t,"a",c);if(!o)return;const i=await this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config||{},r=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,i=r||o;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},h=async function(){const e=await r(this,t,"m",d).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},p=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){r(this,t,"m",h).call(this),r(this,t,"m",p).call(this)},m}));var ue=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),de=()=>Math.random().toString(36).substring(7).split("").join("."),he={INIT:`@@redux/INIT${de()}`,REPLACE:`@@redux/REPLACE${de()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${de()}`};function pe(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 fe(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 ge(e){let t=typeof e;return t=fe(e),t}function ve(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${ge(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: '${ge(n)}'`);return n(ve)(e,t)}let r=e,o=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function u(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function d(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${ge(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function h(e){if(!pe(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${ge(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: '${ge(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,o=r(o,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}h({type:he.INIT});return{dispatch:h,subscribe:d,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${ge(e)}`);r=e,h({type:he.REPLACE})},[ue]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${ge(t)}'`);function n(){const e=t;e.next&&e.next(u())}n();return{unsubscribe:e(n)}},[ue](){return this}}}}}function me(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ye(e){const t=Object.keys(e),n={};for(let r=0;r<t.length;r++){const o=t[r];void 0===e[o]&&me(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const r=Object.keys(n);let o,i;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:he.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:he.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 '${he.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;{const r=function(e,t,n,r){const o=Object.keys(t),i=n&&n.type===he.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!pe(e))return`The ${i} has unexpected type of "${ge(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!r[e]));return s.forEach((e=>{r[e]=!0})),n&&n.type===he.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);r&&me(r)}let s=!1;const a={};for(let o=0;o<r.length;o++){const i=r[o],c=n[i],l=e[i],u=c(l,t);if(void 0===u){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=u,s=s||u!==l}return s=s||r.length!==Object.keys(e).length,s?a:e}}function we(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function be(e){return pe(e)&&"type"in e&&"string"==typeof e.type}var ke=Symbol.for("immer-nothing"),Ie=Symbol.for("immer-draftable"),Oe=Symbol.for("immer-state"),Se=[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 je(e,...t){{const n=Se[e],r="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}}var xe=Object.getPrototypeOf;function Ce(e){return!!e&&!!e[Oe]}function Ee(e){return!!e&&(Ae(e)||Array.isArray(e)||!!e[Ie]||!!e.constructor?.[Ie]||Pe(e)||De(e))}var _e=Object.prototype.constructor.toString();function Ae(e){if(!e||"object"!=typeof e)return!1;const t=xe(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)===_e}function Te(e,t){0===Re(e)?Object.entries(e).forEach((([n,r])=>{t(n,r,e)})):e.forEach(((n,r)=>t(r,n,e)))}function Re(e){const t=e[Oe];return t?t.type_:Array.isArray(e)?1:Pe(e)?2:De(e)?3:0}function $e(e,t){return 2===Re(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ue(e,t,n){const r=Re(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function Pe(e){return e instanceof Map}function De(e){return e instanceof Set}function Le(e){return e.copy_||e.base_}function Me(e,t){if(Pe(e))return new Map(e);if(De(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ae(e)){if(!xe(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Oe];let r=Reflect.ownKeys(n);for(let t=0;t<r.length;t++){const o=r[t],i=n[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(xe(e),n)}function Ne(e,t=!1){return qe(e)||Ce(e)||!Ee(e)||(Re(e)>1&&(e.set=e.add=e.clear=e.delete=We),Object.freeze(e),t&&Te(e,((e,t)=>Ne(t,!0)))),e}function We(){je(2)}function qe(e){return Object.isFrozen(e)}var Fe,ze={};function Je(e){const t=ze[e];return t||je(0,e),t}function Ve(){return Fe}function He(e,t){t&&(Je("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ke(e){Be(e),e.drafts_.forEach(Ye),e.drafts_=null}function Be(e){e===Fe&&(Fe=e.parent_)}function Xe(e){return Fe={drafts_:[],parent_:Fe,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ye(e){const t=e[Oe];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Ge(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Oe].modified_&&(Ke(t),je(4)),Ee(e)&&(e=Ze(t,e),t.parent_||et(t,e)),t.patches_&&Je("Patches").generateReplacementPatches_(n[Oe].base_,e,t.patches_,t.inversePatches_)):e=Ze(t,n,[]),Ke(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ke?e:void 0}function Ze(e,t,n){if(qe(t))return t;const r=t[Oe];if(!r)return Te(t,((o,i)=>Qe(e,r,t,o,i,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return et(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let o=t,i=!1;3===r.type_&&(o=new Set(t),t.clear(),i=!0),Te(o,((o,s)=>Qe(e,r,t,o,s,n,i))),et(e,t,!1),n&&e.patches_&&Je("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Qe(e,t,n,r,o,i,s){if(o===n&&je(5),Ce(o)){const s=Ze(e,o,i&&t&&3!==t.type_&&!$e(t.assigned_,r)?i.concat(r):void 0);if(Ue(n,r,s),!Ce(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(Ee(o)&&!qe(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ze(e,o),t&&t.scope_.parent_||et(e,o)}}function et(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ne(t,n)}var tt={get(e,t){if(t===Oe)return e;const n=Le(e);if(!$e(n,t))return function(e,t,n){const r=ot(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!Ee(r)?r:r===rt(e.base_,t)?(st(e),e.copy_[t]=at(r,e)):r},has:(e,t)=>t in Le(e),ownKeys:e=>Reflect.ownKeys(Le(e)),set(e,t,n){const r=ot(Le(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=rt(Le(e),t),o=r?.[Oe];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,r)&&(void 0!==n||$e(e.base_,t)))return!0;st(e),it(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!==rt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,st(e),it(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Le(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){je(11)},getPrototypeOf:e=>xe(e.base_),setPrototypeOf(){je(12)}},nt={};function rt(e,t){const n=e[Oe];return(n?Le(n):e)[t]}function ot(e,t){if(!(t in e))return;let n=xe(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=xe(n)}}function it(e){e.modified_||(e.modified_=!0,e.parent_&&it(e.parent_))}function st(e){e.copy_||(e.copy_=Me(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Te(tt,((e,t)=>{nt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),nt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&je(13),nt.set.call(this,e,t,void 0)},nt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&je(14),tt.set.call(this,e[0],t,n,e[0])};function at(e,t){const n=Pe(e)?Je("MapSet").proxyMap_(e,t):De(e)?Je("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Ve(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=tt;n&&(o=[r],i=nt);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}(e,t);return(t?t.scope_:Ve()).drafts_.push(n),n}function ct(e){return Ce(e)||je(10,e),lt(e)}function lt(e){if(!Ee(e)||qe(e))return e;const t=e[Oe];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Me(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Me(e,!0);return Te(n,((e,t)=>{Ue(n,e,lt(t))})),t&&(t.finalized_=!1),n}var ut=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const r=this;return function(e=n,...o){return r.produce(e,(e=>t.call(this,e,...o)))}}let r;if("function"!=typeof t&&je(6),void 0!==n&&"function"!=typeof n&&je(7),Ee(e)){const o=Xe(this),i=at(e,void 0);let s=!0;try{r=t(i),s=!1}finally{s?Ke(o):Be(o)}return He(o,n),Ge(r,o)}if(!e||"object"!=typeof e){if(r=t(e),void 0===r&&(r=e),r===ke&&(r=void 0),this.autoFreeze_&&Ne(r,!0),n){const t=[],o=[];Je("Patches").generateReplacementPatches_(e,r,t,o),n(t,o)}return r}je(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;const o=this.produce(e,t,((e,t)=>{n=e,r=t}));return[o,n,r]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Ee(e)||je(8),Ce(e)&&(e=ct(e));const t=Xe(this),n=at(e,void 0);return n[Oe].isManual_=!0,Be(t),n}finishDraft(e,t){const n=e&&e[Oe];n&&n.isManual_||je(9);const{scope_:r}=n;return He(r,t),Ge(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=Je("Patches").applyPatches_;return Ce(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},dt=ut.produce;ut.produceWithPatches.bind(ut),ut.setAutoFreeze.bind(ut),ut.setUseStrictShallowCopy.bind(ut),ut.applyPatches.bind(ut),ut.createDraft.bind(ut),ut.finishDraft.bind(ut);var ht=(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})}}},pt=(e,t,n)=>{const{memoize:r,memoizeOptions:o}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=r((()=>({})),...o);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},ft={inputStabilityCheck:"once",identityFunctionCheck:"once"};var gt=e=>Array.isArray(e)?e:[e];function vt(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function mt(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var yt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},wt=0,bt=1;function kt(){return{s:wt,v:void 0,o:null,p:null}}function It(e,t={}){let n=kt();const{resultEqualityCheck:r}=t;let o,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const r=e.get(n);void 0===r?(t=kt(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=kt(),e.set(n,t)):t=r}}const a=t;let c;if(t.s===bt)c=t.v;else if(c=e.apply(null,arguments),i++,r){const e=o?.deref?.()??o;null!=e&&r(e,c)&&(c=e,0!==i&&i--);o="object"==typeof c&&null!==c||"function"==typeof c?new yt(c):c}return a.s=bt,a.v=c,c}return s.clearCache=()=>{n=kt(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function Ot(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t,r=0,o=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:u=It,argsMemoizeOptions:d=[],devModeChecks:h={}}=a,p=gt(l),f=gt(d),g=vt(e),v=c((function(){return r++,s.apply(null,arguments)}),...p);let m=!0;const y=u((function(){o++;const e=mt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:r}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...ft,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ht},inputStabilityCheck:{shouldRun:"always"===r||"once"===r&&e,run:pt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),r.shouldRun){const t=mt(g,arguments);r.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:c,argsMemoize:u})};return Object.assign(r,{withTypes:()=>r}),r}var St=Ot(It),jt=Object.assign(((e,t=St)=>{!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,r)=>(e[n[r]]=t,e)),{})))}),{withTypes:()=>jt});function xt(e){return({dispatch:t,getState:n})=>r=>o=>"function"==typeof o?o(t,n,e):r(o)}var Ct=xt(),Et=xt;((...e)=>{const t=Ot(...e)})(It);var _t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?we:we.apply(null,arguments)},At=e=>e&&"function"==typeof e.match;function Tt(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw new Error("prepareAction did not return an object");return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>be(t)&&t.type===e,n}function Rt(e){return"function"==typeof e&&"type"in e&&At(e)}function $t(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 Ut=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Pt(e){return Ee(e)?dt(e,(()=>{})):e}function Dt(e,t,n){if(e.has(t)){let r=e.get(t);return n.update&&(r=n.update(r,t,e),e.set(t,r)),r}if(!n.insert)throw new Error("No insert provided for key not already in map");const r=n.insert(t,e);return e.set(t,r),r}function Lt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Mt(e,t,n){const r=Nt(e,t,n);return{detectMutations:()=>Wt(e,t,r,n)}}function Nt(e,t=[],n,r="",o=new Set){const i={value:n};if(!e(n)&&!o.has(n)){o.add(n),i.children={};for(const o in n){const s=r?r+"."+o:o;t.length&&-1!==t.indexOf(s)||(i.children[o]=Nt(e,t,n[o],s))}}return i}function Wt(e,t=[],n,r,o=!1,i=""){const s=n?n.value:void 0,a=s===r;if(o&&!a&&!Number.isNaN(r))return{wasMutated:!0,path:i};if(e(s)||e(r))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in r)c[e]=!0;const l=t.length>0;for(let o in c){const s=i?i+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Wt(e,t,n.children[o],r[o],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function qt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||pe(e)}function Ft(e,t="",n=qt,r,o=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=r?r(e):Object.entries(e),c=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Ft(l,a,n,r,o,i),s))return s}return i&&zt(e)&&i.add(e),!1}function zt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!zt(t))return!1;return!0}function Jt(e){return"boolean"==typeof e}var Vt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:o=!0}=e??{};let i=new Ut;if(t&&(Jt(t)?i.push(Ct):i.push(Et(t.extraArgument))),n){let e={};Jt(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,r,o){return JSON.stringify(e,n(t,o),r)},n=function(e,t){let n=[],r=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+r.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?r.splice(s,1/0,o):r.push(o),~n.indexOf(i)&&(i=t.call(this,o,i))}else n.push(i);return null==e?i:e.call(this,o,i)}},{isImmutable:r=Lt,ignoredPaths:o,warnAfter:i=32}=e;const s=Mt.bind(null,r,o);return({getState:e})=>{let n,r=e(),o=s(r);return a=>c=>{const l=$t(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const u=a(c);return l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),u}}}}(e))}if(r){let e={};Jt(r)||(e=r),i.push(function(e={}){{const{isSerializable:t=qt,getEntries:n,ignoredActions:r=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,u=!l&&WeakSet?new WeakSet:void 0;return e=>l=>d=>{if(!be(d))return l(d);const h=l(d),p=$t(s,"SerializableStateInvariantMiddleware");return c||r.length&&-1!==r.indexOf(d.type)||p.measureTime((()=>{const e=Ft(d,"",t,n,o,u);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",d,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const r=Ft(e.getState(),"",t,n,i,u);if(r){const{keyPath:e,value:t}=r;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${d.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};Jt(o)||(e=o),i.unshift(function(e={}){const{isActionCreator:t=Rt}=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},Ht=e=>t=>{setTimeout(t,e)},Kt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Ht(10),Bt=e=>function(t){const{autoBatch:n=!0}=t??{};let r=new Ut(e);return n&&r.push(((e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let o=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Kt:"callback"===e.type?e.queueNotification:Ht(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},r,{subscribe(e){const t=r.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,i=!o,i&&(s||(s=!0,c(l))),r.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),r};function Xt(e){const t=Vt(),{reducer:n,middleware:r,devTools:o=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!pe(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=ye(n)}if(r&&"function"!=typeof r)throw new Error("`middleware` field must be a callback");if("function"==typeof r){if(c=r(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=we;o&&(l=_t({trace:!0,..."object"==typeof o&&o}));const u=function(...e){return t=>(n,r)=>{const o=t(n,r);let i=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=we(...a)(o.dispatch),{...o,dispatch:i}}}(...c),d=Bt(u);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(d):d();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!h.includes(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return ve(a,i,l(...h))}function Yt(e){const t={},n=[];let r;const o={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(r)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,o},addMatcher(e,t){if(r)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(r)throw new Error("`builder.addDefaultCase` can only be called once");return r=e,o}};return e(o),[t,n,r]}function Gt(...e){return t=>e.some((e=>((e,t)=>At(e)?e.match(t):e(t))(e,t)))}var Zt=["name","message","stack","code"],Qt=class{constructor(e,t){this.payload=e,this.meta=t}_type},en=class{constructor(e,t){this.payload=e,this.meta=t}_type},tn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Zt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},nn=(()=>{function e(e,t,n){const r=Tt(e+"/fulfilled",((e,t,n,r)=>({payload:e,meta:{...r||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Tt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=Tt(e+"/rejected",((e,t,r,o,i)=>({payload:o,error:(n&&n.serializeError||tn)(e||"Rejected"),meta:{...i||{},arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),u=new AbortController;let d;function h(e){d=e,u.abort()}const p=async function(){let p;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||u.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>u.signal.addEventListener("abort",(()=>t({name:"AbortError",message:d||"Aborted"})))));s(o(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:u.signal,abort:h,rejectWithValue:(e,t)=>new Qt(e,t),fulfillWithValue:(e,t)=>new en(e,t)})).then((t=>{if(t instanceof Qt)throw t;return t instanceof en?r(t.payload,l,e,t.meta):r(t,l,e)}))])}catch(t){p=t instanceof Qt?i(null,l,e,t.payload,t.meta):i(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,arg:e,unwrap:()=>p.then(rn)})}}),{pending:o,rejected:i,fulfilled:r,settled:Gt(i,r),typePrefix:e})}return e.withTypes=()=>e,e})();function rn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var on=Symbol.for("rtk-slice-createasyncthunk");function sn(e,t){return`${e}/${t}`}function an(e,t,n,r){function o(o,...i){let s=n.call(e,o);if(void 0===s){if(!r)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return o.unwrapped=t,o}var cn=function({creators:e}={}){const t=e?.asyncThunk?.[on];return function(e){const{name:n,reducerPath:r=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],r]="function"==typeof e.extraReducers?Yt(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[r,o,i]=Yt(t);if(function(e){return"function"==typeof e}(e))n=()=>Pt(e());else{const t=Pt(e);n=()=>t}function s(e=n(),t){let s=[r[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(Ce(e)){const r=n(e,t);return void 0===r?e:r}if(Ee(e))return dt(e,(e=>n(e,t)));{const r=n(e,t);if(void 0===r){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return r}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)}))}i.forEach((r=>{const i=o[r],s={reducerName:r,type:sn(n,r),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},r,o){let i,s;if("reducer"in r){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(r))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=r.reducer,s=r.prepare}else i=r;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?Tt(e,s):Tt(e))}(s,i,a):function({type:e,reducerName:t},n,r,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:u}=n,d=o(e,i,u);r.exposeAction(t,d),s&&r.addCase(d.fulfilled,s);a&&r.addCase(d.pending,a);c&&r.addCase(d.rejected,c);l&&r.addMatcher(d.settled,l);r.exposeCaseReducer(t,{fulfilled:s||ln,pending:a||ln,rejected:c||ln,settled:l||ln})}(s,i,a,t)}));const l=e=>e,u=new WeakMap;let d;const h={name:n,reducerPath:r,reducer:(e,t)=>(d||(d=c()),d(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(d||(d=c()),d.getInitialState()),getSelectors(t=l){const n=Dt(u,this,{insert:()=>new WeakMap});return Dt(n,t,{insert:()=>{const n={};for(const[r,o]of Object.entries(e.selectors??{}))n[r]=an(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const r=t??this.reducerPath;return e.inject({reducerPath:r,reducer:this.reducer},n),{...this,reducerPath:r}}};return h}}();function ln(){}var un="listenerMiddleware";Tt(`${un}/add`),Tt(`${un}/removeAll`),Tt(`${un}/remove`);const dn=e=>l((t=>{const n=cn(e),r=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(y)(t)){constructor(...e){super(...e);const t=Xt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const r=await t.dispatch(e(...n));try{rn(r)}catch(e){this.logger.error(e.message,r.type,e.stack)}return r},i=Object.keys(r).reduce(((e,t)=>(e[t]=o(r[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(y(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()}}));const hn=l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),pn=(e,t)=>t?{[e]:t}:{},fn=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},gn=e=>e.selectedAuditId,vn=St((e=>e.auditList.data),(e=>e.map((e=>{const n=e||{},{occurred:r,ID:o,type:i}=n,s=n.data,a=void 0===s?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:""}:s,{saml_request:c,saml_response:l,saml_generated_user:u,saml_generated_roles:d,oidc_response:h,oidc_generated_user:p}=a,f=t(a,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user"]),g=t(n,["occurred","ID","type","data"]),v=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},g),{data:f}),pn("type",(e=>e&&e[0].toUpperCase()+e.slice(1))(i))),pn("saml_request",c)),pn("saml_response",l)),pn("saml_generated_user",fn(u))),pn("saml_generated_roles",fn(d))),pn("oidc_response",fn(h))),pn("oidc_generated_user",fn(p))),{occurredFormatted:r?new Date(Number(r)||0).toLocaleString():"N/A"});return(e=>Object.fromEntries(Object.entries(e).filter((([e,t])=>!!t))))(v)}))));St(gn,vn,((e,t)=>t.find((t=>e===t.id)))),St(gn,(e=>!!e));const mn=nn("audit/search",((e,{extra:{api:t},getState:n})=>{const r=n().searchParams;return t.audit.search(Object.assign(Object.assign({},r),e))})),yn=(e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))})(mn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(wn=e=>e.auditList,{onFulfilled:e=>{wn(e).loading=!1},onPending:e=>{wn(e).loading=!0,wn(e).error=null},onRejected:(e,t)=>{wn(e).loading=!1,wn(e).error=t.error}}));var wn;const bn={action:mn,reducer:yn},kn={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""};class In extends Error{}function On(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 Sn(e,t){if("string"!=typeof e)throw new In("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,r=e.split(".")[n];if("string"!=typeof r)throw new In(`Invalid token specified: missing part #${n+1}`);let o;try{o=On(r)}catch(e){throw new In(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new In(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}In.prototype.name="InvalidTokenError";var jn={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 xn="<region>",Cn=`https://api.${xn}descope.com`,En=6e5,_n="dct",An=()=>{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")}},Tn=[521,524],Rn=e=>async(...t)=>{let n=await e(...t);Tn.includes(n.status)&&(n=await e(...t),n.retries=1);const r=await n.text();return n.text=()=>Promise.resolve(r),n.json=()=>Promise.resolve(JSON.parse(r)),n.clone=()=>n,n};let $n;const Un=()=>{if($n)return $n;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 $n=`${t}-${n}`,$n};var Pn,Dn;(Dn=Pn||(Pn={})).get="GET",Dn.delete="DELETE",Dn.post="POST",Dn.put="PUT",Dn.patch="PATCH";const Ln=({path:e,baseUrl:t,queryParams:n,projectId:r})=>{const o=r.slice(1,-27);t=t.replace(xn,o?o+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,r)=>{i=`${i}${0===r?"?":""}${t}=${encodeURIComponent(n[t])}${r===e.length-1?"":"&"}`}))}return i},Mn=(...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)),{})),Nn={"Content-Type":"application/json"},Wn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},qn=(e,t)=>{const n={"x-descope-sdk-session-id":Un(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.57.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Fn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var zn=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:r,logger:o,hooks:i,cookiePolicy:s,fetch:a})=>{const c=e||Cn,l=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>An().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await Rn(n)(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return An().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(r)),r}:Rn(n)})(o,a),u=async e=>{var o;const a=(null==i?void 0:i.beforeRequest)?i.beforeRequest(e):e,{path:u,body:d,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(d),m={headers:Mn(Wn(t,g),qn(t,r),(null==n?void 0:n.baseHeaders)||{},Fn(v)?Nn:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const y=await l(Ln({path:u,baseUrl:c,queryParams:p,projectId:t}),m);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(e,null==y?void 0:y.clone()),null==i?void 0:i.transformResponse){const e=await y.json(),t=((null===(o=y.headers)||void 0===o?void 0:o.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,r]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:r})}),{}),n=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}return y};return{get:(e,{headers:t,queryParams:n,token:r}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:Pn.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>u({path:e,headers:n,queryParams:r,body:t,method:Pn.post,token:o}),patch:(e,t,{headers:n,queryParams:r,token:o}={})=>u({path:e,headers:n,queryParams:r,body:t,method:Pn.patch,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>u({path:e,headers:n,queryParams:r,body:t,method:Pn.put,token:o}),delete:(e,{headers:t,queryParams:n,token:r}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:Pn.delete,token:r}),hooks:i,buildUrl:(e,n)=>Ln({projectId:t,baseUrl:c,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const r=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==r?void 0:r.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var r;const o=[].concat((null===(r=e.hooks)||void 0===r?void 0:r.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},Jn=429;function Vn(e,t,n){var r;let o=Hn(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[_n])===t)return(null==o?void 0:o[n])||[];o=null===(r=null==o?void 0:o.tenants)||void 0===r?void 0:r[t]}const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function Hn(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Sn(e)}function Kn(e){const{exp:t}=Hn(e);return(new Date).getTime()/1e3>t}function Bn(e){let t=Hn(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Xn(e,t){return Vn(e,t,"permissions")}function Yn(e,t){return Vn(e,t,"roles")}const Gn=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Zn(e,t){var n;const r=await e,o={code:r.status,ok:r.ok,response:r},i=await r.clone().json();return r.ok?o.data=i:(o.error=i,r.status===Jn&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=r.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function Qn(e){var t;return(null===(t=Hn(e))||void 0===t?void 0:t[_n])||""}const er=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),tr=(e,t)=>(n=t)=>t=>{const r=e.filter((e=>e(t)));return!(r.length<e.length)&&(n?n.replace("{val}",t):r.join(" OR "))},nr=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),rr=e=>t=>e.test(t),or=rr(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ir=rr(/^\+[1-9]{1}[0-9]{3,14}$/),sr=er(or,'"{val}" is not a valid email'),ar=er(ir,'"{val}" is not a valid phone number'),cr=er((e=>e.length>=1),"Minimum length is 1");const lr=er((e=>"string"==typeof e),"Input is not a string"),ur=er((e=>Array.isArray(e)),"Input is not an array"),dr=er((e=>"boolean"==typeof e),"Input is not a boolean"),hr=er((e=>void 0===e),"Input is defined"),pr=tr([lr(),hr()],"Input is not a string or undefined"),fr=tr([ur(),dr()],"Input is not an array or boolean"),gr=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>nr(...e).validate(n[t]))),t(...n)),vr=e=>[lr(`"${e}" must be a string`)],mr=e=>[pr(`"${e}" must be string or undefined`)],yr=e=>[lr(`"${e}" must be a string`),cr(`"${e}" must not be empty`)],wr=e=>[lr(`"${e}" must be a string`),sr()],br=e=>[lr(`"${e}" must be a string`),ar()],kr=gr(yr("accessKey")),Ir=e=>({exchange:kr(((t,n)=>Zn(e.post(jn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Or=(e,t,n)=>(t.forEach((t=>{const r=t.split(".");let o=r.shift(),i=e;for(;r.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=r.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const s=i[o];i[o]=n(s)})),e),Sr=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||En,En)});var jr,xr;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(jr||(jr={})),function(e){e.email="email"}(xr||(xr={}));const Cr=Object.assign(Object.assign({},jr),xr);var Er;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Er||(Er={}));const _r=yr("loginId"),Ar=gr(yr("token")),Tr=gr(_r),Rr=gr(yr("pendingRef")),$r=gr(_r,wr("email")),Ur=e=>({verify:Ar((t=>Zn(e.post(jn.enchantedLink.verify,{token:t})))),signIn:Tr(((n,r,o={},i)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Zn(e.post(Gn(jn.enchantedLink.signIn,Cr.email),{loginId:n,URI:r,loginOptions:a,providerId:s},{token:i}))})),signUpOrIn:Tr(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Zn(e.post(Gn(jn.enchantedLink.signUpOrIn,Cr.email),{loginId:n,URI:r,loginOptions:s,providerId:i}))})),signUp:Tr(((n,r,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Zn(e.post(Gn(jn.enchantedLink.signUp,Cr.email),{loginId:n,URI:r,user:o,loginOptions:a,providerId:s}))})),waitForSession:Rr(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=Sr(n);let s;const a=setInterval((async()=>{const n=await e.post(jn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Zn(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:$r(((t,n,r,o,i)=>Zn(e.post(jn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o}))))}}),Pr=gr(yr("flowId")),Dr=gr(yr("executionId"),yr("stepId"),yr("interactionId")),Lr=e=>({start:Pr(((t,n,r,o,i,s,a,c=!1)=>Zn(e.post(jn.flow.start,{flowId:t,options:n,conditionInteractionId:r,interactionId:o,componentsVersion:i,flowVersions:s,input:a,isCustomScreen:c})))),next:Dr(((t,n,r,o,i,s,a=!1)=>Zn(e.post(jn.flow.next,{executionId:t,stepId:n,interactionId:r,version:o,componentsVersion:i,input:s,isCustomScreen:a}))))}),Mr=yr("loginId"),Nr=gr(yr("token")),Wr=gr(Mr),qr=gr(Mr,br("phone")),Fr=gr(Mr,wr("email")),zr=Object.keys(Cr).filter((e=>e!==jr.voice&&e!==jr.im)),Jr=e=>({verify:Nr((t=>Zn(e.post(jn.magicLink.verify,{token:t})))),signIn:zr.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Wr(((n,o,i={},s)=>{var{providerId:a}=i,c=t(i,["providerId"]);return Zn(e.post(Gn(jn.magicLink.signIn,r),{loginId:n,URI:o,loginOptions:c,providerId:a},{token:s}))}))})),{}),signUp:zr.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Wr(((n,o,i,s={})=>{var{providerId:a}=s,c=t(s,["providerId"]);return Zn(e.post(Gn(jn.magicLink.signUp,r),{loginId:n,URI:o,user:i,loginOptions:c,providerId:a}))}))})),{}),signUpOrIn:zr.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Wr(((n,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Zn(e.post(Gn(jn.magicLink.signUpOrIn,r),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:Fr(((t,n,r,o,i)=>Zn(e.post(jn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o})))),phone:Object.keys(jr).filter((e=>e!==jr.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:qr(((t,r,o,i,s)=>Zn(e.post(Gn(jn.magicLink.update.phone,n),Object.assign({loginId:t,phone:r,URI:o},s),{token:i}))))})),{})}});var Vr;!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"}(Vr||(Vr={}));const Hr=gr(yr("code")),Kr=e=>({start:Object.assign(((t,n,r,o,i)=>Zn(e.post(jn.oauth.start,r||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),i&&{loginHint:i}),token:o}))),Object.keys(Vr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,r,o,i)=>Zn(e.post(jn.oauth.start,r||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),i&&{loginHint:i}),token:o}))})),{})),exchange:Hr((t=>Zn(e.post(jn.oauth.exchange,{code:t})))),startNative:(t,n,r)=>Zn(e.post(jn.oauth.startNative,{provider:t,loginOptions:n,implicit:r})),finishNative:(t,n,r,o,i)=>Zn(e.post(jn.oauth.finishNative,{provider:t,stateId:n,user:r,code:o,idToken:i})),getOneTapClientId:t=>Zn(e.get(jn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,r,o)=>Zn(e.post(jn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:r,loginOptions:o})),exchangeOneTapIDToken:(t,n,r,o)=>Zn(e.post(jn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:r,loginOptions:o}))}),Br=yr("appId"),Xr=gr(Br),Yr=e=>({connect:Xr(((t,n,r)=>{const o=null==n?void 0:n.tenantId,i=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Zn(e.post(jn.outbound.connect,{appId:t,tenantId:o,tenantLevel:i,options:n},{token:r}))}))}),Gr=yr("loginId"),Zr=gr(Gr,yr("code")),Qr=gr(Gr),eo=gr(Gr,br("phone")),to=gr(Gr,wr("email")),no=e=>({verify:Object.keys(Cr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Zr(((t,r)=>Zn(e.post(Gn(jn.otp.verify,n),{code:r,loginId:t}))))})),{}),signIn:Object.keys(Cr).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Qr(((n,o={},i)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Zn(e.post(Gn(jn.otp.signIn,r),{loginId:n,loginOptions:a,providerId:s},{token:i}))}))})),{}),signUp:Object.keys(Cr).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Qr(((n,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Zn(e.post(Gn(jn.otp.signUp,r),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Cr).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Qr(((n,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Zn(e.post(Gn(jn.otp.signUpOrIn,r),{loginId:n,loginOptions:s,providerId:i}))}))})),{}),update:{email:to(((t,n,r,o)=>Zn(e.post(jn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:r})))),phone:Object.keys(jr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:eo(((t,r,o,i)=>Zn(e.post(Gn(jn.otp.update.phone,n),Object.assign({loginId:t,phone:r},i),{token:o}))))})),{})}}),ro=gr(yr("tenant")),oo=gr(yr("code")),io=e=>({start:ro(((t,n,r,o,i,s,a,c)=>Zn(e.post(jn.saml.start,r||{},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}),c&&{initiatedEmail:t})},o&&{token:o}))))),exchange:oo((t=>Zn(e.post(jn.saml.exchange,{code:t}))))}),so=yr("loginId"),ao=gr(so,yr("code")),co=gr(so),lo=gr(so),uo=e=>({signUp:co(((t,n)=>Zn(e.post(jn.totp.signUp,{loginId:t,user:n})))),verify:ao(((t,n,r,o)=>Zn(e.post(jn.totp.verify,{loginId:t,code:n,loginOptions:r},{token:o})))),update:lo(((t,n)=>Zn(e.post(jn.totp.update,{loginId:t},{token:n}))))}),ho=yr("loginId"),po=yr("newPassword"),fo=gr(ho,yr("password")),go=gr(ho),vo=gr(ho,po),mo=gr(ho,yr("oldPassword"),po),yo=e=>({signUp:fo(((n,r,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Zn(e.post(jn.password.signUp,{loginId:n,password:r,user:o,loginOptions:a,providerId:s}))})),signIn:fo(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Zn(e.post(jn.password.signIn,{loginId:n,password:r,loginOptions:s,providerId:i}))})),sendReset:go(((t,n,r)=>Zn(e.post(jn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:r})))),update:vo(((t,n,r)=>Zn(e.post(jn.password.update,{loginId:t,newPassword:n},{token:r})))),replace:mo(((t,n,r)=>Zn(e.post(jn.password.replace,{loginId:t,oldPassword:n,newPassword:r})))),policy:()=>Zn(e.get(jn.password.policy))}),wo=vr("loginId"),bo=yr("loginId"),ko=yr("origin"),Io=gr(bo,ko,yr("name")),Oo=gr(bo,ko),So=gr(wo,ko),jo=gr(bo,ko,mr("token")),xo=gr(yr("transactionId"),yr("response")),Co=e=>({signUp:{start:Io(((t,n,r,o)=>Zn(e.post(jn.webauthn.signUp.start,{user:{loginId:t,name:r},origin:n,passkeyOptions:o})))),finish:xo(((t,n)=>Zn(e.post(jn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:So(((t,n,r,o,i)=>Zn(e.post(jn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:r,passkeyOptions:i},{token:o})))),finish:xo(((t,n)=>Zn(e.post(jn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Oo(((t,n,r)=>Zn(e.post(jn.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:r}))))},update:{start:jo(((t,n,r,o)=>Zn(e.post(jn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:r})))),finish:xo(((t,n)=>Zn(e.post(jn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Eo=vr("loginId"),_o=gr(Eo),Ao=gr(yr("pendingRef")),To=e=>({signUpOrIn:_o(((n,r={})=>{var{providerId:o}=r,i=t(r,["providerId"]);return Zn(e.post(jn.notp.signUpOrIn,{loginId:n,loginOptions:i,providerId:o}))})),signUp:_o(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Zn(e.post(jn.notp.signUp,{loginId:n,user:r,providerId:i,loginOptions:s}))})),signIn:_o(((n,r={},o)=>{var{providerId:i}=r,s=t(r,["providerId"]);return Zn(e.post(jn.notp.signIn,{loginId:n,loginOptions:s,providerId:i},{token:o}))})),waitForSession:Ao(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=Sr(n);let s;const a=setInterval((async()=>{const n=await e.post(jn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Zn(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),Ro=gr(yr("token")),$o=gr(mr("token"));var Uo,Po=gr([(Uo=yr("projectId"),er(((e,t)=>n=>nr(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),r=n.length;let o=0,i=e===Object(e)?e:void 0;for(;null!=i&&o<r;)i=i[n[o++]];return o&&o===r&&void 0!==i?i:void 0})(n,e)))("projectId",Uo))())])((e=>{const{projectId:t,logger:n,baseUrl:r,cookiePolicy:o,baseHeaders:i={},refreshCookieName:s,fetch:a}=e;return c=zn({baseUrl:r,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:o,baseConfig:{baseHeaders:i},refreshCookieName:s,fetch:a}),{accessKey:Ir(c),otp:no(c),magicLink:Jr(c),enchantedLink:Ur(c),oauth:Kr(c),outbound:Yr(c),saml:io(c),totp:uo(c),notp:To(c),webauthn:Co(c),password:yo(c),flow:Lr(c),refresh:$o(((e,t,n,r)=>{const o={};n&&(o.externalToken=n);const i=r?jn.tryRefresh:jn.refresh;return Zn(c.post(i,o,{token:e,queryParams:t}))})),selectTenant:gr([lr("tenantId")],[pr('"token" must be string or undefined')])(((e,t)=>Zn(c.post(jn.selectTenant,{tenant:e},{token:t})))),logout:$o((e=>Zn(c.post(jn.logout,{},{token:e})))),logoutAll:$o((e=>Zn(c.post(jn.logoutAll,{},{token:e})))),me:$o((e=>Zn(c.get(jn.me,{token:e})))),myTenants:gr([fr('"tenants" must a string array or a boolean')],[pr('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Zn(c.post(jn.myTenants,n,{token:t}))})),history:$o((e=>Zn(c.get(jn.history,{token:e})))),isJwtExpired:Ro(Kn),getTenants:Ro(Bn),getJwtPermissions:Ro(Xn),getJwtRoles:Ro(Yn),getCurrentTenant:Ro(Qn),httpClient:c};var c})),Do=Object.assign(Po,{DeliveryMethods:Cr});
|
|
6
|
-
/*! js-cookie v3.0.5 | MIT */function Lo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var Mo=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=Lo({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in o)o[s]&&(i+="; "+s,!0!==o[s]&&(i+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+i}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(r[a]=t.read(s,a),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",Lo({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Lo({},this.attributes,t))},withConverter:function(t){return e(Lo({},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 No={default:"endpoint"},Wo="Blocked by CSP",qo="The endpoint parameter is not a valid URL",Fo="Failed to load the JS script of the agent",zo="9319";function Jo(e,t){var n,r,o,i,s,a=[],c=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],e,!0);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,r=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},o=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===Wo||s===qo)n.exclude(),i=0;else if(s===zo)n.exclude();else if(s===Fo){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!o.has(c)&&(o.add(c),i=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=i?i:e.getTime()+r()-Date.now()]}]),l=c[0],u=c[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(e){var n=new Date,r=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return r()}),r),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=u(n,e);if(!t)throw s;var r,o=t[0],i=t[1];return(r=i,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return d(o)}))}))};return d(l).then((function(e){return[e,a]}))}var Vo="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Ho=Vo;function Ko(n){var r;n.scriptUrlPattern;var o=n.token,i=n.apiKey,s=void 0===i?o:i,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(r=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==r?r:Vo,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,r){return e.addEventListener(t,n,r),function(){return e.removeEventListener(t,n,r)}}(document,"visibilitychange",t);return t(),[e,n]}(),u=l[0],d=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(c,s);return Jo(e,Bo)})).catch((function(e){throw d(),function(e){return e instanceof Error&&e.message===zo?new Error(Fo):e}(e)})).then((function(t){var n=t[0],r=t[1];return d(),n.load(e(e({},a),{ldi:{attempts:r,visibilityStates:u}}))}))}function Bo(e){return function(e,t,n){var r,o=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,a())};o.addEventListener(i,s);var a=function(){return o.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(),r)return n(r);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(qo);var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(Fo))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)}),(function(){throw new Error(Wo)})).then(Xo)}function Xo(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(zo);return n}const Yo="3.2.0",Go="undefined"!=typeof window,Zo=Math.pow(2,31)-1,Qo=`https://descopecdn.com/npm/oidc-client-ts@${Yo}/dist/browser/oidc-client-ts.min.js`,ei=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Yo}/dist/browser/oidc-client-ts.min.js`,ti=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let ni;const ri=e=>{try{return Sn(e).exp}catch(e){return null}},oi=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ri(n)},ii=e=>{const{expires_in:t,expires_at:n,access_token:r}=e;return n||(t?Math.floor(Date.now()/1e3)+t:r?ri(r):void 0)},si=e=>{const{access_token:n,id_token:r,refresh_token:o,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:r,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||ii(e),cookieExpiration:e.cookieExpiration||oi(e)},s)},ai=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,r)=>{var o;return n[r]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[r])||[]).concat((null==t?void 0:t[r])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},ci=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 si(n)},li=()=>Go&&!!window.descopeBridge,ui=(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 ti.includes(n)},di=void 0!==ni||Go&&void 0!==window.localStorage,hi=(e,t)=>{var n,r;return null===(r=null===(n=ni||Go&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===r?void 0:r.call(n,e,t)},pi=e=>{var t,n;return null===(n=null===(t=ni||Go&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},fi=e=>{var t,n;return null===(n=null===(t=ni||Go&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},gi=e=>{var t,n,r,o,i;return null!==(i=null!==(n=null===(t=null==ni?void 0:ni.key)||void 0===t?void 0:t.call(ni,e))&&void 0!==n?n:Go&&(null===(o=null===(r=window.localStorage)||void 0===r?void 0:r.key)||void 0===o?void 0:o.call(r,e)))&&void 0!==i?i:null},vi=(...e)=>{console.debug(...e)},mi=(...e)=>{console.warn(...e)},yi=(e,t)=>{let n;var r;return t>0?(n=1e3*t,vi(`Using provided nextRefreshSeconds: ${t}s`)):n=((r=e)?r.getTime()-(new Date).getTime():0)-2e4,n>Zo&&(vi(`Timeout is too large (${n}ms), setting it to ${Zo}ms`),n=Zo),n},wi="DS",bi="DSR",ki="DSI";function Ii(e,t,n){if(t){const{cookieDomain:r,cookiePath:o,cookieSameSite:i,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=Oi(r);Mo.set(e,t,{path:o,domain:l?r:void 0,expires:c,sameSite:i,secure:a})}}function Oi(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 Si=e=>(null==e?void 0:e.cookieName)||wi,ji=e=>(null==e?void 0:e.cookieName)||bi;function xi(e="",t){return Mo.get(ji(t))||pi(`${e}${bi}`)||""}function Ci(e="",t){return Mo.get(Si(t))||pi(`${e}${wi}`)||""}function Ei(e=""){return pi(`${e}${ki}`)||""}function _i(e="",t,n,r){fi(`${e}${bi}`),fi(`${e}${wi}`),fi(`${e}${ki}`);const o=Si(t);Mo.remove(o,null==r?void 0:r.session);const i=ji(n);Mo.remove(i,null==r?void 0:r.refresh)}const Ai=(e,t)=>n=>{const r=Object.assign(n,{token:n.token||xi(e,t)}),o=function(e=""){return pi(`${e}DTD`)||""}(e);return o&&(r.headers=Object.assign(Object.assign({},r.headers||{}),{"x-descope-trusted-device-token":o})),r},Ti=Go&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Ri="vsid",$i="vrid",Ui=(e=!1)=>{const t=pi("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Pi=async(e,t=Ti)=>{try{if(Ui())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Ko({apiKey:e,endpoint:[r.toString(),No],scriptUrlPattern:[i,Ho]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Ri]:e,[$i]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};hi("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Di=e=>{const t=Ui(!0);return t&&e.body&&(e.body.fpData=t),e},Li="descopeFlowNonce",Mi="X-Descope-Flow-Nonce",Ni="/v1/flow/start",Wi="/v1/flow/next",qi=(e,t=Li)=>`${t}${e}`,Fi=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},zi=e=>{var t;return e.path===Wi&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Fi(e.body.executionId):null},Ji="dls_last_user_login_id",Vi="dls_last_user_display_name",Hi=e=>hi(Ji,e),Ki=()=>pi(Ji),Bi=()=>pi(Vi),Xi=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,r={}]=t,o=Ki(),i=Bi();return o&&(null!==(n=r.lastAuth)&&void 0!==n||(r.lastAuth={}),r.lastAuth.loginId=o,r.lastAuth.name=i),await e(...t)};function Yi(){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 Gi(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=rs(n.publicKey.challenge),n.publicKey.user.id=rs(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=rs(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:os(n.rawId),type:n.type,response:{attestationObject:os(n.response.attestationObject),clientDataJSON:os(n.response.clientDataJSON)}});var n}async function Zi(e){const t=ts(e);return ns(await navigator.credentials.get(t))}async function Qi(e,t){const n=ts(e);return n.signal=t.signal,n.mediation="conditional",ns(await navigator.credentials.get(n))}async function es(e=!1){var t,n;if(!Go)return Promise.resolve(!1);if(li()){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 r=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return r&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():r}function ts(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=rs(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=rs(e.id)})),n}function ns(e){return JSON.stringify({id:e.id,rawId:os(e.rawId),type:e.type,response:{authenticatorData:os(e.response.authenticatorData),clientDataJSON:os(e.response.clientDataJSON),signature:os(e.response.signature),userHandle:e.response.userHandle?os(e.response.userHandle):void 0}})}function rs(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function os(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var is,ss=(is=e=>({async signUp(t,n,r){const o=await e.webauthn.signUp.start(t,window.location.origin,n,r);if(!o.ok)return o;const i=await Gi(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(t,n){const r=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!r.ok)return r;const o=await Zi(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,o)},async signUpOrIn(t,n){var r;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(r=o.data)||void 0===r?void 0:r.create){const t=await Gi(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Zi(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,r){const o=await e.webauthn.update.start(t,window.location.origin,n,r);if(!o.ok)return o;const i=await Gi(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Gi,get:Zi,isSupported:es,conditional:Qi}}),(...e)=>{const t=is(...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 as="/fedcm/config",cs=()=>{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 ls(e,t){var n;try{await us(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function us(e,t){var n,r;const o=await async function(e,t="google",n,r,o){const i=cs(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const c=a.data.clientId;return new Promise((e=>{var a,l;const u=n=>{e({provider:t,nonce:i,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,callback:u,nonce:i})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void u()}if(r&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==r||r(t),void u()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const r=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!r.ok||!r.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,r.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(r=null==t?void 0:t.onAuthenticated)||void 0===r||r.call(t,n.data)}}var ds=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await es(),r=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=r,e.flow.start(...t)}});let hs;const ps=(e,t)=>new Promise(((n,r)=>{if(!e.length)return r(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);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",(()=>{ps(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),fs=(e,t,n)=>{const r=async()=>{let r,o;return r&&o||({client:r,stateUserKey:o}=await(async(e,t,n)=>{hs||(hs=(async()=>{try{return require("oidc-client-ts")}catch(e){return ps([Qo,ei],(()=>window.oidc))}})());const{OidcClient:r,WebStorageStateStore:o}=await hs;if(!r)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,c,l;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,c=`${a}_user`,l="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access");const u={authority:s,client_id:a,redirect_uri:i,response_type:"code",scope:(null==n?void 0:n.scope)||l,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(u.redirect_uri=n.redirectUri),{client:new r(u),stateUserKey:c}})(e,t,n)),{client:r,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:i}=await r(),s=await o.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(e={},t=!1)=>{const{client:n}=await r(),o=await n.createSigninRequest(e),{url:i}=o;return t||(window.location.href=i),{ok:!0,data:o}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:i}=await r(),s=(e=>{const t=pi(e);return t?JSON.parse(t):null})(i);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const c=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await r();e||(e={}),e.id_token_hint=e.id_token_hint||Ei(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const i=await n.createSignoutRequest(e),{url:s}=i;return fi(o),t||window.location.replace(s),i}}},gs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,ni=n,e(t)}),(e=>n=>{var{fpKey:r,fpLoad:o}=n,i=t(n,["fpKey","fpLoad"]);return Go?(r&&o&&Pi(r).catch((()=>null)),e(ai(i,{beforeRequest:Di}))):e(i)}),(e=>n=>{var{autoRefresh:r}=n,o=t(n,["autoRefresh"]);if(!r||li())return e(o);const{clearAllTimers:i,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;Go&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&a&&new Date>a&&(vi("Expiration time passed, refreshing session"),l.refresh(xi()||c))}));const l=e(ai(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:r,sessionExpiration:o,nextRefreshSeconds:u}=await ci(t);if(ui(e,t))vi("Session invalidated, canceling all timers"),i();else if(n||o){if(a=((e,t)=>{if(t)return new Date(1e3*t);vi("Could not extract expiration time from session token, trying to decode the token");try{const t=Sn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!a)return void vi("Could not extract expiration time from session token");c=r;const e=yi(a,u);if(i(),e<=2e4)return void vi("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});vi(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Go&&"hidden"===document.visibilityState?vi("Skipping refresh due to timer - document is hidden"):(vi("Refreshing session due to timer"),l.refresh(xi()||r))}),e)}}}));return Or(l,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return vi("Clearing all timers"),i(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.45.0"},t.baseHeaders)}))),(e=>t=>{const n=Yi(),r=Yi(),o=Yi(),i=Yi(),s=e(ai(t,{afterRequest:async(e,t)=>{if(ui(e,t))vi("Session invalidated, notifying subscribers with empty values"),r.pub(null),o.pub(null),n.pub(null),i.pub(null);else{const e=await(async e=>{const t=await ci(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:c}=await ci(t);s&&r.pub(s),c&&i.pub(c),(a||s)&&n.pub(a||42)}}})),a=Or(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return r.pub(null),o.pub(null),n.pub(null),i.pub(null),s}));return Object.assign(a,{onSessionTokenChange:r.sub,onUserChange:o.sub,onClaimsChange:i.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:r=!0,nonceStoragePrefix:o=Li}=n,i=t(n,["enableFlowNonce","nonceStoragePrefix"]);return r?(((e=Li)=>{try{if(!di)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(r=null!==(t=null==ni?void 0:ni.length)&&void 0!==t?t:Go&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==r?r:0);o++){const t=gi(o);if(t&&t.startsWith(e)){const n=pi(t);if(n)try{JSON.parse(n).expiry<Date.now()&&fi(t)}catch(e){fi(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,r})(o),e(ai(i,{afterRequest:async(e,t)=>{if(e.path!==Ni&&e.path!==Wi)return;const{nonce:n,executionId:r}=await(async(e,t)=>{try{const n=t.headers.get(Mi);let r=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return r||(r=zi(e)),{nonce:n,executionId:Fi(r)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&r&&((e,t,n,r=Li)=>{try{const o=qi(e,r),i=n?172800:10800,s={value:t,expiry:Date.now()+1e3*i,isStart:n};hi(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(r,n,e.path===Ni,o)},beforeRequest:e=>{if(e.path===Wi){const t=zi(e);if(t){const n=((e,t=Li)=>{try{const n=qi(e,t),r=pi(n);if(!r)return null;const o=JSON.parse(r);return o.expiry<Date.now()?(((e,t=Li)=>{try{const n=qi(e,t);fi(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);n&&(e.headers=e.headers||{},e.headers[Mi]=n)}}return e}}))):e(i)}),(e=>n=>{var{storeLastAuthenticatedUser:r=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!r)return Object.assign(e(i),{getLastUserLoginId:Ki,getLastUserDisplayName:Bi});const s=e(ai(i,{afterRequest:async(e,t)=>{var n;const{userInfo:r,lastAuth:o}=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=si((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==r?void 0:r.loginIds)||void 0===n?void 0:n[0],s=null==r?void 0:r.name;i?(Hi(i),(e=>{hi(Vi,e)})(s)):(null==o?void 0:o.loginId)&&Hi(o.loginId)}}));let a=Or(s,["flow.start"],Xi);return a=Or(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const r=await t(...n);return e||(fi(Ji),fi(Vi)),r})(o)),Object.assign(a,{getLastUserLoginId:Ki,getLastUserDisplayName:Bi})}),(e=>n=>{var{persistTokens:r,sessionTokenViaCookie:o,refreshTokenViaCookie:i,storagePrefix:s}=n,a=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix"]);if(!r||!Go)return e(a);let c;const l=e(ai(a,{beforeRequest:Ai(s,i),afterRequest:async(e,t)=>{if(ui(e,t))vi("Session invalidated, clearing persisted tokens"),_i(s,o,i,c);else{const e=((e={},t=!1,n="",r=!1)=>{var o,i,s,a;const{sessionJwt:c,refreshJwt:l,trustedDeviceJwt:u}=e;let d;if(l)if(r){fi(`${n}${bi}`);const t=r.sameSite||"Strict",s=null===(o=r.secure)||void 0===o||o,a=null!==(i=r.domain)&&void 0!==i?i:e.cookieDomain,c=ji(r);s&&"https:"!==window.location.protocol&&mi("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 u=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Ii(c,l,u);const h=Oi(a);d=Object.assign(Object.assign({},d),{refresh:{path:u.cookiePath,domain:h?a:void 0}})}else{const e=ji(r);Mo.remove(e),hi(`${n}${bi}`,l)}if(c)if(t){const n=t.sameSite||"Strict",r=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,i=Si(t);r&&"https:"!==window.location.protocol&&mi("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const l=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r,cookieDomain:o});Ii(i,c,l);const u=Oi(o);d=Object.assign(Object.assign({},d),{session:{path:l.cookiePath,domain:u?o:void 0}})}else hi(`${n}${wi}`,c);return e.idToken&&hi(`${n}${ki}`,e.idToken),u&&hi(`${n}DTD`,u),d})(await ci(t),o,s,i);e&&(c=e)}}})),u=Or(l,["logout","logoutAll","oidc.logout"],((e,t,n,r)=>o=>async(...i)=>{const s=await o(...i);return _i(e,t,n,null==r?void 0:r()),s})(s,o,i,(()=>c)));return Object.assign(u,{getRefreshToken:()=>xi(s,i),getSessionToken:()=>Ci(s,o),getIdToken:()=>Ei(s)})}))((e=>{const t=Do(e),n=fs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(r,o)=>{var i;if(li())return vi(`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(r),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}const s=Ci(),a=xi();let c="";if(e.getExternalToken)try{c=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){vi("Error getting external token while refreshing",e)}return t.refresh(r,{dcs:s?"t":"f",dcr:a?"t":"f"},c,o)},logout:async r=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:r}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(r)},flow:ds(t),webauthn:ss(t),fedcm:(r=t,o=e.projectId,{onetap:{requestExchangeCode(e){ls(r,e)},requestAuthentication(e){ls(r,e)}},async oneTap(e,t,n,o,i){await us(r,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:i})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:r.httpClient.buildUrl(o+as),clientId:o}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return r.refresh(i.token)},isSupported:()=>Go&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=r.httpClient.buildUrl(o+as);try{const r={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(r));return!!i&&!!i.token}catch(e){return!1}}}),oidc:n});var r,o})),vs={search:"/v1/mgmt/audit/search"},ms=e=>n(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((n=>{const r=[],o=(new Date).getTime()/1e3+2592e3,i=new Date(o).toLocaleString();for(let e=1;e<9;e+=1)r.push({id:`Audit ${e}`,action:`Action ${e}`,actorId:`Actor ${e}`,type:"info",method:`Method ${e}`,userId:`User ${e}`,device:`Device ${e}`,geo:`Geo ${e}`,remoteAddress:`127.0.0.${e}`,externalIds:[`Login ID ${e}`],occurred:o,occurredFormatted:i});t.forEach((e=>{r.sort(((t,n)=>{var r,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(r=t[e.field])||void 0===r?void 0:r.localeCompare(n[e.field])}))})),n(r.filter((t=>t.id.toLowerCase().includes(e.toLowerCase())||t.action.toLowerCase().includes(e.toLowerCase())||t.type.toLowerCase().includes(e.toLowerCase())||t.device.toLowerCase().includes(e.toLowerCase())||t.method.toLowerCase().includes(e.toLowerCase())||t.geo.toLowerCase().includes(e.toLowerCase())||t.remoteAddress.toLowerCase().includes(e.toLowerCase())||t.externalIds.includes(e.toLowerCase())||t.userId.toLowerCase().includes(e.toLowerCase()))))}))})),ys=({httpClient:e,tenant:t,mock:r})=>({search:(...o)=>n(void 0,[...o],void 0,(function*({page:o,limit:i=1e4,text:s,sort:a,from:c}={}){if(r)return ms({page:o,limit:i,text:s,sort:a},t);const l=yield e.post(vs.search,{limit:i,page:o,text:s,sort:a,from:c},{queryParams:{tenant:t}});yield(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)})))(l);return(yield l.json()).audits}))}),ws=l((e=>{var t,s,a,c;const l=i(C,j,y,E,hn,x({tenant:x.missingAttrValidator}))(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return r(this,s,"f")||r(this,t,"m",a).call(this),r(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"],(()=>{r(this,s,"f")&&r(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,n,r)=>{const o=gs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":r,"x-descope-widget-version":"0.5.35"}}));return{audit:ys({httpClient:o.httpClient,tenant:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},c})),bs=l((e=>{const t=i(dn({name:"widget",initialState:kn,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{bn.reducer(e)},asyncActions:{searchAudit:bn.action}}),S,y,ws)(e);return class extends t{constructor(...e){super(...e),this.state=kn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),ks=l((e=>{const t=i(T,x({"widget-id":x.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(`audit-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Is=l((e=>{var t,o,a;return a=class extends(i(y,S,F,B,ks,bs)(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([r(this,t,"m",o).call(this)]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=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})),Os=l((e=>{var t,o,s,a,l;return l=class extends(i(y,Is,bs)(e)){constructor(){super(...arguments),t.add(this),o.set(this,c((()=>{const e=this.rangeInput.value,t=new Date;let n;switch(e){case"minuets15":n=t.setMinutes(t.getMinutes()-15);break;case"hour":n=t.setHours(t.getHours()-1);break;case"hour6":n=t.setHours(t.getHours()-6);break;case"day":default:n=t.setDate(t.getDate()-1);break;case"day3":n=t.setDate(t.getDate()-3);break;case"week":n=t.setDate(t.getDate()-7);break;case"week2":n=t.setDate(t.getDate()-14);break;case"month":n=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(n).getTime())})})))}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),r(this,t,"m",s).call(this),r(this,t,"m",a).call(this)}))}},o=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new se(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(r(this,o,"f")),r(this,o,"f").call(this)},a=function(){var e;this.rangeInput=new ie(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(r(this,o,"f"))},l})),Ss=l((e=>{var t,o,s,c;return c=class extends(i(bs,y,Is)(e)){constructor(){super(...arguments),t.add(this),s.set(this,(e=>{let t,n;return(...r)=>(t&&a(t,r)||(t=r,n=e(...r)),n)})((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),r(this,t,"m",o).call(this),r(this,s,"f").call(this,vn(this.state)),this.subscribe(r(this,s,"f").bind(this),vn)}))}},s=new WeakMap,t=new WeakSet,o=function(){var e;this.auditTable=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="audit-table"]'),{logger:this.logger}),this.auditTable.onSelectedItemsChange((e=>{this.actions.setSelectedAuditId(e.detail.value.map((({id:e})=>e)))}))},c})),js=l((e=>class extends(i(U,le,Ss,Os)(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)}))}})),xs=i((e=>class extends(js(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",xs);const Cs=(e,t,n,r={})=>{var o,i,s,a;return[Math.min(Math.max(t,("all"===r.left?e.offsetWidth:null!==(o=r.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===r.right?e.offsetWidth:null!==(i=r.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===r.top?e.offsetHeight:null!==(s=r.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===r.bottom?e.offsetHeight:null!==(a=r.bottom)&&void 0!==a?a:0))]};var Es,_s,As,Ts,Rs,$s,Us,Ps,Ds,Ls;const Ms=document.createElement("template");Ms.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 Ns=i(V)(HTMLElement);class Ws extends Ns{constructor(){var e;super(),Es.add(this),_s.set(this,new g({messages:[]})),As.set(this,void 0),Ts.set(this,void 0),Rs.set(this,void 0),$s.set(this,{resize:r(this,Es,"m",Ls).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Ms.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'),o(this,As,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Ts,r(this,As,"f").querySelector(".content"),"f"),o(this,Rs,r(this,As,"f").querySelector(".header"),"f")}updateData(e){r(this,_s,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let r=0,o=0,i=0,s=0;function a(t){t.preventDefault(),r=i-t.clientX,o=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=Cs(e,e.offsetLeft-r,e.offsetTop-o,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(r(this,As,"f"),r(this,Rs,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",r(this,$s,"f").resize),(e=r(this,As,"f")).onmousemove=t=>{var n;const r=t.target;(r.w&&r.w!==r.offsetWidth||r.h&&r.h!==r.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),r.w=r.offsetWidth,r.h=r.offsetHeight},r(this,As,"f").onresize=r(this,Es,"m",Ds).bind(this),r(this,_s,"f").subscribe(r(this,Es,"m",Us).bind(this))}disconnectedCallback(){r(this,_s,"f").unsubscribeAll(),window.removeEventListener("resize",r(this,$s,"f").resize)}}_s=new WeakMap,As=new WeakMap,Ts=new WeakMap,Rs=new WeakMap,$s=new WeakMap,Es=new WeakSet,Us=function(e){r(this,Es,"m",Ps).call(this,e),r(this,Es,"m",Ds).call(this)},Ps=function(e){r(this,Ts,"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("")},Ds=function(){r(this,Ts,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),r=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;r||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Ls=function(){const[e,t]=Cs(r(this,As,"f"),Number.parseInt(r(this,As,"f").style.left,10),Number.parseInt(r(this,As,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});r(this,As,"f").style.top=`${t}px`,r(this,As,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Ws);var qs=Object.freeze({__proto__:null,default:Ws});return xs}();
|
|
5
|
+
this["descope-audit-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function r(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function o(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),c=(e,t=500)=>{let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},l=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const r=e(n);return r[t]=!0,r}};var u,d,h,p;function f(e,t){const n=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r],i=e[o],s=t[o];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!f(i,s))return!1}else if(i!==s)return!1}return!0}let g=class{constructor(e={},{forceUpdate:t=!1}={}){u.set(this,void 0),d.set(this,{}),h.set(this,0),p.set(this,!0),this.update=e=>{const t="function"==typeof e?e(r(this,u,"f")):e,n=Object.assign(Object.assign({},r(this,u,"f")),t);if(r(this,p,"f")||!f(r(this,u,"f"),n)){const e=r(this,u,"f");o(this,u,n,"f"),Object.freeze(r(this,u,"f")),setTimeout((()=>{Object.values(r(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,u,e,"f"),o(this,p,t,"f")}get current(){return Object.assign({},r(this,u,"f"))}subscribe(e){return o(this,h,r(this,h,"f")+1,"f"),r(this,d,"f")[r(this,h,"f")]=e,r(this,h,"f").toString()}unsubscribe(e){const t=!!r(this,d,"f")[e];return t&&delete r(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};u=new WeakMap,d=new WeakMap,h=new WeakMap,p=new WeakMap;const v=["error","warn","info","debug"],m={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},y=l((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,r(this,t,"m",i).call(this,m))}set logger(e){o(this,n,r(this,t,"m",i).call(this,e||m),"f")}get logger(){return r(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return v.reduce(((t,n)=>(t[n]=(...t)=>{var r;this.onLogEvent(n,t),null===(r=e[n])||void 0===r||r.call(e,...t)},t)),{})},s})),w="undefined"!=typeof localStorage,b="https://static.descope.com/pages",k="https://static2.descope.com/pages",I=w&&localStorage.getItem("base.content.url")||"",O=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,S=l((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)&&r(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),j=l((e=>{var t,n;const o=i(y,S)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=r(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){r(this,t,"f")[e]||(r(this,t,"f")[e]=[]);const o=r(this,t,"f")[e].push(n);return()=>r(this,t,"f")[e].splice(o,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})),x=e=>t=>{var n,o,s;const a=i(y,S,j)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,r(this,n,"m",o).bind(this))}async init(){var e;c.forEach((e=>r(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const r=e[t],o="function"==typeof r?r(t,n):r;o&&this.logger.error(o)},s};x.missingAttrValidator=O;const C=l((e=>{const t=i(x({"project-id":O}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),E=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),_="Trying the next fallback URL...",A=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(r){return null==n||n.debug(`Network error fetching URL ${e} [${r.message}], retrying...`),fetch(e,t)}};const T=l((e=>{var t,n,s,a,c,l,u;const d=i(y,C,E)(e);return u=class extends d{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=r(this,t,"m",c).call(this,e),l=Array.isArray(i)?e=>{const{baseUrl:t}=i[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=i[t].baseUrl;r(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:r}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const i=o[e],s=e===o.length-1;try{const o=await A(i.toString(),t,{logger:n});if(o.ok)return null==r||r(e),null==n||n.debug(`Successfully fetched URL ${i}`),o;const a=`Error fetching URL ${i} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${_}`)}catch(e){const t=`Error fetching URL ${i} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${_}`)}}})(i,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(e){const i=I||this.baseStaticUrl;if(i)return r(this,t,"m",l).call(this,e,i);r(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),r(this,a,"f").clear());const c=[];if(r(this,s,"f"))c.push(r(this,t,"m",l).call(this,e,r(this,s,"f"))),r(this,s,"f")===b&&c.push(r(this,t,"m",l).call(this,e,k));else{const n=this.baseUrl+"/pages";this.baseUrl&&!r(this,a,"f").has(n)&&c.push(r(this,t,"m",l).call(this,e,n)),r(this,a,"f").has(b)||c.push(r(this,t,"m",l).call(this,e,b)),c.push(r(this,t,"m",l).call(this,e,k))}return 1===c.length?c[0]:c},l=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:r=b}){const o=new URL(r);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=r,o}({projectId:this.projectId,filename:e,baseUrl:t})},u})),R=l((e=>{var t,n;const o=i(x({"project-id":O}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(r(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return r(this,t,"f").set(e,n),()=>{r(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(r(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!r(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=r(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),$=l((e=>{var t,n,s,a,c;const l=i(T,R,S)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",r(this,t,"m",n).bind(this))}get config(){return r(this,s,"f")||o(this,s,r(this,a,"f").call(this),"f"),r(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},c})),U=l((e=>{var t,n,s,a,c,l,u;return u=class extends(i(S,y)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,o),"debug"===e&&r(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&r(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),r(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=r(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(r(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Js})),document.body.appendChild(r(this,n,"f"))},c=function(){this.debug?r(this,t,"m",a).call(this):r(this,t,"m",s).call(this)},l=function(e,t){var o;e&&(null===(o=r(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},u})),P=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],D=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(((r,o)=>{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"),o(e)},i.onload=()=>{i.setAttribute("status","loaded"),r(i)},i.src=t.toString(),document.body.appendChild(i)})),M=(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)}))}))},N=l((e=>{const t=i(y)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",r=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const r of e){const{id:e,url:o,integrity:i}=r,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await M(s,i),r}catch(e){t(r,!0)}else try{return await L(e,o,i),r}catch(e){t(r,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,r="",o)=>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}/${r}`);const c={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${D(a)}`};return o&&(c.integrity=o),[...e,c]}),[]))([...r,this.baseCdnUrl,...P],e,t,n,o),((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}"`)}))}}})),W="base.ui.components.url",q=w&&localStorage.getItem(W),F=l((e=>{var t,n,s,a,c,l,u;const d=i(y,$,N)(e);return u=class extends d{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return r(this,a,"f")||o(this,a,r(this,t,"m",l).call(this),"f"),r(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=>r(this,t,"m",c).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},c=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},l=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await r(this,t,"m",n).call(this),o=await r(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[q],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},u})),z=l((e=>{var t,n,o;const s=i(S,j)(e);return o=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",r(this,t,"m",n).bind(this)),r(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class J{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 V=l((e=>{const t=i(z)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new J(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const r=[...e.adoptedStyleSheets||[]];r[t?"unshift":"push"](n),e.adoptedStyleSheets=r}}return n}}})),H="content-root",K="root",B=l((e=>{const t=i(V)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${H}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${H} {\n height: 100%;\n }\n #${K} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(H),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),X="descope-modal";var Y,G;let Z=class{constructor(e,t){Y.set(this,void 0),this.nodeName="",o(this,Y,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const r="function"==typeof e?e():e;r&&(clearInterval(n),t(r))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(r(this,Y,"f"))}get ele(){var e,t;const n="function"==typeof r(this,Y,"f")?r(this,Y,"f").call(this):r(this,Y,"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}};Y=new WeakMap;const Q=/^descope-grid-([^-]+)-column$/,ee={text:class extends Z{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 Z{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 te=class extends Z{constructor(){super(...arguments),this.nodeName="descope-grid",G.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 r=null===(n=Q.exec(t.localName))||void 0===n?void 0:n[1],o=ee[r];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const o=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);o&&this.ele.columns&&(a(o,this.ele.columns)||(this.ele.columns=o,null===(n=r(this,G,"f"))||void 0===n||n.call(this,o)))}onColumnsChange(e){o(this,G,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var ne;G=new WeakMap;let re=class extends Z{constructor(){super(...arguments),ne.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=""),r(this,ne,"f")&&(null===(e=this.ele)||void 0===e||e.append(r(this,ne,"f").content.cloneNode(!0)))}setContent(e){o(this,ne,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};ne=new WeakMap;let oe=class extends Z{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()}},ie=class extends Z{constructor(){super(...arguments),this.nodeName="descope-combo-box"}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)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},se=class extends Z{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")}};l((e=>{var t,n;const o=i(S,B,F)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends re{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(X);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(r(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([X]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));const ae="descope-notification";l((e=>{var t,n;const o=i(S,B,F)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends oe{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ae);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(r(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([ae])}},t=new WeakMap,n}));const ce=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',le=l((e=>{var t,n,s,a,c,l,u,d,h,p,f,g,v,m;const y=i(x({theme:ce}),T,S,F,$,B,j,V)(e);return m=class extends y{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{r(this,t,"m",g).call(this),r(this,v,"f").call(this,"os"===this.getAttribute("theme"))})),v.set(this,(e=>{var n,o,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===i||i.call(o,"change",(()=>r(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),r(this,f,"f").call(this),await Promise.all([r(this,t,"m",l).call(this),r(this,t,"m",u).call(this)]),this.observeAttributes(["theme"],r(this,f,"f")),this.observeAttributes(["style-id"],(()=>{o(this,s,null,"f"),r(this,t,"m",h).call(this),r(this,t,"m",l).call(this),r(this,t,"m",u).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(W))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(W),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},c=function(){return r(this,s,"f")||(o(this,s,r(this,t,"m",a).call(this),"f"),r(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),r(this,s,"f")},l=async function(){var e,i;const s=await r(this,t,"a",c);s&&(r(this,n,"f")||o(this,n,this.injectStyle(""),"f"),r(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)||"")))},u=async function(){var e,n;const o=await r(this,t,"a",c);if(!o)return;const i=await this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config||{},r=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,i=r||o;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},h=async function(){const e=await r(this,t,"m",d).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},p=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){r(this,t,"m",h).call(this),r(this,t,"m",p).call(this)},m}));var ue=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),de=()=>Math.random().toString(36).substring(7).split("").join("."),he={INIT:`@@redux/INIT${de()}`,REPLACE:`@@redux/REPLACE${de()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${de()}`};function pe(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 fe(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 ge(e){let t=typeof e;return t=fe(e),t}function ve(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${ge(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: '${ge(n)}'`);return n(ve)(e,t)}let r=e,o=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function u(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function d(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${ge(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function h(e){if(!pe(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${ge(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: '${ge(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,o=r(o,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}h({type:he.INIT});return{dispatch:h,subscribe:d,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${ge(e)}`);r=e,h({type:he.REPLACE})},[ue]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${ge(t)}'`);function n(){const e=t;e.next&&e.next(u())}n();return{unsubscribe:e(n)}},[ue](){return this}}}}}function me(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ye(e){const t=Object.keys(e),n={};for(let r=0;r<t.length;r++){const o=t[r];void 0===e[o]&&me(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const r=Object.keys(n);let o,i;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:he.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:he.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 '${he.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;{const r=function(e,t,n,r){const o=Object.keys(t),i=n&&n.type===he.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!pe(e))return`The ${i} has unexpected type of "${ge(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!r[e]));return s.forEach((e=>{r[e]=!0})),n&&n.type===he.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);r&&me(r)}let s=!1;const a={};for(let o=0;o<r.length;o++){const i=r[o],c=n[i],l=e[i],u=c(l,t);if(void 0===u){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=u,s=s||u!==l}return s=s||r.length!==Object.keys(e).length,s?a:e}}function we(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function be(e){return pe(e)&&"type"in e&&"string"==typeof e.type}var ke=Symbol.for("immer-nothing"),Ie=Symbol.for("immer-draftable"),Oe=Symbol.for("immer-state"),Se=[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 je(e,...t){{const n=Se[e],r="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}}var xe=Object.getPrototypeOf;function Ce(e){return!!e&&!!e[Oe]}function Ee(e){return!!e&&(Ae(e)||Array.isArray(e)||!!e[Ie]||!!e.constructor?.[Ie]||Pe(e)||De(e))}var _e=Object.prototype.constructor.toString();function Ae(e){if(!e||"object"!=typeof e)return!1;const t=xe(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)===_e}function Te(e,t){0===Re(e)?Object.entries(e).forEach((([n,r])=>{t(n,r,e)})):e.forEach(((n,r)=>t(r,n,e)))}function Re(e){const t=e[Oe];return t?t.type_:Array.isArray(e)?1:Pe(e)?2:De(e)?3:0}function $e(e,t){return 2===Re(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ue(e,t,n){const r=Re(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function Pe(e){return e instanceof Map}function De(e){return e instanceof Set}function Le(e){return e.copy_||e.base_}function Me(e,t){if(Pe(e))return new Map(e);if(De(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ae(e)){if(!xe(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Oe];let r=Reflect.ownKeys(n);for(let t=0;t<r.length;t++){const o=r[t],i=n[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(xe(e),n)}function Ne(e,t=!1){return qe(e)||Ce(e)||!Ee(e)||(Re(e)>1&&(e.set=e.add=e.clear=e.delete=We),Object.freeze(e),t&&Te(e,((e,t)=>Ne(t,!0)))),e}function We(){je(2)}function qe(e){return Object.isFrozen(e)}var Fe,ze={};function Je(e){const t=ze[e];return t||je(0,e),t}function Ve(){return Fe}function He(e,t){t&&(Je("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ke(e){Be(e),e.drafts_.forEach(Ye),e.drafts_=null}function Be(e){e===Fe&&(Fe=e.parent_)}function Xe(e){return Fe={drafts_:[],parent_:Fe,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ye(e){const t=e[Oe];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Ge(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Oe].modified_&&(Ke(t),je(4)),Ee(e)&&(e=Ze(t,e),t.parent_||et(t,e)),t.patches_&&Je("Patches").generateReplacementPatches_(n[Oe].base_,e,t.patches_,t.inversePatches_)):e=Ze(t,n,[]),Ke(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ke?e:void 0}function Ze(e,t,n){if(qe(t))return t;const r=t[Oe];if(!r)return Te(t,((o,i)=>Qe(e,r,t,o,i,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return et(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let o=t,i=!1;3===r.type_&&(o=new Set(t),t.clear(),i=!0),Te(o,((o,s)=>Qe(e,r,t,o,s,n,i))),et(e,t,!1),n&&e.patches_&&Je("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Qe(e,t,n,r,o,i,s){if(o===n&&je(5),Ce(o)){const s=Ze(e,o,i&&t&&3!==t.type_&&!$e(t.assigned_,r)?i.concat(r):void 0);if(Ue(n,r,s),!Ce(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(Ee(o)&&!qe(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ze(e,o),t&&t.scope_.parent_||et(e,o)}}function et(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ne(t,n)}var tt={get(e,t){if(t===Oe)return e;const n=Le(e);if(!$e(n,t))return function(e,t,n){const r=ot(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!Ee(r)?r:r===rt(e.base_,t)?(st(e),e.copy_[t]=at(r,e)):r},has:(e,t)=>t in Le(e),ownKeys:e=>Reflect.ownKeys(Le(e)),set(e,t,n){const r=ot(Le(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=rt(Le(e),t),o=r?.[Oe];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,r)&&(void 0!==n||$e(e.base_,t)))return!0;st(e),it(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!==rt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,st(e),it(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Le(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){je(11)},getPrototypeOf:e=>xe(e.base_),setPrototypeOf(){je(12)}},nt={};function rt(e,t){const n=e[Oe];return(n?Le(n):e)[t]}function ot(e,t){if(!(t in e))return;let n=xe(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=xe(n)}}function it(e){e.modified_||(e.modified_=!0,e.parent_&&it(e.parent_))}function st(e){e.copy_||(e.copy_=Me(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Te(tt,((e,t)=>{nt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),nt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&je(13),nt.set.call(this,e,t,void 0)},nt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&je(14),tt.set.call(this,e[0],t,n,e[0])};function at(e,t){const n=Pe(e)?Je("MapSet").proxyMap_(e,t):De(e)?Je("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Ve(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=tt;n&&(o=[r],i=nt);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}(e,t);return(t?t.scope_:Ve()).drafts_.push(n),n}function ct(e){return Ce(e)||je(10,e),lt(e)}function lt(e){if(!Ee(e)||qe(e))return e;const t=e[Oe];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Me(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Me(e,!0);return Te(n,((e,t)=>{Ue(n,e,lt(t))})),t&&(t.finalized_=!1),n}var ut=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const r=this;return function(e=n,...o){return r.produce(e,(e=>t.call(this,e,...o)))}}let r;if("function"!=typeof t&&je(6),void 0!==n&&"function"!=typeof n&&je(7),Ee(e)){const o=Xe(this),i=at(e,void 0);let s=!0;try{r=t(i),s=!1}finally{s?Ke(o):Be(o)}return He(o,n),Ge(r,o)}if(!e||"object"!=typeof e){if(r=t(e),void 0===r&&(r=e),r===ke&&(r=void 0),this.autoFreeze_&&Ne(r,!0),n){const t=[],o=[];Je("Patches").generateReplacementPatches_(e,r,t,o),n(t,o)}return r}je(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;const o=this.produce(e,t,((e,t)=>{n=e,r=t}));return[o,n,r]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Ee(e)||je(8),Ce(e)&&(e=ct(e));const t=Xe(this),n=at(e,void 0);return n[Oe].isManual_=!0,Be(t),n}finishDraft(e,t){const n=e&&e[Oe];n&&n.isManual_||je(9);const{scope_:r}=n;return He(r,t),Ge(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=Je("Patches").applyPatches_;return Ce(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},dt=ut.produce;ut.produceWithPatches.bind(ut),ut.setAutoFreeze.bind(ut),ut.setUseStrictShallowCopy.bind(ut),ut.applyPatches.bind(ut),ut.createDraft.bind(ut),ut.finishDraft.bind(ut);var ht=(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})}}},pt=(e,t,n)=>{const{memoize:r,memoizeOptions:o}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=r((()=>({})),...o);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},ft={inputStabilityCheck:"once",identityFunctionCheck:"once"};var gt=e=>Array.isArray(e)?e:[e];function vt(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function mt(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var yt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},wt=0,bt=1;function kt(){return{s:wt,v:void 0,o:null,p:null}}function It(e,t={}){let n=kt();const{resultEqualityCheck:r}=t;let o,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const r=e.get(n);void 0===r?(t=kt(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=kt(),e.set(n,t)):t=r}}const a=t;let c;if(t.s===bt)c=t.v;else if(c=e.apply(null,arguments),i++,r){const e=o?.deref?.()??o;null!=e&&r(e,c)&&(c=e,0!==i&&i--);o="object"==typeof c&&null!==c||"function"==typeof c?new yt(c):c}return a.s=bt,a.v=c,c}return s.clearCache=()=>{n=kt(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function Ot(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t,r=0,o=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:u=It,argsMemoizeOptions:d=[],devModeChecks:h={}}=a,p=gt(l),f=gt(d),g=vt(e),v=c((function(){return r++,s.apply(null,arguments)}),...p);let m=!0;const y=u((function(){o++;const e=mt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:r}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...ft,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ht},inputStabilityCheck:{shouldRun:"always"===r||"once"===r&&e,run:pt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),r.shouldRun){const t=mt(g,arguments);r.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:c,argsMemoize:u})};return Object.assign(r,{withTypes:()=>r}),r}var St=Ot(It),jt=Object.assign(((e,t=St)=>{!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,r)=>(e[n[r]]=t,e)),{})))}),{withTypes:()=>jt});function xt(e){return({dispatch:t,getState:n})=>r=>o=>"function"==typeof o?o(t,n,e):r(o)}var Ct=xt(),Et=xt;((...e)=>{const t=Ot(...e)})(It);var _t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?we:we.apply(null,arguments)},At=e=>e&&"function"==typeof e.match;function Tt(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw new Error("prepareAction did not return an object");return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>be(t)&&t.type===e,n}function Rt(e){return"function"==typeof e&&"type"in e&&At(e)}function $t(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 Ut=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Pt(e){return Ee(e)?dt(e,(()=>{})):e}function Dt(e,t,n){if(e.has(t)){let r=e.get(t);return n.update&&(r=n.update(r,t,e),e.set(t,r)),r}if(!n.insert)throw new Error("No insert provided for key not already in map");const r=n.insert(t,e);return e.set(t,r),r}function Lt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Mt(e,t,n){const r=Nt(e,t,n);return{detectMutations:()=>Wt(e,t,r,n)}}function Nt(e,t=[],n,r="",o=new Set){const i={value:n};if(!e(n)&&!o.has(n)){o.add(n),i.children={};for(const o in n){const s=r?r+"."+o:o;t.length&&-1!==t.indexOf(s)||(i.children[o]=Nt(e,t,n[o],s))}}return i}function Wt(e,t=[],n,r,o=!1,i=""){const s=n?n.value:void 0,a=s===r;if(o&&!a&&!Number.isNaN(r))return{wasMutated:!0,path:i};if(e(s)||e(r))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in r)c[e]=!0;const l=t.length>0;for(let o in c){const s=i?i+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Wt(e,t,n.children[o],r[o],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function qt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||pe(e)}function Ft(e,t="",n=qt,r,o=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=r?r(e):Object.entries(e),c=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Ft(l,a,n,r,o,i),s))return s}return i&&zt(e)&&i.add(e),!1}function zt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!zt(t))return!1;return!0}function Jt(e){return"boolean"==typeof e}var Vt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:o=!0}=e??{};let i=new Ut;if(t&&(Jt(t)?i.push(Ct):i.push(Et(t.extraArgument))),n){let e={};Jt(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,r,o){return JSON.stringify(e,n(t,o),r)},n=function(e,t){let n=[],r=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+r.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?r.splice(s,1/0,o):r.push(o),~n.indexOf(i)&&(i=t.call(this,o,i))}else n.push(i);return null==e?i:e.call(this,o,i)}},{isImmutable:r=Lt,ignoredPaths:o,warnAfter:i=32}=e;const s=Mt.bind(null,r,o);return({getState:e})=>{let n,r=e(),o=s(r);return a=>c=>{const l=$t(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const u=a(c);return l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),u}}}}(e))}if(r){let e={};Jt(r)||(e=r),i.push(function(e={}){{const{isSerializable:t=qt,getEntries:n,ignoredActions:r=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,u=!l&&WeakSet?new WeakSet:void 0;return e=>l=>d=>{if(!be(d))return l(d);const h=l(d),p=$t(s,"SerializableStateInvariantMiddleware");return c||r.length&&-1!==r.indexOf(d.type)||p.measureTime((()=>{const e=Ft(d,"",t,n,o,u);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",d,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const r=Ft(e.getState(),"",t,n,i,u);if(r){const{keyPath:e,value:t}=r;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${d.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};Jt(o)||(e=o),i.unshift(function(e={}){const{isActionCreator:t=Rt}=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},Ht=e=>t=>{setTimeout(t,e)},Kt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Ht(10),Bt=e=>function(t){const{autoBatch:n=!0}=t??{};let r=new Ut(e);return n&&r.push(((e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let o=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Kt:"callback"===e.type?e.queueNotification:Ht(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},r,{subscribe(e){const t=r.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,i=!o,i&&(s||(s=!0,c(l))),r.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),r};function Xt(e){const t=Vt(),{reducer:n,middleware:r,devTools:o=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!pe(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=ye(n)}if(r&&"function"!=typeof r)throw new Error("`middleware` field must be a callback");if("function"==typeof r){if(c=r(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=we;o&&(l=_t({trace:!0,..."object"==typeof o&&o}));const u=function(...e){return t=>(n,r)=>{const o=t(n,r);let i=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=we(...a)(o.dispatch),{...o,dispatch:i}}}(...c),d=Bt(u);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(d):d();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!h.includes(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return ve(a,i,l(...h))}function Yt(e){const t={},n=[];let r;const o={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(r)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,o},addMatcher(e,t){if(r)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(r)throw new Error("`builder.addDefaultCase` can only be called once");return r=e,o}};return e(o),[t,n,r]}function Gt(...e){return t=>e.some((e=>((e,t)=>At(e)?e.match(t):e(t))(e,t)))}var Zt=["name","message","stack","code"],Qt=class{constructor(e,t){this.payload=e,this.meta=t}_type},en=class{constructor(e,t){this.payload=e,this.meta=t}_type},tn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Zt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},nn=(()=>{function e(e,t,n){const r=Tt(e+"/fulfilled",((e,t,n,r)=>({payload:e,meta:{...r||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Tt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=Tt(e+"/rejected",((e,t,r,o,i)=>({payload:o,error:(n&&n.serializeError||tn)(e||"Rejected"),meta:{...i||{},arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),u=new AbortController;let d;function h(e){d=e,u.abort()}const p=async function(){let p;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||u.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>u.signal.addEventListener("abort",(()=>t({name:"AbortError",message:d||"Aborted"})))));s(o(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:u.signal,abort:h,rejectWithValue:(e,t)=>new Qt(e,t),fulfillWithValue:(e,t)=>new en(e,t)})).then((t=>{if(t instanceof Qt)throw t;return t instanceof en?r(t.payload,l,e,t.meta):r(t,l,e)}))])}catch(t){p=t instanceof Qt?i(null,l,e,t.payload,t.meta):i(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,arg:e,unwrap:()=>p.then(rn)})}}),{pending:o,rejected:i,fulfilled:r,settled:Gt(i,r),typePrefix:e})}return e.withTypes=()=>e,e})();function rn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var on=Symbol.for("rtk-slice-createasyncthunk");function sn(e,t){return`${e}/${t}`}function an(e,t,n,r){function o(o,...i){let s=n.call(e,o);if(void 0===s){if(!r)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return o.unwrapped=t,o}var cn=function({creators:e}={}){const t=e?.asyncThunk?.[on];return function(e){const{name:n,reducerPath:r=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],r]="function"==typeof e.extraReducers?Yt(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[r,o,i]=Yt(t);if(function(e){return"function"==typeof e}(e))n=()=>Pt(e());else{const t=Pt(e);n=()=>t}function s(e=n(),t){let s=[r[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(Ce(e)){const r=n(e,t);return void 0===r?e:r}if(Ee(e))return dt(e,(e=>n(e,t)));{const r=n(e,t);if(void 0===r){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return r}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)}))}i.forEach((r=>{const i=o[r],s={reducerName:r,type:sn(n,r),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},r,o){let i,s;if("reducer"in r){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(r))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=r.reducer,s=r.prepare}else i=r;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?Tt(e,s):Tt(e))}(s,i,a):function({type:e,reducerName:t},n,r,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:u}=n,d=o(e,i,u);r.exposeAction(t,d),s&&r.addCase(d.fulfilled,s);a&&r.addCase(d.pending,a);c&&r.addCase(d.rejected,c);l&&r.addMatcher(d.settled,l);r.exposeCaseReducer(t,{fulfilled:s||ln,pending:a||ln,rejected:c||ln,settled:l||ln})}(s,i,a,t)}));const l=e=>e,u=new WeakMap;let d;const h={name:n,reducerPath:r,reducer:(e,t)=>(d||(d=c()),d(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(d||(d=c()),d.getInitialState()),getSelectors(t=l){const n=Dt(u,this,{insert:()=>new WeakMap});return Dt(n,t,{insert:()=>{const n={};for(const[r,o]of Object.entries(e.selectors??{}))n[r]=an(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const r=t??this.reducerPath;return e.inject({reducerPath:r,reducer:this.reducer},n),{...this,reducerPath:r}}};return h}}();function ln(){}var un="listenerMiddleware";Tt(`${un}/add`),Tt(`${un}/removeAll`),Tt(`${un}/remove`);const dn=e=>l((t=>{const n=cn(e),r=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(y)(t)){constructor(...e){super(...e);const t=Xt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const r=await t.dispatch(e(...n));try{rn(r)}catch(e){this.logger.error(e.message,r.type,e.stack)}return r},i=Object.keys(r).reduce(((e,t)=>(e[t]=o(r[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(y(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()}}));const hn=l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),pn=(e,t)=>t?{[e]:t}:{},fn=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},gn=e=>e.selectedAuditId,vn=St((e=>e.auditList.data),(e=>e.map((e=>{const n=e||{},{occurred:r,ID:o,type:i}=n,s=n.data,a=void 0===s?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:""}:s,{saml_request:c,saml_response:l,saml_generated_user:u,saml_generated_roles:d,oidc_response:h,oidc_generated_user:p}=a,f=t(a,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user"]),g=t(n,["occurred","ID","type","data"]),v=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},g),{data:f}),pn("type",(e=>e&&e[0].toUpperCase()+e.slice(1))(i))),pn("saml_request",c)),pn("saml_response",l)),pn("saml_generated_user",fn(u))),pn("saml_generated_roles",fn(d))),pn("oidc_response",fn(h))),pn("oidc_generated_user",fn(p))),{occurredFormatted:r?new Date(Number(r)||0).toLocaleString():"N/A"});return(e=>Object.fromEntries(Object.entries(e).filter((([e,t])=>!!t))))(v)}))));St(gn,vn,((e,t)=>t.find((t=>e===t.id)))),St(gn,(e=>!!e));const mn=nn("audit/search",((e,{extra:{api:t},getState:n})=>{const r=n().searchParams;return t.audit.search(Object.assign(Object.assign({},r),e))})),yn=(e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))})(mn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(wn=e=>e.auditList,{onFulfilled:e=>{wn(e).loading=!1},onPending:e=>{wn(e).loading=!0,wn(e).error=null},onRejected:(e,t)=>{wn(e).loading=!1,wn(e).error=t.error}}));var wn;const bn={action:mn,reducer:yn},kn={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""};class In extends Error{}function On(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 Sn(e,t){if("string"!=typeof e)throw new In("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,r=e.split(".")[n];if("string"!=typeof r)throw new In(`Invalid token specified: missing part #${n+1}`);let o;try{o=On(r)}catch(e){throw new In(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new In(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}In.prototype.name="InvalidTokenError";var jn={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 xn="<region>",Cn=`https://api.${xn}descope.com`,En=6e5,_n="dct",An=()=>{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")}},Tn=[503,521,522,524,530],Rn=[100,5e3,5e3],$n=e=>new Promise((t=>setTimeout(t,e))),Un=e=>async(...t)=>{let n=await e(...t),r=0;for(;Tn.includes(n.status)&&r<Rn.length;)await $n(Rn[r]),n=await e(...t),r++;r>0&&(n.retries=r);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let Pn;const Dn=()=>{if(Pn)return Pn;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 Pn=`${t}-${n}`,Pn};var Ln,Mn;(Mn=Ln||(Ln={})).get="GET",Mn.delete="DELETE",Mn.post="POST",Mn.put="PUT",Mn.patch="PATCH";const Nn=({path:e,baseUrl:t,queryParams:n,projectId:r})=>{const o=r.slice(1,-27);t=t.replace(xn,o?o+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,r)=>{i=`${i}${0===r?"?":""}${t}=${encodeURIComponent(n[t])}${r===e.length-1?"":"&"}`}))}return i},Wn=(...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)),{})),qn={"Content-Type":"application/json"},Fn=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},zn=(e,t)=>{const n={"x-descope-sdk-session-id":Dn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.58.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},Jn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var Vn=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:r,logger:o,hooks:i,cookiePolicy:s,fetch:a})=>{const c=e||Cn,l=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>An().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await Un(n)(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return An().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(r)),r}:Un(n)})(o,a),u=async e=>{var o;const a=(null==i?void 0:i.beforeRequest)?i.beforeRequest(e):e,{path:u,body:d,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(d),m={headers:Wn(Fn(t,g),zn(t,r),(null==n?void 0:n.baseHeaders)||{},Jn(v)?qn:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const y=await l(Nn({path:u,baseUrl:c,queryParams:p,projectId:t}),m);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(e,null==y?void 0:y.clone()),null==i?void 0:i.transformResponse){const e=await y.json(),t=((null===(o=y.headers)||void 0===o?void 0:o.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,r]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:r})}),{}),n=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}return y};return{get:(e,{headers:t,queryParams:n,token:r}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:Ln.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>u({path:e,headers:n,queryParams:r,body:t,method:Ln.post,token:o}),patch:(e,t,{headers:n,queryParams:r,token:o}={})=>u({path:e,headers:n,queryParams:r,body:t,method:Ln.patch,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>u({path:e,headers:n,queryParams:r,body:t,method:Ln.put,token:o}),delete:(e,{headers:t,queryParams:n,token:r}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:Ln.delete,token:r}),hooks:i,buildUrl:(e,n)=>Nn({projectId:t,baseUrl:c,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const r=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==r?void 0:r.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var r;const o=[].concat((null===(r=e.hooks)||void 0===r?void 0:r.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},Hn=429;function Kn(e,t,n){var r;let o=Bn(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[_n])===t)return(null==o?void 0:o[n])||[];o=null===(r=null==o?void 0:o.tenants)||void 0===r?void 0:r[t]}const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function Bn(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Sn(e)}function Xn(e){const{exp:t}=Bn(e);return(new Date).getTime()/1e3>t}function Yn(e){let t=Bn(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Gn(e,t){return Kn(e,t,"permissions")}function Zn(e,t){return Kn(e,t,"roles")}const Qn=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function er(e,t){var n;const r=await e,o={code:r.status,ok:r.ok,response:r},i=await r.clone().json();return r.ok?o.data=i:(o.error=i,r.status===Hn&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=r.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function tr(e){var t;return(null===(t=Bn(e))||void 0===t?void 0:t[_n])||""}const nr=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),rr=(e,t)=>(n=t)=>t=>{const r=e.filter((e=>e(t)));return!(r.length<e.length)&&(n?n.replace("{val}",t):r.join(" OR "))},or=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ir=e=>t=>e.test(t),sr=ir(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),ar=ir(/^\+[1-9]{1}[0-9]{3,14}$/),cr=nr(sr,'"{val}" is not a valid email'),lr=nr(ar,'"{val}" is not a valid phone number'),ur=nr((e=>e.length>=1),"Minimum length is 1");const dr=nr((e=>"string"==typeof e),"Input is not a string"),hr=nr((e=>Array.isArray(e)),"Input is not an array"),pr=nr((e=>"boolean"==typeof e),"Input is not a boolean"),fr=nr((e=>void 0===e),"Input is defined"),gr=rr([dr(),fr()],"Input is not a string or undefined"),vr=rr([hr(),pr()],"Input is not an array or boolean"),mr=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>or(...e).validate(n[t]))),t(...n)),yr=e=>[dr(`"${e}" must be a string`)],wr=e=>[gr(`"${e}" must be string or undefined`)],br=e=>[dr(`"${e}" must be a string`),ur(`"${e}" must not be empty`)],kr=e=>[dr(`"${e}" must be a string`),cr()],Ir=e=>[dr(`"${e}" must be a string`),lr()],Or=mr(br("accessKey")),Sr=e=>({exchange:Or(((t,n)=>er(e.post(jn.accessKey.exchange,{loginOptions:n},{token:t}))))}),jr=(e,t,n)=>(t.forEach((t=>{const r=t.split(".");let o=r.shift(),i=e;for(;r.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=r.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const s=i[o];i[o]=n(s)})),e),xr=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||En,En)});var Cr,Er;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Cr||(Cr={})),function(e){e.email="email"}(Er||(Er={}));const _r=Object.assign(Object.assign({},Cr),Er);var Ar;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ar||(Ar={}));const Tr=br("loginId"),Rr=mr(br("token")),$r=mr(Tr),Ur=mr(br("pendingRef")),Pr=mr(Tr,kr("email")),Dr=e=>({verify:Rr((t=>er(e.post(jn.enchantedLink.verify,{token:t})))),signIn:$r(((n,r,o={},i)=>{var{providerId:s}=o,a=t(o,["providerId"]);return er(e.post(Qn(jn.enchantedLink.signIn,_r.email),{loginId:n,URI:r,loginOptions:a,providerId:s},{token:i}))})),signUpOrIn:$r(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return er(e.post(Qn(jn.enchantedLink.signUpOrIn,_r.email),{loginId:n,URI:r,loginOptions:s,providerId:i}))})),signUp:$r(((n,r,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return er(e.post(Qn(jn.enchantedLink.signUp,_r.email),{loginId:n,URI:r,user:o,loginOptions:a,providerId:s}))})),waitForSession:Ur(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=xr(n);let s;const a=setInterval((async()=>{const n=await e.post(jn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(er(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:Pr(((t,n,r,o,i)=>er(e.post(jn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o}))))}}),Lr=mr(br("flowId")),Mr=mr(br("executionId"),br("stepId"),br("interactionId")),Nr=e=>({start:Lr(((t,n,r,o,i,s,a,c=!1)=>er(e.post(jn.flow.start,{flowId:t,options:n,conditionInteractionId:r,interactionId:o,componentsVersion:i,flowVersions:s,input:a,isCustomScreen:c})))),next:Mr(((t,n,r,o,i,s,a=!1)=>er(e.post(jn.flow.next,{executionId:t,stepId:n,interactionId:r,version:o,componentsVersion:i,input:s,isCustomScreen:a}))))}),Wr=br("loginId"),qr=mr(br("token")),Fr=mr(Wr),zr=mr(Wr,Ir("phone")),Jr=mr(Wr,kr("email")),Vr=Object.keys(_r).filter((e=>e!==Cr.voice&&e!==Cr.im)),Hr=e=>({verify:qr((t=>er(e.post(jn.magicLink.verify,{token:t})))),signIn:Vr.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Fr(((n,o,i={},s)=>{var{providerId:a}=i,c=t(i,["providerId"]);return er(e.post(Qn(jn.magicLink.signIn,r),{loginId:n,URI:o,loginOptions:c,providerId:a},{token:s}))}))})),{}),signUp:Vr.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Fr(((n,o,i,s={})=>{var{providerId:a}=s,c=t(s,["providerId"]);return er(e.post(Qn(jn.magicLink.signUp,r),{loginId:n,URI:o,user:i,loginOptions:c,providerId:a}))}))})),{}),signUpOrIn:Vr.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Fr(((n,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return er(e.post(Qn(jn.magicLink.signUpOrIn,r),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:Jr(((t,n,r,o,i)=>er(e.post(jn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o})))),phone:Object.keys(Cr).filter((e=>e!==Cr.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:zr(((t,r,o,i,s)=>er(e.post(Qn(jn.magicLink.update.phone,n),Object.assign({loginId:t,phone:r,URI:o},s),{token:i}))))})),{})}});var Kr;!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"}(Kr||(Kr={}));const Br=mr(br("code")),Xr=e=>({start:Object.assign(((t,n,r,o,i)=>er(e.post(jn.oauth.start,r||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),i&&{loginHint:i}),token:o}))),Object.keys(Kr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,r,o,i)=>er(e.post(jn.oauth.start,r||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),i&&{loginHint:i}),token:o}))})),{})),exchange:Br((t=>er(e.post(jn.oauth.exchange,{code:t})))),startNative:(t,n,r)=>er(e.post(jn.oauth.startNative,{provider:t,loginOptions:n,implicit:r})),finishNative:(t,n,r,o,i)=>er(e.post(jn.oauth.finishNative,{provider:t,stateId:n,user:r,code:o,idToken:i})),getOneTapClientId:t=>er(e.get(jn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,r,o)=>er(e.post(jn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:r,loginOptions:o})),exchangeOneTapIDToken:(t,n,r,o)=>er(e.post(jn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:r,loginOptions:o}))}),Yr=br("appId"),Gr=mr(Yr),Zr=e=>({connect:Gr(((t,n,r)=>{const o=null==n?void 0:n.tenantId,i=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,er(e.post(jn.outbound.connect,{appId:t,tenantId:o,tenantLevel:i,options:n},{token:r}))}))}),Qr=br("loginId"),eo=mr(Qr,br("code")),to=mr(Qr),no=mr(Qr,Ir("phone")),ro=mr(Qr,kr("email")),oo=e=>({verify:Object.keys(_r).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:eo(((t,r)=>er(e.post(Qn(jn.otp.verify,n),{code:r,loginId:t}))))})),{}),signIn:Object.keys(_r).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:to(((n,o={},i)=>{var{providerId:s}=o,a=t(o,["providerId"]);return er(e.post(Qn(jn.otp.signIn,r),{loginId:n,loginOptions:a,providerId:s},{token:i}))}))})),{}),signUp:Object.keys(_r).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:to(((n,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return er(e.post(Qn(jn.otp.signUp,r),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(_r).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:to(((n,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return er(e.post(Qn(jn.otp.signUpOrIn,r),{loginId:n,loginOptions:s,providerId:i}))}))})),{}),update:{email:ro(((t,n,r,o)=>er(e.post(jn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:r})))),phone:Object.keys(Cr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:no(((t,r,o,i)=>er(e.post(Qn(jn.otp.update.phone,n),Object.assign({loginId:t,phone:r},i),{token:o}))))})),{})}}),io=mr(br("tenant")),so=mr(br("code")),ao=e=>({start:io(((t,n,r,o,i,s,a,c)=>er(e.post(jn.saml.start,r||{},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}),c&&{initiatedEmail:t})},o&&{token:o}))))),exchange:so((t=>er(e.post(jn.saml.exchange,{code:t}))))}),co=br("loginId"),lo=mr(co,br("code")),uo=mr(co),ho=mr(co),po=e=>({signUp:uo(((t,n)=>er(e.post(jn.totp.signUp,{loginId:t,user:n})))),verify:lo(((t,n,r,o)=>er(e.post(jn.totp.verify,{loginId:t,code:n,loginOptions:r},{token:o})))),update:ho(((t,n)=>er(e.post(jn.totp.update,{loginId:t},{token:n}))))}),fo=br("loginId"),go=br("newPassword"),vo=mr(fo,br("password")),mo=mr(fo),yo=mr(fo,go),wo=mr(fo,br("oldPassword"),go),bo=e=>({signUp:vo(((n,r,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return er(e.post(jn.password.signUp,{loginId:n,password:r,user:o,loginOptions:a,providerId:s}))})),signIn:vo(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return er(e.post(jn.password.signIn,{loginId:n,password:r,loginOptions:s,providerId:i}))})),sendReset:mo(((t,n,r)=>er(e.post(jn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:r})))),update:yo(((t,n,r)=>er(e.post(jn.password.update,{loginId:t,newPassword:n},{token:r})))),replace:wo(((t,n,r)=>er(e.post(jn.password.replace,{loginId:t,oldPassword:n,newPassword:r})))),policy:()=>er(e.get(jn.password.policy))}),ko=yr("loginId"),Io=br("loginId"),Oo=br("origin"),So=mr(Io,Oo,br("name")),jo=mr(Io,Oo),xo=mr(ko,Oo),Co=mr(Io,Oo,wr("token")),Eo=mr(br("transactionId"),br("response")),_o=e=>({signUp:{start:So(((t,n,r,o)=>er(e.post(jn.webauthn.signUp.start,{user:{loginId:t,name:r},origin:n,passkeyOptions:o})))),finish:Eo(((t,n)=>er(e.post(jn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:xo(((t,n,r,o,i)=>er(e.post(jn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:r,passkeyOptions:i},{token:o})))),finish:Eo(((t,n)=>er(e.post(jn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:jo(((t,n,r)=>er(e.post(jn.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:r}))))},update:{start:Co(((t,n,r,o)=>er(e.post(jn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:r})))),finish:Eo(((t,n)=>er(e.post(jn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Ao=yr("loginId"),To=mr(Ao),Ro=mr(br("pendingRef")),$o=e=>({signUpOrIn:To(((n,r={})=>{var{providerId:o}=r,i=t(r,["providerId"]);return er(e.post(jn.notp.signUpOrIn,{loginId:n,loginOptions:i,providerId:o}))})),signUp:To(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return er(e.post(jn.notp.signUp,{loginId:n,user:r,providerId:i,loginOptions:s}))})),signIn:To(((n,r={},o)=>{var{providerId:i}=r,s=t(r,["providerId"]);return er(e.post(jn.notp.signIn,{loginId:n,loginOptions:s,providerId:i},{token:o}))})),waitForSession:Ro(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=xr(n);let s;const a=setInterval((async()=>{const n=await e.post(jn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(er(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),Uo=mr(br("token")),Po=mr(wr("token"));var Do,Lo=mr([(Do=br("projectId"),nr(((e,t)=>n=>or(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),r=n.length;let o=0,i=e===Object(e)?e:void 0;for(;null!=i&&o<r;)i=i[n[o++]];return o&&o===r&&void 0!==i?i:void 0})(n,e)))("projectId",Do))())])((e=>{const{projectId:t,logger:n,baseUrl:r,cookiePolicy:o,baseHeaders:i={},refreshCookieName:s,fetch:a}=e;return c=Vn({baseUrl:r,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:o,baseConfig:{baseHeaders:i},refreshCookieName:s,fetch:a}),{accessKey:Sr(c),otp:oo(c),magicLink:Hr(c),enchantedLink:Dr(c),oauth:Xr(c),outbound:Zr(c),saml:ao(c),totp:po(c),notp:$o(c),webauthn:_o(c),password:bo(c),flow:Nr(c),refresh:Po(((e,t,n,r)=>{const o={};n&&(o.externalToken=n);const i=r?jn.tryRefresh:jn.refresh;return er(c.post(i,o,{token:e,queryParams:t}))})),selectTenant:mr([dr("tenantId")],[gr('"token" must be string or undefined')])(((e,t)=>er(c.post(jn.selectTenant,{tenant:e},{token:t})))),logout:Po((e=>er(c.post(jn.logout,{},{token:e})))),logoutAll:Po((e=>er(c.post(jn.logoutAll,{},{token:e})))),me:Po((e=>er(c.get(jn.me,{token:e})))),myTenants:mr([vr('"tenants" must a string array or a boolean')],[gr('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,er(c.post(jn.myTenants,n,{token:t}))})),history:Po((e=>er(c.get(jn.history,{token:e})))),isJwtExpired:Uo(Xn),getTenants:Uo(Yn),getJwtPermissions:Uo(Gn),getJwtRoles:Uo(Zn),getCurrentTenant:Uo(tr),httpClient:c};var c})),Mo=Object.assign(Lo,{DeliveryMethods:_r});
|
|
6
|
+
/*! js-cookie v3.0.5 | MIT */function No(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var Wo=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=No({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in o)o[s]&&(i+="; "+s,!0!==o[s]&&(i+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+i}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(r[a]=t.read(s,a),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",No({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,No({},this.attributes,t))},withConverter:function(t){return e(No({},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 qo={default:"endpoint"},Fo="Blocked by CSP",zo="The endpoint parameter is not a valid URL",Jo="Failed to load the JS script of the agent",Vo="9319";function Ho(e,t){var n,r,o,i,s,a=[],c=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],e,!0);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,r=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},o=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===Fo||s===zo)n.exclude(),i=0;else if(s===Vo)n.exclude();else if(s===Jo){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!o.has(c)&&(o.add(c),i=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=i?i:e.getTime()+r()-Date.now()]}]),l=c[0],u=c[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(e){var n=new Date,r=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return r()}),r),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=u(n,e);if(!t)throw s;var r,o=t[0],i=t[1];return(r=i,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return d(o)}))}))};return d(l).then((function(e){return[e,a]}))}var Ko="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Bo=Ko;function Xo(n){var r;n.scriptUrlPattern;var o=n.token,i=n.apiKey,s=void 0===i?o:i,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(r=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==r?r:Ko,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,r){return e.addEventListener(t,n,r),function(){return e.removeEventListener(t,n,r)}}(document,"visibilitychange",t);return t(),[e,n]}(),u=l[0],d=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(c,s);return Ho(e,Yo)})).catch((function(e){throw d(),function(e){return e instanceof Error&&e.message===Vo?new Error(Jo):e}(e)})).then((function(t){var n=t[0],r=t[1];return d(),n.load(e(e({},a),{ldi:{attempts:r,visibilityStates:u}}))}))}function Yo(e){return function(e,t,n){var r,o=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,a())};o.addEventListener(i,s);var a=function(){return o.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(),r)return n(r);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(zo);var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(Jo))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)}),(function(){throw new Error(Fo)})).then(Go)}function Go(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Vo);return n}const Zo="3.2.0",Qo="undefined"!=typeof window,ei=Math.pow(2,31)-1,ti=`https://descopecdn.com/npm/oidc-client-ts@${Zo}/dist/browser/oidc-client-ts.min.js`,ni=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Zo}/dist/browser/oidc-client-ts.min.js`,ri=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let oi;const ii=e=>{try{return Sn(e).exp}catch(e){return null}},si=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ii(n)},ai=e=>{const{expires_in:t,expires_at:n,access_token:r}=e;return n||(t?Math.floor(Date.now()/1e3)+t:r?ii(r):void 0)},ci=e=>{const{access_token:n,id_token:r,refresh_token:o,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:r,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||ai(e),cookieExpiration:e.cookieExpiration||si(e)},s)},li=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,r)=>{var o;return n[r]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[r])||[]).concat((null==t?void 0:t[r])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},ui=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 ci(n)},di=()=>Qo&&!!window.descopeBridge,hi=(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 ri.includes(n)},pi=void 0!==oi||Qo&&void 0!==window.localStorage,fi=(e,t)=>{var n,r;return null===(r=null===(n=oi||Qo&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===r?void 0:r.call(n,e,t)},gi=e=>{var t,n;return null===(n=null===(t=oi||Qo&&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=oi||Qo&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},mi=e=>{var t,n,r,o,i;return null!==(i=null!==(n=null===(t=null==oi?void 0:oi.key)||void 0===t?void 0:t.call(oi,e))&&void 0!==n?n:Qo&&(null===(o=null===(r=window.localStorage)||void 0===r?void 0:r.key)||void 0===o?void 0:o.call(r,e)))&&void 0!==i?i:null},yi=(...e)=>{console.debug(...e)},wi=(...e)=>{console.warn(...e)},bi=(e,t)=>{let n;var r;return t>0?(n=1e3*t,yi(`Using provided nextRefreshSeconds: ${t}s`)):n=((r=e)?r.getTime()-(new Date).getTime():0)-2e4,n>ei&&(yi(`Timeout is too large (${n}ms), setting it to ${ei}ms`),n=ei),n},ki="DS",Ii="DSR",Oi="DSI",Si="DSRCN";function ji(e,t,n){if(t){const{cookieDomain:r,cookiePath:o,cookieSameSite:i,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=xi(r);Wo.set(e,t,{path:o,domain:l?r:void 0,expires:c,sameSite:i,secure:a})}}function xi(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 Ci=e=>(null==e?void 0:e.cookieName)||ki,Ei=e=>(null==e?void 0:e.cookieName)||Ii;function _i(e="",t){return Wo.get(Ei(t))||gi(`${e}${Ii}`)||""}function Ai(e="",t){return Wo.get(Ci(t))||gi(`${e}${ki}`)||""}function Ti(e=""){return gi(`${e}${Oi}`)||""}function Ri(e="",t,n,r){vi(`${e}${Ii}`),vi(`${e}${ki}`),vi(`${e}${Oi}`),vi(`${e}${Si}`);const o=Ci(t);Wo.remove(o,null==r?void 0:r.session);const i=Ei(n);Wo.remove(i,null==r?void 0:r.refresh)}const $i=(e,t,n)=>r=>{const o=Object.assign(r,{token:r.token||_i(e,t)});if(!n){const t=function(e=""){return gi(`${e}${Si}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const i=function(e=""){return gi(`${e}DTD`)||""}(e);return i&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":i})),o},Ui=Qo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Pi="vsid",Di="vrid",Li=(e=!1)=>{const t=gi("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Mi=async(e,t=Ui)=>{try{if(Li())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Xo({apiKey:e,endpoint:[r.toString(),qo],scriptUrlPattern:[i,Bo]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Pi]:e,[Di]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};fi("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Ni=e=>{const t=Li(!0);return t&&e.body&&(e.body.fpData=t),e},Wi="descopeFlowNonce",qi="X-Descope-Flow-Nonce",Fi="/v1/flow/start",zi="/v1/flow/next",Ji=(e,t=Wi)=>`${t}${e}`,Vi=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Hi=e=>{var t;return e.path===zi&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Vi(e.body.executionId):null},Ki="dls_last_user_login_id",Bi="dls_last_user_display_name",Xi=e=>fi(Ki,e),Yi=()=>gi(Ki),Gi=()=>gi(Bi),Zi=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,r={}]=t,o=Yi(),i=Gi();return o&&(null!==(n=r.lastAuth)&&void 0!==n||(r.lastAuth={}),r.lastAuth.loginId=o,r.lastAuth.name=i),await e(...t)};function Qi(){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 es(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ss(n.publicKey.challenge),n.publicKey.user.id=ss(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=ss(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:as(n.rawId),type:n.type,response:{attestationObject:as(n.response.attestationObject),clientDataJSON:as(n.response.clientDataJSON)}});var n}async function ts(e){const t=os(e);return is(await navigator.credentials.get(t))}async function ns(e,t){const n=os(e);return n.signal=t.signal,n.mediation="conditional",is(await navigator.credentials.get(n))}async function rs(e=!1){var t,n;if(!Qo)return Promise.resolve(!1);if(di()){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 r=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return r&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():r}function os(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ss(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=ss(e.id)})),n}function is(e){return JSON.stringify({id:e.id,rawId:as(e.rawId),type:e.type,response:{authenticatorData:as(e.response.authenticatorData),clientDataJSON:as(e.response.clientDataJSON),signature:as(e.response.signature),userHandle:e.response.userHandle?as(e.response.userHandle):void 0}})}function ss(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function as(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var cs,ls=(cs=e=>({async signUp(t,n,r){const o=await e.webauthn.signUp.start(t,window.location.origin,n,r);if(!o.ok)return o;const i=await es(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(t,n){const r=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!r.ok)return r;const o=await ts(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,o)},async signUpOrIn(t,n){var r;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(r=o.data)||void 0===r?void 0:r.create){const t=await es(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await ts(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,r){const o=await e.webauthn.update.start(t,window.location.origin,n,r);if(!o.ok)return o;const i=await es(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:es,get:ts,isSupported:rs,conditional:ns}}),(...e)=>{const t=cs(...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 us="/fedcm/config",ds=()=>{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 ps(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function ps(e,t){var n,r;const o=await async function(e,t="google",n,r,o){const i=ds(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const c=a.data.clientId;return new Promise((e=>{var a,l;const u=n=>{e({provider:t,nonce:i,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,callback:u,nonce:i})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void u()}if(r&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==r||r(t),void u()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const r=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!r.ok||!r.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,r.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(r=null==t?void 0:t.onAuthenticated)||void 0===r||r.call(t,n.data)}}var fs=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await rs(),r=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=r,e.flow.start(...t)}});let gs;const vs=(e,t)=>new Promise(((n,r)=>{if(!e.length)return r(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);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",(()=>{vs(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),ms=(e,t,n)=>{const r=async()=>{let r,o;return r&&o||({client:r,stateUserKey:o}=await(async(e,t,n)=>{gs||(gs=(async()=>{try{return require("oidc-client-ts")}catch(e){return vs([ti,ni],(()=>window.oidc))}})());const{OidcClient:r,WebStorageStateStore:o}=await gs;if(!r)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,c,l;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,c=`${a}_user`,l="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access");const u={authority:s,client_id:a,redirect_uri:i,response_type:"code",scope:(null==n?void 0:n.scope)||l,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(u.redirect_uri=n.redirectUri),{client:new r(u),stateUserKey:c}})(e,t,n)),{client:r,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:i}=await r(),s=await o.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)))),fi(i,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(e={},t=!1)=>{const{client:n}=await r(),o=await n.createSigninRequest(e),{url:i}=o;return t||(window.location.href=i),{ok:!0,data:o}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:i}=await r(),s=(e=>{const t=gi(e);return t?JSON.parse(t):null})(i);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const c=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await r();e||(e={}),e.id_token_hint=e.id_token_hint||Ti(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const i=await n.createSignoutRequest(e),{url:s}=i;return vi(o),t||window.location.replace(s),i}}},ys=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,oi=n,e(t)}),(e=>n=>{var{fpKey:r,fpLoad:o}=n,i=t(n,["fpKey","fpLoad"]);return Qo?(r&&o&&Mi(r).catch((()=>null)),e(li(i,{beforeRequest:Ni}))):e(i)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.47.0"},t.baseHeaders)}))),(e=>t=>{const n=Qi(),r=Qi(),o=Qi(),i=Qi(),s=e(li(t,{afterRequest:async(e,t)=>{if(hi(e,t))yi("Session invalidated, notifying subscribers with empty values"),r.pub(null),o.pub(null),n.pub(null),i.pub(null);else{const e=await(async e=>{const t=await ui(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:c}=await ui(t);s&&r.pub(s),c&&i.pub(c),(a||s)&&n.pub(a||42)}}})),a=jr(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return r.pub(null),o.pub(null),n.pub(null),i.pub(null),s}));return Object.assign(a,{onSessionTokenChange:r.sub,onUserChange:o.sub,onClaimsChange:i.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:r=!0,nonceStoragePrefix:o=Wi}=n,i=t(n,["enableFlowNonce","nonceStoragePrefix"]);return r?(((e=Wi)=>{try{if(!pi)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(r=null!==(t=null==oi?void 0:oi.length)&&void 0!==t?t:Qo&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==r?r:0);o++){const t=mi(o);if(t&&t.startsWith(e)){const n=gi(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,r})(o),e(li(i,{afterRequest:async(e,t)=>{if(e.path!==Fi&&e.path!==zi)return;const{nonce:n,executionId:r}=await(async(e,t)=>{try{const n=t.headers.get(qi);let r=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return r||(r=Hi(e)),{nonce:n,executionId:Vi(r)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&r&&((e,t,n,r=Wi)=>{try{const o=Ji(e,r),i=n?172800:10800,s={value:t,expiry:Date.now()+1e3*i,isStart:n};fi(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(r,n,e.path===Fi,o)},beforeRequest:e=>{if(e.path===zi){const t=Hi(e);if(t){const n=((e,t=Wi)=>{try{const n=Ji(e,t),r=gi(n);if(!r)return null;const o=JSON.parse(r);return o.expiry<Date.now()?(((e,t=Wi)=>{try{const n=Ji(e,t);vi(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);n&&(e.headers=e.headers||{},e.headers[qi]=n)}}return e}}))):e(i)}),(e=>n=>{var{autoRefresh:r}=n,o=t(n,["autoRefresh"]);const i=!!r,s="object"==typeof r&&(null==r?void 0:r.customActivityTracking);if(!i||di())return Object.assign(e(o),{markUserActive:()=>{wi("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,u,d=null,h=!1,p=!1;s&&(yi("Activity-based refresh enabled"),d=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Qo&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(yi("Expiration time passed, refreshing session"),f.refresh(_i()||u))}));const f=e(li(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:r,sessionExpiration:o,nextRefreshSeconds:i}=await ui(t);if(hi(e,t))yi("Session invalidated, canceling all timers"),a();else if(n||o){if(l=((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=Sn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!l)return void yi("Could not extract expiration time from session token");u=r,h=i>0;const e=bi(l,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)`),d&&(d.reset(),p=!1),c((()=>{if(Qo&&"hidden"===document.visibilityState)yi("Skipping refresh due to timer - document is hidden");else{if(d&&h&&!d.hadActivity())return yi("Skipping refresh due to timer - user is idle"),void(p=!0);yi("Refreshing session due to timer"),f.refresh(_i()||r)}}),e)}}}));return Object.assign(jr(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return yi("Clearing all timers"),a(),n})),{markUserActive:d?()=>{yi("markUserActive() called"),h||yi("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),d.markActive(),p&&(yi("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(_i()||u))}:()=>{wi("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:r=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!r)return Object.assign(e(i),{getLastUserLoginId:Yi,getLastUserDisplayName:Gi});const s=e(li(i,{afterRequest:async(e,t)=>{var n;const{userInfo:r,lastAuth:o}=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=ci((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==r?void 0:r.loginIds)||void 0===n?void 0:n[0],s=null==r?void 0:r.name;i?(Xi(i),(e=>{fi(Bi,e)})(s)):(null==o?void 0:o.loginId)&&Xi(o.loginId)}}));let a=jr(s,["flow.start"],Zi);return a=jr(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const r=await t(...n);return e||(vi(Ki),vi(Bi)),r})(o)),Object.assign(a,{getLastUserLoginId:Yi,getLastUserDisplayName:Gi})}),(e=>n=>{var{persistTokens:r,sessionTokenViaCookie:o,refreshTokenViaCookie:i,storagePrefix:s,refreshCookieName:a}=n,c=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!r||!Qo)return e(Object.assign({refreshCookieName:a},c));let l;const u=e(li(Object.assign({refreshCookieName:a},c),{beforeRequest:$i(s,i,a),afterRequest:async(e,t)=>{if(hi(e,t))yi("Session invalidated, clearing persisted tokens"),Ri(s,o,i,l);else{const e=await ui(t);e.cookieName?fi(`${s||""}${Si}`,e.cookieName):e.refreshJwt&&vi(`${s||""}${Si}`);const n=((e={},t=!1,n="",r=!1)=>{var o,i,s,a;const{sessionJwt:c,refreshJwt:l,trustedDeviceJwt:u}=e;let d;if(l)if(r){vi(`${n}${Ii}`);const t=r.sameSite||"Strict",s=null===(o=r.secure)||void 0===o||o,a=null!==(i=r.domain)&&void 0!==i?i:e.cookieDomain,c=Ei(r);s&&"https:"!==window.location.protocol&&wi("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 u=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});ji(c,l,u);const h=xi(a);d=Object.assign(Object.assign({},d),{refresh:{path:u.cookiePath,domain:h?a:void 0}})}else{const e=Ei(r);Wo.remove(e),fi(`${n}${Ii}`,l)}if(c)if(t){const n=t.sameSite||"Strict",r=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,i=Ci(t);r&&"https:"!==window.location.protocol&&wi("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const l=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r,cookieDomain:o});ji(i,c,l);const u=xi(o);d=Object.assign(Object.assign({},d),{session:{path:l.cookiePath,domain:u?o:void 0}})}else fi(`${n}${ki}`,c);return e.idToken&&fi(`${n}${Oi}`,e.idToken),u&&fi(`${n}DTD`,u),d})(e,o,s,i);n&&(l=n)}}})),d=jr(u,["logout","logoutAll","oidc.logout"],((e,t,n,r)=>o=>async(...i)=>{const s=await o(...i);return Ri(e,t,n,null==r?void 0:r()),s})(s,o,i,(()=>l)));return Object.assign(d,{getRefreshToken:()=>_i(s,i),getSessionToken:()=>Ai(s,o),getIdToken:()=>Ti(s)})}))((e=>{const t=Mo(e),n=ms(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(r,o)=>{var i;if(di())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(r),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}const s=Ai(),a=_i();let c="";if(e.getExternalToken)try{c=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(r,{dcs:s?"t":"f",dcr:a?"t":"f"},c,o)},logout:async r=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:r}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(r)},flow:fs(t),webauthn:ls(t),fedcm:(r=t,o=e.projectId,{onetap:{requestExchangeCode(e){hs(r,e)},requestAuthentication(e){hs(r,e)}},async oneTap(e,t,n,o,i){await ps(r,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:i})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:r.httpClient.buildUrl(o+us),clientId:o}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return r.refresh(i.token)},isSupported:()=>Qo&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=r.httpClient.buildUrl(o+us);try{const r={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(r));return!!i&&!!i.token}catch(e){return!1}}}),oidc:n});var r,o})),ws={search:"/v1/mgmt/audit/search"},bs=e=>n(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((n=>{const r=[],o=(new Date).getTime()/1e3+2592e3,i=new Date(o).toLocaleString();for(let e=1;e<9;e+=1)r.push({id:`Audit ${e}`,action:`Action ${e}`,actorId:`Actor ${e}`,type:"info",method:`Method ${e}`,userId:`User ${e}`,device:`Device ${e}`,geo:`Geo ${e}`,remoteAddress:`127.0.0.${e}`,externalIds:[`Login ID ${e}`],occurred:o,occurredFormatted:i});t.forEach((e=>{r.sort(((t,n)=>{var r,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(r=t[e.field])||void 0===r?void 0:r.localeCompare(n[e.field])}))})),n(r.filter((t=>t.id.toLowerCase().includes(e.toLowerCase())||t.action.toLowerCase().includes(e.toLowerCase())||t.type.toLowerCase().includes(e.toLowerCase())||t.device.toLowerCase().includes(e.toLowerCase())||t.method.toLowerCase().includes(e.toLowerCase())||t.geo.toLowerCase().includes(e.toLowerCase())||t.remoteAddress.toLowerCase().includes(e.toLowerCase())||t.externalIds.includes(e.toLowerCase())||t.userId.toLowerCase().includes(e.toLowerCase()))))}))})),ks=({httpClient:e,tenant:t,mock:r})=>({search:(...o)=>n(void 0,[...o],void 0,(function*({page:o,limit:i=1e4,text:s,sort:a,from:c}={}){if(r)return bs({page:o,limit:i,text:s,sort:a},t);const l=yield e.post(ws.search,{limit:i,page:o,text:s,sort:a,from:c},{queryParams:{tenant:t}});yield(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)})))(l);return(yield l.json()).audits}))}),Is=l((e=>{var t,s,a,c;const l=i(C,j,y,E,hn,x({tenant:x.missingAttrValidator}))(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return r(this,s,"f")||r(this,t,"m",a).call(this),r(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"],(()=>{r(this,s,"f")&&r(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,n,r)=>{const o=ys(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":r,"x-descope-widget-version":"0.5.37"}}));return{audit:ks({httpClient:o.httpClient,tenant:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},c})),Os=l((e=>{const t=i(dn({name:"widget",initialState:kn,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{bn.reducer(e)},asyncActions:{searchAudit:bn.action}}),S,y,Is)(e);return class extends t{constructor(...e){super(...e),this.state=kn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ss=l((e=>{const t=i(T,x({"widget-id":x.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(`audit-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),js=l((e=>{var t,o,a;return a=class extends(i(y,S,F,B,Ss,Os)(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([r(this,t,"m",o).call(this)]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=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})),xs=l((e=>{var t,o,s,a,l;return l=class extends(i(y,js,Os)(e)){constructor(){super(...arguments),t.add(this),o.set(this,c((()=>{const e=this.rangeInput.value,t=new Date;let n;switch(e){case"minuets15":n=t.setMinutes(t.getMinutes()-15);break;case"hour":n=t.setHours(t.getHours()-1);break;case"hour6":n=t.setHours(t.getHours()-6);break;case"day":default:n=t.setDate(t.getDate()-1);break;case"day3":n=t.setDate(t.getDate()-3);break;case"week":n=t.setDate(t.getDate()-7);break;case"week2":n=t.setDate(t.getDate()-14);break;case"month":n=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(n).getTime())})})))}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),r(this,t,"m",s).call(this),r(this,t,"m",a).call(this)}))}},o=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new se(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(r(this,o,"f")),r(this,o,"f").call(this)},a=function(){var e;this.rangeInput=new ie(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(r(this,o,"f"))},l})),Cs=l((e=>{var t,o,s,c;return c=class extends(i(Os,y,js)(e)){constructor(){super(...arguments),t.add(this),s.set(this,(e=>{let t,n;return(...r)=>(t&&a(t,r)||(t=r,n=e(...r)),n)})((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),r(this,t,"m",o).call(this),r(this,s,"f").call(this,vn(this.state)),this.subscribe(r(this,s,"f").bind(this),vn)}))}},s=new WeakMap,t=new WeakSet,o=function(){var e;this.auditTable=new te(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="audit-table"]'),{logger:this.logger}),this.auditTable.onSelectedItemsChange((e=>{this.actions.setSelectedAuditId(e.detail.value.map((({id:e})=>e)))}))},c})),Es=l((e=>class extends(i(U,le,Cs,xs)(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)}))}})),_s=i((e=>class extends(Es(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",_s);const As=(e,t,n,r={})=>{var o,i,s,a;return[Math.min(Math.max(t,("all"===r.left?e.offsetWidth:null!==(o=r.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===r.right?e.offsetWidth:null!==(i=r.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===r.top?e.offsetHeight:null!==(s=r.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===r.bottom?e.offsetHeight:null!==(a=r.bottom)&&void 0!==a?a:0))]};var Ts,Rs,$s,Us,Ps,Ds,Ls,Ms,Ns,Ws;const qs=document.createElement("template");qs.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 Fs=i(V)(HTMLElement);class zs extends Fs{constructor(){var e;super(),Ts.add(this),Rs.set(this,new g({messages:[]})),$s.set(this,void 0),Us.set(this,void 0),Ps.set(this,void 0),Ds.set(this,{resize:r(this,Ts,"m",Ws).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(qs.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'),o(this,$s,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Us,r(this,$s,"f").querySelector(".content"),"f"),o(this,Ps,r(this,$s,"f").querySelector(".header"),"f")}updateData(e){r(this,Rs,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let r=0,o=0,i=0,s=0;function a(t){t.preventDefault(),r=i-t.clientX,o=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=As(e,e.offsetLeft-r,e.offsetTop-o,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(r(this,$s,"f"),r(this,Ps,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",r(this,Ds,"f").resize),(e=r(this,$s,"f")).onmousemove=t=>{var n;const r=t.target;(r.w&&r.w!==r.offsetWidth||r.h&&r.h!==r.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),r.w=r.offsetWidth,r.h=r.offsetHeight},r(this,$s,"f").onresize=r(this,Ts,"m",Ns).bind(this),r(this,Rs,"f").subscribe(r(this,Ts,"m",Ls).bind(this))}disconnectedCallback(){r(this,Rs,"f").unsubscribeAll(),window.removeEventListener("resize",r(this,Ds,"f").resize)}}Rs=new WeakMap,$s=new WeakMap,Us=new WeakMap,Ps=new WeakMap,Ds=new WeakMap,Ts=new WeakSet,Ls=function(e){r(this,Ts,"m",Ms).call(this,e),r(this,Ts,"m",Ns).call(this)},Ms=function(e){r(this,Us,"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("")},Ns=function(){r(this,Us,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),r=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;r||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Ws=function(){const[e,t]=As(r(this,$s,"f"),Number.parseInt(r(this,$s,"f").style.left,10),Number.parseInt(r(this,$s,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});r(this,$s,"f").style.top=`${t}px`,r(this,$s,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",zs);var Js=Object.freeze({__proto__:null,default:zs});return _s}();
|
|
7
7
|
//# sourceMappingURL=index.js.map
|