@descope/access-key-management-widget 0.4.11 → 0.4.13
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 +2 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/access-key-management-widget v0.4.
|
|
3
|
+
* @descope/access-key-management-widget v0.4.13
|
|
4
4
|
*/
|
|
5
|
-
this["descope-access-key-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(s=Object.getOwnPropertySymbols(e);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(n[s[i]]=e[s[i]])}return n}function n(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function s(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function i(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const o=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),c=e=>{let t,n;return(...s)=>(t&&a(t,s)||(t=s,n=e(...s)),n)},l=e=>(t,...n)=>t.reduce(((t,s,i)=>{var r;return`${t}${s}${(null===(r=null==n?void 0:n[i])||void 0===r?void 0:r[e>1?1:0])||""}`}),""),d=(e,t=500)=>{let n;return function(...s){clearTimeout(n),n=setTimeout((()=>e.apply(this,s)),t)}},u=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const s=e(n);return s[t]=!0,s}};var h,p,g,f;function m(e,t){const n=Object.getOwnPropertyNames(e),s=Object.getOwnPropertyNames(t);if(n.length!==s.length)return!1;for(let s=0;s<n.length;s+=1){const i=n[s],r=e[i],o=t[i];if(null===r||null===o){if(r!==o)return!1}else if("object"==typeof r&&"object"==typeof o){if(!m(r,o))return!1}else if(r!==o)return!1}return!0}let w=class{constructor(e={},{forceUpdate:t=!1}={}){h.set(this,void 0),p.set(this,{}),g.set(this,0),f.set(this,!0),this.update=e=>{const t="function"==typeof e?e(s(this,h,"f")):e,n=Object.assign(Object.assign({},s(this,h,"f")),t);if(s(this,f,"f")||!m(s(this,h,"f"),n)){const e=s(this,h,"f");i(this,h,n,"f"),Object.freeze(s(this,h,"f")),setTimeout((()=>{Object.values(s(this,p,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,h,e,"f"),i(this,f,t,"f")}get current(){return Object.assign({},s(this,h,"f"))}subscribe(e){return i(this,g,s(this,g,"f")+1,"f"),s(this,p,"f")[s(this,g,"f")]=e,s(this,g,"f").toString()}unsubscribe(e){const t=!!s(this,p,"f")[e];return t&&delete s(this,p,"f")[e],t}unsubscribeAll(){return i(this,p,{},"f"),!0}};h=new WeakMap,p=new WeakMap,g=new WeakMap,f=new WeakMap;const v=["error","warn","info","debug"],y=u((e=>{var t,n,r,o;return o=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,s(this,t,"m",r).call(this,console))}set logger(e){i(this,n,s(this,t,"m",r).call(this,e||console),"f")}get logger(){return s(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return v.reduce(((t,n)=>(t[n]=(...t)=>{var s;this.onLogEvent(n,t),null===(s=e[n])||void 0===s||s.call(e,...t)},t)),{})},o})),_="undefined"!=typeof localStorage,b=_&&localStorage.getItem("base.content.url")||"",k=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,S=u((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&s(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),I=u((e=>{var t,n;const i=r(y,S)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=s(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){s(this,t,"f")[e]||(s(this,t,"f")[e]=[]);const i=s(this,t,"f")[e].push(n);return()=>s(this,t,"f")[e].splice(i,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),x=e=>t=>{var n,i,o;const a=r(y,S,I)(t),c=Object.keys(e);return o=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,s(this,n,"m",i).bind(this))}async init(){var e;c.forEach((e=>s(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const s=e[t],i="function"==typeof s?s(t,n):s;i&&this.logger.error(i)},o};x.missingAttrValidator=k;const E=u((e=>{const t=r(x({"project-id":k}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),C=u((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),R="Trying the next fallback URL...";function T({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:s="https://static.descope.com/pages"}){const i=new URL(s);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=s,i}const O=u((e=>{var t,n,o,a,c;const l=r(y,E,C)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0),o.set(this,void 0)}async fetchStaticResource(e,n){const r=s(this,t,"m",a).call(this,e),c=Array.isArray(r)?e=>{if(e!==r.length-1){const{baseUrl:t}=r[e];i(this,o,t,"f")}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:s})=>{const i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;e++){const r=i[e],o=e===i.length-1;try{const i=await fetch(r.toString(),t);if(i.ok)return null==s||s(e),i;const a=`Error fetching URL ${r} [${i.status}]`;if(o)throw new Error(a);null==n||n.debug(`${a}. ${R}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(o)throw new Error(t);null==n||n.debug(`${t}. ${R}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")}},n=new WeakMap,o=new WeakMap,t=new WeakSet,a=function(e){const t=b||this.baseStaticUrl;if(t)return T({projectId:this.projectId,filename:e,baseUrl:t});const r=s(this,n,"f")!==this.baseUrl,a=r&&!!this.baseUrl;r&&(i(this,n,this.baseUrl,"f"),i(this,o,void 0,"f"));const c=T({projectId:this.projectId,filename:e,baseUrl:s(this,o,"f")});if(!a)return c;return[T({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),c]},c})),j=u((e=>{var t,n;const i=r(x({"project-id":k}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(s(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return s(this,t,"f").set(e,n),()=>{s(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(s(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!s(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=s(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),A=u((e=>{var t,n,o,a,c;const l=r(O,j,S)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),o.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",s(this,t,"m",n).bind(this))}get config(){return s(this,o,"f")||i(this,o,s(this,a,"f").call(this),"f"),s(this,o,"f")}},o=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){i(this,o,void 0,"f")},c})),P=u((e=>{var t,n,o,a,c,l,d;return d=class extends(r(S,y)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&s(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&s(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)),s(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,o=function(){var e;null===(e=s(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(s(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return na})),document.body.appendChild(s(this,n,"f"))},c=function(){this.debug?s(this,t,"m",a).call(this):s(this,t,"m",o).call(this)},l=function(e,t){var i;e&&(null===(i=s(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),U="load-descope-ui",M="base.ui.components.url",$=_&&localStorage.getItem(M)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",N=_&&localStorage.getItem(M)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",q=_&&localStorage.getItem(M)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",D=e=>{const t=document.createElement("script");return t.id=e,t},W=(e,t)=>e.replace("<version>",t),L=u((e=>{var t,n,o,a,c,l,d,u,h,p,g,f;const m=r(y,A)(e);return f=class extends m{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),o.set(this,Symbol("loadCbs")),h.set(this,void 0)}get descopeUi(){return s(this,h,"f")||i(this,h,s(this,t,"m",g).call(this),"f"),s(this,h,"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=>s(this,t,"m",p).call(this,e))))}get baseCdnUrl(){return this.getAttribute("base-cdn-url")}},n=new WeakMap,o=new WeakMap,h=new WeakMap,t=new WeakSet,a=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},c=function(e){const t=s(this,n,"f"),i=s(this,o,"f");e[t]=[],e[i]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[i].push(t)}})},l=async function(e,n,i,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const o=D(i);document.body.append(o),o.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${o.src}"`)))})),o.addEventListener("load",(()=>{n.forEach((e=>e()))})),o.src=W(r,await s(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[s(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),s(this,t,"m",l).call(this,[s(this,t,"m",l).bind(this,e[s(this,n,"f")],e[s(this,o,"f")],"load-descope-ui-fallback-script-2",q),...e[s(this,n,"f")]],e[s(this,o,"f")],"load-descope-ui-fallback-script",N)})),e.addEventListener("load",(()=>{e[s(this,o,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${U}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=D(U);document.body.append(e),s(this,t,"m",c).call(this,e),s(this,t,"m",d).call(this,e),e.src=W(this.baseCdnUrl||$,await s(this,t,"m",a).call(this))}return document.getElementById(U)},p=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(", ")}"`)},g=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),s(this,t,"m",u).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},f})),K="content-root",F="root",H=u((e=>class extends e{constructor(...e){var t,n,s,i;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${F}">\n <div id="${K}"></div>\n </div>\n `;const r=new CSSStyleSheet;r.replaceSync(`\n #${F}, #${K} {\n height: 100%;\n }\n #${F} {\n position: relative;\n height: fit-content;\n }\n `),null!==(t=(i=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(i.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],this.contentRootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K),this.rootElement=null===(s=this.shadowRoot)||void 0===s?void 0:s.getElementById(F)}})),z="descope-modal";var J,B;let V=class{constructor(e,t){J.set(this,void 0),this.nodeName="",i(this,J,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const s="function"==typeof e?e():e;s&&(clearInterval(n),t(s))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(s(this,J,"f"))}get ele(){var e,t;const n="function"==typeof s(this,J,"f")?s(this,J,"f").call(this):s(this,J,"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)}};J=new WeakMap;const Z=/^descope-grid-([^-]+)-column$/,G={text:class extends V{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 V{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 Y=class extends V{constructor(){super(...arguments),this.nodeName="descope-grid",B.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 s=null===(n=Z.exec(t.localName))||void 0===n?void 0:n[1],i=G[s];return i?(e.push(new i(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const i=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);a(i,this.ele.columns)||(this.ele.columns=i,null===(n=s(this,B,"f"))||void 0===n||n.call(this,i))}onColumnsChange(e){i(this,B,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};B=new WeakMap;let X=class extends V{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};var Q;let ee=class extends V{constructor(){super(...arguments),Q.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=""),s(this,Q,"f")&&(null===(e=this.ele)||void 0===e||e.append(s(this,Q,"f").content.cloneNode(!0)))}setContent(e){i(this,Q,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};Q=new WeakMap;let te=class extends V{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}},ne=class extends V{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()}},se=class extends V{constructor(){super(...arguments),this.nodeName="descope-text"}get ele(){return super.ele}get text(){var e;return null===(e=this.ele)||void 0===e?void 0:e.innerText}set text(e){this.ele&&(this.ele.innerText=e)}},ie=class extends V{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const re=u((e=>{var t,n;const i=r(S,H,L)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ee{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(z);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(s(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([z]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),oe="descope-notification",ae=u((e=>{var t,n;const i=r(S,H,L)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ne{setContent(t){const n="string"==typeof t?o(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(oe);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(s(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([oe])}},t=new WeakMap,n})),ce=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',le=u((e=>{var t,n,o,a,c,l,d,u,h,p,g,f,m,w;const v=r(x({theme:ce}),O,S,L,A,H,I)(e);return w=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,void 0),o.set(this,void 0),g.set(this,(()=>{s(this,t,"m",f).call(this),s(this,m,"f").call(this,"os"===this.getAttribute("theme"))})),m.set(this,(e=>{var n,i,r;const o=e?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[o])||void 0===r||r.call(i,"change",(()=>s(this,t,"m",f).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)),s(this,t,"m",l).call(this),s(this,t,"m",d).call(this),s(this,g,"f").call(this),this.observeAttributes(["theme"],s(this,g,"f")),this.observeAttributes(["style-id"],(()=>{i(this,o,null,"f"),s(this,t,"m",h).call(this),s(this,t,"m",l).call(this),s(this,t,"m",d).call(this)}))}},n=new WeakMap,o=new WeakMap,g=new WeakMap,m=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(M))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(M),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 s(this,o,"f")||(i(this,o,s(this,t,"m",a).call(this),"f"),s(this,o,"f").then((e=>this.logger.debug("Fetched theme",e)))),s(this,o,"f")},l=async function(){var e,r,o,a;const l=await s(this,t,"a",c);l&&(s(this,n,"f")||(i(this,n,new CSSStyleSheet,"f"),null!==(e=(a=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(a.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,s(this,n,"f")]),s(this,n,"f").replaceSync(((null===(r=null==l?void 0:l.light)||void 0===r?void 0:r.globals)||"")+((null===(o=null==l?void 0:l.dark)||void 0===o?void 0:o.globals)||"")))},d=async function(){var e,n;const i=Object.assign({},await s(this,t,"a",c));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},u=async function(){var e,t;const{projectConfig:n}=await this.config||{},s=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=s||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},h=async function(){const e=await s(this,t,"m",u).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},p=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},f=function(){s(this,t,"m",h).call(this),s(this,t,"m",p).call(this)},w}));var de=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ue=()=>Math.random().toString(36).substring(7).split("").join("."),he={INIT:`@@redux/INIT${ue()}`,REPLACE:`@@redux/REPLACE${ue()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ue()}`};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 ge(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 fe(e){let t=typeof e;return t=ge(e),t}function me(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${fe(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: '${fe(n)}'`);return n(me)(e,t)}let s=e,i=t,r=new Map,o=r,a=0,c=!1;function l(){o===r&&(o=new Map,r.forEach(((e,t)=>{o.set(t,e)})))}function d(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${fe(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 o.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(),o.delete(n),r=null}}}function h(e){if(!pe(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${fe(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: '${fe(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,i=s(i,e)}finally{c=!1}return(r=o).forEach((e=>{e()})),e}h({type:he.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${fe(e)}`);s=e,h({type:he.REPLACE})},[de]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${fe(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[de](){return this}}}}}function we(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ve(e){const t=Object.keys(e),n={};for(let s=0;s<t.length;s++){const i=t[s];void 0===e[i]&&we(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const s=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type: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){r=e}return function(e={},t){if(r)throw r;{const s=function(e,t,n,s){const i=Object.keys(t),r=n&&n.type===he.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!pe(e))return`The ${r} has unexpected type of "${fe(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const o=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!s[e]));return o.forEach((e=>{s[e]=!0})),n&&n.type===he.REPLACE?void 0:o.length>0?`Unexpected ${o.length>1?"keys":"key"} "${o.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);s&&we(s)}let o=!1;const a={};for(let i=0;i<s.length;i++){const r=s[i],c=n[r],l=e[r],d=c(l,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,o=o||d!==l}return o=o||s.length!==Object.keys(e).length,o?a:e}}function ye(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function _e(e){return pe(e)&&"type"in e&&"string"==typeof e.type}var be=Symbol.for("immer-nothing"),ke=Symbol.for("immer-draftable"),Se=Symbol.for("immer-state"),Ie=[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 xe(e,...t){{const n=Ie[e],s="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${s}`)}}var Ee=Object.getPrototypeOf;function Ce(e){return!!e&&!!e[Se]}function Re(e){return!!e&&(Oe(e)||Array.isArray(e)||!!e[ke]||!!e.constructor?.[ke]||Me(e)||$e(e))}var Te=Object.prototype.constructor.toString();function Oe(e){if(!e||"object"!=typeof e)return!1;const t=Ee(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Te}function je(e,t){0===Ae(e)?Object.entries(e).forEach((([n,s])=>{t(n,s,e)})):e.forEach(((n,s)=>t(s,n,e)))}function Ae(e){const t=e[Se];return t?t.type_:Array.isArray(e)?1:Me(e)?2:$e(e)?3:0}function Pe(e,t){return 2===Ae(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ue(e,t,n){const s=Ae(e);2===s?e.set(t,n):3===s?e.add(n):e[t]=n}function Me(e){return e instanceof Map}function $e(e){return e instanceof Set}function Ne(e){return e.copy_||e.base_}function qe(e,t){if(Me(e))return new Map(e);if($e(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Oe(e)){if(!Ee(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Se];let s=Reflect.ownKeys(n);for(let t=0;t<s.length;t++){const i=s[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(Ee(e),n)}function De(e,t=!1){return Le(e)||Ce(e)||!Re(e)||(Ae(e)>1&&(e.set=e.add=e.clear=e.delete=We),Object.freeze(e),t&&je(e,((e,t)=>De(t,!0)))),e}function We(){xe(2)}function Le(e){return Object.isFrozen(e)}var Ke,Fe={};function He(e){const t=Fe[e];return t||xe(0,e),t}function ze(){return Ke}function Je(e,t){t&&(He("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Be(e){Ve(e),e.drafts_.forEach(Ge),e.drafts_=null}function Ve(e){e===Ke&&(Ke=e.parent_)}function Ze(e){return Ke={drafts_:[],parent_:Ke,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ge(e){const t=e[Se];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Ye(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Se].modified_&&(Be(t),xe(4)),Re(e)&&(e=Xe(t,e),t.parent_||et(t,e)),t.patches_&&He("Patches").generateReplacementPatches_(n[Se].base_,e,t.patches_,t.inversePatches_)):e=Xe(t,n,[]),Be(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==be?e:void 0}function Xe(e,t,n){if(Le(t))return t;const s=t[Se];if(!s)return je(t,((i,r)=>Qe(e,s,t,i,r,n))),t;if(s.scope_!==e)return t;if(!s.modified_)return et(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const t=s.copy_;let i=t,r=!1;3===s.type_&&(i=new Set(t),t.clear(),r=!0),je(i,((i,o)=>Qe(e,s,t,i,o,n,r))),et(e,t,!1),n&&e.patches_&&He("Patches").generatePatches_(s,n,e.patches_,e.inversePatches_)}return s.copy_}function Qe(e,t,n,s,i,r,o){if(i===n&&xe(5),Ce(i)){const o=Xe(e,i,r&&t&&3!==t.type_&&!Pe(t.assigned_,s)?r.concat(s):void 0);if(Ue(n,s,o),!Ce(o))return;e.canAutoFreeze_=!1}else o&&n.add(i);if(Re(i)&&!Le(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Xe(e,i),t&&t.scope_.parent_||et(e,i)}}function et(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&De(t,n)}var tt={get(e,t){if(t===Se)return e;const n=Ne(e);if(!Pe(n,t))return function(e,t,n){const s=it(t,n);return s?"value"in s?s.value:s.get?.call(e.draft_):void 0}(e,n,t);const s=n[t];return e.finalized_||!Re(s)?s:s===st(e.base_,t)?(ot(e),e.copy_[t]=at(s,e)):s},has:(e,t)=>t in Ne(e),ownKeys:e=>Reflect.ownKeys(Ne(e)),set(e,t,n){const s=it(Ne(e),t);if(s?.set)return s.set.call(e.draft_,n),!0;if(!e.modified_){const s=st(Ne(e),t),i=s?.[Se];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,s)&&(void 0!==n||Pe(e.base_,t)))return!0;ot(e),rt(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!==st(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,ot(e),rt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ne(e),s=Reflect.getOwnPropertyDescriptor(n,t);return s?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:s.enumerable,value:n[t]}:s},defineProperty(){xe(11)},getPrototypeOf:e=>Ee(e.base_),setPrototypeOf(){xe(12)}},nt={};function st(e,t){const n=e[Se];return(n?Ne(n):e)[t]}function it(e,t){if(!(t in e))return;let n=Ee(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ee(n)}}function rt(e){e.modified_||(e.modified_=!0,e.parent_&&rt(e.parent_))}function ot(e){e.copy_||(e.copy_=qe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}je(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))&&xe(13),nt.set.call(this,e,t,void 0)},nt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&xe(14),tt.set.call(this,e[0],t,n,e[0])};function at(e,t){const n=Me(e)?He("MapSet").proxyMap_(e,t):$e(e)?He("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),s={type_:n?1:0,scope_:t?t.scope_:ze(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=s,r=tt;n&&(i=[s],r=nt);const{revoke:o,proxy:a}=Proxy.revocable(i,r);return s.draft_=a,s.revoke_=o,a}(e,t);return(t?t.scope_:ze()).drafts_.push(n),n}function ct(e){return Ce(e)||xe(10,e),lt(e)}function lt(e){if(!Re(e)||Le(e))return e;const t=e[Se];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=qe(e,t.scope_.immer_.useStrictShallowCopy_)}else n=qe(e,!0);return je(n,((e,t)=>{Ue(n,e,lt(t))})),t&&(t.finalized_=!1),n}var dt=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 s=this;return function(e=n,...i){return s.produce(e,(e=>t.call(this,e,...i)))}}let s;if("function"!=typeof t&&xe(6),void 0!==n&&"function"!=typeof n&&xe(7),Re(e)){const i=Ze(this),r=at(e,void 0);let o=!0;try{s=t(r),o=!1}finally{o?Be(i):Ve(i)}return Je(i,n),Ye(s,i)}if(!e||"object"!=typeof e){if(s=t(e),void 0===s&&(s=e),s===be&&(s=void 0),this.autoFreeze_&&De(s,!0),n){const t=[],i=[];He("Patches").generateReplacementPatches_(e,s,t,i),n(t,i)}return s}xe(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,s;const i=this.produce(e,t,((e,t)=>{n=e,s=t}));return[i,n,s]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Re(e)||xe(8),Ce(e)&&(e=ct(e));const t=Ze(this),n=at(e,void 0);return n[Se].isManual_=!0,Ve(t),n}finishDraft(e,t){const n=e&&e[Se];n&&n.isManual_||xe(9);const{scope_:s}=n;return Je(s,t),Ye(void 0,s)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const s=t[n];if(0===s.path.length&&"replace"===s.op){e=s.value;break}}n>-1&&(t=t.slice(n+1));const s=He("Patches").applyPatches_;return Ce(e)?s(e,t):this.produce(e,(e=>s(e,t)))}},ut=dt.produce;dt.produceWithPatches.bind(dt),dt.setAutoFreeze.bind(dt),dt.setUseStrictShallowCopy.bind(dt),dt.applyPatches.bind(dt),dt.createDraft.bind(dt),dt.finishDraft.bind(dt);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:s,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:o}=e,a=s((()=>({})),...i);if(!(a.apply(null,r)===a.apply(null,o))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:o,stack:e})}},gt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var ft=e=>Array.isArray(e)?e:[e];function mt(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 wt(e,t){const n=[],{length:s}=e;for(let i=0;i<s;i++)n.push(e[i].apply(null,t));return n}var vt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},yt=0,_t=1;function bt(){return{s:yt,v:void 0,o:null,p:null}}function kt(e,t={}){let n=bt();const{resultEqualityCheck:s}=t;let i,r=0;function o(){let t=n;const{length:o}=arguments;for(let e=0,n=o;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 s=e.get(n);void 0===s?(t=bt(),e.set(n,t)):t=s}else{let e=t.p;null===e&&(t.p=e=new Map);const s=e.get(n);void 0===s?(t=bt(),e.set(n,t)):t=s}}const a=t;let c;if(t.s===_t)c=t.v;else if(c=e.apply(null,arguments),r++,s){const e=i?.deref?.()??i;null!=e&&s(e,c)&&(c=e,0!==r&&r--);i="object"==typeof c&&null!==c||"function"==typeof c?new vt(c):c}return a.s=_t,a.v=c,c}return o.clearCache=()=>{n=bt(),o.resetResultsCount()},o.resultsCount=()=>r,o.resetResultsCount=()=>{r=0},o}function St(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,s=(...e)=>{let t,s=0,i=0,r={},o=e.pop();"object"==typeof o&&(r=o,o=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);const a={...n,...r},{memoize:c,memoizeOptions:l=[],argsMemoize:d=kt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=ft(l),g=ft(u),f=mt(e),m=c((function(){return s++,o.apply(null,arguments)}),...p);let w=!0;const v=d((function(){i++;const e=wt(f,arguments);t=m.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:s}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:s}={...gt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ht},inputStabilityCheck:{shouldRun:"always"===s||"once"===s&&e,run:pt}}})(w,h);if(n.shouldRun&&n.run(o,e,t),s.shouldRun){const t=wt(f,arguments);s.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}w&&(w=!1)}return t}),...g);return Object.assign(v,{resultFunc:o,memoizedResultFunc:m,dependencies:f,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:c,argsMemoize:d})};return Object.assign(s,{withTypes:()=>s}),s}var It=St(kt),xt=Object.assign(((e,t=It)=>{!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,s)=>(e[n[s]]=t,e)),{})))}),{withTypes:()=>xt});function Et(e){return({dispatch:t,getState:n})=>s=>i=>"function"==typeof i?i(t,n,e):s(i)}var Ct=Et(),Rt=Et;((...e)=>{const t=St(...e)})(kt);var Tt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?ye:ye.apply(null,arguments)},Ot=e=>e&&"function"==typeof e.match;function jt(e,t){function n(...n){if(t){let s=t(...n);if(!s)throw new Error("prepareAction did not return an object");return{type:e,payload:s.payload,..."meta"in s&&{meta:s.meta},..."error"in s&&{error:s.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>_e(t)&&t.type===e,n}function At(e){return"function"==typeof e&&"type"in e&&Ot(e)}function Pt(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 Mt(e){return Re(e)?ut(e,(()=>{})):e}function $t(e,t,n){if(e.has(t)){let s=e.get(t);return n.update&&(s=n.update(s,t,e),e.set(t,s)),s}if(!n.insert)throw new Error("No insert provided for key not already in map");const s=n.insert(t,e);return e.set(t,s),s}function Nt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function qt(e,t,n){const s=Dt(e,t,n);return{detectMutations:()=>Wt(e,t,s,n)}}function Dt(e,t=[],n,s="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const o=s?s+"."+i:i;t.length&&-1!==t.indexOf(o)||(r.children[i]=Dt(e,t,n[i],o))}}return r}function Wt(e,t=[],n,s,i=!1,r=""){const o=n?n.value:void 0,a=o===s;if(i&&!a&&!Number.isNaN(s))return{wasMutated:!0,path:r};if(e(o)||e(s))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in s)c[e]=!0;const l=t.length>0;for(let i in c){const o=r?r+"."+i:i;if(l){if(t.some((e=>e instanceof RegExp?e.test(o):o===e)))continue}const c=Wt(e,t,n.children[i],s[i],a,o);if(c.wasMutated)return c}return{wasMutated:!1}}function Lt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||pe(e)}function Kt(e,t="",n=Lt,s,i=[],r){let o;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=s?s(e):Object.entries(e),c=i.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(o=Kt(l,a,n,s,i,r),o))return o}return r&&Ft(e)&&r.add(e),!1}function Ft(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Ft(t))return!1;return!0}function Ht(e){return"boolean"==typeof e}var zt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:s=!0,actionCreatorCheck:i=!0}=e??{};let r=new Ut;if(t&&(Ht(t)?r.push(Ct):r.push(Rt(t.extraArgument))),n){let e={};Ht(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,s,i){return JSON.stringify(e,n(t,i),s)},n=function(e,t){let n=[],s=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+s.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var o=n.indexOf(this);~o?n.splice(o+1):n.push(this),~o?s.splice(o,1/0,i):s.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:s=Nt,ignoredPaths:i,warnAfter:r=32}=e;const o=qt.bind(null,s,i);return({getState:e})=>{let n,s=e(),i=o(s);return a=>c=>{const l=Pt(r,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(s=e(),n=i.detectMutations(),i=o(s),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(c);return l.measureTime((()=>{if(s=e(),n=i.detectMutations(),i=o(s),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(s){let e={};Ht(s)||(e=s),r.push(function(e={}){{const{isSerializable:t=Lt,getEntries:n,ignoredActions:s=[],ignoredActionPaths:i=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:o=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!_e(u))return l(u);const h=l(u),p=Pt(o,"SerializableStateInvariantMiddleware");return c||s.length&&-1!==s.indexOf(u.type)||p.measureTime((()=>{const e=Kt(u,"",t,n,i,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const s=Kt(e.getState(),"",t,n,r,d);if(s){const{keyPath:e,value:t}=s;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(i){let e={};Ht(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=At}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},Jt=e=>t=>{setTimeout(t,e)},Bt="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Jt(10),Vt=e=>function(t){const{autoBatch:n=!0}=t??{};let s=new Ut(e);return n&&s.push(((e={type:"raf"})=>t=>(...n)=>{const s=t(...n);let i=!0,r=!1,o=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Bt:"callback"===e.type?e.queueNotification:Jt(e.timeout),l=()=>{o=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},s,{subscribe(e){const t=s.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(o||(o=!0,c(l))),s.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),s};function Zt(e){const t=zt(),{reducer:n,middleware:s,devTools:i=!0,preloadedState:r,enhancers:o}=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=ve(n)}if(s&&"function"!=typeof s)throw new Error("`middleware` field must be a callback");if("function"==typeof s){if(c=s(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=ye;i&&(l=Tt({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,s)=>{const i=t(n,s);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const o={getState:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(o)));return r=ye(...a)(i.dispatch),{...i,dispatch:r}}}(...c),u=Vt(d);if(o&&"function"!=typeof o)throw new Error("`enhancers` field must be a callback");let h="function"==typeof o?o(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return me(a,r,l(...h))}function Gt(e){const t={},n=[];let s;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(s)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const o="string"==typeof e?e:e.type;if(!o)throw new Error("`builder.addCase` cannot be called with an empty action type");if(o in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${o}'`);return t[o]=r,i},addMatcher(e,t){if(s)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(s)throw new Error("`builder.addDefaultCase` can only be called once");return s=e,i}};return e(i),[t,n,s]}function Yt(...e){return t=>e.some((e=>((e,t)=>Ot(e)?e.match(t):e(t))(e,t)))}var Xt=["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 Xt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},nn=(()=>{function e(e,t,n){const s=jt(e+"/fulfilled",((e,t,n,s)=>({payload:e,meta:{...s||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=jt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=jt(e+"/rejected",((e,t,s,i,r)=>({payload:i,error:(n&&n.serializeError||tn)(e||"Rejected"),meta:{...r||{},arg:s,requestId:t,rejectedWithValue:!!i,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(o,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:c});if(null!==(g=r)&&"object"==typeof g&&"function"==typeof g.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const f=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));o(i(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([f,Promise.resolve(t(e,{dispatch:o,getState:a,extra:c,requestId:l,signal:d.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?s(t.payload,l,e,t.meta):s(t,l,e)}))])}catch(t){p=t instanceof Qt?r(null,l,e,t.payload,t.meta):r(t,l,e)}var g;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||o(p),p}();return Object.assign(p,{abort:h,requestId:l,arg:e,unwrap:()=>p.then(sn)})}}),{pending:i,rejected:r,fulfilled:s,settled:Yt(r,s),typePrefix:e})}return e.withTypes=()=>e,e})();function sn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var rn=Symbol.for("rtk-slice-createasyncthunk");function on(e,t){return`${e}/${t}`}function an(e,t,n,s){function i(i,...r){let o=n.call(e,i);if(void 0===o){if(!s)throw new Error("selectState returned undefined for an uninjected slice reducer");o=e.getInitialState()}return t(o,...r)}return i.unwrapped=t,i}var cn=function({creators:e}={}){const t=e?.asyncThunk?.[rn];return function(e){const{name:n,reducerPath:s=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const i=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(i),o={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 o.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return o.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(o.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(o.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(o.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=[],s]="function"==typeof e.extraReducers?Gt(e.extraReducers):[e.extraReducers],i={...t,...o.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,[s,i,r]=Gt(t);if(function(e){return"function"==typeof e}(e))n=()=>Mt(e());else{const t=Mt(e);n=()=>t}function o(e=n(),t){let o=[s[t.type],...i.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===o.filter((e=>!!e)).length&&(o=[r]),o.reduce(((e,n)=>{if(n){if(Ce(e)){const s=n(e,t);return void 0===s?e:s}if(Re(e))return ut(e,(e=>n(e,t)));{const s=n(e,t);if(void 0===s){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return s}}return e}),e)}return o.getInitialState=n,o}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of o.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);s&&e.addDefaultCase(s)}))}r.forEach((s=>{const r=i[s],o={reducerName:s,type:on(n,s),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},s,i){let r,o;if("reducer"in s){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(s))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=s.reducer,o=s.prepare}else r=s;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,o?jt(e,o):jt(e))}(o,r,a):function({type:e,reducerName:t},n,s,i){if(!i)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:o,pending:a,rejected:c,settled:l,options:d}=n,u=i(e,r,d);s.exposeAction(t,u),o&&s.addCase(u.fulfilled,o);a&&s.addCase(u.pending,a);c&&s.addCase(u.rejected,c);l&&s.addMatcher(u.settled,l);s.exposeCaseReducer(t,{fulfilled:o||ln,pending:a||ln,rejected:c||ln,settled:l||ln})}(o,r,a,t)}));const l=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:s,reducer:(e,t)=>(u||(u=c()),u(e,t)),actions:o.actionCreators,caseReducers:o.sliceCaseReducersByName,getInitialState:()=>(u||(u=c()),u.getInitialState()),getSelectors(t=l){const n=$t(d,this,{insert:()=>new WeakMap});return $t(n,t,{insert:()=>{const n={};for(const[s,i]of Object.entries(e.selectors??{}))n[s]=an(this,i,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const s=t??this.reducerPath;return e.inject({reducerPath:s,reducer:this.reducer},n),{...this,reducerPath:s}}};return h}}();function ln(){}var dn="listenerMiddleware";jt(`${dn}/add`),jt(`${dn}/removeAll`),jt(`${dn}/remove`);const un=e=>u((t=>{const n=cn(e),s=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(y)(t)){constructor(...e){super(...e);const t=Zt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const s=await t.dispatch(e(...n));try{sn(s)}catch(e){this.logger.error(e.message,s.type,e.stack)}return s},r=Object.keys(s).reduce(((e,t)=>(e[t]=i(s[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),hn=u((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()}})),pn=u((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),gn=e=>e.selectedAccessKeysIds,fn=e=>e.notifications,mn=It((e=>e.accessKeysList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{expireTimeFormatted:(null==e?void 0:e.expireTime)?new Date(1e3*((null==e?void 0:e.expireTime)||0)).toLocaleString():"Never",createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:(null==e?void 0:e.expireTime)&&new Date(1e3*((null==e?void 0:e.expireTime)||0))<new Date?"expired":null==e?void 0:e.status}))))),wn=It(gn,mn,((e,t)=>t.filter((t=>e.includes(t.id))))),vn=It(gn,(e=>!!e.length)),yn=It(wn,(e=>e.every((e=>e.editable)))),_n=It(yn,vn,((e,t)=>e&&t));It(gn,(e=>1===e.length));const bn=It(wn,(e=>1===e.length?e[0].name:`${e.length} access keys`)),kn=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)}))}))},Sn=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),In=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),xn=nn("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),En=kn(xn)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},Sn((e=>e.createAccessKey)),In({getSuccessMsg:()=>"Access Key created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create access key</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Cn={action:xn,reducer:En},Rn=nn("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),Tn=kn(Rn)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},Sn((e=>e.deleteAccessKey)),In({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deleted successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to delete access key${["","s"]}`})),On={action:Rn,reducer:Tn},jn=nn("accessKeys/search",((e,{extra:{api:t},getState:n})=>{const s=n().searchParams;return t.accesskey.search(Object.assign(Object.assign({},s),e))})),An=kn(jn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},Sn((e=>e.accessKeysList))),Pn={action:jn,reducer:An},Un=nn("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),Mn=kn(Un)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},Sn((e=>e.activateAccessKey)),In({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} activated successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to activate access key${["","s"]}`})),$n={action:Un,reducer:Mn},Nn=nn("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),qn=kn(Nn)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},Sn((e=>e.deactivateAccessKey)),In({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deactivated successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to deactivate access key${["","s"]}`})),Dn={action:Nn,reducer:qn},Wn=nn("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),Ln={action:Wn,reducer:kn(Wn)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},Sn((e=>e.tenantRoles)))},Kn={accessKeysList:{data:[],loading:!1,error:null},createAccessKey:{loading:!1,error:null},activateAccessKey:{loading:!1,error:null},deactivateAccessKey:{loading:!1,error:null},deleteAccessKey:{loading:!1,error:null},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]};class Fn extends Error{}function Hn(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function zn(e,t){if("string"!=typeof e)throw new Fn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,s=e.split(".")[n];if("string"!=typeof s)throw new Fn(`Invalid token specified: missing part #${n+1}`);let i;try{i=Hn(s)}catch(e){throw new Fn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new Fn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Fn.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"}},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const Bn="<region>",Vn=`https://api.${Bn}descope.com`,Zn=6e5,Gn="dct",Yn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let Xn;const Qn=()=>{if(Xn)return Xn;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 Xn=`${t}-${n}`,Xn};var es,ts;(ts=es||(es={})).get="GET",ts.delete="DELETE",ts.post="POST",ts.put="PUT",ts.patch="PATCH";const ns=({path:e,baseUrl:t,queryParams:n,projectId:s})=>{const i=s.slice(1,-27);t=t.replace(Bn,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,s)=>{r=`${r}${0===s?"?":""}${t}=${encodeURIComponent(n[t])}${s===e.length-1?"":"&"}`}))}return r},ss=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,s])=>(e[n]=s,e)),e),e}),{})),is={"Content-Type":"application/json"},rs=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},os=e=>{const t={"x-descope-sdk-session-id":Qn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.40.0"};return e&&(t["x-descope-refresh-cookie-name"]=e),t},as=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},cs=({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:s,logger:i,hooks:r,cookiePolicy:o,fetch:a})=>{const c=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Yn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const s=await n(...t);return e[s.ok?"log":"error"](await(async e=>{const t=await e.text();return Yn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(s)),s}:n})(i,a),l=async i=>{var a;const l=(null==r?void 0:r.beforeRequest)?r.beforeRequest(i):i,{path:d,body:u,headers:h,queryParams:p,method:g,token:f}=l,m=(e=>void 0===e?void 0:JSON.stringify(e))(u),w={headers:ss(rs(t,f),os(s),(null==n?void 0:n.baseHeaders)||{},as(m)?is:{},h),method:g,body:m};null!==o&&(w.credentials=o||"include");const v=await c(ns({path:d,baseUrl:e,queryParams:p,projectId:t}),w);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(i,null==v?void 0:v.clone()),null==r?void 0:r.transformResponse){const e=await v.json(),t=((null===(a=v.headers)||void 0===a?void 0:a.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,s]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:s})}),{}),n=Object.assign(Object.assign({},v),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return v};return{get:(e,{headers:t,queryParams:n,token:s}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:es.get,token:s}),post:(e,t,{headers:n,queryParams:s,token:i}={})=>l({path:e,headers:n,queryParams:s,body:t,method:es.post,token:i}),patch:(e,t,{headers:n,queryParams:s,token:i}={})=>l({path:e,headers:n,queryParams:s,body:t,method:es.patch,token:i}),put:(e,t,{headers:n,queryParams:s,token:i}={})=>l({path:e,headers:n,queryParams:s,body:t,method:es.put,token:i}),delete:(e,{headers:t,queryParams:n,token:s}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:es.delete,token:s}),hooks:r,buildUrl:(n,s)=>ns({projectId:t,baseUrl:e,path:n,queryParams:s})}};var ls=429;function ds(e,t,n){var s;let i=us(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[Gn])===t)return(null==i?void 0:i[n])||[];i=null===(s=null==i?void 0:i.tenants)||void 0===s?void 0:s[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function us(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return zn(e)}function hs(e){const{exp:t}=us(e);return(new Date).getTime()/1e3>t}function ps(e){let t=us(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function gs(e,t){return ds(e,t,"permissions")}function fs(e,t){return ds(e,t,"roles")}const ms=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function ws(e,t){var n;const s=await e,i={code:s.status,ok:s.ok,response:s},r=await s.clone().json();return s.ok?i.data=r:(i.error=r,s.status===ls&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=s.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}function vs(e){var t;return(null===(t=us(e))||void 0===t?void 0:t[Gn])||""}const ys=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),_s=(e,t)=>(n=t)=>t=>{const s=e.filter((e=>e(t)));return!(s.length<e.length)&&(n?n.replace("{val}",t):s.join(" OR "))},bs=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ks=e=>t=>e.test(t),Ss=ks(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Is=ks(/^\+[1-9]{1}[0-9]{3,14}$/),xs=ys(Ss,'"{val}" is not a valid email'),Es=ys(Is,'"{val}" is not a valid phone number'),Cs=ys((e=>e.length>=1),"Minimum length is 1");const Rs=ys((e=>"string"==typeof e),"Input is not a string"),Ts=ys((e=>Array.isArray(e)),"Input is not an array"),Os=ys((e=>"boolean"==typeof e),"Input is not a boolean"),js=ys((e=>void 0===e),"Input is defined"),As=_s([Rs(),js()],"Input is not a string or undefined"),Ps=_s([Ts(),Os()],"Input is not an array or boolean"),Us=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>bs(...e).validate(n[t]))),t(...n)),Ms=e=>[Rs(`"${e}" must be a string`)],$s=e=>[As(`"${e}" must be string or undefined`)],Ns=e=>[Rs(`"${e}" must be a string`),Cs(`"${e}" must not be empty`)],qs=e=>[Rs(`"${e}" must be a string`),xs()],Ds=e=>[Rs(`"${e}" must be a string`),Es()],Ws=Us(Ns("accessKey")),Ls=e=>({exchange:Ws(((t,n)=>ws(e.post(Jn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Ks=(e,t,n)=>(t.forEach((t=>{const s=t.split(".");let i=s.shift(),r=e;for(;s.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=s.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const o=r[i];r[i]=n(o)})),e),Fs=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Zn,Zn)});var Hs,zs;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(Hs||(Hs={})),function(e){e.email="email"}(zs||(zs={}));const Js=Object.assign(Object.assign({},Hs),zs);var Bs;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Bs||(Bs={}));const Vs=Ns("loginId"),Zs=Us(Ns("token")),Gs=Us(Vs),Ys=Us(Ns("pendingRef")),Xs=Us(Vs,qs("email")),Qs=e=>({verify:Zs((t=>ws(e.post(Jn.enchantedLink.verify,{token:t})))),signIn:Gs(((t,n,s,i)=>ws(e.post(ms(Jn.enchantedLink.signIn,Js.email),{loginId:t,URI:n,loginOptions:s},{token:i})))),signUpOrIn:Gs(((t,n,s)=>ws(e.post(ms(Jn.enchantedLink.signUpOrIn,Js.email),{loginId:t,URI:n,loginOptions:s})))),signUp:Gs(((t,n,s,i)=>ws(e.post(ms(Jn.enchantedLink.signUp,Js.email),{loginId:t,URI:n,user:s,loginOptions:i})))),waitForSession:Ys(((t,n)=>new Promise((s=>{const{pollingIntervalMs:i,timeoutMs:r}=Fs(n);let o;const a=setInterval((async()=>{const n=await e.post(Jn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),o&&clearTimeout(o),s(ws(Promise.resolve(n))))}),i);o=setTimeout((()=>{s({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Xs(((t,n,s,i,r)=>ws(e.post(Jn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:s},r),{token:i}))))}}),ei=Us(Ns("flowId")),ti=Us(Ns("executionId"),Ns("stepId"),Ns("interactionId")),ni=e=>({start:ei(((t,n,s,i,r,o,a)=>ws(e.post(Jn.flow.start,{flowId:t,options:n,conditionInteractionId:s,interactionId:i,componentsVersion:r,flowVersions:o,input:a})))),next:ti(((t,n,s,i,r,o)=>ws(e.post(Jn.flow.next,{executionId:t,stepId:n,interactionId:s,version:i,componentsVersion:r,input:o}))))}),si=Ns("loginId"),ii=Us(Ns("token")),ri=Us(si),oi=Us(si,Ds("phone")),ai=Us(si,qs("email")),ci=Object.keys(Js).filter((e=>e!==Hs.voice)),li=e=>({verify:ii((t=>ws(e.post(Jn.magicLink.verify,{token:t})))),signIn:ci.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ri(((t,s,i,r)=>ws(e.post(ms(Jn.magicLink.signIn,n),{loginId:t,URI:s,loginOptions:i},{token:r}))))})),{}),signUp:ci.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ri(((t,s,i,r)=>ws(e.post(ms(Jn.magicLink.signUp,n),{loginId:t,URI:s,user:i,loginOptions:r}))))})),{}),signUpOrIn:ci.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ri(((t,s,i)=>ws(e.post(ms(Jn.magicLink.signUpOrIn,n),{loginId:t,URI:s,loginOptions:i}))))})),{}),update:{email:ai(((t,n,s,i,r)=>ws(e.post(Jn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:s},r),{token:i})))),phone:Object.keys(Hs).filter((e=>e!==Hs.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:oi(((t,s,i,r,o)=>ws(e.post(ms(Jn.magicLink.update.phone,n),Object.assign({loginId:t,phone:s,URI:i},o),{token:r}))))})),{})}});var di;!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"}(di||(di={}));const ui=Us(Ns("code")),hi=e=>({start:Object.assign(((t,n,s,i)=>ws(e.post(Jn.oauth.start,s||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:i}))),Object.keys(di).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,s,i)=>ws(e.post(Jn.oauth.start,s||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i}))})),{})),exchange:ui((t=>ws(e.post(Jn.oauth.exchange,{code:t})))),startNative:(t,n,s)=>ws(e.post(Jn.oauth.startNative,{provider:t,loginOptions:n,implicit:s})),finishNative:(t,n,s,i,r)=>ws(e.post(Jn.oauth.finishNative,{provider:t,stateId:n,user:s,code:i,idToken:r})),getOneTapClientId:t=>ws(e.get(Jn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,s,i)=>ws(e.post(Jn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:s,loginOptions:i})),exchangeOneTapIDToken:(t,n,s,i)=>ws(e.post(Jn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:s,loginOptions:i}))}),pi=Ns("loginId"),gi=Us(pi,Ns("code")),fi=Us(pi),mi=Us(pi,Ds("phone")),wi=Us(pi,qs("email")),vi=e=>({verify:Object.keys(Js).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:gi(((t,s)=>ws(e.post(ms(Jn.otp.verify,n),{code:s,loginId:t}))))})),{}),signIn:Object.keys(Js).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:fi(((t,s,i)=>ws(e.post(ms(Jn.otp.signIn,n),{loginId:t,loginOptions:s},{token:i}))))})),{}),signUp:Object.keys(Js).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:fi(((t,s,i)=>ws(e.post(ms(Jn.otp.signUp,n),{loginId:t,user:s,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Js).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:fi(((t,s)=>ws(e.post(ms(Jn.otp.signUpOrIn,n),{loginId:t,loginOptions:s}))))})),{}),update:{email:wi(((t,n,s,i)=>ws(e.post(Jn.otp.update.email,Object.assign({loginId:t,email:n},i),{token:s})))),phone:Object.keys(Hs).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:mi(((t,s,i,r)=>ws(e.post(ms(Jn.otp.update.phone,n),Object.assign({loginId:t,phone:s},r),{token:i}))))})),{})}}),yi=Us(Ns("tenant")),_i=Us(Ns("code")),bi=e=>({start:yi(((t,n,s,i,r)=>ws(e.post(Jn.saml.start,s||{},Object.assign({queryParams:Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r})},i&&{token:i}))))),exchange:_i((t=>ws(e.post(Jn.saml.exchange,{code:t}))))}),ki=Ns("loginId"),Si=Us(ki,Ns("code")),Ii=Us(ki),xi=Us(ki),Ei=e=>({signUp:Ii(((t,n)=>ws(e.post(Jn.totp.signUp,{loginId:t,user:n})))),verify:Si(((t,n,s,i)=>ws(e.post(Jn.totp.verify,{loginId:t,code:n,loginOptions:s},{token:i})))),update:xi(((t,n)=>ws(e.post(Jn.totp.update,{loginId:t},{token:n}))))}),Ci=Ns("loginId"),Ri=Ns("newPassword"),Ti=Us(Ci,Ns("password")),Oi=Us(Ci),ji=Us(Ci,Ri),Ai=Us(Ci,Ns("oldPassword"),Ri),Pi=e=>({signUp:Ti(((t,n,s,i)=>ws(e.post(Jn.password.signUp,{loginId:t,password:n,user:s,loginOptions:i})))),signIn:Ti(((t,n,s)=>ws(e.post(Jn.password.signIn,{loginId:t,password:n,loginOptions:s})))),sendReset:Oi(((t,n,s)=>ws(e.post(Jn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:s})))),update:ji(((t,n,s)=>ws(e.post(Jn.password.update,{loginId:t,newPassword:n},{token:s})))),replace:Ai(((t,n,s)=>ws(e.post(Jn.password.replace,{loginId:t,oldPassword:n,newPassword:s})))),policy:()=>ws(e.get(Jn.password.policy))}),Ui=Ms("loginId"),Mi=Ns("loginId"),$i=Ns("origin"),Ni=Us(Mi,$i,Ns("name")),qi=Us(Mi,$i),Di=Us(Ui,$i),Wi=Us(Mi,$i,$s("token")),Li=Us(Ns("transactionId"),Ns("response")),Ki=e=>({signUp:{start:Ni(((t,n,s,i)=>ws(e.post(Jn.webauthn.signUp.start,{user:{loginId:t,name:s},origin:n,passkeyOptions:i})))),finish:Li(((t,n)=>ws(e.post(Jn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Di(((t,n,s,i,r)=>ws(e.post(Jn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:s,passkeyOptions:r},{token:i})))),finish:Li(((t,n)=>ws(e.post(Jn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:qi(((t,n,s)=>ws(e.post(Jn.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:s}))))},update:{start:Wi(((t,n,s,i)=>ws(e.post(Jn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i},{token:s})))),finish:Li(((t,n)=>ws(e.post(Jn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Fi=Ms("loginId"),Hi=Us(Fi),zi=Us(Ns("pendingRef")),Ji=e=>({signUpOrIn:Hi(((t,n)=>ws(e.post(Jn.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:Hi(((t,n,s)=>ws(e.post(Jn.notp.signUp,{loginId:t,user:n,loginOptions:s})))),signIn:Hi(((t,n,s)=>ws(e.post(Jn.notp.signIn,{loginId:t,loginOptions:n},{token:s})))),waitForSession:zi(((t,n)=>new Promise((s=>{const{pollingIntervalMs:i,timeoutMs:r}=Fs(n);let o;const a=setInterval((async()=>{const n=await e.post(Jn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),o&&clearTimeout(o),s(ws(Promise.resolve(n))))}),i);o=setTimeout((()=>{s({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Bi=Us(Ns("token")),Vi=Us($s("token"));var Zi,Gi=Us([(Zi=Ns("projectId"),ys(((e,t)=>n=>bs(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),s=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<s;)r=r[n[i++]];return i&&i===s&&void 0!==r?r:void 0})(n,e)))("projectId",Zi))())])((e=>t=>{var n;return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>{var n;const s=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==s?void 0:s.reduce(((e,t)=>t(e)),e)},afterRequest:async(e,n)=>{var s;const i=[].concat((null===(s=t.hooks)||void 0===s?void 0:s.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))},transformResponse:null===(n=t.hooks)||void 0===n?void 0:n.transformResponse}}))})((({projectId:e,logger:t,baseUrl:n,hooks:s,cookiePolicy:i,baseHeaders:r={},refreshCookieName:o,fetch:a})=>{return c=cs({baseUrl:n||Vn,projectId:e,logger:t,hooks:s,cookiePolicy:i,baseConfig:{baseHeaders:r},refreshCookieName:o,fetch:a}),{accessKey:Ls(c),otp:vi(c),magicLink:li(c),enchantedLink:Qs(c),oauth:hi(c),saml:bi(c),totp:Ei(c),notp:Ji(c),webauthn:Ki(c),password:Pi(c),flow:ni(c),refresh:Vi(((e,t)=>ws(c.post(Jn.refresh,{},{token:e,queryParams:t})))),selectTenant:Us([Rs("tenantId")],[As('"token" must be string or undefined')])(((e,t)=>ws(c.post(Jn.selectTenant,{tenant:e},{token:t})))),logout:Vi((e=>ws(c.post(Jn.logout,{},{token:e})))),logoutAll:Vi((e=>ws(c.post(Jn.logoutAll,{},{token:e})))),me:Vi((e=>ws(c.get(Jn.me,{token:e})))),myTenants:Us([Ps('"tenants" must a string array or a boolean')],[As('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,ws(c.post(Jn.myTenants,n,{token:t}))})),history:Vi((e=>ws(c.get(Jn.history,{token:e})))),isJwtExpired:Bi(hs),getTenants:Bi(ps),getJwtPermissions:Bi(gs),getJwtRoles:Bi(fs),getCurrentTenant:Bi(vs),httpClient:c};var c}))),Yi=Object.assign(Gi,{DeliveryMethods:Js});
|
|
5
|
+
this["descope-access-key-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function r(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),c=e=>{let t,n;return(...o)=>(t&&a(t,o)||(t=o,n=e(...o)),n)},l=e=>(t,...n)=>t.reduce(((t,o,r)=>{var i;return`${t}${o}${(null===(i=null==n?void 0:n[r])||void 0===i?void 0:i[e>1?1:0])||""}`}),""),d=(e,t=500)=>{let n;return function(...o){clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}},u=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const o=e(n);return o[t]=!0,o}};var h,p,f,g;function v(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!v(i,s))return!1}else if(i!==s)return!1}return!0}let m=class{constructor(e={},{forceUpdate:t=!1}={}){h.set(this,void 0),p.set(this,{}),f.set(this,0),g.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,h,"f")):e,n=Object.assign(Object.assign({},o(this,h,"f")),t);if(o(this,g,"f")||!v(o(this,h,"f"),n)){const e=o(this,h,"f");r(this,h,n,"f"),Object.freeze(o(this,h,"f")),setTimeout((()=>{Object.values(o(this,p,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},r(this,h,e,"f"),r(this,g,t,"f")}get current(){return Object.assign({},o(this,h,"f"))}subscribe(e){return r(this,f,o(this,f,"f")+1,"f"),o(this,p,"f")[o(this,f,"f")]=e,o(this,f,"f").toString()}unsubscribe(e){const t=!!o(this,p,"f")[e];return t&&delete o(this,p,"f")[e],t}unsubscribeAll(){return r(this,p,{},"f"),!0}};h=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap;const y=["error","warn","info","debug"],w=u((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",i).call(this,console))}set logger(e){r(this,n,o(this,t,"m",i).call(this,e||console),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return y.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),b="undefined"!=typeof localStorage,k=b&&localStorage.getItem("base.content.url")||"",S=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,I=u((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(r(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),x=u((e=>{var t,n;const r=i(w,I)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,r;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,r=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>r(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&r(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const r=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(r,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),O=e=>t=>{var n,r,s;const a=i(w,I,x)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,o(this,n,"m",r).bind(this))}async init(){var e;c.forEach((e=>o(this,n,"m",r).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,r=function(t,n){const o=e[t],r="function"==typeof o?o(t,n):o;r&&this.logger.error(r)},s};O.missingAttrValidator=S;const j=u((e=>{const t=i(O({"project-id":S}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),C=u((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),R="Trying the next fallback URL...";function A({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o="https://static.descope.com/pages"}){const r=new URL(o);return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,n,t),r.baseUrl=o,r}const E=u((e=>{var t,n,s,a,c;const l=i(w,j,C)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0)}async fetchStaticResource(e,n){const i=o(this,t,"m",a).call(this,e),c=Array.isArray(i)?e=>{if(e!==i.length-1){const{baseUrl:t}=i[e];r(this,s,t,"f")}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o})=>{const r=Array.isArray(e)?e:[e];for(let e=0;e<r.length;e++){const i=r[e],s=e===r.length-1;try{const r=await fetch(i.toString(),t);if(r.ok)return null==o||o(e),r;const a=`Error fetching URL ${i} [${r.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${R}`)}catch(e){const t=`Error fetching URL ${i} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${R}`)}}})(i,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(e){const t=k||this.baseStaticUrl;if(t)return A({projectId:this.projectId,filename:e,baseUrl:t});const i=o(this,n,"f")!==this.baseUrl,a=i&&!!this.baseUrl;i&&(r(this,n,this.baseUrl,"f"),r(this,s,void 0,"f"));const c=A({projectId:this.projectId,filename:e,baseUrl:o(this,s,"f")});if(!a)return c;return[A({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),c]},c})),T=u((e=>{var t,n;const r=i(O({"project-id":S}))(e);return n=class extends r{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),_=u((e=>{var t,n,s,a,c;const l=i(E,T,I)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",o(this,t,"m",n).bind(this))}get config(){return o(this,s,"f")||r(this,s,o(this,a,"f").call(this),"f"),o(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){r(this,s,void 0,"f")},c})),M=u((e=>{var t,n,s,a,c,l,d;return d=class extends(i(I,w)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,r)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,r),"debug"===e&&o(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var r;null===(r=super.onLogEvent)||void 0===r||r.call(this,e,n),"error"===e&&o(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),r(this,n,null,"f")},a=async function(){r(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Qs})),document.body.appendChild(o(this,n,"f"))},c=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},l=function(e,t){var r;e&&(null===(r=o(this,n,"f"))||void 0===r||r.updateData({title:e,description:t}))},d})),U="load-descope-ui",$="base.ui.components.url",P=b&&localStorage.getItem($)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",D=b&&localStorage.getItem($)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",L=b&&localStorage.getItem($)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",W=e=>{const t=document.createElement("script");return t.id=e,t},N=(e,t)=>e.replace("<version>",t),K=u((e=>{var t,n,s,a,c,l,d,u,h,p,f,g;const v=i(w,_)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),s.set(this,Symbol("loadCbs")),h.set(this,void 0)}get descopeUi(){return o(this,h,"f")||r(this,h,o(this,t,"m",f).call(this),"f"),o(this,h,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",p).call(this,e))))}get baseCdnUrl(){return this.getAttribute("base-cdn-url")}},n=new WeakMap,s=new WeakMap,h=new WeakMap,t=new WeakSet,a=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},c=function(e){const t=o(this,n,"f"),r=o(this,s,"f");e[t]=[],e[r]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[r].push(t)}})},l=async function(e,n,r,i){this.logger.debug("Trying to load DescopeUI from a fallback URL");const s=W(r);document.body.append(s),s.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${s.src}"`)))})),s.addEventListener("load",(()=>{n.forEach((e=>e()))})),s.src=N(i,await o(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[o(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),o(this,t,"m",l).call(this,[o(this,t,"m",l).bind(this,e[o(this,n,"f")],e[o(this,s,"f")],"load-descope-ui-fallback-script-2",L),...e[o(this,n,"f")]],e[o(this,s,"f")],"load-descope-ui-fallback-script",D)})),e.addEventListener("load",(()=>{e[o(this,s,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${U}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=W(U);document.body.append(e),o(this,t,"m",c).call(this,e),o(this,t,"m",d).call(this,e),e.src=N(this.baseCdnUrl||P,await o(this,t,"m",a).call(this))}return document.getElementById(U)},p=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(", ")}"`)},f=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),o(this,t,"m",u).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),q="content-root",F="root",z=u((e=>class extends e{constructor(...e){var t,n,o,r;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${F}">\n <div id="${q}"></div>\n </div>\n `;const i=new CSSStyleSheet;i.replaceSync(`\n #${F}, #${q} {\n height: 100%;\n }\n #${F} {\n position: relative;\n height: fit-content;\n }\n `),null!==(t=(r=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(r.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,i],this.contentRootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(q),this.rootElement=null===(o=this.shadowRoot)||void 0===o?void 0:o.getElementById(F)}})),B="descope-modal";var J,H;let V=class{constructor(e,t){J.set(this,void 0),this.nodeName="",r(this,J,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,J,"f"))}get ele(){var e,t;const n="function"==typeof o(this,J,"f")?o(this,J,"f").call(this):o(this,J,"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)}};J=new WeakMap;const Z=/^descope-grid-([^-]+)-column$/,Y={text:class extends V{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 V{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 X=class extends V{constructor(){super(...arguments),this.nodeName="descope-grid",H.set(this,void 0)}onSelectedItemsChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("selected-items-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get columns(){return this.ele?Array.from(this.ele.children).reduce(((e,t)=>{var n;const o=null===(n=Z.exec(t.localName))||void 0===n?void 0:n[1],r=Y[o];return r?(e.push(new r(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const r=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);a(r,this.ele.columns)||(this.ele.columns=r,null===(n=o(this,H,"f"))||void 0===n||n.call(this,r))}onColumnsChange(e){r(this,H,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};H=new WeakMap;let G=class extends V{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};var Q;let ee=class extends V{constructor(){super(...arguments),Q.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,Q,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,Q,"f").content.cloneNode(!0)))}setContent(e){r(this,Q,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};Q=new WeakMap;let te=class extends V{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}},ne=class extends V{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()}},oe=class extends V{constructor(){super(...arguments),this.nodeName="descope-text"}get ele(){return super.ele}get text(){var e;return null===(e=this.ele)||void 0===e?void 0:e.innerText}set text(e){this.ele&&(this.ele.innerText=e)}},re=class extends V{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const ie=u((e=>{var t,n;const r=i(I,z,K)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ee{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(B);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([B]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),se="descope-notification",ae=u((e=>{var t,n;const r=i(I,z,K)(e);return n=class extends r{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ne{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(se);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([se])}},t=new WeakMap,n})),ce=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',le=u((e=>{var t,n,s,a,c,l,d,u,h,p,f,g,v,m;const y=i(O({theme:ce}),E,I,K,_,z,x)(e);return m=class extends y{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{o(this,t,"m",g).call(this),o(this,v,"f").call(this,"os"===this.getAttribute("theme"))})),v.set(this,(e=>{var n,r,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(r=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===r?void 0:r[s])||void 0===i||i.call(r,"change",(()=>o(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this),o(this,t,"m",d).call(this),o(this,f,"f").call(this),this.observeAttributes(["theme"],o(this,f,"f")),this.observeAttributes(["style-id"],(()=>{r(this,s,null,"f"),o(this,t,"m",h).call(this),o(this,t,"m",l).call(this),o(this,t,"m",d).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem($))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($),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},c=function(){return o(this,s,"f")||(r(this,s,o(this,t,"m",a).call(this),"f"),o(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,s,"f")},l=async function(){var e,i,s,a;const l=await o(this,t,"a",c);l&&(o(this,n,"f")||(r(this,n,new CSSStyleSheet,"f"),null!==(e=(a=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(a.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,o(this,n,"f")]),o(this,n,"f").replaceSync(((null===(i=null==l?void 0:l.light)||void 0===i?void 0:i.globals)||"")+((null===(s=null==l?void 0:l.dark)||void 0===s?void 0:s.globals)||"")))},d=async function(){var e,n;const r=Object.assign({},await o(this,t,"a",c));if(!r)return;const i=await this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components,dark:null===(n=null==r?void 0:r.dark)||void 0===n?void 0:n.components})},u=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],r=null==n?void 0:n.cssTemplate,i=o||r;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},h=async function(){const e=await o(this,t,"m",u).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},p=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){o(this,t,"m",h).call(this),o(this,t,"m",p).call(this)},m}));var de=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ue=()=>Math.random().toString(36).substring(7).split("").join("."),he={INIT:`@@redux/INIT${ue()}`,REPLACE:`@@redux/REPLACE${ue()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ue()}`};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 o=e,r=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${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,r=o(r,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}h({type:he.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${ge(e)}`);o=e,h({type:he.REPLACE})},[de]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${ge(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[de](){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 o=0;o<t.length;o++){const r=t[o];void 0===e[r]&&me(`No reducer provided for key "${r}"`),"function"==typeof e[r]&&(n[r]=e[r])}const o=Object.keys(n);let r,i;r={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type: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 o=function(e,t,n,o){const r=Object.keys(t),i=n&&n.type===he.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!pe(e))return`The ${i} has unexpected type of "${ge(e)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===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: "${r.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,r);o&&me(o)}let s=!1;const a={};for(let r=0;r<o.length;r++){const i=o[r],c=n[i],l=e[i],d=c(l,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=d,s=s||d!==l}return s=s||o.length!==Object.keys(e).length,s?a:e}}function 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"),Se=Symbol.for("immer-draftable"),Ie=Symbol.for("immer-state"),xe=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function Oe(e,...t){{const n=xe[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var je=Object.getPrototypeOf;function Ce(e){return!!e&&!!e[Ie]}function Re(e){return!!e&&(Ee(e)||Array.isArray(e)||!!e[Se]||!!e.constructor?.[Se]||$e(e)||Pe(e))}var Ae=Object.prototype.constructor.toString();function Ee(e){if(!e||"object"!=typeof e)return!1;const t=je(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)===Ae}function Te(e,t){0===_e(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function _e(e){const t=e[Ie];return t?t.type_:Array.isArray(e)?1:$e(e)?2:Pe(e)?3:0}function Me(e,t){return 2===_e(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ue(e,t,n){const o=_e(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function $e(e){return e instanceof Map}function Pe(e){return e instanceof Set}function De(e){return e.copy_||e.base_}function Le(e,t){if($e(e))return new Map(e);if(Pe(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ee(e)){if(!je(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ie];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const r=o[t],i=n[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[r]})}return Object.create(je(e),n)}function We(e,t=!1){return Ke(e)||Ce(e)||!Re(e)||(_e(e)>1&&(e.set=e.add=e.clear=e.delete=Ne),Object.freeze(e),t&&Te(e,((e,t)=>We(t,!0)))),e}function Ne(){Oe(2)}function Ke(e){return Object.isFrozen(e)}var qe,Fe={};function ze(e){const t=Fe[e];return t||Oe(0,e),t}function Be(){return qe}function Je(e,t){t&&(ze("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function He(e){Ve(e),e.drafts_.forEach(Ye),e.drafts_=null}function Ve(e){e===qe&&(qe=e.parent_)}function Ze(e){return qe={drafts_:[],parent_:qe,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ye(e){const t=e[Ie];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Xe(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ie].modified_&&(He(t),Oe(4)),Re(e)&&(e=Ge(t,e),t.parent_||et(t,e)),t.patches_&&ze("Patches").generateReplacementPatches_(n[Ie].base_,e,t.patches_,t.inversePatches_)):e=Ge(t,n,[]),He(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ke?e:void 0}function Ge(e,t,n){if(Ke(t))return t;const o=t[Ie];if(!o)return Te(t,((r,i)=>Qe(e,o,t,r,i,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return et(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let r=t,i=!1;3===o.type_&&(r=new Set(t),t.clear(),i=!0),Te(r,((r,s)=>Qe(e,o,t,r,s,n,i))),et(e,t,!1),n&&e.patches_&&ze("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Qe(e,t,n,o,r,i,s){if(r===n&&Oe(5),Ce(r)){const s=Ge(e,r,i&&t&&3!==t.type_&&!Me(t.assigned_,o)?i.concat(o):void 0);if(Ue(n,o,s),!Ce(s))return;e.canAutoFreeze_=!1}else s&&n.add(r);if(Re(r)&&!Ke(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ge(e,r),t&&t.scope_.parent_||et(e,r)}}function et(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&We(t,n)}var tt={get(e,t){if(t===Ie)return e;const n=De(e);if(!Me(n,t))return function(e,t,n){const o=rt(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!Re(o)?o:o===ot(e.base_,t)?(st(e),e.copy_[t]=at(o,e)):o},has:(e,t)=>t in De(e),ownKeys:e=>Reflect.ownKeys(De(e)),set(e,t,n){const o=rt(De(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=ot(De(e),t),r=o?.[Ie];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||Me(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!==ot(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=De(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Oe(11)},getPrototypeOf:e=>je(e.base_),setPrototypeOf(){Oe(12)}},nt={};function ot(e,t){const n=e[Ie];return(n?De(n):e)[t]}function rt(e,t){if(!(t in e))return;let n=je(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=je(n)}}function it(e){e.modified_||(e.modified_=!0,e.parent_&&it(e.parent_))}function st(e){e.copy_||(e.copy_=Le(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))&&Oe(13),nt.set.call(this,e,t,void 0)},nt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Oe(14),tt.set.call(this,e[0],t,n,e[0])};function at(e,t){const n=$e(e)?ze("MapSet").proxyMap_(e,t):Pe(e)?ze("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Be(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=tt;n&&(r=[o],i=nt);const{revoke:s,proxy:a}=Proxy.revocable(r,i);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Be()).drafts_.push(n),n}function ct(e){return Ce(e)||Oe(10,e),lt(e)}function lt(e){if(!Re(e)||Ke(e))return e;const t=e[Ie];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Le(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Le(e,!0);return Te(n,((e,t)=>{Ue(n,e,lt(t))})),t&&(t.finalized_=!1),n}var dt=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...r){return o.produce(e,(e=>t.call(this,e,...r)))}}let o;if("function"!=typeof t&&Oe(6),void 0!==n&&"function"!=typeof n&&Oe(7),Re(e)){const r=Ze(this),i=at(e,void 0);let s=!0;try{o=t(i),s=!1}finally{s?He(r):Ve(r)}return Je(r,n),Xe(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===ke&&(o=void 0),this.autoFreeze_&&We(o,!0),n){const t=[],r=[];ze("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}Oe(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const r=this.produce(e,t,((e,t)=>{n=e,o=t}));return[r,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Re(e)||Oe(8),Ce(e)&&(e=ct(e));const t=Ze(this),n=at(e,void 0);return n[Ie].isManual_=!0,Ve(t),n}finishDraft(e,t){const n=e&&e[Ie];n&&n.isManual_||Oe(9);const{scope_:o}=n;return Je(o,t),Xe(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=ze("Patches").applyPatches_;return Ce(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},ut=dt.produce;dt.produceWithPatches.bind(dt),dt.setAutoFreeze.bind(dt),dt.setUseStrictShallowCopy.bind(dt),dt.applyPatches.bind(dt),dt.createDraft.bind(dt),dt.finishDraft.bind(dt);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:o,memoizeOptions:r}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...r);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},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:o}=e;for(let r=0;r<o;r++)n.push(e[r].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 St(e,t={}){let n=kt();const{resultEqualityCheck:o}=t;let r,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=kt(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=kt(),e.set(n,t)):t=o}}const a=t;let c;if(t.s===bt)c=t.v;else if(c=e.apply(null,arguments),i++,o){const e=r?.deref?.()??r;null!=e&&o(e,c)&&(c=e,0!==i&&i--);r="object"==typeof c&&null!==c||"function"==typeof c?new 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 It(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,r=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:d=St,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=gt(l),f=gt(u),g=vt(e),v=c((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){r++;const e=mt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...ft,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ht},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:pt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=mt(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:c,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var xt=It(St),Ot=Object.assign(((e,t=xt)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})))}),{withTypes:()=>Ot});function jt(e){return({dispatch:t,getState:n})=>o=>r=>"function"==typeof r?r(t,n,e):o(r)}var Ct=jt(),Rt=jt;((...e)=>{const t=It(...e)})(St);var At="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?we:we.apply(null,arguments)},Et=e=>e&&"function"==typeof e.match;function Tt(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>be(t)&&t.type===e,n}function _t(e){return"function"==typeof e&&"type"in e&&Et(e)}function Mt(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 $t(e){return Re(e)?ut(e,(()=>{})):e}function Pt(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Dt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Lt(e,t,n){const o=Wt(e,t,n);return{detectMutations:()=>Nt(e,t,o,n)}}function Wt(e,t=[],n,o="",r=new Set){const i={value:n};if(!e(n)&&!r.has(n)){r.add(n),i.children={};for(const r in n){const s=o?o+"."+r:r;t.length&&-1!==t.indexOf(s)||(i.children[r]=Wt(e,t,n[r],s))}}return i}function Nt(e,t=[],n,o,r=!1,i=""){const s=n?n.value:void 0,a=s===o;if(r&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:i};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let r in c){const s=i?i+"."+r:r;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Nt(e,t,n.children[r],o[r],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function Kt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||pe(e)}function qt(e,t="",n=Kt,o,r=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),c=r.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(r.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=qt(l,a,n,o,r,i),s))return s}return i&&Ft(e)&&i.add(e),!1}function Ft(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Ft(t))return!1;return!0}function zt(e){return"boolean"==typeof e}var Bt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:r=!0}=e??{};let i=new Ut;if(t&&(zt(t)?i.push(Ct):i.push(Rt(t.extraArgument))),n){let e={};zt(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,o,r){return JSON.stringify(e,n(t,r),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(r,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,r):o.push(r),~n.indexOf(i)&&(i=t.call(this,r,i))}else n.push(i);return null==e?i:e.call(this,r,i)}},{isImmutable:o=Dt,ignoredPaths:r,warnAfter:i=32}=e;const s=Lt.bind(null,o,r);return({getState:e})=>{let n,o=e(),r=s(o);return a=>c=>{const l=Mt(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(c);return l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(o){let e={};zt(o)||(e=o),i.push(function(e={}){{const{isSerializable:t=Kt,getEntries:n,ignoredActions:o=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!be(u))return l(u);const h=l(u),p=Mt(s,"SerializableStateInvariantMiddleware");return c||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=qt(u,"",t,n,r,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const o=qt(e.getState(),"",t,n,i,d);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(r){let e={};zt(r)||(e=r),i.unshift(function(e={}){const{isActionCreator:t=_t}=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},Jt=e=>t=>{setTimeout(t,e)},Ht="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Jt(10),Vt=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Ut(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let r=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Ht:"callback"===e.type?e.queueNotification:Jt(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>r&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return r=!e?.meta?.RTK_autoBatch,i=!r,i&&(s||(s=!0,c(l))),o.dispatch(e)}finally{r=!0}}})})("object"==typeof n?n:void 0)),o};function Zt(e){const t=Bt(),{reducer:n,middleware:o,devTools:r=!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(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(c=o(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=we;r&&(l=At({trace:!0,..."object"==typeof r&&r}));const d=function(...e){return t=>(n,o)=>{const r=t(n,o);let i=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:r.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=we(...a)(r.dispatch),{...r,dispatch:i}}}(...c),u=Vt(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return ve(a,i,l(...h))}function Yt(e){const t={},n=[];let o;const r={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,r},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),r},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,r}};return e(r),[t,n,o]}function Xt(...e){return t=>e.some((e=>((e,t)=>Et(e)?e.match(t):e(t))(e,t)))}var Gt=["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 Gt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},nn=(()=>{function e(e,t,n){const o=Tt(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),r=Tt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=Tt(e+"/rejected",((e,t,o,r,i)=>({payload:r,error:(n&&n.serializeError||tn)(e||"Rejected"),meta:{...i||{},arg:o,requestId:t,rejectedWithValue:!!r,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(r(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new Qt(e,t),fulfillWithValue:(e,t)=>new en(e,t)})).then((t=>{if(t instanceof Qt)throw t;return t instanceof en?o(t.payload,l,e,t.meta):o(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(on)})}}),{pending:r,rejected:i,fulfilled:o,settled:Xt(i,o),typePrefix:e})}return e.withTypes=()=>e,e})();function on(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var rn=Symbol.for("rtk-slice-createasyncthunk");function sn(e,t){return`${e}/${t}`}function an(e,t,n,o){function r(r,...i){let s=n.call(e,r);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return r.unwrapped=t,r}var cn=function({creators:e}={}){const t=e?.asyncThunk?.[rn];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const r=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(r),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?Yt(e.extraReducers):[e.extraReducers],r={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,r,i]=Yt(t);if(function(e){return"function"==typeof e}(e))n=()=>$t(e());else{const t=$t(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...r.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(Ce(e)){const o=n(e,t);return void 0===o?e:o}if(Re(e))return ut(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in r)e.addCase(t,r[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}i.forEach((o=>{const i=r[o],s={reducerName:o,type:sn(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,r){let i,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=o.reducer,s=o.prepare}else i=o;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?Tt(e,s):Tt(e))}(s,i,a):function({type:e,reducerName:t},n,o,r){if(!r)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:d}=n,u=r(e,i,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);c&&o.addCase(u.rejected,c);l&&o.addMatcher(u.settled,l);o.exposeCaseReducer(t,{fulfilled:s||ln,pending:a||ln,rejected:c||ln,settled:l||ln})}(s,i,a,t)}));const l=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,reducer:(e,t)=>(u||(u=c()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=c()),u.getInitialState()),getSelectors(t=l){const n=Pt(d,this,{insert:()=>new WeakMap});return Pt(n,t,{insert:()=>{const n={};for(const[o,r]of Object.entries(e.selectors??{}))n[o]=an(this,r,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function ln(){}var dn="listenerMiddleware";Tt(`${dn}/add`),Tt(`${dn}/removeAll`),Tt(`${dn}/remove`);const un=e=>u((t=>{const n=cn(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(w)(t)){constructor(...e){super(...e);const t=Zt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),r=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{on(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},i=Object.keys(o).reduce(((e,t)=>(e[t]=r(o[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),hn=u((e=>class extends(w(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}})),pn=u((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),fn=e=>e.selectedAccessKeysIds,gn=e=>e.notifications,vn=xt((e=>e.accessKeysList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{expireTimeFormatted:(null==e?void 0:e.expireTime)?new Date(1e3*((null==e?void 0:e.expireTime)||0)).toLocaleString():"Never",createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:(null==e?void 0:e.expireTime)&&new Date(1e3*((null==e?void 0:e.expireTime)||0))<new Date?"expired":null==e?void 0:e.status}))))),mn=xt(fn,vn,((e,t)=>t.filter((t=>e.includes(t.id))))),yn=xt(fn,(e=>!!e.length)),wn=xt(mn,(e=>e.every((e=>e.editable)))),bn=xt(wn,yn,((e,t)=>e&&t));xt(fn,(e=>1===e.length));const kn=xt(mn,(e=>1===e.length?e[0].name:`${e.length} access keys`)),Sn=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)}))}))},In=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),xn=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),On=nn("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),jn=Sn(On)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},In((e=>e.createAccessKey)),xn({getSuccessMsg:()=>"Access Key created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create access key</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Cn={action:On,reducer:jn},Rn=nn("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),An=Sn(Rn)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},In((e=>e.deleteAccessKey)),xn({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deleted successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to delete access key${["","s"]}`})),En={action:Rn,reducer:An},Tn=nn("accessKeys/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.accesskey.search(Object.assign(Object.assign({},o),e))})),_n=Sn(Tn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},In((e=>e.accessKeysList))),Mn={action:Tn,reducer:_n},Un=nn("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),$n=Sn(Un)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},In((e=>e.activateAccessKey)),xn({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} activated successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to activate access key${["","s"]}`})),Pn={action:Un,reducer:$n},Dn=nn("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),Ln=Sn(Dn)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},In((e=>e.deactivateAccessKey)),xn({getSuccessMsg:e=>l(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deactivated successfully`,getErrorMsg:e=>l(e.meta.arg.length)`Failed to deactivate access key${["","s"]}`})),Wn={action:Dn,reducer:Ln},Nn=nn("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),Kn={action:Nn,reducer:Sn(Nn)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},In((e=>e.tenantRoles)))},qn={accessKeysList:{data:[],loading:!1,error:null},createAccessKey:{loading:!1,error:null},activateAccessKey:{loading:!1,error:null},deactivateAccessKey:{loading:!1,error:null},deleteAccessKey:{loading:!1,error:null},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]};class Fn extends Error{}function zn(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 Bn(e,t){if("string"!=typeof e)throw new Fn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,o=e.split(".")[n];if("string"!=typeof o)throw new Fn(`Invalid token specified: missing part #${n+1}`);let r;try{r=zn(o)}catch(e){throw new Fn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new Fn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Fn.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"}},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const Hn="<region>",Vn=`https://api.${Hn}descope.com`,Zn=6e5,Yn="dct",Xn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let Gn;const Qn=()=>{if(Gn)return Gn;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 Gn=`${t}-${n}`,Gn};var eo,to;(to=eo||(eo={})).get="GET",to.delete="DELETE",to.post="POST",to.put="PUT",to.patch="PATCH";const no=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(Hn,r?r+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{i=`${i}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return i},oo=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),ro={"Content-Type":"application/json"},io=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},so=e=>{const t={"x-descope-sdk-session-id":Qn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.41.0"};return e&&(t["x-descope-refresh-cookie-name"]=e),t},ao=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},co=({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:o,logger:r,hooks:i,cookiePolicy:s,fetch:a})=>{const c=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Xn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return Xn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(r,a),l=async r=>{var a;const l=(null==i?void 0:i.beforeRequest)?i.beforeRequest(r):r,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=l,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:oo(io(t,g),so(o),(null==n?void 0:n.baseHeaders)||{},ao(v)?ro:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const y=await c(no({path:d,baseUrl:e,queryParams:p,projectId:t}),m);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(r,null==y?void 0:y.clone()),null==i?void 0:i.transformResponse){const e=await y.json(),t=((null===(a=y.headers)||void 0===a?void 0:a.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}return y};return{get:(e,{headers:t,queryParams:n,token:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:eo.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>l({path:e,headers:n,queryParams:o,body:t,method:eo.post,token:r}),patch:(e,t,{headers:n,queryParams:o,token:r}={})=>l({path:e,headers:n,queryParams:o,body:t,method:eo.patch,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>l({path:e,headers:n,queryParams:o,body:t,method:eo.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:eo.delete,token:o}),hooks:i,buildUrl:(n,o)=>no({projectId:t,baseUrl:e,path:n,queryParams:o})}};var lo=429;function uo(e,t,n){var o;let r=ho(e);if(t){if(!(null==r?void 0:r.tenants)&&(null==r?void 0:r[Yn])===t)return(null==r?void 0:r[n])||[];r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]}const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function ho(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Bn(e)}function po(e){const{exp:t}=ho(e);return(new Date).getTime()/1e3>t}function fo(e){let t=ho(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function go(e,t){return uo(e,t,"permissions")}function vo(e,t){return uo(e,t,"roles")}const mo=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function yo(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=i:(r.error=i,o.status===lo&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}function wo(e){var t;return(null===(t=ho(e))||void 0===t?void 0:t[Yn])||""}const bo=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),ko=(e,t)=>(n=t)=>t=>{const o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.join(" OR "))},So=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Io=e=>t=>e.test(t),xo=Io(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Oo=Io(/^\+[1-9]{1}[0-9]{3,14}$/),jo=bo(xo,'"{val}" is not a valid email'),Co=bo(Oo,'"{val}" is not a valid phone number'),Ro=bo((e=>e.length>=1),"Minimum length is 1");const Ao=bo((e=>"string"==typeof e),"Input is not a string"),Eo=bo((e=>Array.isArray(e)),"Input is not an array"),To=bo((e=>"boolean"==typeof e),"Input is not a boolean"),_o=bo((e=>void 0===e),"Input is defined"),Mo=ko([Ao(),_o()],"Input is not a string or undefined"),Uo=ko([Eo(),To()],"Input is not an array or boolean"),$o=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>So(...e).validate(n[t]))),t(...n)),Po=e=>[Ao(`"${e}" must be a string`)],Do=e=>[Mo(`"${e}" must be string or undefined`)],Lo=e=>[Ao(`"${e}" must be a string`),Ro(`"${e}" must not be empty`)],Wo=e=>[Ao(`"${e}" must be a string`),jo()],No=e=>[Ao(`"${e}" must be a string`),Co()],Ko=$o(Lo("accessKey")),qo=e=>({exchange:Ko(((t,n)=>yo(e.post(Jn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Fo=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const s=i[r];i[r]=n(s)})),e),zo=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Zn,Zn)});var Bo,Jo;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(Bo||(Bo={})),function(e){e.email="email"}(Jo||(Jo={}));const Ho=Object.assign(Object.assign({},Bo),Jo);var Vo;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Vo||(Vo={}));const Zo=Lo("loginId"),Yo=$o(Lo("token")),Xo=$o(Zo),Go=$o(Lo("pendingRef")),Qo=$o(Zo,Wo("email")),er=e=>({verify:Yo((t=>yo(e.post(Jn.enchantedLink.verify,{token:t})))),signIn:Xo(((t,n,o,r)=>yo(e.post(mo(Jn.enchantedLink.signIn,Ho.email),{loginId:t,URI:n,loginOptions:o},{token:r})))),signUpOrIn:Xo(((t,n,o)=>yo(e.post(mo(Jn.enchantedLink.signUpOrIn,Ho.email),{loginId:t,URI:n,loginOptions:o})))),signUp:Xo(((t,n,o,r)=>yo(e.post(mo(Jn.enchantedLink.signUp,Ho.email),{loginId:t,URI:n,user:o,loginOptions:r})))),waitForSession:Go(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=zo(n);let s;const a=setInterval((async()=>{const n=await e.post(Jn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(yo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:Qo(((t,n,o,r,i)=>yo(e.post(Jn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),tr=$o(Lo("flowId")),nr=$o(Lo("executionId"),Lo("stepId"),Lo("interactionId")),or=e=>({start:tr(((t,n,o,r,i,s,a)=>yo(e.post(Jn.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,componentsVersion:i,flowVersions:s,input:a})))),next:nr(((t,n,o,r,i,s)=>yo(e.post(Jn.flow.next,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:s}))))}),rr=Lo("loginId"),ir=$o(Lo("token")),sr=$o(rr),ar=$o(rr,No("phone")),cr=$o(rr,Wo("email")),lr=Object.keys(Ho).filter((e=>e!==Bo.voice)),dr=e=>({verify:ir((t=>yo(e.post(Jn.magicLink.verify,{token:t})))),signIn:lr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:sr(((t,o,r,i)=>yo(e.post(mo(Jn.magicLink.signIn,n),{loginId:t,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:lr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:sr(((t,o,r,i)=>yo(e.post(mo(Jn.magicLink.signUp,n),{loginId:t,URI:o,user:r,loginOptions:i}))))})),{}),signUpOrIn:lr.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:sr(((t,o,r)=>yo(e.post(mo(Jn.magicLink.signUpOrIn,n),{loginId:t,URI:o,loginOptions:r}))))})),{}),update:{email:cr(((t,n,o,r,i)=>yo(e.post(Jn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(Bo).filter((e=>e!==Bo.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ar(((t,o,r,i,s)=>yo(e.post(mo(Jn.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:r},s),{token:i}))))})),{})}});var ur;!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"}(ur||(ur={}));const hr=$o(Lo("code")),pr=e=>({start:Object.assign(((t,n,o,r)=>yo(e.post(Jn.oauth.start,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:r}))),Object.keys(ur).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r)=>yo(e.post(Jn.oauth.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:r}))})),{})),exchange:hr((t=>yo(e.post(Jn.oauth.exchange,{code:t})))),startNative:(t,n,o)=>yo(e.post(Jn.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,r,i)=>yo(e.post(Jn.oauth.finishNative,{provider:t,stateId:n,user:o,code:r,idToken:i})),getOneTapClientId:t=>yo(e.get(Jn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,r)=>yo(e.post(Jn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r})),exchangeOneTapIDToken:(t,n,o,r)=>yo(e.post(Jn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:r}))}),fr=Lo("loginId"),gr=$o(fr,Lo("code")),vr=$o(fr),mr=$o(fr,No("phone")),yr=$o(fr,Wo("email")),wr=e=>({verify:Object.keys(Ho).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:gr(((t,o)=>yo(e.post(mo(Jn.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Ho).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vr(((t,o,r)=>yo(e.post(mo(Jn.otp.signIn,n),{loginId:t,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(Ho).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vr(((t,o,r)=>yo(e.post(mo(Jn.otp.signUp,n),{loginId:t,user:o,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Ho).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vr(((t,o)=>yo(e.post(mo(Jn.otp.signUpOrIn,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:yr(((t,n,o,r)=>yo(e.post(Jn.otp.update.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(Bo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:mr(((t,o,r,i)=>yo(e.post(mo(Jn.otp.update.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),br=$o(Lo("tenant")),kr=$o(Lo("code")),Sr=e=>({start:br(((t,n,o,r,i)=>yo(e.post(Jn.saml.start,o||{},Object.assign({queryParams:Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),i&&{ssoId:i})},r&&{token:r}))))),exchange:kr((t=>yo(e.post(Jn.saml.exchange,{code:t}))))}),Ir=Lo("loginId"),xr=$o(Ir,Lo("code")),Or=$o(Ir),jr=$o(Ir),Cr=e=>({signUp:Or(((t,n)=>yo(e.post(Jn.totp.signUp,{loginId:t,user:n})))),verify:xr(((t,n,o,r)=>yo(e.post(Jn.totp.verify,{loginId:t,code:n,loginOptions:o},{token:r})))),update:jr(((t,n)=>yo(e.post(Jn.totp.update,{loginId:t},{token:n}))))}),Rr=Lo("loginId"),Ar=Lo("newPassword"),Er=$o(Rr,Lo("password")),Tr=$o(Rr),_r=$o(Rr,Ar),Mr=$o(Rr,Lo("oldPassword"),Ar),Ur=e=>({signUp:Er(((t,n,o,r)=>yo(e.post(Jn.password.signUp,{loginId:t,password:n,user:o,loginOptions:r})))),signIn:Er(((t,n,o)=>yo(e.post(Jn.password.signIn,{loginId:t,password:n,loginOptions:o})))),sendReset:Tr(((t,n,o)=>yo(e.post(Jn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:_r(((t,n,o)=>yo(e.post(Jn.password.update,{loginId:t,newPassword:n},{token:o})))),replace:Mr(((t,n,o)=>yo(e.post(Jn.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>yo(e.get(Jn.password.policy))}),$r=Po("loginId"),Pr=Lo("loginId"),Dr=Lo("origin"),Lr=$o(Pr,Dr,Lo("name")),Wr=$o(Pr,Dr),Nr=$o($r,Dr),Kr=$o(Pr,Dr,Do("token")),qr=$o(Lo("transactionId"),Lo("response")),Fr=e=>({signUp:{start:Lr(((t,n,o,r)=>yo(e.post(Jn.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,passkeyOptions:r})))),finish:qr(((t,n)=>yo(e.post(Jn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Nr(((t,n,o,r,i)=>yo(e.post(Jn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i},{token:r})))),finish:qr(((t,n)=>yo(e.post(Jn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Wr(((t,n,o)=>yo(e.post(Jn.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:o}))))},update:{start:Kr(((t,n,o,r)=>yo(e.post(Jn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:r},{token:o})))),finish:qr(((t,n)=>yo(e.post(Jn.webauthn.update.finish,{transactionId:t,response:n}))))}}),zr=Po("loginId"),Br=$o(zr),Jr=$o(Lo("pendingRef")),Hr=e=>({signUpOrIn:Br(((t,n)=>yo(e.post(Jn.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:Br(((t,n,o)=>yo(e.post(Jn.notp.signUp,{loginId:t,user:n,loginOptions:o})))),signIn:Br(((t,n,o)=>yo(e.post(Jn.notp.signIn,{loginId:t,loginOptions:n},{token:o})))),waitForSession:Jr(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=zo(n);let s;const a=setInterval((async()=>{const n=await e.post(Jn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(yo(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),Vr=$o(Lo("token")),Zr=$o(Do("token"));var Yr,Xr=$o([(Yr=Lo("projectId"),bo(((e,t)=>n=>So(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let r=0,i=e===Object(e)?e:void 0;for(;null!=i&&r<o;)i=i[n[r++]];return r&&r===o&&void 0!==i?i:void 0})(n,e)))("projectId",Yr))())])((e=>t=>{var n;return e(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>{var n;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),e)},afterRequest:async(e,n)=>{var o;const r=[].concat((null===(o=t.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=r.length&&(await Promise.allSettled(null==r?void 0:r.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))},transformResponse:null===(n=t.hooks)||void 0===n?void 0:n.transformResponse}}))})((({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},refreshCookieName:s,fetch:a})=>{return c=co({baseUrl:n||Vn,projectId:e,logger:t,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},refreshCookieName:s,fetch:a}),{accessKey:qo(c),otp:wr(c),magicLink:dr(c),enchantedLink:er(c),oauth:pr(c),saml:Sr(c),totp:Cr(c),notp:Hr(c),webauthn:Fr(c),password:Ur(c),flow:or(c),refresh:Zr(((e,t,n)=>{const o={};return n&&(o.externalToken=n),yo(c.post(Jn.refresh,o,{token:e,queryParams:t}))})),selectTenant:$o([Ao("tenantId")],[Mo('"token" must be string or undefined')])(((e,t)=>yo(c.post(Jn.selectTenant,{tenant:e},{token:t})))),logout:Zr((e=>yo(c.post(Jn.logout,{},{token:e})))),logoutAll:Zr((e=>yo(c.post(Jn.logoutAll,{},{token:e})))),me:Zr((e=>yo(c.get(Jn.me,{token:e})))),myTenants:$o([Uo('"tenants" must a string array or a boolean')],[Mo('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,yo(c.post(Jn.myTenants,n,{token:t}))})),history:Zr((e=>yo(c.get(Jn.history,{token:e})))),isJwtExpired:Vr(po),getTenants:Vr(fo),getJwtPermissions:Vr(go),getJwtRoles:Vr(vo),getCurrentTenant:Vr(wo),httpClient:c};var c}))),Gr=Object.assign(Xr,{DeliveryMethods:Ho});
|
|
6
6
|
/*! js-cookie v3.0.5 | MIT */
|
|
7
|
-
function Xi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)e[s]=n[s]}return e}var Qi=function e(t,n){function s(e,s,i){if("undefined"!=typeof document){"number"==typeof(i=Xi({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var o in i)i[o]&&(r+="; "+o,!0!==i[o]&&(r+="="+i[o].split(";")[0]));return document.cookie=e+"="+t.write(s,e)+r}}return Object.create({set:s,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],s={},i=0;i<n.length;i++){var r=n[i].split("="),o=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(s[a]=t.read(o,a),e===a)break}catch(e){}}return e?s[e]:s}},remove:function(e,t){s(e,"",Xi({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Xi({},this.attributes,t))},withConverter:function(t){return e(Xi({},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 er={default:"endpoint"},tr="Blocked by CSP",nr="The endpoint parameter is not a valid URL",sr="Failed to load the JS script of the agent",ir="9319";function rr(e,t){var n,s,i,r,o,a=[],c=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var s,i=0,r=t.length;i<r;i++)!s&&i in t||(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return e.concat(s||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,s=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,o=t instanceof Error?t.message:"";if(o===tr||o===nr)n.exclude(),r=0;else if(o===ir)n.exclude();else if(o===sr){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!i.has(c)&&(i.add(c),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+s()-Date.now()]}]),l=c[0],d=c[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,s=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return s()}),s),i.catch((function(e){if(null!=o||(o=e),a.length>=5)throw o;var t=d(n,e);if(!t)throw o;var s,i=t[0],r=t[1];return(s=r,new Promise((function(e){return setTimeout(e,s)}))).then((function(){return u(i)}))}))};return u(l).then((function(e){return[e,a]}))}var or="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",ar=or;function cr(n){var s;n.scriptUrlPattern;var i=n.token,r=n.apiKey,o=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(s=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==s?s:or,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,s){return e.addEventListener(t,n,s),function(){return e.removeEventListener(t,n,s)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=l[0],u=l[1];return Promise.resolve().then((function(){if(!o||"string"!=typeof o)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,o);return rr(e,lr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===ir?new Error(sr):e}(e)})).then((function(t){var n=t[0],s=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:s,visibilityStates:d}}))}))}function lr(e){return function(e,t,n){var s,i=document,r="securitypolicyviolation",o=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(s=t,a())};i.addEventListener(r,o);var a=function(){return i.removeEventListener(r,o)};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(),s)return n(s);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(nr);var s=document.createElement("script"),i=function(){var e;return null===(e=s.parentNode)||void 0===e?void 0:e.removeChild(s)},r=document.head||document.getElementsByTagName("head")[0];s.onload=function(){i(),t()},s.onerror=function(){i(),n(new Error(sr))},s.async=!0,s.src=e,r.appendChild(s)}))}(e)}),(function(){throw new Error(tr)})).then(dr)}function dr(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,s=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==s?void 0:s.configurable)?delete e[t]:s&&!s.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(ir);return n}const ur=e=>{try{return zn(e).exp}catch(e){return null}},hr=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:ur(n)},pr=e=>{const{expires_in:t,expires_at:n,access_token:s}=e;return n||(t?Math.floor(Date.now()/1e3)+t:s?ur(s):void 0)},gr=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,s)=>{var i;return n[s]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[s])||[]).concat((null==t?void 0:t[s])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},fr=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(e=>{const{access_token:n,id_token:s,refresh_token:i,refresh_expire_in:r}=e,o=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:s,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||pr(e),cookieExpiration:e.cookieExpiration||hr(e)},o)})((null==n?void 0:n.authInfo)||n||{})},mr=async e=>{const t=await fr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},wr="undefined"!=typeof localStorage,vr=(e,t)=>wr&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),yr=e=>wr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),_r=e=>wr&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),br=(...e)=>{console.debug(...e)},kr="3.2.0",Sr="undefined"!=typeof window,Ir=Math.pow(2,31)-1,xr=`https://descopecdn.com/npm/oidc-client-ts@${kr}/dist/browser/oidc-client-ts.min.js`,Er=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${kr}/dist/browser/oidc-client-ts.min.js`,Cr="DS",Rr="DSR",Tr="DSI";function Or(e=""){return yr(`${e}${Rr}`)||""}function jr(e=""){return Qi.get(Cr)||yr(`${e}${Cr}`)||""}function Ar(e=""){return yr(`${e}${Tr}`)||""}function Pr(e=""){_r(`${e}${Rr}`),_r(`${e}${Cr}`),_r(`${e}${Tr}`),Qi.remove(Cr)}const Ur=Sr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Mr="vsid",$r="vrid",Nr=(e=!1)=>{const t=localStorage.getItem("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},qr=async(e,t=Ur)=>{try{if(Nr())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),s=new URL(t);s.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",o=cr({apiKey:e,endpoint:[s.toString(),er],scriptUrlPattern:[r,ar]}),a=await o,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Mr]:e,[$r]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Dr=e=>{const t=Nr(!0);return t&&e.body&&(e.body.fpData=t),e},Wr="dls_last_user_login_id",Lr="dls_last_user_display_name",Kr=()=>yr(Wr),Fr=()=>yr(Lr),Hr=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,s={}]=t,i=Kr(),r=Fr();return i&&(null!==(n=s.lastAuth)&&void 0!==n||(s.lastAuth={}),s.lastAuth.loginId=i,s.lastAuth.name=r),await e(...t)};function zr(){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 Jr(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Xr(n.publicKey.challenge),n.publicKey.user.id=Xr(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Xr(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Qr(n.rawId),type:n.type,response:{attestationObject:Qr(n.response.attestationObject),clientDataJSON:Qr(n.response.clientDataJSON)}});var n}async function Br(e){const t=Gr(e);return Yr(await navigator.credentials.get(t))}async function Vr(e,t){const n=Gr(e);return n.signal=t.signal,n.mediation="conditional",Yr(await navigator.credentials.get(n))}async function Zr(e=!1){if(!Sr)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Gr(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Xr(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Xr(e.id)})),n}function Yr(e){return JSON.stringify({id:e.id,rawId:Qr(e.rawId),type:e.type,response:{authenticatorData:Qr(e.response.authenticatorData),clientDataJSON:Qr(e.response.clientDataJSON),signature:Qr(e.response.signature),userHandle:e.response.userHandle?Qr(e.response.userHandle):void 0}})}function Xr(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Qr(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var eo,to=(eo=e=>({async signUp(t,n,s){const i=await e.webauthn.signUp.start(t,window.location.origin,n,s);if(!i.ok)return i;const r=await Jr(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const s=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!s.ok)return s;const i=await Br(s.data.options);return await e.webauthn.signIn.finish(s.data.transactionId,i)},async signUpOrIn(t,n){var s;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(s=i.data)||void 0===s?void 0:s.create){const t=await Jr(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await Br(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,s){const i=await e.webauthn.update.start(t,window.location.origin,n,s);if(!i.ok)return i;const r=await Jr(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Jr,get:Br,isSupported:Zr,conditional:Vr}}),(...e)=>{const t=eo(...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 no="/fedcm/config";async function so(e,t){var n,s,i;try{const i=await async function(e,t="google",n,s,i){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),o=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const c=a.data.clientId;return new Promise((e=>{var a,l;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};o.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,callback:d,nonce:r})),o.prompt((e=>{var t,n;if(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(s&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==s||s(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const s=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!s.ok||!s.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,s.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(s=null==t?void 0:t.onAuthenticated)||void 0===s||s.call(t,n.data)}}catch(e){null===(i=null==t?void 0:t.onFailed)||void 0===i||i.call(t,e)}}var io=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Zr(),s=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=s,e.flow.start(...t)}});let ro;const oo=(e,t)=>new Promise(((n,s)=>{if(!e.length)return s(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);const r=e.shift(),o=document.createElement("script");o.src=r,o.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),o.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},o.addEventListener("error",(()=>{oo(e,t),o.setAttribute("data-error","true")})),document.body.appendChild(o)})),ao=(e,t,n)=>{const s=async()=>{let s,i;return s&&i||({client:s,stateUserKey:i}=await(async(e,t,n)=>{ro||(ro=(async()=>{try{return Promise.resolve().then((function(){return sc}))}catch(e){return oo([xr,Er],(()=>window.oidc))}})());const{OidcClient:s,WebStorageStateStore:i}=await ro;if(!s)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=t,o=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",c=`${r}_user`;let l=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(l=`${l}/${n.applicationId}`);const d={authority:l,client_id:t,redirect_uri:o,response_type:"code",scope:a,stateStore:new i({store:window.localStorage,prefix:r}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new s(d),stateUserKey:c}})(e,t,n)),{client:s,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await s(),o=await i.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(o)))),window.localStorage.setItem(r,JSON.stringify({id_token:(a=o).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())})(),o};return{loginWithRedirect:async(e={},t=!1)=>{const{client:n}=await s(),i=await n.createSigninRequest(e),{url:r}=i;return t||(window.location.href=r),{ok:!0,data:i}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await s(),o=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(r);if(!o)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const c=await i.useRefreshToken({state:{refresh_token:a,session_state:o.session_state,profile:o.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await s();e||(e={}),e.id_token_hint=e.id_token_hint||Ar(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:o}=r;return window.localStorage.removeItem(i),t||window.location.replace(o),r}}},co=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:s,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Sr?(s&&i&&qr(s).catch((()=>null)),e(gr(r,{beforeRequest:Dr}))):e(r)}),(e=>n=>{var{autoRefresh:s}=n,i=t(n,["autoRefresh"]);if(!s)return e(i);const{clearAllTimers:r,setTimer:o}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;Sr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&a&&new Date>a&&(br("Expiration time passed, refreshing session"),l.refresh(Or()||c))}));const l=e(gr(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:s,sessionExpiration:i}=await fr(t);if(401===(null==t?void 0:t.status))br("Received 401, canceling all timers"),r();else if(n||i){if(a=((e,t)=>{if(t)return new Date(1e3*t);br("Could not extract expiration time from session token, trying to decode the token");try{const t=zn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!a)return void br("Could not extract expiration time from session token");c=s;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>Ir&&(br(`Timeout is too large (${t}ms), setting it to ${Ir}ms`),t=Ir),t})(a);if(r(),e<=2e4)return void br("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});br(`Setting refresh timer for ${t}. (${e}ms)`),o((()=>{br("Refreshing session due to timer"),l.refresh(Or()||s)}),e)}}}));return Ks(l,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return br("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.29.0"},t.baseHeaders)}))),(e=>t=>{const n=zr(),s=zr(),i=zr(),r=e(gr(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))s.pub(null),i.pub(null),n.pub(null);else{const e=await mr(t);e&&i.pub(e);const{sessionJwt:r,sessionExpiration:o}=await fr(t);r&&s.pub(r),(o||r)&&n.pub(o||42)}}})),o=Ks(r,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const r=await e(...t);return s.pub(null),i.pub(null),n.pub(null),r}));return Object.assign(o,{onSessionTokenChange:s.sub,onUserChange:i.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var{storeLastAuthenticatedUser:s=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!s)return Object.assign(e(r),{getLastUserLoginId:Kr,getLastUserDisplayName:Fr});const o=e(gr(r,{afterRequest:async(e,t)=>{var n;const s=await mr(t),i=null===(n=null==s?void 0:s.loginIds)||void 0===n?void 0:n[0],r=null==s?void 0:s.name;i&&((e=>{vr(Wr,e)})(i),(e=>{vr(Lr,e)})(r))}}));let a=Ks(o,["flow.start"],Hr);return a=Ks(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const s=await t(...n);return e||(_r(Wr),_r(Lr)),s})(i)),Object.assign(a,{getLastUserLoginId:Kr,getLastUserDisplayName:Fr})}),(e=>n=>{var{persistTokens:s,sessionTokenViaCookie:i,storagePrefix:r}=n,o=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!s||!Sr)return e(o);const a=e(gr(o,{beforeRequest:(c=r,e=>Object.assign(e,{token:e.token||Or(c)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||Pr(r):((e={},t=!1,n="")=>{var s;const{sessionJwt:i,refreshJwt:r}=e;if(r&&vr(`${n}${Rr}`,r),i)if(t){const n=t.sameSite||"Strict",r=null===(s=t.secure)||void 0===s||s;!function(e,t,n){if(t){const{cookieDomain:s,cookiePath:i,cookieSameSite:r,cookieExpiration:o,cookieSecure:a}=n,c=new Date(1e3*o),l=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(s);Qi.set(e,t,{path:i,domain:l?s:void 0,expires:c,sameSite:r,secure:a})}}(Cr,i,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r}))}else vr(`${n}${Cr}`,i);e.idToken&&vr(`${n}${Tr}`,e.idToken)})(await fr(t),i,r)}}));var c;const l=Ks(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const s=await t(...n);return Pr(e),s})(r));return Object.assign(l,{getRefreshToken:()=>Or(r),getSessionToken:()=>jr(r),getIdToken:()=>Ar(r)})}))((e=>{const t=Yi(e),n=ao(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async s=>{if(e.oidcConfig)try{return await n.refreshToken(s),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}const i=jr(),r=Or();return t.refresh(s,{dcs:i?"t":"f",dcr:r?"t":"f"})},logout:async s=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:s}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(s)},flow:io(t),webauthn:to(t),fedcm:(s=t,i=e.projectId,{onetap:{requestExchangeCode(e){so(s,e)},requestAuthentication(e){so(s,e)}},oneTap(e,t,n,i,r){so(s,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:i,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:s.httpClient.buildUrl(i+no),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return s.refresh(r.token)},isSupported:()=>Sr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=s.httpClient.buildUrl(i+no);try{const s={identity:{context:e||"signin",providers:[{configURL:n,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(s));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var s,i})),lo={search:"/v1/mgmt/accesskey/search",deleteBatch:"/v1/mgmt/accesskey/delete/batch",create:"/v1/mgmt/accesskey/create",deactivate:"/v1/mgmt/accesskey/deactivate/batch",activate:"/v1/mgmt/accesskey/activate/batch"},uo={roles:"/v1/mgmt/role/all"},ho=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)})),po=(...e)=>n(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((n=>{const s=[],i=(new Date).getTime()/1e3+2592e3,r=new Date(i).toLocaleString();for(let e=1;e<10;e+=1)s.push({id:`access-key-id-${e}`,name:`Access Key ${e}`,createdBy:`User ${e}`,editable:!0,expireTime:i,expireTimeFormatted:r,createdTime:i,createdTimeFormatted:r,roleNames:[`Role ${e}`],permittedIps:["127.1.2.3"],status:"active",clientId:`Client ID ${e}`,boundUserId:`User ${e}`});t.forEach((e=>{s.sort(((t,n)=>{var s,i;return e.desc?null===(i=n[e.field])||void 0===i?void 0:i.localeCompare(t[e.field]):null===(s=t[e.field])||void 0===s?void 0:s.localeCompare(n[e.field])}))})),n(s.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.createdBy.toLowerCase().includes(e.toLowerCase()))))}))})),go=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:n,permittedIps:s},i){const r=Math.random().toString(10).substring(15);return new Promise((o=>{o({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${r}`,name:e||`Access Key ${r}`,createdBy:n||`User ${r}`,editable:!0,expireTime:i,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:s,status:"active",clientId:`Client ID ${r}`,boundUserId:n||`User ${r}`}})}))})),fo=()=>n(void 0,void 0,void 0,(function*(){})),mo=()=>n(void 0,void 0,void 0,(function*(){})),wo=()=>n(void 0,void 0,void 0,(function*(){})),vo=e=>new Promise((t=>{const n=[];for(let t=1;t<5;t+=1)n.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:n})})),yo=({httpClient:e,tenant:t,mock:s})=>({search:(...i)=>n(void 0,[...i],void 0,(function*({page:n,limit:i=1e4,text:r,sort:o}={}){if(s)return po({page:n,limit:i,text:r,sort:o});const a=yield e.post(lo.search,{limit:i,page:n,text:r,sort:o},{queryParams:{tenant:t}});yield ho(a);return(yield a.json()).keys})),deleteBatch:i=>n(void 0,void 0,void 0,(function*(){if(s)return wo();const n=yield e.post(lo.deleteBatch,{ids:i},{queryParams:{tenant:t}});return yield ho(n),n.json()})),create:i=>n(void 0,[i],void 0,(function*({name:n,expiration:i,roleNames:r,userId:o,permittedIps:a}){const c=new Date;c.setDate(c.getDate()+ +i);const l="0"===i[0]?0:Math.floor(c.getTime()/1e3);if(s)return go({name:n,expiration:i,roleNames:r,userId:o,permittedIps:a},l);const d=yield e.post(lo.create,{name:n,expireTime:l,roleNames:r,userId:o,permittedIps:a},{queryParams:{tenant:t}});yield ho(d);return yield d.json()})),activate:i=>n(void 0,void 0,void 0,(function*(){if(s)return fo();const n=yield e.post(lo.activate,{ids:i},{queryParams:{tenant:t}});yield ho(n);return yield n.json()})),deactivate:i=>n(void 0,void 0,void 0,(function*(){if(s)return mo();const n=yield e.post(lo.deactivate,{ids:i},{queryParams:{tenant:t}});yield ho(n);return yield n.json()}))}),_o=({httpClient:e,tenant:t,mock:s})=>({getTenantRoles:()=>n(void 0,void 0,void 0,(function*(){if(s)return vo(t);const n=yield e.get(uo.roles,{queryParams:{tenant:t}});return yield ho(n),n.json()}))}),bo=u((e=>{var t,o,a,c;const l=r(E,I,y,C,pn,x({tenant:x.missingAttrValidator}))(e);return c=class extends l{constructor(){super(...arguments),t.add(this),o.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 s(this,o,"f")||s(this,t,"m",a).call(this),s(this,o,"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"],(()=>{s(this,o,"f")&&s(this,t,"m",a).call(this)}))}))}},o=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,o,((e,t,n,s)=>{const i=co(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"access-key-management-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.4.11"}}));return{accesskey:yo({httpClient:i.httpClient,tenant:t,mock:n}),tenant:_o({httpClient:i.httpClient,tenant:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},c})),ko=u((e=>{const t=r(un({name:"widget",initialState:Kn,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Cn.reducer(e),On.reducer(e),Pn.reducer(e),$n.reducer(e),Dn.reducer(e),Ln.reducer(e)},asyncActions:{searchAccessKeys:Pn.action,createAccessKey:Cn.action,activateAccessKeys:$n.action,deactivateAccessKeys:Dn.action,deleteAccessKeys:On.action,getTenantRoles:Ln.action}}),S,y,bo)(e);return class extends t{constructor(...e){super(...e),this.state=Kn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),So=u((e=>{const t=r(O,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(`access-key-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Io=u((e=>{var t,i,a;return a=class extends(r(y,S,L,H,So,ko)(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([s(this,t,"m",i).call(this),this.actions.searchAccessKeys(),this.actions.getTenantRoles()]),this.onWidgetRootReady()}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){const e=o(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),xo=u((e=>{var t,i,o,a,l;return l=class extends(r(ko,y,Io)(e)){constructor(){super(...arguments),t.add(this),o.set(this,c((e=>{this.accessKeysTable.data=e}))),a.set(this,d(((e,t)=>{const n=[],{value:s}=t;if(s){const t=e.path;n.push({field:t,desc:"desc"===s})}this.actions.searchAccessKeys({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),s(this,t,"m",i).call(this),this.accessKeysTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{s(this,a,"f").call(this,e.target,e.detail)}))})),s(this,o,"f").call(this,mn(this.state)),this.subscribe(s(this,o,"f").bind(this),mn)}))}},o=new WeakMap,a=new WeakMap,t=new WeakSet,i=function(){var e;this.accessKeysTable=new Y(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="access-keys-table"]'),{logger:this.logger}),this.accessKeysTable.onSelectedItemsChange((e=>{this.actions.setSelectedAccessKeysIds(e.detail.value.map((({id:e})=>e)))}))},l})),Eo=u((e=>{var t,i,a;return a=class extends(r(ko,re,y,Io)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield s(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){var e;this.activateAccessKeysModal=this.createModal(),this.activateAccessKeysModal.setContent(o(yield this.fetchWidgetPage("activate-access-keys-modal.html")));const t=new X((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.activateAccessKeysModal.close()));const n=new X((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=wn(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const s=new se(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=bn(this.state);s.text=`Activate ${e}?`}}))},a})),Co=u((e=>{var t,i,o,a;return a=class extends(r(y,Io,ko,Eo)(e)){constructor(){super(...arguments),t.add(this),o.set(this,c((e=>{e?this.activateButton.enable():this.activateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),s(this,t,"m",i).call(this),this.subscribe(s(this,o,"f").bind(this),_n)}))}},o=new WeakMap,t=new WeakSet,i=function(){var e;this.activateButton=new X(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="activate-access-keys"]'),{logger:this.logger}),this.activateButton.disable(),this.activateButton.onClick((()=>{this.activateAccessKeysModal.open()}))},a})),Ro=u((e=>{var t,i,a;return a=class extends(r(ko,re,hn,y,Io)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),s(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){this.createdAccessKeyModal=this.createModal(),this.createdAccessKeyModal.setContent(o(yield this.fetchWidgetPage("created-access-key-modal.html")));new X((()=>{var e;return null===(e=this.createdAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.createdAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.createdAccessKeyModal.ele),this.createdAccessKeyModal.close()}))}))},a})),To=u((e=>{var t,a,c,l,d;return d=class extends(r(ko,re,hn,y,Io,Ro)(e)){constructor(){super(...arguments),t.add(this),a.set(this,void 0),l.set(this,(()=>n(this,void 0,void 0,(function*(){var e,t;yield s(this,a,"f").setData(null===(t=this.state,e=t.tenantRoles.data||[])||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),s(this,t,"m",c).call(this)}))}},a=new WeakMap,l=new WeakMap,t=new WeakSet,c=function e(){return n(this,void 0,void 0,(function*(){this.createAccessKeyModal=this.createModal(),this.createAccessKeyModal.setContent(o(yield this.fetchWidgetPage("create-access-key-modal.html")));new X((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.createAccessKeyModal.close(),this.resetFormData(this.createAccessKeyModal.ele)}));new X((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>n(this,void 0,void 0,(function*(){var e,t;if(this.validateForm(this.createAccessKeyModal.ele)){const n=yield this.actions.createAccessKey(Object.assign({},this.getFormData(this.createAccessKeyModal.ele)));this.createAccessKeyModal.close(),(null===(e=null==n?void 0:n.payload)||void 0===e?void 0:e.cleartext)&&(this.setFormData(this.createdAccessKeyModal.ele,{"generated-key":null===(t=null==n?void 0:n.payload)||void 0===t?void 0:t.cleartext}),this.createdAccessKeyModal.open())}})))),i(this,a,new te((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),s(this,l,"f").call(this),this.createAccessKeyModal.afterClose=()=>{s(this,t,"m",e).call(this)}}))},d})),Oo=u((e=>{var t,i,o;return o=class extends(r(y,To,Io)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),s(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.createButton=new X(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-access-key"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createAccessKeyModal.open()))},o})),jo=u((e=>{var t,i,a;return a=class extends(r(ko,re,y,Io)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield s(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){var e;this.deactivateAccessKeysModal=this.createModal(),this.deactivateAccessKeysModal.setContent(o(yield this.fetchWidgetPage("deactivate-access-keys-modal.html")));const t=new X((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deactivateAccessKeysModal.close()));const n=new X((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=wn(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const s=new se(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=bn(this.state);s.text=`Deactivate ${e}?`}}))},a})),Ao=u((e=>{var t,i,o,a;return a=class extends(r(y,Io,ko,jo)(e)){constructor(){super(...arguments),t.add(this),o.set(this,c((e=>{e?this.deactivateButton.enable():this.deactivateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),s(this,t,"m",i).call(this),this.subscribe(s(this,o,"f").bind(this),_n)}))}},o=new WeakMap,t=new WeakSet,i=function(){var e;this.deactivateButton=new X(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="deactivate-access-keys"]'),{logger:this.logger}),this.deactivateButton.disable(),this.deactivateButton.onClick((()=>{this.deactivateAccessKeysModal.open()}))},a})),Po=u((e=>{var t,i,a;return a=class extends(r(ko,re,y,Io)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield s(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){var e;this.deleteAccessKeysModal=this.createModal(),this.deleteAccessKeysModal.setContent(o(yield this.fetchWidgetPage("delete-access-keys-modal.html")));const t=new X((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteAccessKeysModal.close()));const n=new X((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=wn(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const s=new se(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=bn(this.state);s.text=`Delete ${e}?`}}))},a})),Uo=u((e=>{var t,i,o,a;return a=class extends(r(y,Io,ko,Po)(e)){constructor(){super(...arguments),t.add(this),o.set(this,c((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),s(this,t,"m",i).call(this),this.subscribe(s(this,o,"f").bind(this),_n)}))}},o=new WeakMap,t=new WeakSet,i=function(){var e;this.deleteButton=new X(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-access-keys"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteAccessKeysModal.open()}))},a})),Mo=u((e=>{var t,i,o,a;return a=class extends(r(y,Io,ko)(e)){constructor(){super(...arguments),t.add(this),i.set(this,d((()=>{this.actions.searchAccessKeys({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),s(this,t,"m",o).call(this)}))}},i=new WeakMap,t=new WeakSet,o=function(){var e;this.searchInput=new ie(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(s(this,i,"f"))},a}));const $o={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},No=u((e=>{var t,i,o,a,l;return l=class extends(r(y,ko,ae,S)(e)){constructor(){super(...arguments),t.add(this),a.set(this,c((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const r=s(this,t,"m",o).call(this,e);r.setContent(s(this,t,"m",i).call(this,{type:e,msg:n})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(s(this,a,"f").bind(this),fn)}))}},a=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const n=$o[e],s=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${s.outerHTML}`},o=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},l})),qo=u((e=>class extends(r(P,le,xo,Oo,Uo,Mo,Co,Ao,No)(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)}))}})),Do=r((e=>class extends(qo(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",Do);const Wo=(e,t,n,s={})=>{var i,r,o,a;return[Math.min(Math.max(t,("all"===s.left?e.offsetWidth:null!==(i=s.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(r=s.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===s.top?e.offsetHeight:null!==(o=s.top)&&void 0!==o?o:0)-e.offsetHeight),window.innerHeight-("all"===s.bottom?e.offsetHeight:null!==(a=s.bottom)&&void 0!==a?a:0))]};var Lo,Ko,Fo,Ho,zo,Jo,Bo,Vo,Zo,Go;const Yo=document.createElement("template");Yo.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`;class Xo extends HTMLElement{constructor(){var e,t,n;super(),Lo.add(this),Ko.set(this,new w({messages:[]})),Fo.set(this,void 0),Ho.set(this,void 0),zo.set(this,void 0),Jo.set(this,{resize:s(this,Lo,"m",Go).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Yo.content.cloneNode(!0));const r=new CSSStyleSheet;r.replaceSync('\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'),null!==(t=(n=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(n.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],i(this,Fo,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Ho,s(this,Fo,"f").querySelector(".content"),"f"),i(this,zo,s(this,Fo,"f").querySelector(".header"),"f")}updateData(e){s(this,Ko,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let s=0,i=0,r=0,o=0;function a(t){t.preventDefault(),s=r-t.clientX,i=o-t.clientY,r=t.clientX,o=t.clientY;const[a,c]=Wo(e,e.offsetLeft-s,e.offsetTop-i,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,o=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(s(this,Fo,"f"),s(this,zo,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",s(this,Jo,"f").resize),(e=s(this,Fo,"f")).onmousemove=t=>{var n;const s=t.target;(s.w&&s.w!==s.offsetWidth||s.h&&s.h!==s.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),s.w=s.offsetWidth,s.h=s.offsetHeight},s(this,Fo,"f").onresize=s(this,Lo,"m",Zo).bind(this),s(this,Ko,"f").subscribe(s(this,Lo,"m",Bo).bind(this))}disconnectedCallback(){s(this,Ko,"f").unsubscribeAll(),window.removeEventListener("resize",s(this,Jo,"f").resize)}}Ko=new WeakMap,Fo=new WeakMap,Ho=new WeakMap,zo=new WeakMap,Jo=new WeakMap,Lo=new WeakSet,Bo=function(e){s(this,Lo,"m",Vo).call(this,e),s(this,Lo,"m",Zo).call(this)},Vo=function(e){s(this,Ho,"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("")},Zo=function(){s(this,Ho,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),s=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;s||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Go=function(){const[e,t]=Wo(s(this,Fo,"f"),Number.parseInt(s(this,Fo,"f").style.left,10),Number.parseInt(s(this,Fo,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});s(this,Fo,"f").style.top=`${t}px`,s(this,Fo,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Xo);var Qo,ea,ta,na=Object.freeze({__proto__:null,default:Xo}),sa={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},ia=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(ia||{});(ta=ia||(ia={})).reset=function(){Qo=3,ea=sa},ta.setLevel=function(e){if(!(0<=e&&e<=4))throw new Error("Invalid log level");Qo=e},ta.setLogger=function(e){ea=e};var ra=class e{constructor(e){this._name=e}debug(...t){Qo>=4&&ea.debug(e._format(this._name,this._method),...t)}info(...t){Qo>=3&&ea.info(e._format(this._name,this._method),...t)}warn(...t){Qo>=2&&ea.warn(e._format(this._name,this._method),...t)}error(...t){Qo>=1&&ea.error(e._format(this._name,this._method),...t)}throw(e){throw this.error(e),e}create(e){const t=Object.create(this);return t._method=e,t.debug("begin"),t}static createStatic(t,n){const s=new e(`${t}.${n}`);return s.debug("begin"),s}static _format(e,t){const n=`[${e}]`;return t?`${n} ${t}:`:n}static debug(t,...n){Qo>=4&&ea.debug(e._format(t),...n)}static info(t,...n){Qo>=3&&ea.info(e._format(t),...n)}static warn(t,...n){Qo>=2&&ea.warn(e._format(t),...n)}static error(t,...n){Qo>=1&&ea.error(e._format(t),...n)}};ia.reset();var oa=class{static decode(e){try{return zn(e)}catch(e){throw ra.error("JwtUtils.decode",e),e}}static async generateSignedJwt(e,t,n){const s=`${la.encodeBase64Url((new TextEncoder).encode(JSON.stringify(e)))}.${la.encodeBase64Url((new TextEncoder).encode(JSON.stringify(t)))}`,i=await window.crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,(new TextEncoder).encode(s));return`${s}.${la.encodeBase64Url(new Uint8Array(i))}`}},aa=e=>btoa([...new Uint8Array(e)].map((e=>String.fromCharCode(e))).join("")),ca=class e{static _randomWord(){const e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}static generateUUIDv4(){const t="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(t=>(+t^e._randomWord()&15>>+t/4).toString(16)));return t.replace(/-/g,"")}static generateCodeVerifier(){return e.generateUUIDv4()+e.generateUUIDv4()+e.generateUUIDv4()}static async generateCodeChallenge(e){if(!crypto.subtle)throw new Error("Crypto.subtle is available only in secure contexts (HTTPS).");try{const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return aa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(e){throw ra.error("CryptoUtils.generateCodeChallenge",e),e}}static generateBasicAuth(e,t){const n=(new TextEncoder).encode([e,t].join(":"));return aa(n)}static async hash(e,t){const n=(new TextEncoder).encode(t),s=await crypto.subtle.digest(e,n);return new Uint8Array(s)}static async customCalculateJwkThumbprint(t){let n;switch(t.kty){case"RSA":n={e:t.e,kty:t.kty,n:t.n};break;case"EC":n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case"OKP":n={crv:t.crv,kty:t.kty,x:t.x};break;case"oct":n={crv:t.k,kty:t.kty};break;default:throw new Error("Unknown jwk type")}const s=await e.hash("SHA-256",JSON.stringify(n));return e.encodeBase64Url(s)}static async generateDPoPProof({url:t,accessToken:n,httpMethod:s,keyPair:i,nonce:r}){let o,a;const c={jti:window.crypto.randomUUID(),htm:null!=s?s:"GET",htu:t,iat:Math.floor(Date.now()/1e3)};n&&(o=await e.hash("SHA-256",n),a=e.encodeBase64Url(o),c.ath=a),r&&(c.nonce=r);try{const e=await crypto.subtle.exportKey("jwk",i.publicKey),t={alg:"ES256",typ:"dpop+jwt",jwk:{crv:e.crv,kty:e.kty,x:e.x,y:e.y}};return await oa.generateSignedJwt(t,c,i.privateKey)}catch(e){throw e instanceof TypeError?new Error(`Error exporting dpop public key: ${e.message}`):e}}static async generateDPoPJkt(t){try{const n=await crypto.subtle.exportKey("jwk",t.publicKey);return await e.customCalculateJwkThumbprint(n)}catch(e){throw e instanceof TypeError?new Error(`Could not retrieve dpop keys from storage: ${e.message}`):e}}static async generateDPoPKeys(){return await window.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign","verify"])}};ca.encodeBase64Url=e=>aa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var la=ca,da=class{constructor(e){this._name=e,this._callbacks=[],this._logger=new ra(`Event('${this._name}')`)}addHandler(e){return this._callbacks.push(e),()=>this.removeHandler(e)}removeHandler(e){const t=this._callbacks.lastIndexOf(e);t>=0&&this._callbacks.splice(t,1)}async raise(...e){this._logger.debug("raise:",...e);for(const t of this._callbacks)await t(...e)}},ua=class{static center({...e}){var t;return null==e.width&&(e.width=null!=(t=[800,720,600,480].find((e=>e<=window.outerWidth/1.618)))?t:360),null!=e.left||(e.left=Math.max(0,Math.round(window.screenX+(window.outerWidth-e.width)/2))),null!=e.height&&(null!=e.top||(e.top=Math.max(0,Math.round(window.screenY+(window.outerHeight-e.height)/2)))),e}static serialize(e){return Object.entries(e).filter((([,e])=>null!=e)).map((([e,t])=>`${e}=${"boolean"!=typeof t?t:t?"yes":"no"}`)).join(",")}},ha=class e extends da{constructor(){super(...arguments),this._logger=new ra(`Timer('${this._name}')`),this._timerHandle=null,this._expiration=0,this._callback=()=>{const t=this._expiration-e.getEpochTime();this._logger.debug("timer completes in",t),this._expiration<=e.getEpochTime()&&(this.cancel(),super.raise())}}static getEpochTime(){return Math.floor(Date.now()/1e3)}init(t){const n=this._logger.create("init");t=Math.max(Math.floor(t),1);const s=e.getEpochTime()+t;if(this.expiration===s&&this._timerHandle)return void n.debug("skipping since already initialized for expiration at",this.expiration);this.cancel(),n.debug("using duration",t),this._expiration=s;const i=Math.min(t,5);this._timerHandle=setInterval(this._callback,1e3*i)}get expiration(){return this._expiration}cancel(){this._logger.create("cancel"),this._timerHandle&&(clearInterval(this._timerHandle),this._timerHandle=null)}},pa=class{static readParams(e,t="query"){if(!e)throw new TypeError("Invalid URL");const n=new URL(e,"http://127.0.0.1")["fragment"===t?"hash":"search"];return new URLSearchParams(n.slice(1))}},ga=";",fa=class extends Error{constructor(e,t){var n,s,i;if(super(e.error_description||e.error||""),this.form=t,this.name="ErrorResponse",!e.error)throw ra.error("ErrorResponse","No error passed"),new Error("No error passed");this.error=e.error,this.error_description=null!=(n=e.error_description)?n:null,this.error_uri=null!=(s=e.error_uri)?s:null,this.state=e.userState,this.session_state=null!=(i=e.session_state)?i:null,this.url_state=e.url_state}},ma=class extends Error{constructor(e){super(e),this.name="ErrorTimeout"}},wa=class{constructor(e){this._logger=new ra("AccessTokenEvents"),this._expiringTimer=new ha("Access token expiring"),this._expiredTimer=new ha("Access token expired"),this._expiringNotificationTimeInSeconds=e.expiringNotificationTimeInSeconds}async load(e){const t=this._logger.create("load");if(e.access_token&&void 0!==e.expires_in){const n=e.expires_in;if(t.debug("access token present, remaining duration:",n),n>0){let e=n-this._expiringNotificationTimeInSeconds;e<=0&&(e=1),t.debug("registering expiring timer, raising in",e,"seconds"),this._expiringTimer.init(e)}else t.debug("canceling existing expiring timer because we're past expiration."),this._expiringTimer.cancel();const s=n+1;t.debug("registering expired timer, raising in",s,"seconds"),this._expiredTimer.init(s)}else this._expiringTimer.cancel(),this._expiredTimer.cancel()}async unload(){this._logger.debug("unload: canceling existing access token timers"),this._expiringTimer.cancel(),this._expiredTimer.cancel()}addAccessTokenExpiring(e){return this._expiringTimer.addHandler(e)}removeAccessTokenExpiring(e){this._expiringTimer.removeHandler(e)}addAccessTokenExpired(e){return this._expiredTimer.addHandler(e)}removeAccessTokenExpired(e){this._expiredTimer.removeHandler(e)}},va=class{constructor(e,t,n,s,i){this._callback=e,this._client_id=t,this._intervalInSeconds=s,this._stopOnError=i,this._logger=new ra("CheckSessionIFrame"),this._timer=null,this._session_state=null,this._message=e=>{e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&("error"===e.data?(this._logger.error("error message from check session op iframe"),this._stopOnError&&this.stop()):"changed"===e.data?(this._logger.debug("changed message from check session op iframe"),this.stop(),this._callback()):this._logger.debug(e.data+" message from check session op iframe"))};const r=new URL(n);this._frame_origin=r.origin,this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="fixed",this._frame.style.left="-1000px",this._frame.style.top="0",this._frame.width="0",this._frame.height="0",this._frame.src=r.href}load(){return new Promise((e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),window.addEventListener("message",this._message,!1)}))}start(e){if(this._session_state===e)return;this._logger.create("start"),this.stop(),this._session_state=e;const t=()=>{this._frame.contentWindow&&this._session_state&&this._frame.contentWindow.postMessage(this._client_id+" "+this._session_state,this._frame_origin)};t(),this._timer=setInterval(t,1e3*this._intervalInSeconds)}stop(){this._logger.create("stop"),this._session_state=null,this._timer&&(clearInterval(this._timer),this._timer=null)}},ya=class{constructor(){this._logger=new ra("InMemoryWebStorage"),this._data={}}clear(){this._logger.create("clear"),this._data={}}getItem(e){return this._logger.create(`getItem('${e}')`),this._data[e]}setItem(e,t){this._logger.create(`setItem('${e}')`),this._data[e]=t}removeItem(e){this._logger.create(`removeItem('${e}')`),delete this._data[e]}get length(){return Object.getOwnPropertyNames(this._data).length}key(e){return Object.getOwnPropertyNames(this._data)[e]}},_a=class extends Error{constructor(e,t){super(t),this.name="ErrorDPoPNonce",this.nonce=e}},ba=class{constructor(e=[],t=null,n={}){this._jwtHandler=t,this._extraHeaders=n,this._logger=new ra("JsonService"),this._contentTypes=[],this._contentTypes.push(...e,"application/json"),t&&this._contentTypes.push("application/jwt")}async fetchWithTimeout(e,t={}){const{timeoutInSeconds:n,...s}=t;if(!n)return await fetch(e,s);const i=new AbortController,r=setTimeout((()=>i.abort()),1e3*n);try{return await fetch(e,{...t,signal:i.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw new ma("Network timed out");throw e}finally{clearTimeout(r)}}async getJson(e,{token:t,credentials:n,timeoutInSeconds:s}={}){const i=this._logger.create("getJson"),r={Accept:this._contentTypes.join(", ")};let o;t&&(i.debug("token passed, setting Authorization header"),r.Authorization="Bearer "+t),this._appendExtraHeaders(r);try{i.debug("url:",e),o=await this.fetchWithTimeout(e,{method:"GET",headers:r,timeoutInSeconds:s,credentials:n})}catch(e){throw i.error("Network Error"),e}i.debug("HTTP response received, status",o.status);const a=o.headers.get("Content-Type");if(a&&!this._contentTypes.find((e=>a.startsWith(e)))&&i.throw(new Error(`Invalid response Content-Type: ${null!=a?a:"undefined"}, from URL: ${e}`)),o.ok&&this._jwtHandler&&(null==a?void 0:a.startsWith("application/jwt")))return await this._jwtHandler(await o.text());let c;try{c=await o.json()}catch(e){if(i.error("Error parsing JSON response",e),o.ok)throw e;throw new Error(`${o.statusText} (${o.status})`)}if(!o.ok){if(i.error("Error from server:",c),c.error)throw new fa(c);throw new Error(`${o.statusText} (${o.status}): ${JSON.stringify(c)}`)}return c}async postForm(e,{body:t,basicAuth:n,timeoutInSeconds:s,initCredentials:i,extraHeaders:r}){const o=this._logger.create("postForm"),a={Accept:this._contentTypes.join(", "),"Content-Type":"application/x-www-form-urlencoded",...r};let c;void 0!==n&&(a.Authorization="Basic "+n),this._appendExtraHeaders(a);try{o.debug("url:",e),c=await this.fetchWithTimeout(e,{method:"POST",headers:a,body:t,timeoutInSeconds:s,credentials:i})}catch(e){throw o.error("Network error"),e}o.debug("HTTP response received, status",c.status);const l=c.headers.get("Content-Type");if(l&&!this._contentTypes.find((e=>l.startsWith(e))))throw new Error(`Invalid response Content-Type: ${null!=l?l:"undefined"}, from URL: ${e}`);const d=await c.text();let u={};if(d)try{u=JSON.parse(d)}catch(e){if(o.error("Error parsing JSON response",e),c.ok)throw e;throw new Error(`${c.statusText} (${c.status})`)}if(!c.ok){if(o.error("Error from server:",u),c.headers.has("dpop-nonce")){const e=c.headers.get("dpop-nonce");throw new _a(e,`${JSON.stringify(u)}`)}if(u.error)throw new fa(u,t);throw new Error(`${c.statusText} (${c.status}): ${JSON.stringify(u)}`)}return u}_appendExtraHeaders(e){const t=this._logger.create("appendExtraHeaders"),n=Object.keys(this._extraHeaders),s=["accept","content-type"],i=["authorization"];0!==n.length&&n.forEach((n=>{if(s.includes(n.toLocaleLowerCase()))return void t.warn("Protected header could not be set",n,s);if(i.includes(n.toLocaleLowerCase())&&Object.keys(e).includes(n))return void t.warn("Header could not be overridden",n,i);const r="function"==typeof this._extraHeaders[n]?this._extraHeaders[n]():this._extraHeaders[n];r&&""!==r&&(e[n]=r)}))}},ka=class{constructor(e){this._settings=e,this._logger=new ra("MetadataService"),this._signingKeys=null,this._metadata=null,this._metadataUrl=this._settings.metadataUrl,this._jsonService=new ba(["application/jwk-set+json"],null,this._settings.extraHeaders),this._settings.signingKeys&&(this._logger.debug("using signingKeys from settings"),this._signingKeys=this._settings.signingKeys),this._settings.metadata&&(this._logger.debug("using metadata from settings"),this._metadata=this._settings.metadata),this._settings.fetchRequestCredentials&&(this._logger.debug("using fetchRequestCredentials from settings"),this._fetchRequestCredentials=this._settings.fetchRequestCredentials)}resetSigningKeys(){this._signingKeys=null}async getMetadata(){const e=this._logger.create("getMetadata");if(this._metadata)return e.debug("using cached values"),this._metadata;if(!this._metadataUrl)throw e.throw(new Error("No authority or metadataUrl configured on settings")),null;e.debug("getting metadata from",this._metadataUrl);const t=await this._jsonService.getJson(this._metadataUrl,{credentials:this._fetchRequestCredentials,timeoutInSeconds:this._settings.requestTimeoutInSeconds});return e.debug("merging remote JSON with seed metadata"),this._metadata=Object.assign({},t,this._settings.metadataSeed),this._metadata}getIssuer(){return this._getMetadataProperty("issuer")}getAuthorizationEndpoint(){return this._getMetadataProperty("authorization_endpoint")}getUserInfoEndpoint(){return this._getMetadataProperty("userinfo_endpoint")}getTokenEndpoint(e=!0){return this._getMetadataProperty("token_endpoint",e)}getCheckSessionIframe(){return this._getMetadataProperty("check_session_iframe",!0)}getEndSessionEndpoint(){return this._getMetadataProperty("end_session_endpoint",!0)}getRevocationEndpoint(e=!0){return this._getMetadataProperty("revocation_endpoint",e)}getKeysEndpoint(e=!0){return this._getMetadataProperty("jwks_uri",e)}async _getMetadataProperty(e,t=!1){const n=this._logger.create(`_getMetadataProperty('${e}')`),s=await this.getMetadata();if(n.debug("resolved"),void 0===s[e]){if(!0===t)return void n.warn("Metadata does not contain optional property");n.throw(new Error("Metadata does not contain property "+e))}return s[e]}async getSigningKeys(){const e=this._logger.create("getSigningKeys");if(this._signingKeys)return e.debug("returning signingKeys from cache"),this._signingKeys;const t=await this.getKeysEndpoint(!1);e.debug("got jwks_uri",t);const n=await this._jsonService.getJson(t,{timeoutInSeconds:this._settings.requestTimeoutInSeconds});if(e.debug("got key set",n),!Array.isArray(n.keys))throw e.throw(new Error("Missing keys on keyset")),null;return this._signingKeys=n.keys,this._signingKeys}},Sa=class{constructor({prefix:e="oidc.",store:t=localStorage}={}){this._logger=new ra("WebStorageStateStore"),this._store=t,this._prefix=e}async set(e,t){this._logger.create(`set('${e}')`),e=this._prefix+e,await this._store.setItem(e,t)}async get(e){this._logger.create(`get('${e}')`),e=this._prefix+e;return await this._store.getItem(e)}async remove(e){this._logger.create(`remove('${e}')`),e=this._prefix+e;const t=await this._store.getItem(e);return await this._store.removeItem(e),t}async getAllKeys(){this._logger.create("getAllKeys");const e=await this._store.length,t=[];for(let n=0;n<e;n++){const e=await this._store.key(n);e&&0===e.indexOf(this._prefix)&&t.push(e.substr(this._prefix.length))}return t}},Ia=class{constructor({authority:e,metadataUrl:t,metadata:n,signingKeys:s,metadataSeed:i,client_id:r,client_secret:o,response_type:a="code",scope:c="openid",redirect_uri:l,post_logout_redirect_uri:d,client_authentication:u="client_secret_post",prompt:h,display:p,max_age:g,ui_locales:f,acr_values:m,resource:w,response_mode:v,filterProtocolClaims:y=!0,loadUserInfo:_=!1,requestTimeoutInSeconds:b,staleStateAgeInSeconds:k=900,mergeClaimsStrategy:S={array:"replace"},disablePKCE:I=!1,stateStore:x,revokeTokenAdditionalContentTypes:E,fetchRequestCredentials:C,refreshTokenAllowedScope:R,extraQueryParams:T={},extraTokenParams:O={},extraHeaders:j={},dpop:A,omitScopeWhenRequesting:P=!1}){var U;if(this.authority=e,t?this.metadataUrl=t:(this.metadataUrl=e,e&&(this.metadataUrl.endsWith("/")||(this.metadataUrl+="/"),this.metadataUrl+=".well-known/openid-configuration")),this.metadata=n,this.metadataSeed=i,this.signingKeys=s,this.client_id=r,this.client_secret=o,this.response_type=a,this.scope=c,this.redirect_uri=l,this.post_logout_redirect_uri=d,this.client_authentication=u,this.prompt=h,this.display=p,this.max_age=g,this.ui_locales=f,this.acr_values=m,this.resource=w,this.response_mode=v,this.filterProtocolClaims=null==y||y,this.loadUserInfo=!!_,this.staleStateAgeInSeconds=k,this.mergeClaimsStrategy=S,this.omitScopeWhenRequesting=P,this.disablePKCE=!!I,this.revokeTokenAdditionalContentTypes=E,this.fetchRequestCredentials=C||"same-origin",this.requestTimeoutInSeconds=b,x)this.stateStore=x;else{const e="undefined"!=typeof window?window.localStorage:new ya;this.stateStore=new Sa({store:e})}if(this.refreshTokenAllowedScope=R,this.extraQueryParams=T,this.extraTokenParams=O,this.extraHeaders=j,this.dpop=A,this.dpop&&!(null==(U=this.dpop)?void 0:U.store))throw new Error("A DPoPStore is required when dpop is enabled")}},xa=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new ra("UserInfoService"),this._getClaimsFromJwt=async e=>{const t=this._logger.create("_getClaimsFromJwt");try{const n=oa.decode(e);return t.debug("JWT decoding successful"),n}catch(e){throw t.error("Error parsing JWT response"),e}},this._jsonService=new ba(void 0,this._getClaimsFromJwt,this._settings.extraHeaders)}async getClaims(e){const t=this._logger.create("getClaims");e||this._logger.throw(new Error("No token passed"));const n=await this._metadataService.getUserInfoEndpoint();t.debug("got userinfo url",n);const s=await this._jsonService.getJson(n,{token:e,credentials:this._settings.fetchRequestCredentials,timeoutInSeconds:this._settings.requestTimeoutInSeconds});return t.debug("got claims",s),s}},Ea=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new ra("TokenClient"),this._jsonService=new ba(this._settings.revokeTokenAdditionalContentTypes,null,this._settings.extraHeaders)}async exchangeCode({grant_type:e="authorization_code",redirect_uri:t=this._settings.redirect_uri,client_id:n=this._settings.client_id,client_secret:s=this._settings.client_secret,extraHeaders:i,...r}){const o=this._logger.create("exchangeCode");n||o.throw(new Error("A client_id is required")),t||o.throw(new Error("A redirect_uri is required")),r.code||o.throw(new Error("A code is required"));const a=new URLSearchParams({grant_type:e,redirect_uri:t});for(const[e,t]of Object.entries(r))null!=t&&a.set(e,t);let c;switch(this._settings.client_authentication){case"client_secret_basic":if(null==s)throw o.throw(new Error("A client_secret is required")),null;c=la.generateBasicAuth(n,s);break;case"client_secret_post":a.append("client_id",n),s&&a.append("client_secret",s)}const l=await this._metadataService.getTokenEndpoint(!1);o.debug("got token endpoint");const d=await this._jsonService.postForm(l,{body:a,basicAuth:c,timeoutInSeconds:this._settings.requestTimeoutInSeconds,initCredentials:this._settings.fetchRequestCredentials,extraHeaders:i});return o.debug("got response"),d}async exchangeCredentials({grant_type:e="password",client_id:t=this._settings.client_id,client_secret:n=this._settings.client_secret,scope:s=this._settings.scope,...i}){const r=this._logger.create("exchangeCredentials");t||r.throw(new Error("A client_id is required"));const o=new URLSearchParams({grant_type:e});this._settings.omitScopeWhenRequesting||o.set("scope",s);for(const[e,t]of Object.entries(i))null!=t&&o.set(e,t);let a;switch(this._settings.client_authentication){case"client_secret_basic":if(null==n)throw r.throw(new Error("A client_secret is required")),null;a=la.generateBasicAuth(t,n);break;case"client_secret_post":o.append("client_id",t),n&&o.append("client_secret",n)}const c=await this._metadataService.getTokenEndpoint(!1);r.debug("got token endpoint");const l=await this._jsonService.postForm(c,{body:o,basicAuth:a,timeoutInSeconds:this._settings.requestTimeoutInSeconds,initCredentials:this._settings.fetchRequestCredentials});return r.debug("got response"),l}async exchangeRefreshToken({grant_type:e="refresh_token",client_id:t=this._settings.client_id,client_secret:n=this._settings.client_secret,timeoutInSeconds:s,extraHeaders:i,...r}){const o=this._logger.create("exchangeRefreshToken");t||o.throw(new Error("A client_id is required")),r.refresh_token||o.throw(new Error("A refresh_token is required"));const a=new URLSearchParams({grant_type:e});for(const[e,t]of Object.entries(r))Array.isArray(t)?t.forEach((t=>a.append(e,t))):null!=t&&a.set(e,t);let c;switch(this._settings.client_authentication){case"client_secret_basic":if(null==n)throw o.throw(new Error("A client_secret is required")),null;c=la.generateBasicAuth(t,n);break;case"client_secret_post":a.append("client_id",t),n&&a.append("client_secret",n)}const l=await this._metadataService.getTokenEndpoint(!1);o.debug("got token endpoint");const d=await this._jsonService.postForm(l,{body:a,basicAuth:c,timeoutInSeconds:s,initCredentials:this._settings.fetchRequestCredentials,extraHeaders:i});return o.debug("got response"),d}async revoke(e){var t;const n=this._logger.create("revoke");e.token||n.throw(new Error("A token is required"));const s=await this._metadataService.getRevocationEndpoint(!1);n.debug(`got revocation endpoint, revoking ${null!=(t=e.token_type_hint)?t:"default token type"}`);const i=new URLSearchParams;for(const[t,n]of Object.entries(e))null!=n&&i.set(t,n);i.set("client_id",this._settings.client_id),this._settings.client_secret&&i.set("client_secret",this._settings.client_secret),await this._jsonService.postForm(s,{body:i,timeoutInSeconds:this._settings.requestTimeoutInSeconds}),n.debug("got response")}},Ca=class{constructor(e,t,n){this._settings=e,this._metadataService=t,this._claimsService=n,this._logger=new ra("ResponseValidator"),this._userInfoService=new xa(this._settings,this._metadataService),this._tokenClient=new Ea(this._settings,this._metadataService)}async validateSigninResponse(e,t,n){const s=this._logger.create("validateSigninResponse");this._processSigninState(e,t),s.debug("state processed"),await this._processCode(e,t,n),s.debug("code processed"),e.isOpenId&&this._validateIdTokenAttributes(e),s.debug("tokens validated"),await this._processClaims(e,null==t?void 0:t.skipUserInfo,e.isOpenId),s.debug("claims processed")}async validateCredentialsResponse(e,t){const n=this._logger.create("validateCredentialsResponse");e.isOpenId&&e.id_token&&this._validateIdTokenAttributes(e),n.debug("tokens validated"),await this._processClaims(e,t,e.isOpenId),n.debug("claims processed")}async validateRefreshResponse(e,t){const n=this._logger.create("validateRefreshResponse");e.userState=t.data,null!=e.session_state||(e.session_state=t.session_state),null!=e.scope||(e.scope=t.scope),e.isOpenId&&e.id_token&&(this._validateIdTokenAttributes(e,t.id_token),n.debug("ID Token validated")),e.id_token||(e.id_token=t.id_token,e.profile=t.profile);const s=e.isOpenId&&!!e.id_token;await this._processClaims(e,!1,s),n.debug("claims processed")}validateSignoutResponse(e,t){const n=this._logger.create("validateSignoutResponse");if(t.id!==e.state&&n.throw(new Error("State does not match")),n.debug("state validated"),e.userState=t.data,e.error)throw n.warn("Response was error",e.error),new fa(e)}_processSigninState(e,t){const n=this._logger.create("_processSigninState");if(t.id!==e.state&&n.throw(new Error("State does not match")),t.client_id||n.throw(new Error("No client_id on state")),t.authority||n.throw(new Error("No authority on state")),this._settings.authority!==t.authority&&n.throw(new Error("authority mismatch on settings vs. signin state")),this._settings.client_id&&this._settings.client_id!==t.client_id&&n.throw(new Error("client_id mismatch on settings vs. signin state")),n.debug("state validated"),e.userState=t.data,e.url_state=t.url_state,null!=e.scope||(e.scope=t.scope),e.error)throw n.warn("Response was error",e.error),new fa(e);t.code_verifier&&!e.code&&n.throw(new Error("Expected code in response"))}async _processClaims(e,t=!1,n=!0){const s=this._logger.create("_processClaims");if(e.profile=this._claimsService.filterProtocolClaims(e.profile),t||!this._settings.loadUserInfo||!e.access_token)return void s.debug("not loading user info");s.debug("loading user info");const i=await this._userInfoService.getClaims(e.access_token);s.debug("user info claims received from user info endpoint"),n&&i.sub!==e.profile.sub&&s.throw(new Error("subject from UserInfo response does not match subject in ID Token")),e.profile=this._claimsService.mergeClaims(e.profile,this._claimsService.filterProtocolClaims(i)),s.debug("user info claims received, updated profile:",e.profile)}async _processCode(e,t,n){const s=this._logger.create("_processCode");if(e.code){s.debug("Validating code");const i=await this._tokenClient.exchangeCode({client_id:t.client_id,client_secret:t.client_secret,code:e.code,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier,extraHeaders:n,...t.extraTokenParams});Object.assign(e,i)}else s.debug("No code to process")}_validateIdTokenAttributes(e,t){var n;const s=this._logger.create("_validateIdTokenAttributes");s.debug("decoding ID Token JWT");const i=oa.decode(null!=(n=e.id_token)?n:"");if(i.sub||s.throw(new Error("ID Token is missing a subject claim")),t){const e=oa.decode(t);i.sub!==e.sub&&s.throw(new Error("sub in id_token does not match current sub")),i.auth_time&&i.auth_time!==e.auth_time&&s.throw(new Error("auth_time in id_token does not match original auth_time")),i.azp&&i.azp!==e.azp&&s.throw(new Error("azp in id_token does not match original azp")),!i.azp&&e.azp&&s.throw(new Error("azp not in id_token, but present in original id_token"))}e.profile=i}},Ra=class e{constructor(e){this.id=e.id||la.generateUUIDv4(),this.data=e.data,e.created&&e.created>0?this.created=e.created:this.created=ha.getEpochTime(),this.request_type=e.request_type,this.url_state=e.url_state}toStorageString(){return new ra("State").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,url_state:this.url_state})}static fromStorageString(t){return ra.createStatic("State","fromStorageString"),Promise.resolve(new e(JSON.parse(t)))}static async clearStaleState(t,n){const s=ra.createStatic("State","clearStaleState"),i=ha.getEpochTime()-n,r=await t.getAllKeys();s.debug("got keys",r);for(let n=0;n<r.length;n++){const o=r[n],a=await t.get(o);let c=!1;if(a)try{const t=await e.fromStorageString(a);s.debug("got item from key:",o,t.created),t.created<=i&&(c=!0)}catch(e){s.error("Error parsing state for key:",o,e),c=!0}else s.debug("no item in storage for key:",o),c=!0;c&&(s.debug("removed item for key:",o),t.remove(o))}}},Ta=class e extends Ra{constructor(e){super(e),this.code_verifier=e.code_verifier,this.code_challenge=e.code_challenge,this.authority=e.authority,this.client_id=e.client_id,this.redirect_uri=e.redirect_uri,this.scope=e.scope,this.client_secret=e.client_secret,this.extraTokenParams=e.extraTokenParams,this.response_mode=e.response_mode,this.skipUserInfo=e.skipUserInfo}static async create(t){const n=!0===t.code_verifier?la.generateCodeVerifier():t.code_verifier||void 0,s=n?await la.generateCodeChallenge(n):void 0;return new e({...t,code_verifier:n,code_challenge:s})}toStorageString(){return new ra("SigninState").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,url_state:this.url_state,code_verifier:this.code_verifier,authority:this.authority,client_id:this.client_id,redirect_uri:this.redirect_uri,scope:this.scope,client_secret:this.client_secret,extraTokenParams:this.extraTokenParams,response_mode:this.response_mode,skipUserInfo:this.skipUserInfo})}static fromStorageString(t){ra.createStatic("SigninState","fromStorageString");const n=JSON.parse(t);return e.create(n)}},Oa=class e{constructor(e){this.url=e.url,this.state=e.state}static async create({url:t,authority:n,client_id:s,redirect_uri:i,response_type:r,scope:o,state_data:a,response_mode:c,request_type:l,client_secret:d,nonce:u,url_state:h,resource:p,skipUserInfo:g,extraQueryParams:f,extraTokenParams:m,disablePKCE:w,dpopJkt:v,omitScopeWhenRequesting:y,..._}){if(!t)throw this._logger.error("create: No url passed"),new Error("url");if(!s)throw this._logger.error("create: No client_id passed"),new Error("client_id");if(!i)throw this._logger.error("create: No redirect_uri passed"),new Error("redirect_uri");if(!r)throw this._logger.error("create: No response_type passed"),new Error("response_type");if(!o)throw this._logger.error("create: No scope passed"),new Error("scope");if(!n)throw this._logger.error("create: No authority passed"),new Error("authority");const b=await Ta.create({data:a,request_type:l,url_state:h,code_verifier:!w,client_id:s,authority:n,redirect_uri:i,response_mode:c,client_secret:d,scope:o,extraTokenParams:m,skipUserInfo:g}),k=new URL(t);k.searchParams.append("client_id",s),k.searchParams.append("redirect_uri",i),k.searchParams.append("response_type",r),y||k.searchParams.append("scope",o),u&&k.searchParams.append("nonce",u),v&&k.searchParams.append("dpop_jkt",v);let S=b.id;if(h&&(S=`${S}${ga}${h}`),k.searchParams.append("state",S),b.code_challenge&&(k.searchParams.append("code_challenge",b.code_challenge),k.searchParams.append("code_challenge_method","S256")),p){(Array.isArray(p)?p:[p]).forEach((e=>k.searchParams.append("resource",e)))}for(const[e,t]of Object.entries({response_mode:c,..._,...f}))null!=t&&k.searchParams.append(e,t.toString());return new e({url:k.href,state:b})}};Oa._logger=new ra("SigninRequest");var ja=Oa,Aa=class{constructor(e){if(this.access_token="",this.token_type="",this.profile={},this.state=e.get("state"),this.session_state=e.get("session_state"),this.state){const e=decodeURIComponent(this.state).split(ga);this.state=e[0],e.length>1&&(this.url_state=e.slice(1).join(ga))}this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri"),this.code=e.get("code")}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-ha.getEpochTime()}set expires_in(e){"string"==typeof e&&(e=Number(e)),void 0!==e&&e>=0&&(this.expires_at=Math.floor(e)+ha.getEpochTime())}get isOpenId(){var e;return(null==(e=this.scope)?void 0:e.split(" ").includes("openid"))||!!this.id_token}},Pa=class{constructor({url:e,state_data:t,id_token_hint:n,post_logout_redirect_uri:s,extraQueryParams:i,request_type:r,client_id:o,url_state:a}){if(this._logger=new ra("SignoutRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");const c=new URL(e);if(n&&c.searchParams.append("id_token_hint",n),o&&c.searchParams.append("client_id",o),s&&(c.searchParams.append("post_logout_redirect_uri",s),t||a)){this.state=new Ra({data:t,request_type:r,url_state:a});let e=this.state.id;a&&(e=`${e}${ga}${a}`),c.searchParams.append("state",e)}for(const[e,t]of Object.entries({...i}))null!=t&&c.searchParams.append(e,t.toString());this.url=c.href}},Ua=class{constructor(e){if(this.state=e.get("state"),this.state){const e=decodeURIComponent(this.state).split(ga);this.state=e[0],e.length>1&&(this.url_state=e.slice(1).join(ga))}this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri")}},Ma=["nbf","jti","auth_time","nonce","acr","amr","azp","at_hash"],$a=["sub","iss","aud","exp","iat"],Na=class{constructor(e){this._settings=e,this._logger=new ra("ClaimsService")}filterProtocolClaims(e){const t={...e};if(this._settings.filterProtocolClaims){let e;e=Array.isArray(this._settings.filterProtocolClaims)?this._settings.filterProtocolClaims:Ma;for(const n of e)$a.includes(n)||delete t[n]}return t}mergeClaims(e,t){const n={...e};for(const[e,s]of Object.entries(t))if(n[e]!==s)if(Array.isArray(n[e])||Array.isArray(s))if("replace"==this._settings.mergeClaimsStrategy.array)n[e]=s;else{const t=Array.isArray(n[e])?n[e]:[n[e]];for(const e of Array.isArray(s)?s:[s])t.includes(e)||t.push(e);n[e]=t}else"object"==typeof n[e]&&"object"==typeof s?n[e]=this.mergeClaims(n[e],s):n[e]=s;return n}},qa=class{constructor(e,t){this.keys=e,this.nonce=t}},Da=class{constructor(e,t){this._logger=new ra("OidcClient"),this.settings=e instanceof Ia?e:new Ia(e),this.metadataService=null!=t?t:new ka(this.settings),this._claimsService=new Na(this.settings),this._validator=new Ca(this.settings,this.metadataService,this._claimsService),this._tokenClient=new Ea(this.settings,this.metadataService)}async createSigninRequest({state:e,request:t,request_uri:n,request_type:s,id_token_hint:i,login_hint:r,skipUserInfo:o,nonce:a,url_state:c,response_type:l=this.settings.response_type,scope:d=this.settings.scope,redirect_uri:u=this.settings.redirect_uri,prompt:h=this.settings.prompt,display:p=this.settings.display,max_age:g=this.settings.max_age,ui_locales:f=this.settings.ui_locales,acr_values:m=this.settings.acr_values,resource:w=this.settings.resource,response_mode:v=this.settings.response_mode,extraQueryParams:y=this.settings.extraQueryParams,extraTokenParams:_=this.settings.extraTokenParams,dpopJkt:b,omitScopeWhenRequesting:k=this.settings.omitScopeWhenRequesting}){const S=this._logger.create("createSigninRequest");if("code"!==l)throw new Error("Only the Authorization Code flow (with PKCE) is supported");const I=await this.metadataService.getAuthorizationEndpoint();S.debug("Received authorization endpoint",I);const x=await ja.create({url:I,authority:this.settings.authority,client_id:this.settings.client_id,redirect_uri:u,response_type:l,scope:d,state_data:e,url_state:c,prompt:h,display:p,max_age:g,ui_locales:f,id_token_hint:i,login_hint:r,acr_values:m,dpopJkt:b,resource:w,request:t,request_uri:n,extraQueryParams:y,extraTokenParams:_,request_type:s,response_mode:v,client_secret:this.settings.client_secret,skipUserInfo:o,nonce:a,disablePKCE:this.settings.disablePKCE,omitScopeWhenRequesting:k});await this.clearStaleState();const E=x.state;return await this.settings.stateStore.set(E.id,E.toStorageString()),x}async readSigninResponseState(e,t=!1){const n=this._logger.create("readSigninResponseState"),s=new Aa(pa.readParams(e,this.settings.response_mode));if(!s.state)throw n.throw(new Error("No state in response")),null;const i=await this.settings.stateStore[t?"remove":"get"](s.state);if(!i)throw n.throw(new Error("No matching state found in storage")),null;return{state:await Ta.fromStorageString(i),response:s}}async processSigninResponse(e,t,n=!0){const s=this._logger.create("processSigninResponse"),{state:i,response:r}=await this.readSigninResponseState(e,n);if(s.debug("received state from storage; validating response"),this.settings.dpop&&this.settings.dpop.store){const e=await this.getDpopProof(this.settings.dpop.store);t={...t,DPoP:e}}try{await this._validator.validateSigninResponse(r,i,t)}catch(e){if(!(e instanceof _a&&this.settings.dpop))throw e;{const n=await this.getDpopProof(this.settings.dpop.store,e.nonce);t.DPoP=n,await this._validator.validateSigninResponse(r,i,t)}}return r}async getDpopProof(e,t){let n,s;return(await e.getAllKeys()).includes(this.settings.client_id)?(s=await e.get(this.settings.client_id),s.nonce!==t&&t&&(s.nonce=t,await e.set(this.settings.client_id,s))):(n=await la.generateDPoPKeys(),s=new qa(n,t),await e.set(this.settings.client_id,s)),await la.generateDPoPProof({url:await this.metadataService.getTokenEndpoint(!1),httpMethod:"POST",keyPair:s.keys,nonce:s.nonce})}async processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:n=!1,extraTokenParams:s={}}){const i=await this._tokenClient.exchangeCredentials({username:e,password:t,...s}),r=new Aa(new URLSearchParams);return Object.assign(r,i),await this._validator.validateCredentialsResponse(r,n),r}async useRefreshToken({state:e,redirect_uri:t,resource:n,timeoutInSeconds:s,extraHeaders:i,extraTokenParams:r}){var o;const a=this._logger.create("useRefreshToken");let c,l;if(void 0===this.settings.refreshTokenAllowedScope)c=e.scope;else{const t=this.settings.refreshTokenAllowedScope.split(" ");c=((null==(o=e.scope)?void 0:o.split(" "))||[]).filter((e=>t.includes(e))).join(" ")}if(this.settings.dpop&&this.settings.dpop.store){const e=await this.getDpopProof(this.settings.dpop.store);i={...i,DPoP:e}}try{l=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:c,redirect_uri:t,resource:n,timeoutInSeconds:s,extraHeaders:i,...r})}catch(o){if(!(o instanceof _a&&this.settings.dpop))throw o;i.DPoP=await this.getDpopProof(this.settings.dpop.store,o.nonce),l=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:c,redirect_uri:t,resource:n,timeoutInSeconds:s,extraHeaders:i,...r})}const d=new Aa(new URLSearchParams);return Object.assign(d,l),a.debug("validating response",d),await this._validator.validateRefreshResponse(d,{...e,scope:c}),d}async createSignoutRequest({state:e,id_token_hint:t,client_id:n,request_type:s,url_state:i,post_logout_redirect_uri:r=this.settings.post_logout_redirect_uri,extraQueryParams:o=this.settings.extraQueryParams}={}){const a=this._logger.create("createSignoutRequest"),c=await this.metadataService.getEndSessionEndpoint();if(!c)throw a.throw(new Error("No end session endpoint")),null;a.debug("Received end session endpoint",c),n||!r||t||(n=this.settings.client_id);const l=new Pa({url:c,id_token_hint:t,client_id:n,post_logout_redirect_uri:r,state_data:e,extraQueryParams:o,request_type:s,url_state:i});await this.clearStaleState();const d=l.state;return d&&(a.debug("Signout request has state to persist"),await this.settings.stateStore.set(d.id,d.toStorageString())),l}async readSignoutResponseState(e,t=!1){const n=this._logger.create("readSignoutResponseState"),s=new Ua(pa.readParams(e,this.settings.response_mode));if(!s.state){if(n.debug("No state in response"),s.error)throw n.warn("Response was error:",s.error),new fa(s);return{state:void 0,response:s}}const i=await this.settings.stateStore[t?"remove":"get"](s.state);if(!i)throw n.throw(new Error("No matching state found in storage")),null;return{state:await Ra.fromStorageString(i),response:s}}async processSignoutResponse(e){const t=this._logger.create("processSignoutResponse"),{state:n,response:s}=await this.readSignoutResponseState(e,!0);return n?(t.debug("Received state from storage; validating response"),this._validator.validateSignoutResponse(s,n)):t.debug("No state from storage; skipping response validation"),s}clearStaleState(){return this._logger.create("clearStaleState"),Ra.clearStaleState(this.settings.stateStore,this.settings.staleStateAgeInSeconds)}async revokeToken(e,t){return this._logger.create("revokeToken"),await this._tokenClient.revoke({token:e,token_type_hint:t})}},Wa=class{constructor(e){this._userManager=e,this._logger=new ra("SessionMonitor"),this._start=async e=>{const t=e.session_state;if(!t)return;const n=this._logger.create("_start");if(e.profile?(this._sub=e.profile.sub,n.debug("session_state",t,", sub",this._sub)):(this._sub=void 0,n.debug("session_state",t,", anonymous user")),this._checkSessionIFrame)this._checkSessionIFrame.start(t);else try{const e=await this._userManager.metadataService.getCheckSessionIframe();if(e){n.debug("initializing check session iframe");const s=this._userManager.settings.client_id,i=this._userManager.settings.checkSessionIntervalInSeconds,r=this._userManager.settings.stopCheckSessionOnError,o=new va(this._callback,s,e,i,r);await o.load(),this._checkSessionIFrame=o,o.start(t)}else n.warn("no check session iframe found in the metadata")}catch(e){n.error("Error from getCheckSessionIframe:",e instanceof Error?e.message:e)}},this._stop=()=>{const e=this._logger.create("_stop");if(this._sub=void 0,this._checkSessionIFrame&&this._checkSessionIFrame.stop(),this._userManager.settings.monitorAnonymousSession){const t=setInterval((async()=>{clearInterval(t);try{const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub?{sub:e.sub}:null};this._start(t)}}catch(t){e.error("error from querySessionStatus",t instanceof Error?t.message:t)}}),1e3)}},this._callback=async()=>{const e=this._logger.create("_callback");try{const t=await this._userManager.querySessionStatus();let n=!0;t&&this._checkSessionIFrame?t.sub===this._sub?(n=!1,this._checkSessionIFrame.start(t.session_state),e.debug("same sub still logged in at OP, session state has changed, restarting check session iframe; session_state",t.session_state),await this._userManager.events._raiseUserSessionChanged()):e.debug("different subject signed into OP",t.sub):e.debug("subject no longer signed into OP"),n?this._sub?await this._userManager.events._raiseUserSignedOut():await this._userManager.events._raiseUserSignedIn():e.debug("no change in session detected, no event to raise")}catch(t){this._sub&&(e.debug("Error calling queryCurrentSigninSession; raising signed out event",t),await this._userManager.events._raiseUserSignedOut())}},e||this._logger.throw(new Error("No user manager passed")),this._userManager.events.addUserLoaded(this._start),this._userManager.events.addUserUnloaded(this._stop),this._init().catch((e=>{this._logger.error(e)}))}async _init(){this._logger.create("_init");const e=await this._userManager.getUser();if(e)this._start(e);else if(this._userManager.settings.monitorAnonymousSession){const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub?{sub:e.sub}:null};this._start(t)}}}},La=class e{constructor(e){var t;this.id_token=e.id_token,this.session_state=null!=(t=e.session_state)?t:null,this.access_token=e.access_token,this.refresh_token=e.refresh_token,this.token_type=e.token_type,this.scope=e.scope,this.profile=e.profile,this.expires_at=e.expires_at,this.state=e.userState,this.url_state=e.url_state}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-ha.getEpochTime()}set expires_in(e){void 0!==e&&(this.expires_at=Math.floor(e)+ha.getEpochTime())}get expired(){const e=this.expires_in;if(void 0!==e)return e<=0}get scopes(){var e,t;return null!=(t=null==(e=this.scope)?void 0:e.split(" "))?t:[]}toStorageString(){return new ra("User").create("toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})}static fromStorageString(t){return ra.createStatic("User","fromStorageString"),new e(JSON.parse(t))}},Ka="oidc-client",Fa=class{constructor(){this._abort=new da("Window navigation aborted"),this._disposeHandlers=new Set,this._window=null}async navigate(e){const t=this._logger.create("navigate");if(!this._window)throw new Error("Attempted to navigate on a disposed window");t.debug("setting URL in window"),this._window.location.replace(e.url);const{url:n,keepOpen:s}=await new Promise(((n,s)=>{const i=i=>{var r;const o=i.data,a=null!=(r=e.scriptOrigin)?r:window.location.origin;if(i.origin===a&&(null==o?void 0:o.source)===Ka){try{const n=pa.readParams(o.url,e.response_mode).get("state");if(n||t.warn("no state found in response url"),i.source!==this._window&&n!==e.state)return}catch{this._dispose(),s(new Error("Invalid response from window"))}n(o)}};window.addEventListener("message",i,!1),this._disposeHandlers.add((()=>window.removeEventListener("message",i,!1))),this._disposeHandlers.add(this._abort.addHandler((e=>{this._dispose(),s(e)})))}));return t.debug("got response from window"),this._dispose(),s||this.close(),{url:n}}_dispose(){this._logger.create("_dispose");for(const e of this._disposeHandlers)e();this._disposeHandlers.clear()}static _notifyParent(e,t,n=!1,s=window.location.origin){e.postMessage({source:Ka,url:t,keepOpen:n},s)}},Ha={location:!1,toolbar:!1,height:640,closePopupWindowAfterInSeconds:-1},za="_blank",Ja=60,Ba=2,Va=class extends Ia{constructor(e){const{popup_redirect_uri:t=e.redirect_uri,popup_post_logout_redirect_uri:n=e.post_logout_redirect_uri,popupWindowFeatures:s=Ha,popupWindowTarget:i=za,redirectMethod:r="assign",redirectTarget:o="self",iframeNotifyParentOrigin:a=e.iframeNotifyParentOrigin,iframeScriptOrigin:c=e.iframeScriptOrigin,requestTimeoutInSeconds:l,silent_redirect_uri:d=e.redirect_uri,silentRequestTimeoutInSeconds:u,automaticSilentRenew:h=!0,validateSubOnSilentRenew:p=!0,includeIdTokenInSilentRenew:g=!1,monitorSession:f=!1,monitorAnonymousSession:m=!1,checkSessionIntervalInSeconds:w=Ba,query_status_response_type:v="code",stopCheckSessionOnError:y=!0,revokeTokenTypes:_=["access_token","refresh_token"],revokeTokensOnSignout:b=!1,includeIdTokenInSilentSignout:k=!1,accessTokenExpiringNotificationTimeInSeconds:S=Ja,userStore:I}=e;if(super(e),this.popup_redirect_uri=t,this.popup_post_logout_redirect_uri=n,this.popupWindowFeatures=s,this.popupWindowTarget=i,this.redirectMethod=r,this.redirectTarget=o,this.iframeNotifyParentOrigin=a,this.iframeScriptOrigin=c,this.silent_redirect_uri=d,this.silentRequestTimeoutInSeconds=u||l||10,this.automaticSilentRenew=h,this.validateSubOnSilentRenew=p,this.includeIdTokenInSilentRenew=g,this.monitorSession=f,this.monitorAnonymousSession=m,this.checkSessionIntervalInSeconds=w,this.stopCheckSessionOnError=y,this.query_status_response_type=v,this.revokeTokenTypes=_,this.revokeTokensOnSignout=b,this.includeIdTokenInSilentSignout=k,this.accessTokenExpiringNotificationTimeInSeconds=S,I)this.userStore=I;else{const e="undefined"!=typeof window?window.sessionStorage:new ya;this.userStore=new Sa({store:e})}}},Za=class e extends Fa{constructor({silentRequestTimeoutInSeconds:t=10}){super(),this._logger=new ra("IFrameWindow"),this._timeoutInSeconds=t,this._frame=e.createHiddenIframe(),this._window=this._frame.contentWindow}static createHiddenIframe(){const e=window.document.createElement("iframe");return e.style.visibility="hidden",e.style.position="fixed",e.style.left="-1000px",e.style.top="0",e.width="0",e.height="0",window.document.body.appendChild(e),e}async navigate(e){this._logger.debug("navigate: Using timeout of:",this._timeoutInSeconds);const t=setTimeout((()=>{this._abort.raise(new ma("IFrame timed out without a response"))}),1e3*this._timeoutInSeconds);return this._disposeHandlers.add((()=>clearTimeout(t))),await super.navigate(e)}close(){var e;this._frame&&(this._frame.parentNode&&(this._frame.addEventListener("load",(e=>{var t;const n=e.target;null==(t=n.parentNode)||t.removeChild(n),this._abort.raise(new Error("IFrame removed from DOM"))}),!0),null==(e=this._frame.contentWindow)||e.location.replace("about:blank")),this._frame=null),this._window=null}static notifyParent(e,t){return super._notifyParent(window.parent,e,!1,t)}},Ga=class{constructor(e){this._settings=e,this._logger=new ra("IFrameNavigator")}async prepare({silentRequestTimeoutInSeconds:e=this._settings.silentRequestTimeoutInSeconds}){return new Za({silentRequestTimeoutInSeconds:e})}async callback(e){this._logger.create("callback"),Za.notifyParent(e,this._settings.iframeNotifyParentOrigin)}},Ya=class extends Fa{constructor({popupWindowTarget:e=za,popupWindowFeatures:t={},popupSignal:n}){super(),this._logger=new ra("PopupWindow");const s=ua.center({...Ha,...t});this._window=window.open(void 0,e,ua.serialize(s)),n&&n.addEventListener("abort",(()=>{var e;this._abort.raise(new Error(null!=(e=n.reason)?e:"Popup aborted"))})),t.closePopupWindowAfterInSeconds&&t.closePopupWindowAfterInSeconds>0&&setTimeout((()=>{this._window&&"boolean"==typeof this._window.closed&&!this._window.closed?this.close():this._abort.raise(new Error("Popup blocked by user"))}),1e3*t.closePopupWindowAfterInSeconds)}async navigate(e){var t;null==(t=this._window)||t.focus();const n=setInterval((()=>{this._window&&!this._window.closed||this._abort.raise(new Error("Popup closed by user"))}),500);return this._disposeHandlers.add((()=>clearInterval(n))),await super.navigate(e)}close(){this._window&&(this._window.closed||(this._window.close(),this._abort.raise(new Error("Popup closed")))),this._window=null}static notifyOpener(e,t){if(!window.opener)throw new Error("No window.opener. Can't complete notification.");return super._notifyParent(window.opener,e,t)}},Xa=class{constructor(e){this._settings=e,this._logger=new ra("PopupNavigator")}async prepare({popupWindowFeatures:e=this._settings.popupWindowFeatures,popupWindowTarget:t=this._settings.popupWindowTarget,popupSignal:n}){return new Ya({popupWindowFeatures:e,popupWindowTarget:t,popupSignal:n})}async callback(e,{keepOpen:t=!1}){this._logger.create("callback"),Ya.notifyOpener(e,t)}},Qa=class{constructor(e){this._settings=e,this._logger=new ra("RedirectNavigator")}async prepare({redirectMethod:e=this._settings.redirectMethod,redirectTarget:t=this._settings.redirectTarget}){var n;this._logger.create("prepare");let s=window.self;"top"===t&&(s=null!=(n=window.top)?n:window.self);const i=s.location[e].bind(s.location);let r;return{navigate:async e=>{this._logger.create("navigate");const t=new Promise(((e,t)=>{r=t}));return i(e.url),await t},close:()=>{this._logger.create("close"),null==r||r(new Error("Redirect aborted")),s.stop()}}}async callback(){}},ec=class extends wa{constructor(e){super({expiringNotificationTimeInSeconds:e.accessTokenExpiringNotificationTimeInSeconds}),this._logger=new ra("UserManagerEvents"),this._userLoaded=new da("User loaded"),this._userUnloaded=new da("User unloaded"),this._silentRenewError=new da("Silent renew error"),this._userSignedIn=new da("User signed in"),this._userSignedOut=new da("User signed out"),this._userSessionChanged=new da("User session changed")}async load(e,t=!0){await super.load(e),t&&await this._userLoaded.raise(e)}async unload(){await super.unload(),await this._userUnloaded.raise()}addUserLoaded(e){return this._userLoaded.addHandler(e)}removeUserLoaded(e){return this._userLoaded.removeHandler(e)}addUserUnloaded(e){return this._userUnloaded.addHandler(e)}removeUserUnloaded(e){return this._userUnloaded.removeHandler(e)}addSilentRenewError(e){return this._silentRenewError.addHandler(e)}removeSilentRenewError(e){return this._silentRenewError.removeHandler(e)}async _raiseSilentRenewError(e){await this._silentRenewError.raise(e)}addUserSignedIn(e){return this._userSignedIn.addHandler(e)}removeUserSignedIn(e){this._userSignedIn.removeHandler(e)}async _raiseUserSignedIn(){await this._userSignedIn.raise()}addUserSignedOut(e){return this._userSignedOut.addHandler(e)}removeUserSignedOut(e){this._userSignedOut.removeHandler(e)}async _raiseUserSignedOut(){await this._userSignedOut.raise()}addUserSessionChanged(e){return this._userSessionChanged.addHandler(e)}removeUserSessionChanged(e){this._userSessionChanged.removeHandler(e)}async _raiseUserSessionChanged(){await this._userSessionChanged.raise()}},tc=class{constructor(e){this._userManager=e,this._logger=new ra("SilentRenewService"),this._isStarted=!1,this._retryTimer=new ha("Retry Silent Renew"),this._tokenExpiring=async()=>{const e=this._logger.create("_tokenExpiring");try{await this._userManager.signinSilent(),e.debug("silent token renewal successful")}catch(t){if(t instanceof ma)return e.warn("ErrorTimeout from signinSilent:",t,"retry in 5s"),void this._retryTimer.init(5);e.error("Error from signinSilent:",t),await this._userManager.events._raiseSilentRenewError(t)}}}async start(){const e=this._logger.create("start");if(!this._isStarted){this._isStarted=!0,this._userManager.events.addAccessTokenExpiring(this._tokenExpiring),this._retryTimer.addHandler(this._tokenExpiring);try{await this._userManager.getUser()}catch(t){e.error("getUser error",t)}}}stop(){this._isStarted&&(this._retryTimer.cancel(),this._retryTimer.removeHandler(this._tokenExpiring),this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring),this._isStarted=!1)}},nc=class{constructor(e){this.refresh_token=e.refresh_token,this.id_token=e.id_token,this.session_state=e.session_state,this.scope=e.scope,this.profile=e.profile,this.data=e.state}},sc=Object.freeze({__proto__:null,AccessTokenEvents:wa,CheckSessionIFrame:va,DPoPState:qa,ErrorResponse:fa,ErrorTimeout:ma,InMemoryWebStorage:ya,IndexedDbDPoPStore:class{constructor(){this._dbName="oidc",this._storeName="dpop"}async set(e,t){const n=await this.createStore(this._dbName,this._storeName);await n("readwrite",(n=>(n.put(t,e),this.promisifyRequest(n.transaction))))}async get(e){const t=await this.createStore(this._dbName,this._storeName);return await t("readonly",(t=>this.promisifyRequest(t.get(e))))}async remove(e){const t=await this.get(e),n=await this.createStore(this._dbName,this._storeName);return await n("readwrite",(t=>this.promisifyRequest(t.delete(e)))),t}async getAllKeys(){const e=await this.createStore(this._dbName,this._storeName);return await e("readonly",(e=>this.promisifyRequest(e.getAllKeys())))}promisifyRequest(e){return new Promise(((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}))}async createStore(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const s=await this.promisifyRequest(n);return async(e,n)=>{const i=s.transaction(t,e).objectStore(t);return await n(i)}}},get Log(){return ia},Logger:ra,MetadataService:ka,OidcClient:Da,OidcClientSettingsStore:Ia,SessionMonitor:Wa,SigninResponse:Aa,SigninState:Ta,SignoutResponse:Ua,State:Ra,User:La,UserManager:class{constructor(e,t,n,s){this._logger=new ra("UserManager"),this.settings=new Va(e),this._client=new Da(e),this._redirectNavigator=null!=t?t:new Qa(this.settings),this._popupNavigator=null!=n?n:new Xa(this.settings),this._iframeNavigator=null!=s?s:new Ga(this.settings),this._events=new ec(this.settings),this._silentRenewService=new tc(this),this.settings.automaticSilentRenew&&this.startSilentRenew(),this._sessionMonitor=null,this.settings.monitorSession&&(this._sessionMonitor=new Wa(this))}get events(){return this._events}get metadataService(){return this._client.metadataService}async getUser(e=!1){const t=this._logger.create("getUser"),n=await this._loadUser();return n?(t.info("user loaded"),await this._events.load(n,e),n):(t.info("user not found in storage"),null)}async removeUser(){const e=this._logger.create("removeUser");await this.storeUser(null),e.info("user removed from storage"),await this._events.unload()}async signinRedirect(e={}){var t;this._logger.create("signinRedirect");const{redirectMethod:n,...s}=e;let i;(null==(t=this.settings.dpop)?void 0:t.bind_authorization_code)&&(i=await this.generateDPoPJkt(this.settings.dpop));const r=await this._redirectNavigator.prepare({redirectMethod:n});await this._signinStart({request_type:"si:r",dpopJkt:i,...s},r)}async signinRedirectCallback(e=window.location.href){const t=this._logger.create("signinRedirectCallback"),n=await this._signinEnd(e);return n.profile&&n.profile.sub?t.info("success, signed in subject",n.profile.sub):t.info("no subject"),n}async signinResourceOwnerCredentials({username:e,password:t,skipUserInfo:n=!1}){const s=this._logger.create("signinResourceOwnerCredential"),i=await this._client.processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:n,extraTokenParams:this.settings.extraTokenParams});s.debug("got signin response");const r=await this._buildUser(i);return r.profile&&r.profile.sub?s.info("success, signed in subject",r.profile.sub):s.info("no subject"),r}async signinPopup(e={}){var t;const n=this._logger.create("signinPopup");let s;(null==(t=this.settings.dpop)?void 0:t.bind_authorization_code)&&(s=await this.generateDPoPJkt(this.settings.dpop));const{popupWindowFeatures:i,popupWindowTarget:r,popupSignal:o,...a}=e,c=this.settings.popup_redirect_uri;c||n.throw(new Error("No popup_redirect_uri configured"));const l=await this._popupNavigator.prepare({popupWindowFeatures:i,popupWindowTarget:r,popupSignal:o}),d=await this._signin({request_type:"si:p",redirect_uri:c,display:"popup",dpopJkt:s,...a},l);return d&&(d.profile&&d.profile.sub?n.info("success, signed in subject",d.profile.sub):n.info("no subject")),d}async signinPopupCallback(e=window.location.href,t=!1){const n=this._logger.create("signinPopupCallback");await this._popupNavigator.callback(e,{keepOpen:t}),n.info("success")}async signinSilent(e={}){var t,n;const s=this._logger.create("signinSilent"),{silentRequestTimeoutInSeconds:i,...r}=e;let o,a=await this._loadUser();if(null==a?void 0:a.refresh_token){s.debug("using refresh token");const e=new nc(a);return await this._useRefreshToken({state:e,redirect_uri:r.redirect_uri,resource:r.resource,extraTokenParams:r.extraTokenParams,timeoutInSeconds:i})}(null==(t=this.settings.dpop)?void 0:t.bind_authorization_code)&&(o=await this.generateDPoPJkt(this.settings.dpop));const c=this.settings.silent_redirect_uri;let l;c||s.throw(new Error("No silent_redirect_uri configured")),a&&this.settings.validateSubOnSilentRenew&&(s.debug("subject prior to silent renew:",a.profile.sub),l=a.profile.sub);const d=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:i});return a=await this._signin({request_type:"si:s",redirect_uri:c,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==a?void 0:a.id_token:void 0,dpopJkt:o,...r},d,l),a&&((null==(n=a.profile)?void 0:n.sub)?s.info("success, signed in subject",a.profile.sub):s.info("no subject")),a}async _useRefreshToken(e){const t=await this._client.useRefreshToken({timeoutInSeconds:this.settings.silentRequestTimeoutInSeconds,...e}),n=new La({...e.state,...t});return await this.storeUser(n),await this._events.load(n),n}async signinSilentCallback(e=window.location.href){const t=this._logger.create("signinSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async signinCallback(e=window.location.href){const{state:t}=await this._client.readSigninResponseState(e);switch(t.request_type){case"si:r":return await this.signinRedirectCallback(e);case"si:p":await this.signinPopupCallback(e);break;case"si:s":await this.signinSilentCallback(e);break;default:throw new Error("invalid response_type in state")}}async signoutCallback(e=window.location.href,t=!1){const{state:n}=await this._client.readSignoutResponseState(e);if(n)switch(n.request_type){case"so:r":return await this.signoutRedirectCallback(e);case"so:p":await this.signoutPopupCallback(e,t);break;case"so:s":await this.signoutSilentCallback(e);break;default:throw new Error("invalid response_type in state")}}async querySessionStatus(e={}){const t=this._logger.create("querySessionStatus"),{silentRequestTimeoutInSeconds:n,...s}=e,i=this.settings.silent_redirect_uri;i||t.throw(new Error("No silent_redirect_uri configured"));const r=await this._loadUser(),o=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:n}),a=await this._signinStart({request_type:"si:s",redirect_uri:i,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==r?void 0:r.id_token:void 0,response_type:this.settings.query_status_response_type,scope:"openid",skipUserInfo:!0,...s},o);try{const e={},n=await this._client.processSigninResponse(a.url,e);return t.debug("got signin response"),n.session_state&&n.profile.sub?(t.info("success for subject",n.profile.sub),{session_state:n.session_state,sub:n.profile.sub}):(t.info("success, user not authenticated"),null)}catch(e){if(this.settings.monitorAnonymousSession&&e instanceof fa)switch(e.error){case"login_required":case"consent_required":case"interaction_required":case"account_selection_required":return t.info("success for anonymous user"),{session_state:e.session_state}}throw e}}async _signin(e,t,n){const s=await this._signinStart(e,t);return await this._signinEnd(s.url,n)}async _signinStart(e,t){const n=this._logger.create("_signinStart");try{const s=await this._client.createSigninRequest(e);return n.debug("got signin request"),await t.navigate({url:s.url,state:s.state.id,response_mode:s.state.response_mode,scriptOrigin:this.settings.iframeScriptOrigin})}catch(e){throw n.debug("error after preparing navigator, closing navigator window"),t.close(),e}}async _signinEnd(e,t){const n=this._logger.create("_signinEnd"),s=await this._client.processSigninResponse(e,{});n.debug("got signin response");return await this._buildUser(s,t)}async _buildUser(e,t){const n=this._logger.create("_buildUser"),s=new La(e);if(t){if(t!==s.profile.sub)throw n.debug("current user does not match user returned from signin. sub from signin:",s.profile.sub),new fa({...e,error:"login_required"});n.debug("current user matches user returned from signin")}return await this.storeUser(s),n.debug("user stored"),await this._events.load(s),s}async signoutRedirect(e={}){const t=this._logger.create("signoutRedirect"),{redirectMethod:n,...s}=e,i=await this._redirectNavigator.prepare({redirectMethod:n});await this._signoutStart({request_type:"so:r",post_logout_redirect_uri:this.settings.post_logout_redirect_uri,...s},i),t.info("success")}async signoutRedirectCallback(e=window.location.href){const t=this._logger.create("signoutRedirectCallback"),n=await this._signoutEnd(e);return t.info("success"),n}async signoutPopup(e={}){const t=this._logger.create("signoutPopup"),{popupWindowFeatures:n,popupWindowTarget:s,popupSignal:i,...r}=e,o=this.settings.popup_post_logout_redirect_uri,a=await this._popupNavigator.prepare({popupWindowFeatures:n,popupWindowTarget:s,popupSignal:i});await this._signout({request_type:"so:p",post_logout_redirect_uri:o,state:null==o?void 0:{},...r},a),t.info("success")}async signoutPopupCallback(e=window.location.href,t=!1){const n=this._logger.create("signoutPopupCallback");await this._popupNavigator.callback(e,{keepOpen:t}),n.info("success")}async _signout(e,t){const n=await this._signoutStart(e,t);return await this._signoutEnd(n.url)}async _signoutStart(e={},t){var n;const s=this._logger.create("_signoutStart");try{const i=await this._loadUser();s.debug("loaded current user from storage"),this.settings.revokeTokensOnSignout&&await this._revokeInternal(i);const r=e.id_token_hint||i&&i.id_token;r&&(s.debug("setting id_token_hint in signout request"),e.id_token_hint=r),await this.removeUser(),s.debug("user removed, creating signout request");const o=await this._client.createSignoutRequest(e);return s.debug("got signout request"),await t.navigate({url:o.url,state:null==(n=o.state)?void 0:n.id,scriptOrigin:this.settings.iframeScriptOrigin})}catch(e){throw s.debug("error after preparing navigator, closing navigator window"),t.close(),e}}async _signoutEnd(e){const t=this._logger.create("_signoutEnd"),n=await this._client.processSignoutResponse(e);return t.debug("got signout response"),n}async signoutSilent(e={}){var t;const n=this._logger.create("signoutSilent"),{silentRequestTimeoutInSeconds:s,...i}=e,r=this.settings.includeIdTokenInSilentSignout?null==(t=await this._loadUser())?void 0:t.id_token:void 0,o=this.settings.popup_post_logout_redirect_uri,a=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:s});await this._signout({request_type:"so:s",post_logout_redirect_uri:o,id_token_hint:r,...i},a),n.info("success")}async signoutSilentCallback(e=window.location.href){const t=this._logger.create("signoutSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async revokeTokens(e){const t=await this._loadUser();await this._revokeInternal(t,e)}async _revokeInternal(e,t=this.settings.revokeTokenTypes){const n=this._logger.create("_revokeInternal");if(!e)return;const s=t.filter((t=>"string"==typeof e[t]));if(s.length){for(const t of s)await this._client.revokeToken(e[t],t),n.info(`${t} revoked successfully`),"access_token"!==t&&(e[t]=null);await this.storeUser(e),n.debug("user stored"),await this._events.load(e)}else n.debug("no need to revoke due to no token(s)")}startSilentRenew(){this._logger.create("startSilentRenew"),this._silentRenewService.start()}stopSilentRenew(){this._silentRenewService.stop()}get _userStoreKey(){return`user:${this.settings.authority}:${this.settings.client_id}`}async _loadUser(){const e=this._logger.create("_loadUser"),t=await this.settings.userStore.get(this._userStoreKey);return t?(e.debug("user storageString loaded"),La.fromStorageString(t)):(e.debug("no user storageString"),null)}async storeUser(e){const t=this._logger.create("storeUser");if(e){t.debug("storing user");const n=e.toStorageString();await this.settings.userStore.set(this._userStoreKey,n)}else this._logger.debug("removing user"),await this.settings.userStore.remove(this._userStoreKey),this.settings.dpop&&await this.settings.dpop.store.remove(this.settings.client_id)}async clearStaleState(){await this._client.clearStaleState()}async dpopProof(e,t,n,s){var i,r;const o=await(null==(r=null==(i=this.settings.dpop)?void 0:i.store)?void 0:r.get(this.settings.client_id));if(o)return await la.generateDPoPProof({url:e,accessToken:null==t?void 0:t.access_token,httpMethod:n,keyPair:o.keys,nonce:s})}async generateDPoPJkt(e){let t=await e.store.get(this.settings.client_id);if(!t){const n=await la.generateDPoPKeys();t=new qa(n),await e.store.set(this.settings.client_id,t)}return await la.generateDPoPJkt(t.keys)}},UserManagerSettingsStore:Va,Version:"3.2.0",WebStorageStateStore:Sa});return Do}();
|
|
7
|
+
function Qr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var ei=function e(t,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=Qr({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",Qr({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Qr({},this.attributes,t))},withConverter:function(t){return e(Qr({},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 ti={default:"endpoint"},ni="Blocked by CSP",oi="The endpoint parameter is not a valid URL",ri="Failed to load the JS script of the agent",ii="9319";function si(e,t){var n,o,r,i,s,a=[],c=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),i=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},r=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===ni||s===oi)n.exclude(),i=0;else if(s===ii)n.exclude();else if(s===ri){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!r.has(c)&&(r.add(c),i=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=i?i:e.getTime()+o()-Date.now()]}]),l=c[0],d=c[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},r=t(e);return r.then((function(){return o()}),o),r.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,r=t[0],i=t[1];return(o=i,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(r)}))}))};return u(l).then((function(e){return[e,a]}))}var ai="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",ci=ai;function li(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:ai,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=l[0],u=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(c,s);return si(e,di)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===ii?new Error(ri):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function di(e){return function(e,t,n){var o,r=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=t,a())};r.addEventListener(i,s);var a=function(){return r.removeEventListener(i,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),o)return n(o);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(oi);var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(ri))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)}),(function(){throw new Error(ni)})).then(ui)}function ui(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(ii);return n}const hi=e=>{try{return Bn(e).exp}catch(e){return null}},pi=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:hi(n)},fi=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?hi(o):void 0)},gi=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},vi=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(e=>{const{access_token:n,id_token:o,refresh_token:r,refresh_expire_in:i}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:o,refreshJwt:e.refreshJwt||r,sessionExpiration:e.sessionExpiration||fi(e),cookieExpiration:e.cookieExpiration||pi(e)},s)})((null==n?void 0:n.authInfo)||n||{})},mi=async e=>{const t=await vi(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},yi="undefined"!=typeof localStorage,wi=(e,t)=>yi&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),bi=e=>yi&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),ki=e=>yi&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Si=(...e)=>{console.debug(...e)},Ii="3.2.0",xi="undefined"!=typeof window,Oi=Math.pow(2,31)-1,ji=`https://descopecdn.com/npm/oidc-client-ts@${Ii}/dist/browser/oidc-client-ts.min.js`,Ci=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Ii}/dist/browser/oidc-client-ts.min.js`,Ri="DS",Ai="DSR",Ei="DSI";function Ti(e=""){return bi(`${e}${Ai}`)||""}function _i(e=""){return ei.get(Ri)||bi(`${e}${Ri}`)||""}function Mi(e=""){return bi(`${e}${Ei}`)||""}function Ui(e=""){ki(`${e}${Ai}`),ki(`${e}${Ri}`),ki(`${e}${Ei}`),ei.remove(Ri)}const $i=xi&&(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=localStorage.getItem("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Wi=async(e,t=$i)=>{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),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=r.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=li({apiKey:e,endpoint:[o.toString(),ti],scriptUrlPattern:[i,ci]}),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};localStorage.setItem("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},Ki="dls_last_user_login_id",qi="dls_last_user_display_name",Fi=()=>bi(Ki),zi=()=>bi(qi),Bi=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=Fi(),i=zi();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await e(...t)};function Ji(){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 Hi(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Qi(n.publicKey.challenge),n.publicKey.user.id=Qi(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Qi(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:es(n.rawId),type:n.type,response:{attestationObject:es(n.response.attestationObject),clientDataJSON:es(n.response.clientDataJSON)}});var n}async function Vi(e){const t=Xi(e);return Gi(await navigator.credentials.get(t))}async function Zi(e,t){const n=Xi(e);return n.signal=t.signal,n.mediation="conditional",Gi(await navigator.credentials.get(n))}async function Yi(e=!1){if(!xi)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Xi(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Qi(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Qi(e.id)})),n}function Gi(e){return JSON.stringify({id:e.id,rawId:es(e.rawId),type:e.type,response:{authenticatorData:es(e.response.authenticatorData),clientDataJSON:es(e.response.clientDataJSON),signature:es(e.response.signature),userHandle:e.response.userHandle?es(e.response.userHandle):void 0}})}function Qi(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function es(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ts,ns=(ts=e=>({async signUp(t,n,o){const r=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await Hi(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,i)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const r=await Vi(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,r)},async signUpOrIn(t,n){var o;const r=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!r.ok)return r;if(null===(o=r.data)||void 0===o?void 0:o.create){const t=await Hi(r.data.options);return await e.webauthn.signUp.finish(r.data.transactionId,t)}{const t=await Vi(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,t)}},async update(t,n,o){const r=await e.webauthn.update.start(t,window.location.origin,n,o);if(!r.ok)return r;const i=await Hi(r.data.options);return await e.webauthn.update.finish(r.data.transactionId,i)},helpers:{create:Hi,get:Vi,isSupported:Yi,conditional:Zi}}),(...e)=>{const t=ts(...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 os="/fedcm/config";async function rs(e,t){var n,o,r;try{const r=await async function(e,t="google",n,o,r){const i=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const c=a.data.clientId;return new Promise((e=>{var a,l;const d=n=>{e({provider:t,nonce:i,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,callback:d,nonce:i})),s.prompt((e=>{var t,n;if(r&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==r||r(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!r.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+r.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(r.provider,r.credential,r.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+r.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}catch(e){null===(r=null==t?void 0:t.onFailed)||void 0===r||r.call(t,e)}}var is=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Yi(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let ss;const as=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const r=t();if(r)return n(r);const i=e.shift(),s=document.createElement("script");s.src=i,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(i),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{as(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),cs=(e,t,n)=>{const o=async()=>{let o,r;return o&&r||({client:o,stateUserKey:r}=await(async(e,t,n)=>{ss||(ss=(async()=>{try{return require("oidc-client-ts")}catch(e){return as([ji,Ci],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:r}=await ss;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const i=t,s=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",c=`${i}_user`;let l=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(l=`${l}/${n.applicationId}`);const d={authority:l,client_id:t,redirect_uri:s,response_type:"code",scope:a,stateStore:new r({store:window.localStorage,prefix:i}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new o(d),stateUserKey:c}})(e,t,n)),{client:o,stateUserKey:r}},r=async(t="")=>{var n;const{client:r,stateUserKey:i}=await o(),s=await r.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),window.localStorage.setItem(i,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(e={},t=!1)=>{const{client:n}=await o(),r=await n.createSigninRequest(e),{url:i}=r;return t||(window.location.href=i),{ok:!0,data:r}},finishLogin:r,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await r(e)},refreshToken:async t=>{var n;const{client:r,stateUserKey:i}=await o(),s=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(i);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const c=await r.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:r}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||Mi(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const i=await n.createSignoutRequest(e),{url:s}=i;return window.localStorage.removeItem(r),t||window.location.replace(s),i}}},ls=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:r}=n,i=t(n,["fpKey","fpLoad"]);return xi?(o&&r&&Wi(o).catch((()=>null)),e(gi(i,{beforeRequest:Ni}))):e(i)}),(e=>n=>{var{autoRefresh:o}=n,r=t(n,["autoRefresh"]);if(!o)return e(r);const{clearAllTimers:i,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;xi&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&a&&new Date>a&&(Si("Expiration time passed, refreshing session"),l.refresh(Ti()||c))}));const l=e(gi(r,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:r}=await vi(t);if(401===(null==t?void 0:t.status))Si("Received 401, canceling all timers"),i();else if(n||r){if(a=((e,t)=>{if(t)return new Date(1e3*t);Si("Could not extract expiration time from session token, trying to decode the token");try{const t=Bn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,r),!a)return void Si("Could not extract expiration time from session token");c=o;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>Oi&&(Si(`Timeout is too large (${t}ms), setting it to ${Oi}ms`),t=Oi),t})(a);if(i(),e<=2e4)return void Si("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Si(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Si("Refreshing session due to timer"),l.refresh(Ti()||o)}),e)}}}));return Fo(l,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Si("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.30.0"},t.baseHeaders)}))),(e=>t=>{const n=Ji(),o=Ji(),r=Ji(),i=e(gi(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))o.pub(null),r.pub(null),n.pub(null);else{const e=await mi(t);e&&r.pub(e);const{sessionJwt:i,sessionExpiration:s}=await vi(t);i&&o.pub(i),(s||i)&&n.pub(s||42)}}})),s=Fo(i,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const i=await e(...t);return o.pub(null),r.pub(null),n.pub(null),i}));return Object.assign(s,{onSessionTokenChange:o.sub,onUserChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(i),{getLastUserLoginId:Fi,getLastUserDisplayName:zi});const s=e(gi(i,{afterRequest:async(e,t)=>{var n;const o=await mi(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((e=>{wi(Ki,e)})(r),(e=>{wi(qi,e)})(i))}}));let a=Fo(s,["flow.start"],Bi);return a=Fo(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(ki(Ki),ki(qi)),o})(r)),Object.assign(a,{getLastUserLoginId:Fi,getLastUserDisplayName:zi})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:r,storagePrefix:i}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!xi)return e(s);const a=e(gi(s,{beforeRequest:(c=i,e=>Object.assign(e,{token:e.token||Ti(c)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||Ui(i):((e={},t=!1,n="")=>{var o;const{sessionJwt:r,refreshJwt:i}=e;if(i&&wi(`${n}${Ai}`,i),r)if(t){const n=t.sameSite||"Strict",i=null===(o=t.secure)||void 0===o||o;!function(e,t,n){if(t){const{cookieDomain:o,cookiePath:r,cookieSameSite:i,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);ei.set(e,t,{path:r,domain:l?o:void 0,expires:c,sameSite:i,secure:a})}}(Ri,r,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i}))}else wi(`${n}${Ri}`,r);e.idToken&&wi(`${n}${Ei}`,e.idToken)})(await vi(t),r,i)}}));var c;const l=Fo(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const o=await t(...n);return Ui(e),o})(i));return Object.assign(l,{getRefreshToken:()=>Ti(i),getSessionToken:()=>_i(i),getIdToken:()=>Mi(i)})}))((e=>{const t=Gr(e),n=cs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async o=>{var r;if(e.oidcConfig)try{return await n.refreshToken(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}const i=_i(),s=Ti();let a="";if(e.getExternalToken)try{a=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){Si("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:i?"t":"f",dcr:s?"t":"f"},a)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:is(t),webauthn:ns(t),fedcm:(o=t,r=e.projectId,{onetap:{requestExchangeCode(e){rs(o,e)},requestAuthentication(e){rs(o,e)}},oneTap(e,t,n,r,i){rs(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:r,onDismissed:i})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(r+os),clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(i.token)},isSupported:()=>xi&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(r+os);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!i&&!!i.token}catch(e){return!1}}}),oidc:n});var o,r})),ds={search:"/v1/mgmt/accesskey/search",deleteBatch:"/v1/mgmt/accesskey/delete/batch",create:"/v1/mgmt/accesskey/create",deactivate:"/v1/mgmt/accesskey/deactivate/batch",activate:"/v1/mgmt/accesskey/activate/batch"},us={roles:"/v1/mgmt/role/all"},hs=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)})),ps=(...e)=>n(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((n=>{const o=[],r=(new Date).getTime()/1e3+2592e3,i=new Date(r).toLocaleString();for(let e=1;e<10;e+=1)o.push({id:`access-key-id-${e}`,name:`Access Key ${e}`,createdBy:`User ${e}`,editable:!0,expireTime:r,expireTimeFormatted:i,createdTime:r,createdTimeFormatted:i,roleNames:[`Role ${e}`],permittedIps:["127.1.2.3"],status:"active",clientId:`Client ID ${e}`,boundUserId:`User ${e}`});t.forEach((e=>{o.sort(((t,n)=>{var o,r;return e.desc?null===(r=n[e.field])||void 0===r?void 0:r.localeCompare(t[e.field]):null===(o=t[e.field])||void 0===o?void 0:o.localeCompare(n[e.field])}))})),n(o.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.createdBy.toLowerCase().includes(e.toLowerCase()))))}))})),fs=(e,t)=>n(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:n,permittedIps:o},r){const i=Math.random().toString(10).substring(15);return new Promise((s=>{s({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${i}`,name:e||`Access Key ${i}`,createdBy:n||`User ${i}`,editable:!0,expireTime:r,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:o,status:"active",clientId:`Client ID ${i}`,boundUserId:n||`User ${i}`}})}))})),gs=()=>n(void 0,void 0,void 0,(function*(){})),vs=()=>n(void 0,void 0,void 0,(function*(){})),ms=()=>n(void 0,void 0,void 0,(function*(){})),ys=e=>new Promise((t=>{const n=[];for(let t=1;t<5;t+=1)n.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:n})})),ws=({httpClient:e,tenant:t,mock:o})=>({search:(...r)=>n(void 0,[...r],void 0,(function*({page:n,limit:r=1e4,text:i,sort:s}={}){if(o)return ps({page:n,limit:r,text:i,sort:s});const a=yield e.post(ds.search,{limit:r,page:n,text:i,sort:s},{queryParams:{tenant:t}});yield hs(a);return(yield a.json()).keys})),deleteBatch:r=>n(void 0,void 0,void 0,(function*(){if(o)return ms();const n=yield e.post(ds.deleteBatch,{ids:r},{queryParams:{tenant:t}});return yield hs(n),n.json()})),create:r=>n(void 0,[r],void 0,(function*({name:n,expiration:r,roleNames:i,userId:s,permittedIps:a}){const c=new Date;c.setDate(c.getDate()+ +r);const l="0"===r[0]?0:Math.floor(c.getTime()/1e3);if(o)return fs({name:n,expiration:r,roleNames:i,userId:s,permittedIps:a},l);const d=yield e.post(ds.create,{name:n,expireTime:l,roleNames:i,userId:s,permittedIps:a},{queryParams:{tenant:t}});yield hs(d);return yield d.json()})),activate:r=>n(void 0,void 0,void 0,(function*(){if(o)return gs();const n=yield e.post(ds.activate,{ids:r},{queryParams:{tenant:t}});yield hs(n);return yield n.json()})),deactivate:r=>n(void 0,void 0,void 0,(function*(){if(o)return vs();const n=yield e.post(ds.deactivate,{ids:r},{queryParams:{tenant:t}});yield hs(n);return yield n.json()}))}),bs=({httpClient:e,tenant:t,mock:o})=>({getTenantRoles:()=>n(void 0,void 0,void 0,(function*(){if(o)return ys(t);const n=yield e.get(us.roles,{queryParams:{tenant:t}});return yield hs(n),n.json()}))}),ks=u((e=>{var t,s,a,c;const l=i(j,x,w,C,pn,O({tenant:O.missingAttrValidator}))(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),r(this,s,((e,t,n,o)=>{const r=ls(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"access-key-management-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.4.13"}}));return{accesskey:ws({httpClient:r.httpClient,tenant:t,mock:n}),tenant:bs({httpClient:r.httpClient,tenant:t,mock:n})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},c})),Ss=u((e=>{const t=i(un({name:"widget",initialState:qn,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Cn.reducer(e),En.reducer(e),Mn.reducer(e),Pn.reducer(e),Wn.reducer(e),Kn.reducer(e)},asyncActions:{searchAccessKeys:Mn.action,createAccessKey:Cn.action,activateAccessKeys:Pn.action,deactivateAccessKeys:Wn.action,deleteAccessKeys:En.action,getTenantRoles:Kn.action}}),I,w,ks)(e);return class extends t{constructor(...e){super(...e),this.state=qn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Is=u((e=>{const t=i(E,O({"widget-id":O.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`access-key-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),xs=u((e=>{var t,r,a;return a=class extends(i(w,I,K,z,Is,Ss)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([o(this,t,"m",r).call(this),this.actions.searchAccessKeys(),this.actions.getTenantRoles()]),this.onWidgetRootReady()}))}},t=new WeakSet,r=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),Os=u((e=>{var t,r,s,a,l;return l=class extends(i(Ss,w,xs)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{this.accessKeysTable.data=e}))),a.set(this,d(((e,t)=>{const n=[],{value:o}=t;if(o){const t=e.path;n.push({field:t,desc:"desc"===o})}this.actions.searchAccessKeys({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.accessKeysTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{o(this,a,"f").call(this,e.target,e.detail)}))})),o(this,s,"f").call(this,vn(this.state)),this.subscribe(o(this,s,"f").bind(this),vn)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,r=function(){var e;this.accessKeysTable=new X(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="access-keys-table"]'),{logger:this.logger}),this.accessKeysTable.onSelectedItemsChange((e=>{this.actions.setSelectedAccessKeysIds(e.detail.value.map((({id:e})=>e)))}))},l})),js=u((e=>{var t,r,a;return a=class extends(i(Ss,ie,w,xs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){return n(this,void 0,void 0,(function*(){var e;this.activateAccessKeysModal=this.createModal(),this.activateAccessKeysModal.setContent(s(yield this.fetchWidgetPage("activate-access-keys-modal.html")));const t=new G((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.activateAccessKeysModal.close()));const n=new G((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=mn(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const o=new oe(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=kn(this.state);o.text=`Activate ${e}?`}}))},a})),Cs=u((e=>{var t,r,s,a;return a=class extends(i(w,xs,Ss,js)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{e?this.activateButton.enable():this.activateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.subscribe(o(this,s,"f").bind(this),bn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.activateButton=new G(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="activate-access-keys"]'),{logger:this.logger}),this.activateButton.disable(),this.activateButton.onClick((()=>{this.activateAccessKeysModal.open()}))},a})),Rs=u((e=>{var t,r,a;return a=class extends(i(Ss,ie,hn,w,xs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){return n(this,void 0,void 0,(function*(){this.createdAccessKeyModal=this.createModal(),this.createdAccessKeyModal.setContent(s(yield this.fetchWidgetPage("created-access-key-modal.html")));new G((()=>{var e;return null===(e=this.createdAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.createdAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.createdAccessKeyModal.ele),this.createdAccessKeyModal.close()}))}))},a})),As=u((e=>{var t,a,c,l,d;return d=class extends(i(Ss,ie,hn,w,xs,Rs)(e)){constructor(){super(...arguments),t.add(this),a.set(this,void 0),l.set(this,(()=>n(this,void 0,void 0,(function*(){var e,t;yield o(this,a,"f").setData(null===(t=this.state,e=t.tenantRoles.data||[])||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",c).call(this)}))}},a=new WeakMap,l=new WeakMap,t=new WeakSet,c=function e(){return n(this,void 0,void 0,(function*(){this.createAccessKeyModal=this.createModal(),this.createAccessKeyModal.setContent(s(yield this.fetchWidgetPage("create-access-key-modal.html")));new G((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.createAccessKeyModal.close(),this.resetFormData(this.createAccessKeyModal.ele)}));new G((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>n(this,void 0,void 0,(function*(){var e,t;if(this.validateForm(this.createAccessKeyModal.ele)){const n=yield this.actions.createAccessKey(Object.assign({},this.getFormData(this.createAccessKeyModal.ele)));this.createAccessKeyModal.close(),(null===(e=null==n?void 0:n.payload)||void 0===e?void 0:e.cleartext)&&(this.setFormData(this.createdAccessKeyModal.ele,{"generated-key":null===(t=null==n?void 0:n.payload)||void 0===t?void 0:t.cleartext}),this.createdAccessKeyModal.open())}})))),r(this,a,new te((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),o(this,l,"f").call(this),this.createAccessKeyModal.afterClose=()=>{o(this,t,"m",e).call(this)}}))},d})),Es=u((e=>{var t,r,s;return s=class extends(i(w,As,xs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){var e;this.createButton=new G(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-access-key"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createAccessKeyModal.open()))},s})),Ts=u((e=>{var t,r,a;return a=class extends(i(Ss,ie,w,xs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){return n(this,void 0,void 0,(function*(){var e;this.deactivateAccessKeysModal=this.createModal(),this.deactivateAccessKeysModal.setContent(s(yield this.fetchWidgetPage("deactivate-access-keys-modal.html")));const t=new G((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deactivateAccessKeysModal.close()));const n=new G((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=mn(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const o=new oe(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=kn(this.state);o.text=`Deactivate ${e}?`}}))},a})),_s=u((e=>{var t,r,s,a;return a=class extends(i(w,xs,Ss,Ts)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{e?this.deactivateButton.enable():this.deactivateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.subscribe(o(this,s,"f").bind(this),bn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.deactivateButton=new G(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="deactivate-access-keys"]'),{logger:this.logger}),this.deactivateButton.disable(),this.deactivateButton.onClick((()=>{this.deactivateAccessKeysModal.open()}))},a})),Ms=u((e=>{var t,r,a;return a=class extends(i(Ss,ie,w,xs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield o(this,t,"m",r).call(this)}))}},t=new WeakSet,r=function(){return n(this,void 0,void 0,(function*(){var e;this.deleteAccessKeysModal=this.createModal(),this.deleteAccessKeysModal.setContent(s(yield this.fetchWidgetPage("delete-access-keys-modal.html")));const t=new G((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteAccessKeysModal.close()));const n=new G((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=mn(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const o=new oe(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=kn(this.state);o.text=`Delete ${e}?`}}))},a})),Us=u((e=>{var t,r,s,a;return a=class extends(i(w,xs,Ss,Ms)(e)){constructor(){super(...arguments),t.add(this),s.set(this,c((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",r).call(this),this.subscribe(o(this,s,"f").bind(this),bn)}))}},s=new WeakMap,t=new WeakSet,r=function(){var e;this.deleteButton=new G(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-access-keys"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteAccessKeysModal.open()}))},a})),$s=u((e=>{var t,r,s,a;return a=class extends(i(w,xs,Ss)(e)){constructor(){super(...arguments),t.add(this),r.set(this,d((()=>{this.actions.searchAccessKeys({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",s).call(this)}))}},r=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new re(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(o(this,r,"f"))},a}));const Ps={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Ds=u((e=>{var t,r,s,a,l;return l=class extends(i(w,Ss,ae,I)(e)){constructor(){super(...arguments),t.add(this),a.set(this,c((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const i=o(this,t,"m",s).call(this,e);i.setContent(o(this,t,"m",r).call(this,{type:e,msg:n})),i.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(o(this,a,"f").bind(this),gn)}))}},a=new WeakMap,t=new WeakSet,r=function({type:e,msg:t}){const n=Ps[e],o=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${o.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},l})),Ls=u((e=>class extends(i(M,le,Os,Es,Us,$s,Cs,_s,Ds)(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)}))}})),Ws=i((e=>class extends(Ls(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",Ws);const Ns=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Ks,qs,Fs,zs,Bs,Js,Hs,Vs,Zs,Ys;const Xs=document.createElement("template");Xs.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`;class Gs extends HTMLElement{constructor(){var e,t,n;super(),Ks.add(this),qs.set(this,new m({messages:[]})),Fs.set(this,void 0),zs.set(this,void 0),Bs.set(this,void 0),Js.set(this,{resize:o(this,Ks,"m",Ys).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Xs.content.cloneNode(!0));const i=new CSSStyleSheet;i.replaceSync('\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'),null!==(t=(n=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(n.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,i],r(this,Fs,this.shadowRoot.querySelector(".debugger"),"f"),r(this,zs,o(this,Fs,"f").querySelector(".content"),"f"),r(this,Bs,o(this,Fs,"f").querySelector(".header"),"f")}updateData(e){o(this,qs,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=Ns(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,Fs,"f"),o(this,Bs,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Js,"f").resize),(e=o(this,Fs,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,Fs,"f").onresize=o(this,Ks,"m",Zs).bind(this),o(this,qs,"f").subscribe(o(this,Ks,"m",Hs).bind(this))}disconnectedCallback(){o(this,qs,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Js,"f").resize)}}qs=new WeakMap,Fs=new WeakMap,zs=new WeakMap,Bs=new WeakMap,Js=new WeakMap,Ks=new WeakSet,Hs=function(e){o(this,Ks,"m",Vs).call(this,e),o(this,Ks,"m",Zs).call(this)},Vs=function(e){o(this,zs,"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("")},Zs=function(){o(this,zs,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,r=n.clientHeight>20;o||r?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},Ys=function(){const[e,t]=Ns(o(this,Fs,"f"),Number.parseInt(o(this,Fs,"f").style.left,10),Number.parseInt(o(this,Fs,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Fs,"f").style.top=`${t}px`,o(this,Fs,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Gs);var Qs=Object.freeze({__proto__:null,default:Gs});return Ws}();
|
|
8
8
|
//# sourceMappingURL=index.js.map
|