@openmrs/esm-cohort-builder-app 4.0.7-pre.1449 → 4.0.7-pre.1453
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/240.js
CHANGED
|
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
|
|
|
12
12
|
${t}`)}return n}let ox=(e,t)=>{let r=structuredClone(t);if(!e)return r;for(let t of Object.keys(e)){let n=r[t],o=e[t];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){r.hasOwnProperty(t)||(r[t]=o._default);let e=o._elements;if(n&&oE(e)){if(o._type===nC.Array&&Array.isArray(n)){let o=n.map(t=>ox(e,t));r[t]=o}else if(o._type===nC.Object)for(let t of Object.keys(n))n[t]=ox(e,n[t])}}else if(oS(o)){let e=n??{};oS(e)&&(r[t]=ox(o,e))}}return r};function oE(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function oS(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let oO=new Set;function oD(e,t){let r=`${e}:::${t}`;oO||(oO=new Set),oO.has(r)||(console.error(t),oO.add(r))}function oP(e){e?oO.forEach(t=>{t.startsWith(e)&&oO.delete(t)}):oO.clear()}function ok(){n5.forEach(e=>e()),n5.length=0,oe.clear(),od.clear(),op.clear(),of.clear(),n9()}let oC={"Translation overrides":{_description:"Per-language overrides for frontend translations should be keyed by language code and each language dictionary contains the translation key and the display value",_type:nC.Object,_default:{},_validators:[nj(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let t=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${t.join(", ")}.`})]}},oj={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nC.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nC.String,_default:void 0}},...oC},oT=(e,t)=>nj(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),oR=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return nj(e=>{if(!e||"string"!=typeof e)return!1;let r=/\${(.*?)}/g,n=r.exec(e);for(;n;){if(!t.includes(n[1]))return!1;n=r.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},oA=oR([]),oN=e=>nj(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),oI={inRange:oT,isUrl:oA,isUrlWithTemplateParameters:oR,oneOf:oN};var oM=r(8067);let o$=q("breadcrumbs",[]);function oL(e){return oF([e])}function oF(e){let t=[...oB(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,oM.pathToRegexp)(e.matcher).regexp:(0,oM.pathToRegexp)(e.path).regexp,settings:e}))];o$.setState(t,!0)}function oB(){return o$.getState()}function oV(e,t){if(t)return function(e,t){let[r]=e.filter(e=>e.matcher.test(t));return r}(e,t)||function(e,t){let r=t.split("/");for(;r.length>1;){r.pop();let t=oV(e,r.join("/"));if(t)return t}}(e,t)}function oU(e,t){if(e.length>0){let r=oV(e,t);if(r){let t=[r],n=oV(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=oV(e,n.settings.parent);return t.reverse()}}return[]}function oW(e){return oU(oB(),e)}var oK=Object.freeze({__proto__:null,get start(){return aa},get ensureJQuerySupport(){return iz},get setBootstrapMaxTime(){return iD},get setMountMaxTime(){return iP},get setUnmountMaxTime(){return ik},get setUnloadMaxTime(){return iC},get registerApplication(){return i2},get unregisterApplication(){return i4},get getMountedApps(){return iX},get getAppStatus(){return i0},get unloadApplication(){return i6},get checkActivityFunctions(){return i3},get getAppNames(){return iQ},get pathToActiveWhen(){return i9},get navigateToUrl(){return iM},get patchHistoryApi(){return iU},get triggerAppChange(){return ar},get addErrorHandler(){return oY},get removeErrorHandler(){return oZ},get mountRootParcel(){return iw},get NOT_LOADED(){return oQ},get LOADING_SOURCE_CODE(){return o0},get NOT_BOOTSTRAPPED(){return o1},get BOOTSTRAPPING(){return o2},get NOT_MOUNTED(){return o3},get MOUNTING(){return o4},get UPDATING(){return o5},get LOAD_ERROR(){return o7},get MOUNTED(){return o6},get UNLOADING(){return o9},get UNMOUNTING(){return o8},get SKIP_BECAUSE_BROKEN(){return ie}}),oz=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,oH=!function(){try{var e=new oz("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var r=document.createEvent("CustomEvent");return t?r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):r.initCustomEvent(e,!1,!1,void 0),r}:function(e,t){var r=document.createEventObject();return r.type=e,t?(r.bubbles=!!t.bubbles,r.cancelable=!!t.cancelable,r.detail=t.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r}:oz;let oG=[];function oq(e,t,r){let n=oX(e,t,r);oG.length?oG.forEach(e=>e(n)):setTimeout(()=>{throw n})}function oY(e){if("function"!=typeof e)throw Error(oJ(28,!1));oG.push(e)}function oZ(e){if("function"!=typeof e)throw Error(oJ(29,!1));let t=!1;return oG=oG.filter(r=>{let n=r===e;return t=t||n,!n}),t}function oJ(e,t,...r){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${r.length?`&arg=${r.join("&arg=")}`:""}`}function oX(e,t,r){let n,o=`${ia(t)} '${io(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}n=e}else{console.warn(oJ(30,!1,t.status,io(t)));try{n=Error(o+JSON.stringify(e))}catch(t){n=e}}return n.appOrParcelName=io(t),t.status=r,n}let oQ="NOT_LOADED",o0="LOADING_SOURCE_CODE",o1="NOT_BOOTSTRAPPED",o2="BOOTSTRAPPING",o3="NOT_MOUNTED",o4="MOUNTING",o6="MOUNTED",o5="UPDATING",o8="UNMOUNTING",o9="UNLOADING",o7="LOAD_ERROR",ie="SKIP_BECAUSE_BROKEN";function it(e){return e.status===o6}function ir(e){try{return e.activeWhen(window.location)}catch(t){return oq(t,e,ie),!1}}function io(e){return e.name}function ii(e){return!!e.unmountThisParcel}function ia(e){return ii(e)?"parcel":"application"}function is(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function iu(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r];return null}function il(e){return e&&("function"==typeof e||Array.isArray(e)&&!iu(e,e=>"function"!=typeof e))}function ic(e,t){let r=e[t]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[()=>Promise.resolve()]);let n=ia(e),o=io(e);return function(e){return r.reduce((r,i,a)=>r.then(()=>{let r=i(e);return id(r)?r:Promise.reject(oJ(15,!1,n,o,t,a))}),Promise.resolve())}}function id(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let ip=[];function ih(e,t){return Promise.resolve().then(()=>e.status!==o1?e:(e.status=o2,e.bootstrap?ij(e,"bootstrap").then(r).catch(r=>{if(t)throw oX(r,e,ie);return oq(r,e,ie),e}):Promise.resolve().then(r)));function r(){return e.status=o3,e}}function im(e,t){return Promise.resolve().then(()=>{if(e.status!==o6)return e;return e.status=o8,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(r,n=>r().then(()=>{let r=Error(n.message);if(t)throw oX(r,e,ie);oq(r,e,ie)})).then(()=>e);function r(){return ij(e,"unmount").then(()=>{e.status=o3},r=>{if(t)throw oX(r,e,ie);oq(r,e,ie)})}})}let iy=!1,ig=!1;function ib(e,t){return Promise.resolve().then(()=>e.status!==o3?e:(iy||(window.dispatchEvent(new oH("single-spa:before-first-mount")),iy=!0),e.status=o4,ij(e,"mount").then(()=>(e.status=o6,ig||(window.dispatchEvent(new oH("single-spa:first-mount")),ig=!0),e)).catch(r=>{return e.status=o6,im(e,!0).then(n,n);function n(){if(t)throw oX(r,e,ie);return oq(r,e,ie),e}})))}let iv=0,i_={parcels:{}};function iw(){return ix.apply(i_,arguments)}function ix(e,t){let r,n,o,i=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(oJ(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(oJ(3,!1,typeof e.name));let a=iv++,s=e.name||`parcel-${a}`;if("object"!=typeof t)throw Error(oJ(4,!1,s,typeof t));if(!t.domElement)throw Error(oJ(5,!1,s));let u="function"==typeof e,l=u?e:()=>Promise.resolve(e),c={id:a,parcels:{},status:u?o0:o1,customProps:t,parentName:io(i),unmountThisParcel:()=>p.then(()=>{if(c.status!==o6)throw Error(oJ(6,!1,s,c.status));return im(c,!0)}).then(e=>(c.parentName&&delete i.parcels[c.id],e)).then(e=>(n(e),e)).catch(e=>{throw c.status=ie,o(e),e})};i.parcels[a]=c;let d=l();if(!d||"function"!=typeof d.then)throw Error(oJ(7,!1));let f=(d=d.then(e=>{if(!e)throw Error(oJ(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!il(e.bootstrap))throw Error(oJ(9,!1,s));if(!il(e.mount))throw Error(oJ(10,!1,s));if(!il(e.unmount))throw Error(oJ(11,!1,s));if(e.update&&!il(e.update))throw Error(oJ(12,!1,s));let t=ic(e,"bootstrap"),n=ic(e,"mount"),o=ic(e,"unmount");c.status=o1,c.name=s,c.bootstrap=t,c.mount=n,c.unmount=o,c.timeouts=iT(e.timeouts),e.update&&(c.update=ic(e,"update"),r.update=function(e){return c.customProps=e,iE(Promise.resolve().then(()=>{if(c.status!==o6)throw Error(oJ(32,!1,io(c)));return c.status=o5,ij(c,"update").then(()=>(c.status=o6,c)).catch(e=>{throw oX(e,c,ie)})}))})})).then(()=>ih(c,!0)),p=f.then(()=>ib(c,!0)),h=new Promise((e,t)=>{n=e,o=t});return r={mount:()=>iE(Promise.resolve().then(()=>{if(c.status!==o3)throw Error(oJ(13,!1,s,c.status));return i.parcels[a]=c,ib(c)})),unmount:()=>iE(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:iE(d),bootstrapPromise:iE(f),mountPromise:iE(p),unmountPromise:iE(h)}}function iE(e){return e.then(()=>null)}function iS(e){let t=io(e),r="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(oJ(40,!1),t,r));let n=is({},r,{name:t,mountParcel:ix.bind(e),singleSpa:oK});return ii(e)&&(n.unmountSelf=e.unmountThisParcel),n}let iO={bootstrap:{millis:4e3,dieOnTimeout:!1,warningMillis:1e3},mount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unmount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unload:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},update:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3}};function iD(e,t,r){if("number"!=typeof e||e<=0)throw Error(oJ(16,!1));iO.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function iP(e,t,r){if("number"!=typeof e||e<=0)throw Error(oJ(17,!1));iO.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function ik(e,t,r){if("number"!=typeof e||e<=0)throw Error(oJ(18,!1));iO.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function iC(e,t,r){if("number"!=typeof e||e<=0)throw Error(oJ(19,!1));iO.unload={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function ij(e,t){let r=e.timeouts[t],n=r.warningMillis,o=ia(e);return new Promise((i,a)=>{let s=!1,u=!1;e[t](iS(e)).then(e=>{s=!0,i(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>c(1),n),setTimeout(()=>c(!0),r.millis);let l=oJ(31,!1,t,o,io(e),r.millis);function c(e){s||(!0===e?(u=!0,r.dieOnTimeout?a(Error(l)):console.error(l)):!u&&(console.warn(l),e*n+n<r.millis&&setTimeout(()=>c(e+1),n)))}})}function iT(e){let t={};for(let r in iO)t[r]=is({},iO[r],e&&e[r]||{});return t}function iR(e){return Promise.resolve().then(()=>{let t,r;return e.loadPromise?e.loadPromise:e.status!==oQ&&e.status!==o7?e:(e.status=o0,e.loadPromise=Promise.resolve().then(()=>{let n=e.loadApp(iS(e));if(!id(n))throw r=!0,Error(oJ(33,!1,io(e)));return n.then(r=>{let n;e.loadErrorTime=null,"object"!=typeof(t=r)&&(n=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!il(t.bootstrap)&&(n=35),il(t.mount)||(n=36),il(t.unmount)||(n=37);let o=ia(t);if(n){let r;try{r=JSON.stringify(t)}catch(e){}return console.error(oJ(n,!1,o,io(e),r),t),oq(void 0,e,ie),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=is({},e.devtools.overlays,t.devtools.overlays)),e.status=o1,e.bootstrap=ic(t,"bootstrap"),e.mount=ic(t,"mount"),e.unmount=ic(t,"unmount"),e.unload=ic(t,"unload"),e.timeouts=iT(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let n;return delete e.loadPromise,r?n=ie:(n=o7,e.loadErrorTime=(new Date).getTime()),oq(t,e,n),e}))})}let iA="u">typeof window,iN={hashchange:[],popstate:[]},iI=["hashchange","popstate"];function iM(e){let t;if("string"==typeof e)t=e;else if(this&&this.href)t=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(oJ(14,!1));t=e.currentTarget.href,e.preventDefault()}let r=iW(window.location.href),n=iW(t);0===t.indexOf("#")?window.location.hash=n.hash:r.host!==n.host&&n.host?window.location.href=t:n.pathname===r.pathname&&n.search===r.search?window.location.hash=n.hash:window.history.pushState(null,null,t)}function i$(e){if(e){let t=e[0].type;iI.indexOf(t)>=0&&iN[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function iL(){an([],arguments)}function iF(e,t){return function(){let r=window.location.href,n=e.apply(this,arguments),i=window.location.href;return o&&r===i||window.dispatchEvent(function(e,t){let r;try{r=new PopStateEvent("popstate",{state:e})}catch(t){(r=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return r.singleSpa=!0,r.singleSpaTrigger=t,r}(window.history.state,t)),n}}let iB=null,iV=!1;function iU(e){if(iV)throw Error(oJ(43,!1));o=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,iV=!0,iB=window.history.replaceState,window.addEventListener("hashchange",iL),window.addEventListener("popstate",iL);let t=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(e,r){if(!("function"==typeof r&&iI.indexOf(e)>=0)||iu(iN[e],e=>e===r))return t.apply(this,arguments);iN[e].push(r)},window.removeEventListener=function(e,t){return"function"==typeof t&&iI.indexOf(e)>=0&&(iN[e]=iN[e].filter(e=>e!==t)),r.apply(this,arguments)},window.history.pushState=iF(window.history.pushState,"pushState"),window.history.replaceState=iF(iB,"replaceState")}function iW(e){let t=document.createElement("a");return t.href=e,t}iA&&(window.singleSpaNavigate?console.warn(oJ(41,!1)):window.singleSpaNavigate=iM);let iK=!1;function iz(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!iK){let t=e.fn.on,r=e.fn.off;e.fn.on=function(e,r){return iH.call(this,t,window.addEventListener,e,r,arguments)},e.fn.off=function(e,t){return iH.call(this,r,window.removeEventListener,e,t,arguments)},iK=!0}}function iH(e,t,r,n,o){return"string"!=typeof r?e.apply(this,o):(r.split(/\s+/).forEach(e=>{iI.indexOf(e)>=0&&(t(e,n),r=r.replace(e,""))}),""===r.trim()?this:e.apply(this,o))}let iG={};function iq(e){return Promise.resolve().then(()=>{let t=iG[io(e)];if(!t)return e;if(e.status===oQ)return iY(e,t),e;if(e.status===o9)return t.promise.then(()=>e);if(e.status!==o3&&e.status!==o7)return e;let r=e.status===o7?Promise.resolve():ij(e,"unload");return e.status=o9,r.then(()=>(iY(e,t),e)).catch(r=>(delete iG[io(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,oq(r,e,ie),t.reject(r),e))})}function iY(e,t){delete iG[io(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=oQ,t.resolve()}function iZ(e,t,r,n){iG[io(e)]={app:e,resolve:r,reject:n},Object.defineProperty(iG[io(e)],"promise",{get:t})}let iJ=[];function iX(){return iJ.filter(it).map(io)}function iQ(){return iJ.map(io)}function i0(e){let t=iu(iJ,t=>io(t)===e);return t?t.status:null}let i1=!1;function i2(e,t,r,n){var o,i;let a,s,u=(a={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(oJ(39,!1));let t=["name","app","activeWhen","customProps"],r=Object.keys(e).reduce((e,r)=>t.indexOf(r)>=0?e:e.concat(r),[]);if(0!==r.length)throw Error(oJ(38,!1,t.join(", "),r.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(oJ(20,!1));let n=e=>"string"==typeof e||"function"==typeof e;if(!(n(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(n)))throw Error(oJ(24,!1));if(!i8(e.customProps))throw Error(oJ(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,t,r,n){if("string"!=typeof e||0===e.length)throw Error(oJ(20,!1));if(!t)throw Error(oJ(23,!1));if("function"!=typeof r)throw Error(oJ(24,!1));if(!i8(n))throw Error(oJ(22,!1))}(e,t,r,n),a.name=e,a.loadApp=t,a.activeWhen=r,a.customProps=n),a.loadApp="function"!=typeof(o=a.loadApp)?()=>Promise.resolve(o):o,a.customProps=a.customProps||{},s=(s=Array.isArray(i=a.activeWhen)?i:[i]).map(e=>"function"==typeof e?e:i9(e)),a.activeWhen=e=>s.some(t=>t(e)),a);if(ai||i1||(i1=!0,setTimeout(()=>{ai||console.warn(oJ(1,!1))},5e3)),-1!==iQ().indexOf(u.name))throw Error(oJ(21,!1,u.name));iJ.push(is({loadErrorTime:null,status:oQ,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},u)),iA&&(iz(),an())}function i3(e=window.location){return iJ.filter(t=>t.activeWhen(e)).map(io)}function i4(e){if(0===iJ.filter(t=>io(t)===e).length)throw Error(oJ(25,!1,e));return(iA?i6(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=iJ.map(io).indexOf(e);iJ.splice(t,1)})}function i6(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(oJ(26,!1));let r=iu(iJ,t=>io(t)===e);if(!r)throw Error(oJ(27,!1,e));let n=iG[io(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{iZ(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,i5(r,n.resolve,n.reject)):e=new Promise((t,n)=>{iZ(r,()=>e,t,n),i5(r,t,n)}),e}}function i5(e,t,r){Promise.resolve().then(()=>{if(iu(i3(),t=>t===io(e)))return ar()}).then(()=>im(e).then(iq).then(()=>{t(),setTimeout(()=>{an()})})).catch(r)}function i8(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function i9(e,t){let r=function(e,t){let r=0,n=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let r=e[t],o=n&&"/"===r;(!n&&":"===r||o)&&i(t)}return i(e.length),RegExp(o,"i");function i(i){let a=e.slice(r,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=n?"[^/]+/?":a,i===e.length)if(n)t&&(o+="$");else{let e=t?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}n=!n,r=i}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let n=e.href.replace(t,"").replace(e.search,"").split("?")[0];return r.test(n)}}let i7=!1,ae=[],at=iA&&window.location.href;function ar(){return an()}function an(e=[],t,r=!1){let n,o,i,a,s;if(i7)return new Promise((e,r)=>{ae.push({resolve:e,reject:r,eventArguments:t})});let{appsToUnload:u,appsToUnmount:l,appsToLoad:c,appsToMount:d}=(n=[],o=[],i=[],a=[],s=(new Date).getTime(),iJ.forEach(e=>{let t=e.status!==ie&&ir(e);switch(e.status){case o7:t&&s-e.loadErrorTime>=200&&i.push(e);break;case oQ:case o0:t&&i.push(e);break;case o1:case o3:!t&&iG[io(e)]?n.push(e):t&&a.push(e);break;case o6:t||o.push(e)}}),{appsToUnload:n,appsToUnmount:o,appsToLoad:i,appsToMount:a}),f,p=[],h=at,m=at=window.location.href;return ai?(i7=!0,f=u.concat(c,l,d),Promise.resolve().then(()=>(w(0===f.length?"before-no-app-change":"before-app-change",v(!0)),w("before-routing-event",v(!0,{cancelNavigation:y})),Promise.all(p).then(r=>{if(r.some(e=>e))return iB.call(window.history,history.state,"",h.substring(location.origin.length)),at=location.href,i7=!1,an(e,t,!0);let n=u.map(iq),o=Promise.all(l.map(im).map(e=>e.then(iq)).concat(n));o.then(()=>{w("before-mount-routing-event",v(!0))},e=>{throw e});let i=c.map(e=>iR(e).then(e=>ao(e,o))),a=d.filter(e=>0>c.indexOf(e)).map(e=>ao(e,o));return o.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(i.concat(a)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(g).then(()=>{},e=>{throw e})))})))):(f=c,Promise.resolve().then(()=>Promise.all(c.map(iR)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function y(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);p.push(t.catch(e=>(console.warn(Error(oJ(42,!1))),console.warn(e),!1)))}function g(){let t=iX();e.forEach(e=>e.resolve(t));try{w(0===f.length?"no-app-change":"app-change",v()),w("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(i7=!1,ae.length>0){let e=ae;ae=[],an(e)}return t}function b(){r||(e.forEach(e=>{i$(e.eventArguments)}),i$(t))}function v(e=!1,r){let n={},o={[o6]:[],[o3]:[],[oQ]:[],[ie]:[]};e?(c.concat(d).forEach((e,t)=>{a(e,o6)}),u.forEach(e=>{a(e,oQ)}),l.forEach(e=>{a(e,o3)})):f.forEach(e=>{a(e)});let i={detail:{newAppStatuses:n,appsByNewStatus:o,totalAppChanges:f.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return r&&is(i.detail,r),i;function a(e,t){let r=io(e);t=t||i0(r),n[r]=t,(o[t]=o[t]||[]).push(r)}}function w(e,t){r||window.dispatchEvent(new oH(`single-spa:${e}`,t))}}function ao(e,t){return ir(e)?ih(e).then(e=>t.then(()=>ir(e)?ib(e):e)):t.then(()=>e)}let ai=!1;function aa(e){ai=!0,iA&&(iU(e),an())}function as(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,"");return au(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t}).replace(/^\/\//,"/")}function au(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function al({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=as(e,t).replace(window.location.origin,"");n.startsWith(r)?iM(n):window.location.assign(n)}iA&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...iJ]},reroute:an,NOT_LOADED:oQ,toLoadPromise:iR,toBootstrapPromise:ih,unregisterApplication:i4,getProfilerData:function(){return ip}});let ac="openmrs:history";function ad(e){let t=JSON.parse(sessionStorage.getItem(ac)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(ac,JSON.stringify(t))}function af(){0===JSON.parse(sessionStorage.getItem(ac)??"[]").length&&document.referrer&&ad(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=ap();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(ac,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?ah({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&ad(window.location.href)})}function ap(){return JSON.parse(sessionStorage.getItem(ac)??"[]")}function ah({toUrl:e}){let t=ap(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);al({to:t[r]}),sessionStorage.setItem(ac,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function am(){sessionStorage.removeItem(ac)}let ay="${openmrsSpaBase}/login",ag={redirectAuthFailure:{enabled:{_type:nC.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nC.String,_default:ay,_validators:[oI.isUrl],_description:"The url to which users will be redirected when they are logged out. If set to blank, the `location` header from the response will be used."},errors:{_type:nC.Array,_default:[401],_elements:{_type:nC.Number,_validators:[oI.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nC.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}},followRedirects:{_type:nC.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function ab(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let av="/ws/rest/v1",a_="/ws/fhir2/R4",aw=`${av}/session`;function ax(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function aE(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let r=ax(e);if(t.headers||(t.headers={}),eF(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept,e.startsWith(av)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(a_)){let e=new URL(r,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),r=e.toString())}let n=Error();return window.fetch(r,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:o}=await ou("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(r===ax(aw)||204===e.status)&&al({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return r===ax(aw)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(am(),al({to:t.url||e.headers.get("location")||ay}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let o=t;try{o=JSON.parse(t)}catch(e){}throw new aO(r,e,o,n)},t=>{throw new aO(r,e,null,n)})})}function aS(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let r=new AbortController;return t.signal=r.signal,new eC(n=>{let o=!1;return aE(e,t).then(e=>{o=!0,n.next(e),n.complete()},e=>{o=!0,n.error(e)}),()=>{o||r.abort()}})}class aO extends Error{constructor(e,t,r,n){super(),ab(this,"response",void 0),ab(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${n.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
|
-
${this.stack}`}}let aD=q("session",{loaded:!1,session:null}),aP=0;function ak(e={includeAuthStatus:!0}){return(aP<Date.now()-6e4||!aD.getState().loaded)&&aT(),new eC(t=>{let r=r=>{r.loaded&&(e.includeAuthStatus?t.next(r.session):t.next(r.session?.user))};return r(aD.getState()),aD.subscribe(r)})}function aC(){return(aP<Date.now()-6e4||!aD.getState().loaded)&&aT(),aD}function aj(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function aT(e,t){aP=Date.now();let r={};return e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),aL(aE(aw,{headers:r}))}function aR(){aD.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function aA(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!Q(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!Q(n.privileges.find(t=>e===t.display))):(Q(r)||console.error(`Could not understand privileges "${r}"`),!0))||!Q(t.roles.find(e=>"System Developer"===e.display))}function aN(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(aD.getState()),e||(t=aD.subscribe(n))})}function aI(){return new Promise((e,t)=>{ak().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function aM(e,t){return aL(aE(aw,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function a$(e,t,r){return r||(r=new AbortController),await aE(`${av}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),aT()}function aL(e){return new Promise((t,r)=>{e.then(e=>{let n;"object"==typeof e?.data?(n={loaded:!0,session:e.data},aD.setState(n),t(n)):(n={loaded:!1,session:null},aD.setState(n),r(n))}).catch(e=>{I(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};aD.setState(t),r(t)})})}function aF(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}aD.subscribe(e=>{e.loaded&&e.session&&aj(e.session)});let aB={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function aV(){ot("@openmrs/esm-api",ag),aT()}let aU={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var aW=r(2284),aK=r(3029),az=r(2901);function aH(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function aG(e,t){return(aG=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function aq(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&aG(e,t)}function aY(e,t){if(t&&("object"==(0,aW.A)(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return aH(e)}function aZ(e){return(aZ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var aJ=r(4467),aX=r(6369),aQ=r(3612),a0=r(6562);function a1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function a2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a1(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a1(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var a3={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},a4=new(function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,aK.A)(this,e),this.init(t,r)}return(0,az.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||a3,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,r,n){return n&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(r).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,a2(a2({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),a6=function(){function e(){(0,aK.A)(this,e),this.observers={}}return(0,az.A)(e,[{key:"on",value:function(e,t){var r=this;return e.split(" ").forEach(function(e){r.observers[e]=r.observers[e]||[],r.observers[e].push(t)}),this}},{key:"off",value:function(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e]=this.observers[e].filter(function(e){return e!==t})}}},{key:"emit",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.observers[e]&&[].concat(this.observers[e]).forEach(function(e){e.apply(void 0,r)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(t){t.apply(t,[e].concat(r))})}}]),e}();function a5(){var e,t,r=new Promise(function(r,n){e=r,t=n});return r.resolve=e,r.reject=t,r}function a8(e){return null==e?"":""+e}function a9(e,t,r){function n(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function o(){return!e||"string"==typeof e}for(var i="string"!=typeof t?[].concat(t):t.split(".");i.length>1;){if(o())return{};var a=n(i.shift());!e[a]&&r&&(e[a]=new r),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return o()?{}:{obj:e,k:n(i.shift())}}function a7(e,t,r){var n=a9(e,t,Object);n.obj[n.k]=r}function se(e,t){var r=a9(e,t),n=r.obj,o=r.k;if(n)return n[o]}function st(e,t,r){var n=se(e,r);return void 0!==n?n:se(t,r)}function sr(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var sn={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function so(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return sn[e]}):e}var si="u">typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,sa=[" ",",","?","!",";"];function ss(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function su(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ss(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ss(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var sl=function(e){aq(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=aZ(n);return e=t?Reflect.construct(r,arguments,aZ(this).constructor):r.apply(this,arguments),aY(this,e)});function n(e){var t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return(0,aK.A)(this,n),t=r.call(this),si&&a6.call(aH(t)),t.data=e||{},t.options=o,void 0===t.options.keySeparator&&(t.options.keySeparator="."),void 0===t.options.ignoreJSONStructure&&(t.options.ignoreJSONStructure=!0),t}return(0,az.A)(n,[{key:"addNamespaces",value:function(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,i=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure,a=[e,t];r&&"string"!=typeof r&&(a=a.concat(r)),r&&"string"==typeof r&&(a=a.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(a=e.split("."));var s=se(this.data,a);return s||!i||"string"!=typeof r?s:function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(t){if(t[r])return t[r];for(var o=r.split(n),i=t,a=0;a<o.length;++a){if(!i||"string"==typeof i[o[a]]&&a+1<o.length)return;if(void 0===i[o[a]]){for(var s=2,u=o.slice(a,a+s).join(n),l=i[u];void 0===l&&o.length>a+s;)s++,l=i[u=o.slice(a,a+s).join(n)];if(void 0===l)return;if(null===l)return null;if(r.endsWith(u)){if("string"==typeof l)return l;if(u&&"string"==typeof l[u])return l[u]}var c=o.slice(a+s).join(n);if(c)return e(l,c,n);return}i=i[o[a]]}return i}}(this.data&&this.data[e]&&this.data[e][t],r,o)}},{key:"addResource",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},i=this.options.keySeparator;void 0===i&&(i=".");var a=[e,t];r&&(a=a.concat(i?r.split(i):r)),e.indexOf(".")>-1&&(a=e.split("."),n=t,t=a[1]),this.addNamespaces(t),a7(this.data,a,n),o.silent||this.emit("added",e,t,r,n)}},{key:"addResources",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var o in r)("string"==typeof r[o]||"[object Array]"===Object.prototype.toString.apply(r[o]))&&this.addResource(e,t,o,r[o],{silent:!0});n.silent||this.emit("added",e,t,r)}},{key:"addResourceBundle",value:function(e,t,r,n,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),n=r,r=t,t=a[1]),this.addNamespaces(t);var s=se(this.data,a)||{};n?function e(t,r,n){for(var o in r)"__proto__"!==o&&"constructor"!==o&&(o in t?"string"==typeof t[o]||t[o]instanceof String||"string"==typeof r[o]||r[o]instanceof String?n&&(t[o]=r[o]):e(t[o],r[o],n):t[o]=r[o]);return t}(s,r,o):s=su(su({},s),r),a7(this.data,a,s),i.silent||this.emit("added",e,t,r)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return(t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI)?su(su({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(function(e){return t[e]&&Object.keys(t[e]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),n}(a6),sc={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,r,n,o){var i=this;return e.forEach(function(e){i.processors[e]&&(t=i.processors[e].process(t,r,n,o))}),t}};function sd(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sd(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sd(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var sp={},sh=function(e){aq(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=aZ(n);return e=t?Reflect.construct(r,arguments,aZ(this).constructor):r.apply(this,arguments),aY(this,e)});function n(e){var t,o,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,aK.A)(this,n),i=r.call(this),si&&a6.call(aH(i)),t=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],o=aH(i),t.forEach(function(t){e[t]&&(o[t]=e[t])}),i.options=a,void 0===i.options.keySeparator&&(i.options.keySeparator="."),i.logger=a4.create("translator"),i}return(0,az.A)(n,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var r=this.resolve(e,t);return r&&void 0!==r.res}},{key:"extractFromKey",value:function(e,t){var r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");var n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS||[],i=r&&e.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!function(e,t,r){t=t||"",r=r||"";var n=sa.filter(function(e){return 0>t.indexOf(e)&&0>r.indexOf(e)});if(0===n.length)return!0;var o=new RegExp("(".concat(n.map(function(e){return"?"===e?"\\?":e}).join("|"),")")),i=!o.test(e);if(!i){var a=e.indexOf(r);a>0&&!o.test(e.substring(0,a))&&(i=!0)}return i}(e,r,n);if(i&&!a){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:o};var u=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),e=u.join(n)}return"string"==typeof o&&(o=[o]),{key:e,namespaces:o}}},{key:"translate",value:function(e,t,r){var o=this;if("object"!==(0,aW.A)(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var i=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(e[e.length-1],t),u=s.key,l=s.namespaces,c=l[l.length-1],d=t.lng||this.language,f=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&"cimode"===d.toLowerCase()){if(f){var p=t.nsSeparator||this.options.nsSeparator;return i?(h.res="".concat(c).concat(p).concat(u),h):"".concat(c).concat(p).concat(u)}return i?(h.res=u,h):u}var h=this.resolve(e,t),m=h&&h.res,y=h&&h.usedKey||u,g=h&&h.exactUsedKey||u,b=Object.prototype.toString.apply(m),v=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,x="string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m;if(w&&m&&x&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(b)&&("string"!=typeof v||"[object Array]"!==b)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var E=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,m,sf(sf({},t),{},{ns:l})):"key '".concat(u," (").concat(this.language,")' returned an object instead of string.");return i?(h.res=E,h):E}if(a){var S="[object Array]"===b,O=S?[]:{},D=S?g:y;for(var P in m)if(Object.prototype.hasOwnProperty.call(m,P)){var k="".concat(D).concat(a).concat(P);O[P]=this.translate(k,sf(sf({},t),{joinArrays:!1,ns:l})),O[P]===k&&(O[P]=m[P])}m=O}}else if(w&&"string"==typeof v&&"[object Array]"===b)(m=m.join(v))&&(m=this.extendTranslation(m,e,t,r));else{var C=!1,j=!1,T=void 0!==t.count&&"string"!=typeof t.count,R=n.hasDefaultValue(t),A=T?this.pluralResolver.getSuffix(d,t.count,t):"",N=t["defaultValue".concat(A)]||t.defaultValue;!this.isValidLookup(m)&&R&&(C=!0,m=N),this.isValidLookup(m)||(j=!0,m=u);var I=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:m,M=R&&N!==m&&this.options.updateMissing;if(j||C||M){if(this.logger.log(M?"updateKey":"missingKey",d,c,u,M?N:m),a){var $=this.resolve(u,sf(sf({},t),{},{keySeparator:!1}));$&&$.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var L=[],F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&F&&F[0])for(var B=0;B<F.length;B++)L.push(F[B]);else"all"===this.options.saveMissingTo?L=this.languageUtils.toResolveHierarchy(t.lng||this.language):L.push(t.lng||this.language);var V=function(e,r,n){var i=R&&n!==m?n:I;o.options.missingKeyHandler?o.options.missingKeyHandler(e,c,r,i,M,t):o.backendConnector&&o.backendConnector.saveMissing&&o.backendConnector.saveMissing(e,c,r,i,M,t),o.emit("missingKey",e,c,r,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?L.forEach(function(e){o.pluralResolver.getSuffixes(e,t).forEach(function(r){V([e],u+r,t["defaultValue".concat(r)]||N)})}):V(L,u,N))}m=this.extendTranslation(m,e,t,h,r),j&&m===u&&this.options.appendNamespaceToMissingKey&&(m="".concat(c,":").concat(u)),(j||C)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(c,":").concat(u):u,C?m:void 0):this.options.parseMissingKeyHandler(m))}return i?(h.res=m,h):m}},{key:"extendTranslation",value:function(e,t,r,n,o){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,sf(sf({},this.options.interpolation.defaultVariables),r),n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init(sf(sf({},r),{interpolation:sf(sf({},this.options.interpolation),r.interpolation)}));var a,s="string"==typeof e&&(r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(s){var u=e.match(this.interpolator.nestingRegexp);a=u&&u.length}var l=r.replace&&"string"!=typeof r.replace?r.replace:r;if(this.options.interpolation.defaultVariables&&(l=sf(sf({},this.options.interpolation.defaultVariables),l)),e=this.interpolator.interpolate(e,l,r.lng||this.language,r),s){var c=e.match(this.interpolator.nestingRegexp);a<(c&&c.length)&&(r.nest=!1)}!1!==r.nest&&(e=this.interpolator.nest(e,function(){for(var e=arguments.length,n=Array(e),a=0;a<e;a++)n[a]=arguments[a];return o&&o[0]===n[0]&&!r.context?(i.logger.warn("It seems you are nesting recursively key: ".concat(n[0]," in key: ").concat(t[0])),null):i.translate.apply(i,n.concat([t]))},r)),r.interpolation&&this.interpolator.reset()}var d=r.postProcess||this.options.postProcess,f="string"==typeof d?[d]:d;return null!=e&&f&&f.length&&!1!==r.applyPostProcessor&&(e=sc.handle(f,e,t,this.options&&this.options.postProcessPassResolved?sf({i18nResolved:n},r):r,this)),e}},{key:"resolve",value:function(e){var t,r,n,o,i,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!a.isValidLookup(t)){var u=a.extractFromKey(e,s),l=u.key;r=l;var c=u.namespaces;a.options.fallbackNS&&(c=c.concat(a.options.fallbackNS));var d=void 0!==s.count&&"string"!=typeof s.count,f=d&&!s.ordinal&&0===s.count&&a.pluralResolver.shouldUseIntlApi(),p=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,h=s.lngs?s.lngs:a.languageUtils.toResolveHierarchy(s.lng||a.language,s.fallbackLng);c.forEach(function(e){a.isValidLookup(t)||(i=e,!sp["".concat(h[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(i)&&(sp["".concat(h[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(r,'" for languages "').concat(h.join(", "),'" won\'t get resolved as namespace "').concat(i,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),h.forEach(function(r){if(!a.isValidLookup(t)){o=r;var i,u=[l];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(u,l,r,e,s);else{d&&(c=a.pluralResolver.getSuffix(r,s.count,s));var c,h="".concat(a.options.pluralSeparator,"zero");if(d&&(u.push(l+c),f&&u.push(l+h)),p){var m="".concat(l).concat(a.options.contextSeparator).concat(s.context);u.push(m),d&&(u.push(m+c),f&&u.push(m+h))}}for(;i=u.pop();)a.isValidLookup(t)||(n=i,t=a.getResource(r,e,i,s))}}))})}}),{res:t,usedKey:r,exactUsedKey:n,usedLng:o,usedNS:i}}},{key:"isValidLookup",value:function(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}]),n}(a6);function sm(e){return e.charAt(0).toUpperCase()+e.slice(1)}var sy=function(){function e(t){(0,aK.A)(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=a4.create("languageUtils")}return(0,az.A)(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return null;var t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],r=e.split("-");return this.options.lowerCaseLng?r=r.map(function(e){return e.toLowerCase()}):2===r.length?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=sm(r[1].toLowerCase()))):3===r.length&&(r[0]=r[0].toLowerCase(),2===r[1].length&&(r[1]=r[1].toUpperCase()),"sgn"!==r[0]&&2===r[2].length&&(r[2]=r[2].toUpperCase()),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=sm(r[1].toLowerCase())),t.indexOf(r[2].toLowerCase())>-1&&(r[2]=sm(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,r=this;return e?(e.forEach(function(e){if(!t){var n=r.formatLanguageCode(e);(!r.options.supportedLngs||r.isSupportedCode(n))&&(t=n)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var n=r.getLanguagePartFromCode(e);if(r.isSupportedCode(n))return t=n;t=r.options.supportedLngs.find(function(e){if(0===e.indexOf(n))return e})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}},{key:"toResolveHierarchy",value:function(e,t){var r=this,n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),o=[],i=function(e){e&&(r.isSupportedCode(e)?o.push(e):r.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&i(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&i(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&i(this.getLanguagePartFromCode(e))):"string"==typeof e&&i(this.formatLanguageCode(e)),n.forEach(function(e){0>o.indexOf(e)&&i(r.formatLanguageCode(e))}),o}}]),e}(),sg=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],sb={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(+(1!=e&&(e%10!=1||e%100==11)))},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:3*(e%100==3||e%100==4))},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},sv=["v1","v2","v3"],s_={zero:0,one:1,two:2,few:3,many:4,other:5},sw=function(){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,aK.A)(this,e),this.languageUtils=t,this.options=n,this.logger=a4.create("pluralResolver"),(!this.options.compatibilityJSON||"v4"===this.options.compatibilityJSON)&&("u"<typeof Intl||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(r={},sg.forEach(function(e){e.lngs.forEach(function(t){r[t]={numbers:e.nr,plurals:sb[e.fc]}})}),r)}return(0,az.A)(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.getRule(e,t);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,r).map(function(e){return"".concat(t).concat(e)})}},{key:"getSuffixes",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,r);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort(function(e,t){return s_[e]-s_[t]}).map(function(e){return"".concat(t.options.prepend).concat(e)}):n.numbers.map(function(n){return t.getSuffix(e,n,r)}):[]}},{key:"getSuffix",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getRule(e,r);return n?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(n.select(t)):this.getSuffixRetroCompatible(n,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var r=this,n=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),o=e.numbers[n];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===o?o="plural":1===o&&(o=""));var i=function(){return r.options.prepend&&o.toString()?r.options.prepend+o.toString():o.toString()};return"v1"===this.options.compatibilityJSON?1===o?"":"number"==typeof o?"_plural_".concat(o.toString()):i():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?i():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}},{key:"shouldUseIntlApi",value:function(){return!sv.includes(this.options.compatibilityJSON)}}]),e}();function sx(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sE(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sx(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sx(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var sS=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,aK.A)(this,e),this.logger=a4.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return(0,az.A)(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:so,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?sr(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?sr(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?sr(t.nestingPrefix):t.nestingPrefixEscaped||sr("$t("),this.nestingSuffix=t.nestingSuffix?sr(t.nestingSuffix):t.nestingSuffixEscaped||sr(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=RegExp(t,"g");var r="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=RegExp(r,"g")}},{key:"interpolate",value:function(e,t,r,n){var o,i,a,s=this,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function l(e){return e.replace(/\$/g,"$$$$")}var c=function(e){if(0>e.indexOf(s.formatSeparator)){var o=st(t,u,e);return s.alwaysFormat?s.format(o,void 0,r,sE(sE(sE({},n),t),{},{interpolationkey:e})):o}var i=e.split(s.formatSeparator),a=i.shift().trim(),l=i.join(s.formatSeparator).trim();return s.format(st(t,u,a),l,r,sE(sE(sE({},n),t),{},{interpolationkey:a}))};this.resetRegExp();var d=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,f=n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return l(e)}},{regex:this.regexp,safeValue:function(e){return s.escapeValue?l(s.escape(e)):l(e)}}].forEach(function(t){for(a=0;o=t.regex.exec(e);){var r=o[1].trim();if(void 0===(i=c(r)))if("function"==typeof d){var u=d(e,o,n);i="string"==typeof u?u:""}else if(n&&n.hasOwnProperty(r))i="";else if(f){i=o[0];continue}else s.logger.warn("missed to pass in variable ".concat(r," for interpolating ").concat(e)),i="";else"string"==typeof i||s.useRawValueToEscape||(i=a8(i));var l=t.safeValue(i);if(e=e.replace(o[0],l),f?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,++a>=s.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var r,n,o=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=sE({},i);function s(e,t){var r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;var n=e.split(new RegExp("".concat(r,"[ ]*{"))),o="{".concat(n[1]);e=n[0];var i=(o=this.interpolate(o,a)).match(/'/g),s=o.match(/"/g);(i&&i.length%2==0&&!s||s.length%2!=0)&&(o=o.replace(/'/g,'"'));try{a=JSON.parse(o),t&&(a=sE(sE({},t),a))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(r).concat(o)}return delete a.defaultValue,e}for(a.applyPostProcessor=!1,delete a.defaultValue;r=this.nestingRegexp.exec(e);){var u=[],l=!1;if(-1!==r[0].indexOf(this.formatSeparator)&&!/{.*}/.test(r[1])){var c=r[1].split(this.formatSeparator).map(function(e){return e.trim()});r[1]=c.shift(),u=c,l=!0}if((n=t(s.call(this,r[1].trim(),a),a))&&r[0]===e&&"string"!=typeof n)return n;"string"!=typeof n&&(n=a8(n)),n||(this.logger.warn("missed to resolve ".concat(r[1]," for nesting ").concat(e)),n=""),l&&(n=u.reduce(function(e,t){return o.format(e,t,i.lng,sE(sE({},i),{},{interpolationkey:r[1].trim()}))},n.trim())),e=e.replace(r[0],n),this.regexp.lastIndex=0}return e}}]),e}();function sO(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sD(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sO(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sO(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function sP(e){var t={};return function(r,n,o){var i=n+JSON.stringify(o),a=t[i];return a||(a=e(n,o),t[i]=a),a(r)}}var sk=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,aK.A)(this,e),this.logger=a4.create("formatter"),this.options=t,this.formats={number:sP(function(e,t){var r=new Intl.NumberFormat(e,t);return function(e){return r.format(e)}}),currency:sP(function(e,t){var r=new Intl.NumberFormat(e,sD(sD({},t),{},{style:"currency"}));return function(e){return r.format(e)}}),datetime:sP(function(e,t){var r=new Intl.DateTimeFormat(e,sD({},t));return function(e){return r.format(e)}}),relativetime:sP(function(e,t){var r=new Intl.RelativeTimeFormat(e,sD({},t));return function(e){return r.format(e,t.range||"day")}}),list:sP(function(e,t){var r=new Intl.ListFormat(e,sD({},t));return function(e){return r.format(e)}})},this.init(t)}return(0,az.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},r=t.interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=sP(t)}},{key:"format",value:function(e,t,r,n){var o=this;return t.split(this.formatSeparator).reduce(function(e,t){var i=function(e){var t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){var n=e.split("(");t=n[0].toLowerCase().trim();var o=n[1].substring(0,n[1].length-1);"currency"===t&&0>o.indexOf(":")?r.currency||(r.currency=o.trim()):"relativetime"===t&&0>o.indexOf(":")?r.range||(r.range=o.trim()):o.split(";").forEach(function(e){if(e){var t,n=(t=e.split(":"),(0,aX.A)(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||(0,aQ.A)(t)||(0,a0.A)()),o=n[0],i=n.slice(1).join(":").trim().replace(/^'+|'+$/g,"");r[o.trim()]||(r[o.trim()]=i),"false"===i&&(r[o.trim()]=!1),"true"===i&&(r[o.trim()]=!0),isNaN(i)||(r[o.trim()]=parseInt(i,10))}})}return{formatName:t,formatOptions:r}}(t),a=i.formatName,s=i.formatOptions;if(o.formats[a]){var u=e;try{var l=n&&n.formatParams&&n.formatParams[n.interpolationkey]||{},c=l.locale||l.lng||n.locale||n.lng||r;u=o.formats[a](e,c,sD(sD(sD({},s),n),l))}catch(e){o.logger.warn(e)}return u}return o.logger.warn("there was no format function for ".concat(a)),e},e)}}]),e}();function sC(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sj(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sC(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sC(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var sT=function(e){aq(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=aZ(n);return e=t?Reflect.construct(r,arguments,aZ(this).constructor):r.apply(this,arguments),aY(this,e)});function n(e,t,o){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,aK.A)(this,n),i=r.call(this),si&&a6.call(aH(i)),i.backend=e,i.store=t,i.services=o,i.languageUtils=o.languageUtils,i.options=a,i.logger=a4.create("backendConnector"),i.waitingReads=[],i.maxParallelReads=a.maxParallelReads||10,i.readingCalls=0,i.maxRetries=a.maxRetries>=0?a.maxRetries:5,i.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,i.state={},i.queue=[],i.backend&&i.backend.init&&i.backend.init(o,a.backend,a),i}return(0,az.A)(n,[{key:"queueLoad",value:function(e,t,r,n){var o=this,i={},a={},s={},u={};return e.forEach(function(e){var n=!0;t.forEach(function(t){var s="".concat(e,"|").concat(t);!r.reload&&o.store.hasResourceBundle(e,t)?o.state[s]=2:o.state[s]<0||(1===o.state[s]?void 0===a[s]&&(a[s]=!0):(o.state[s]=1,n=!1,void 0===a[s]&&(a[s]=!0),void 0===i[s]&&(i[s]=!0),void 0===u[t]&&(u[t]=!0)))}),n||(s[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(u)}}},{key:"loaded",value:function(e,t,r){var n=e.split("|"),o=n[0],i=n[1];t&&this.emit("failedLoading",o,i,t),r&&this.store.addResourceBundle(o,i,r),this.state[e]=t?-1:2;var a={};this.queue.forEach(function(r){var n,s,u,l;n=r.loaded,(u=(s=a9(n,[o],Object)).obj)[l=s.k]=u[l]||[],u[l].push(i),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(function(e){a[e]||(a[e]={});var t=r.loaded[e];t.length&&t.forEach(function(t){void 0===a[e][t]&&(a[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,r){var n=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:o,wait:i,callback:a}):(this.readingCalls++,this.backend[r](e,t,function(s,u){if(n.readingCalls--,n.waitingReads.length>0){var l=n.waitingReads.shift();n.read(l.lng,l.ns,l.fcName,l.tried,l.wait,l.callback)}s&&u&&o<n.maxRetries?setTimeout(function(){n.read.call(n,e,t,r,o+1,2*i,a)},i):a(s,u)})):a(null,{})}},{key:"prepareLoading",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var i=this.queueLoad(e,t,n,o);if(!i.toLoad.length)return i.pending.length||o(),null;i.toLoad.forEach(function(e){r.loadOne(e)})}},{key:"load",value:function(e,t,r){this.prepareLoading(e,t,{},r)}},{key:"reload",value:function(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}},{key:"loadOne",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e.split("|"),o=n[0],i=n[1];this.read(o,i,"read",void 0,void 0,function(n,a){n&&t.logger.warn("".concat(r,"loading namespace ").concat(i," for language ").concat(o," failed"),n),!n&&a&&t.logger.log("".concat(r,"loaded namespace ").concat(i," for language ").concat(o),a),t.loaded(e,n,a)})}},{key:"saveMissing",value:function(e,t,r,n,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(r,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null==r||""===r||(this.backend&&this.backend.create&&this.backend.create(e,t,r,n,null,sj(sj({},i),{},{isUpdate:o})),e&&e[0]&&this.store.addResource(e[0],t,r,n))}}]),n}(a6);function sR(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&0>e.supportedLngs.indexOf("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function sA(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sN(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sA(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sA(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function sI(){}var sM=function(e){aq(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=aZ(n);return e=t?Reflect.construct(r,arguments,aZ(this).constructor):r.apply(this,arguments),aY(this,e)});function n(){var e,t,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if((0,aK.A)(this,n),t=r.call(this),si&&a6.call(aH(t)),t.options=sR(o),t.services={},t.logger=a4,t.modules={external:[]},Object.getOwnPropertyNames(Object.getPrototypeOf(e=aH(t))).forEach(function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}),i&&!t.isInitialized&&!o.isClone){if(!t.options.initImmediate)return t.init(o,i),aY(t,aH(t));setTimeout(function(){t.init(o,i)},0)}return t}return(0,az.A)(n,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(r=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:0>t.ns.indexOf("translation")&&(t.defaultNS=t.ns[0]));var n={debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===(0,aW.A)(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===(0,aW.A)(e[2])||"object"===(0,aW.A)(e[3])){var r=e[3]||e[2];Object.keys(r).forEach(function(e){t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:function(e,t,r,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}};function o(e){return e?"function"==typeof e?new e:e:null}if(this.options=sN(sN(sN({},n),this.options),sR(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=sN(sN({},n.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){this.modules.logger?a4.init(o(this.modules.logger),this.options):a4.init(null,this.options),this.modules.formatter?i=this.modules.formatter:"u">typeof Intl&&(i=sk);var i,a=new sy(this.options);this.store=new sl(this.options.resources,this.options);var s=this.services;s.logger=a4,s.resourceStore=this.store,s.languageUtils=a,s.pluralResolver=new sw(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),i&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(s.formatter=o(i),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new sS(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new sT(o(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",function(t){for(var r=arguments.length,n=Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];e.emit.apply(e,[t].concat(n))}),this.modules.languageDetector&&(s.languageDetector=o(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=o(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new sh(this.services,this.options),this.translator.on("*",function(t){for(var r=arguments.length,n=Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];e.emit.apply(e,[t].concat(n))}),this.modules.external.forEach(function(t){t.init&&t.init(e)})}if(this.format=this.options.interpolation.format,r||(r=sI),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&"dev"!==u[0]&&(this.options.lng=u[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments),e}});var l=a5(),c=function(){var t=function(t,n){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),l.resolve(n),r(t,n)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),l}},{key:"loadResources",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:sI,n=r,o="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(o&&"cimode"===o.toLowerCase())return n();var i=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){0>i.indexOf(e)&&i.push(e)})};o?a(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(e){return a(e)}),this.options.preload&&this.options.preload.forEach(function(e){return a(e)}),this.services.backendConnector.load(i,this.options.ns,function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),n(e)})}else n(null)}},{key:"reloadResources",value:function(e,t,r){var n=a5();return e||(e=this.languages),t||(t=this.options.ns),r||(r=sI),this.services.backendConnector.reload(e,t,function(e){n.resolve(),r(e)}),n}},{key:"use",value:function(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&sc.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var r=this.languages[t];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}},{key:"changeLanguage",value:function(e,t){var r=this;this.isLanguageChangingTo=e;var n=a5();this.emit("languageChanging",e);var o=function(e){r.language=e,r.languages=r.services.languageUtils.toResolveHierarchy(e),r.resolvedLanguage=void 0,r.setResolvedLanguage(e)},i=function(e,i){i?(o(i),r.translator.changeLanguage(i),r.isLanguageChangingTo=void 0,r.emit("languageChanged",i),r.logger.log("languageChanged",i)):r.isLanguageChangingTo=void 0,n.resolve(function(){return r.t.apply(r,arguments)}),t&&t(e,function(){return r.t.apply(r,arguments)})},a=function(t){e||t||!r.services.languageDetector||(t=[]);var n="string"==typeof t?t:r.services.languageUtils.getBestMatchFromCodes(t);n&&(r.language||o(n),r.translator.language||r.translator.changeLanguage(n),r.services.languageDetector&&r.services.languageDetector.cacheUserLanguage(n)),r.loadResources(n,function(e){i(e,n)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),n}},{key:"getFixedT",value:function(e,t,r){var n=this,o=function e(t,o){if("object"!==(0,aW.A)(o)){for(var i,a=arguments.length,s=Array(a>2?a-2:0),u=2;u<a;u++)s[u-2]=arguments[u];i=n.options.overloadTranslationOptionHandler([t,o].concat(s))}else i=sN({},o);i.lng=i.lng||e.lng,i.lngs=i.lngs||e.lngs,i.ns=i.ns||e.ns,i.keyPrefix=i.keyPrefix||r||e.keyPrefix;var l=n.options.keySeparator||".",c=i.keyPrefix?"".concat(i.keyPrefix).concat(l).concat(t):t;return n.t(c,i)};return"string"==typeof e?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=r,o}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var n=this.resolvedLanguage||this.languages[0],o=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var a=function(e,r){var n=t.services.backendConnector.state["".concat(e,"|").concat(r)];return -1===n||2===n};if(r.precheck){var s=r.precheck(this,a);if(void 0!==s)return s}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!o||a(i,e)))}},{key:"loadNamespaces",value:function(e,t){var r=this,n=a5();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){0>r.options.ns.indexOf(e)&&r.options.ns.push(e)}),this.loadResources(function(e){n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var r=a5();"string"==typeof e&&(e=[e]);var n=this.options.preload||[],o=e.filter(function(e){return 0>n.indexOf(e)});return o.length?(this.options.preload=n.concat(o),this.loadResources(function(e){r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),e)?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr":"rtl"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:sI,o=sN(sN(sN({},this.options),t),{isClone:!0}),i=new n(o);return(void 0!==t.debug||void 0!==t.prefix)&&(i.logger=i.logger.clone(t)),["store","services","language"].forEach(function(t){i[t]=e[t]}),i.services=sN({},this.services),i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i.translator=new sh(i.services,i.options),i.translator.on("*",function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];i.emit.apply(i,[e].concat(r))}),i.init(o,r),i.translator.options=i.options,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),n}(a6);(0,aJ.A)(sM,"createInstance",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new sM(e,t)});var s$=sM.createInstance();s$.createInstance=sM.createInstance,s$.createInstance,s$.init,s$.loadResources,s$.reloadResources,s$.use,s$.changeLanguage,s$.getFixedT,s$.t,s$.exists,s$.setDefaultNamespace,s$.hasLoadedNamespace,s$.loadNamespaces,s$.loadLanguages;let sL=s$.default||s$;function sF(e,t,r,n){return sL.t(t,{ns:e,defaultValue:r,...n})}function sB(e,t,r){return aU[e]?sF("core",e,t??aU[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}sL.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let sV="import-map-override:",sU="import-map-overrides-disabled",sW="import-map-overrides:change",sK=!1,sz=null,sH=null;async function sG(){return sH??(sH=sq().then(({map:e,complete:t})=>(t||(sH=null),e))),sH}async function sq(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let o=e[n];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else o.textContent&&t.push(JSON.parse(o.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:sY(t),complete:r}}function sY(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function sZ(){let e={};try{let t=s1();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(sV)){let r=n.slice(sV.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function sJ(){let e=await sG();return sK?sY([e,sz??sZ()]):e}async function sX(){return sG()}async function sQ(){return sK?sY([await sG(),sZ()]):sG()}function s0(e){if(!sK)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sV)){let t=localStorage.getItem(r);t&&(e[r.slice(sV.length)]=t)}}return{imports:e}}return sZ()}function s1(){if(!sK)return[];try{let e=localStorage.getItem(sU);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function s2(e){return!!sK&&s1().includes(e)}function s3(e,t){if(!sK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sV+e,t),window.dispatchEvent(new CustomEvent(sW))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function s4(e){if(!sK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sV+e);let t=s1().filter(t=>t!==e);t.length>0?localStorage.setItem(sU,JSON.stringify(t)):localStorage.removeItem(sU),window.dispatchEvent(new CustomEvent(sW))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function s6(){if(!sK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(sV)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(sU),window.dispatchEvent(new CustomEvent(sW))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function s5(e){if(!sK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=s1().filter(t=>t!==e);t.length>0?localStorage.setItem(sU,JSON.stringify(t)):localStorage.removeItem(sU),window.dispatchEvent(new CustomEvent(sW))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let s8=!1;function s9(){!s8&&(s8=!0,(sK="development"===window.spaEnv)&&(sz=sZ()))}function s7(e){return e.replace(/[\/\-@]/g,"_")}async function ue(e,t="./start",n){var o;let i,a=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([ut(e,n?.importMap),new Promise((t,r)=>{i=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=a)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},a)})]),i&&clearTimeout(i);let s=s7(e),u=window[s];if(!("object"==typeof(o=u)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}u.init(r.S.default);let l=(await u.get(t))();if("object"!=typeof l||null===l){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return l}async function ut(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=s7(e);if(!window[r]){let r=t??await ur();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let o=e in s0().imports;try{return await function(e){var t;let r=(t=window)[un]??(t[un]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let o=document.createElement("script");o.src=e,o.type="text/javascript",o.async=!0;let i=new Promise((t,n)=>{let i=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function a(){clearTimeout(i),o.removeEventListener("load",s),o.removeEventListener("error",u)}function s(){a(),t()}function u(t){a(),r.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),n(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",u),document.head.appendChild(o)});return r.set(e,i),i}(n)}catch(e){return o&&j({kind:"error",title:sB("scriptLoadingFailed","Error: Script failed to load"),description:sB("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:sB("resetOverrides","Reset overrides"),onActionButtonClick(){s6(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function ur(){return sJ()}let un=Symbol.for("__openmrs_script_loading");function uo(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function ui(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&uo(t))}let ua="openmrs-routes:",us="openmrs-routes:change",uu=!1,ul=null,uc=null;async function ud(){return uc??(uc=uf().then(({map:e,complete:t})=>(t||(uc=null),e))),uc}async function uf(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let o=e[n];try{let e;if(o.src){let t=await fetch(o.src);if(!t.ok)throw Error(`Request for ${o.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&ui(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:up(t),complete:r}}function up(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function uh(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(ua)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(ua.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(uo(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(uo(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function um(){let e=await ud();return uu?up([e,ul??await uh()]):e}async function uy(){return ud()}async function ug(){return uu?up([await ud(),await uh()]):ud()}function ub(){if(!uu)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(ua)){let t=localStorage.getItem(r);t&&(e[r.slice(ua.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function uv(e,t){if(!uu)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(ua+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!uo(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(ua+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(ua+e,JSON.stringify(t.toString()));else{if(!uo(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(ua+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(us))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function u_(e){if(!uu)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(ua+e),window.dispatchEvent(new CustomEvent(us))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function uw(){if(!uu)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(ua)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(us))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let ux=null;function uE(){return ux||(ux=(uu="development"===window.spaEnv)?uh().then(e=>{ul=e}):Promise.resolve())}let uS=`${av}/attachment`;function uO(e,t){return aE(`${uS}/${e}`,{signal:t.signal})}function uD(e,t,r){return aE(`${uS}?patient=${e}&includeEncounterless=${t}`,{signal:r.signal})}async function uP(e,t){let r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),aE(`${uS}`,{method:"POST",body:r})}function uk(e,t){return aE(`${uS}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function uC(e,t){return new Promise(function(r){var n=new MessageChannel;n.port1.onmessage=function(e){r(e.data)},e.postMessage(t,[n.port2])})}function uj(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function uT(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var uR=function(){var e=this;this.promise=new Promise(function(t,r){e.resolve=t,e.reject=r})};function uA(e,t){var r=location.href;return new URL(e,r).href===new URL(t,r).href}var uN=function(e,t){this.type=e,Object.assign(this,t)};function uI(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function uM(){}var u$={type:"SKIP_WAITING"};function uL(e,t){if(!t)return e&&e.then?e.then(uM):Promise.resolve()}var uF=function(e){function t(t,r){var n,o;return void 0===r&&(r={}),(n=e.call(this)||this).nn={},n.tn=0,n.rn=new uR,n.en=new uR,n.on=new uR,n.un=0,n.an=new Set,n.cn=function(){var e=n.fn,t=e.installing;n.tn>0||!uA(t.scriptURL,n.sn.toString())||performance.now()>n.un+6e4?(n.vn=t,e.removeEventListener("updatefound",n.cn)):(n.hn=t,n.an.add(t),n.rn.resolve(t)),++n.tn,t.addEventListener("statechange",n.ln)},n.ln=function(e){var t=n.fn,r=e.target,o=r.state,i=r===n.vn,a={sw:r,isExternal:i,originalEvent:e};!i&&n.mn&&(a.isUpdate=!0),n.dispatchEvent(new uN(o,a)),"installed"===o?n.wn=self.setTimeout(function(){"installed"===o&&t.waiting===r&&n.dispatchEvent(new uN("waiting",a))},200):"activating"===o&&(clearTimeout(n.wn),i||n.en.resolve(r))},n.dn=function(e){var t=n.hn,r=t!==navigator.serviceWorker.controller;n.dispatchEvent(new uN("controlling",{isExternal:r,originalEvent:e,sw:t,isUpdate:n.mn})),r||n.on.resolve(t)},o=function(e){var t=e.data,r=e.ports,o=e.source;return uI(n.getSW(),function(){n.an.has(o)&&n.dispatchEvent(new uN("message",{data:t,originalEvent:e,ports:r,sw:o}))})},n.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},n.sn=t,n.nn=r,navigator.serviceWorker.addEventListener("message",n.gn),n}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var r,n,o=t.prototype;return o.register=function(e){var t=(void 0===e?{}:e).immediate,r=void 0!==t&&t;try{var n,o,i,a=this;return n=function(){if(!r&&"complete"!==document.readyState)return uL(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),uI(a.bn(),function(e){a.fn=e,a.yn&&(a.hn=a.yn,a.en.resolve(a.yn),a.on.resolve(a.yn),a.yn.addEventListener("statechange",a.ln,{once:!0}));var t=a.fn.waiting;return t&&uA(t.scriptURL,a.sn.toString())&&(a.hn=t,Promise.resolve().then(function(){a.dispatchEvent(new uN("waiting",{sw:t,wasWaitingBeforeRegister:!0}))}).then(function(){})),a.hn&&(a.rn.resolve(a.hn),a.an.add(a.hn)),a.fn.addEventListener("updatefound",a.cn),navigator.serviceWorker.addEventListener("controllerchange",a.dn),a.fn})},(i=n())&&i.then?i.then(o):o(i)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?uL(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},o.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},o.messageSW=function(e){try{return uI(this.getSW(),function(t){return uC(t,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&uC(this.fn.waiting,u$)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&uA(e.scriptURL,this.sn.toString())?e:void 0},o.bn=function(){try{var e=this;return function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return uI(navigator.serviceWorker.register(e.sn,e.nn),function(t){return e.un=performance.now(),t})},function(e){throw e})}catch(e){return Promise.reject(e)}},r=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],uj(t.prototype,r),n&&uj(t,n),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,r=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return uT(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?uT(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=r()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function uB(e,t){if(void 0!==f)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),f;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let r=new uF(e,t);return f=r.register().then(()=>r.controlling.then(()=>r))}function uV(){return f??Promise.resolve(void 0)}let uU="x-omrs-offline-response-body",uW="x-omrs-offline-response-status",uK="x-omrs-offline-caching-strategy";async function uz(e){let t=await uV();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function uH(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function uG(){return!window.indexedDB}async function uq(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function uY(){return await uq()||await uG()||await uH()}let uZ="openmrs3:offline-mode",uJ="unavailable";function uX(){return{current:uJ,notAvailable:"unavailable"===uJ,active:"on"===uJ}}function uQ(e){"unavailable"!==uJ&&"unavailable"!==e&&(localStorage.setItem(uZ,"on"===e?"active":"disabled"),uJ=e)}async function u0(){await uY()||(uJ="active"===localStorage.getItem(uZ)?"on":"off"),navigator.onLine}let u1="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,u2=Object.keys,u3=Array.isArray;function u4(e,t){return"object"!=typeof t||u2(t).forEach(function(r){e[r]=t[r]}),e}"u"<typeof Promise||u1.Promise||(u1.Promise=Promise);let u6=Object.getPrototypeOf,u5={}.hasOwnProperty;function u8(e,t){return u5.call(e,t)}function u9(e,t){"function"==typeof t&&(t=t(u6(e))),("u"<typeof Reflect?u2:Reflect.ownKeys)(t).forEach(r=>{le(e,r,t[r])})}let u7=Object.defineProperty;function le(e,t,r,n){u7(e,t,u4(r&&u8(r,"get")&&"function"==typeof r.get?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function lt(e){return{from:function(t){return e.prototype=Object.create(t.prototype),le(e.prototype,"constructor",e),{extend:u9.bind(null,e.prototype)}}}}let lr=Object.getOwnPropertyDescriptor;function ln(e,t){let r;return lr(e,t)||(r=u6(e))&&ln(r,t)}let lo=[].slice;function li(e,t,r){return lo.call(e,t,r)}function la(e,t){return t(e)}function ls(e){if(!e)throw Error("Assertion Failed")}function lu(e){u1.setImmediate?setImmediate(e):setTimeout(e,0)}function ll(e,t){return e.reduce((e,r,n)=>{var o=t(r,n);return o&&(e[o[0]]=o[1]),e},{})}function lc(e,t){if(u8(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var r=[],n=0,o=t.length;n<o;++n){var i=lc(e,t[n]);r.push(i)}return r}var a=t.indexOf(".");if(-1!==a){var s=e[t.substr(0,a)];return void 0===s?void 0:lc(s,t.substr(a+1))}}function ld(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){ls("string"!=typeof r&&"length"in r);for(var n=0,o=t.length;n<o;++n)ld(e,t[n],r[n])}else{var i=t.indexOf(".");if(-1!==i){var a=t.substr(0,i),s=t.substr(i+1);if(""===s)void 0===r?u3(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=r;else{var u=e[a];u&&u8(e,a)||(u=e[a]={}),ld(u,s,r)}}else void 0===r?u3(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function lf(e){var t={};for(var r in e)u8(e,r)&&(t[r]=e[r]);return t}let lp=[].concat;function lh(e){return lp.apply([],e)}let lm="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(lh([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>u1[e]),ly=lm.map(e=>u1[e]);ll(lm,e=>[e,!0]);let lg=null;function lb(e){lg="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let r=lg&&lg.get(t);if(r)return r;if(u3(t)){r=[],lg&&lg.set(t,r);for(var n=0,o=t.length;n<o;++n)r.push(e(t[n]))}else if(ly.indexOf(t.constructor)>=0)r=t;else{let n=u6(t);for(var i in r=n===Object.prototype?{}:Object.create(n),lg&&lg.set(t,r),t)u8(t,i)&&(r[i]=e(t[i]))}return r}(e);return lg=null,t}let{toString:lv}={};function l_(e){return lv.call(e).slice(8,-1)}let lw="u">typeof Symbol?Symbol.iterator:"@@iterator",lx="symbol"==typeof lw?function(e){var t;return null!=e&&(t=e[lw])&&t.apply(e)}:function(){return null},lE={};function lS(e){var t,r,n,o;if(1==arguments.length){if(u3(e))return e.slice();if(this===lE&&"string"==typeof e)return[e];if(o=lx(e)){for(r=[];!(n=o.next()).done;)r.push(n.value);return r}if(null==e)return[e];if("number"==typeof(t=e.length)){for(r=Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=Array(t);t--;)r[t]=arguments[t];return r}let lO="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var lD="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),lP=()=>!0;let lk=!Error("").stack;function lC(){if(lk)try{throw lC.arguments,Error()}catch(e){return e}return Error()}function lj(e,t){var r=e.stack;return r?(t=t||0,0===r.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),r.split("\n").slice(t).filter(lP).map(e=>"\n"+e).join("")):""}var lT=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],lR=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(lT),lA={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function lN(e,t){this._e=lC(),this.name=e,this.message=t}function lI(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,r)=>r.indexOf(e)===t).join("\n")}function lM(e,t,r,n){this._e=lC(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=lI(e,t)}function l$(e,t){this._e=lC(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=lI(e,t)}lt(lN).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+lj(this._e,2))}},toString:function(){return this.name+": "+this.message}}),lt(lM).from(lN),lt(l$).from(lN);var lL=lR.reduce((e,t)=>(e[t]=t+"Error",e),{}),lF=lR.reduce((e,t)=>{var r=t+"Error";function n(e,n){this._e=lC(),this.name=r,e?"string"==typeof e?(this.message=`${e}${n?"\n "+n:""}`,this.inner=n||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=lA[t]||r,this.inner=null)}return lt(n).from(lN),e[t]=n,e},{});lF.Syntax=SyntaxError,lF.Type=TypeError,lF.Range=RangeError;var lB=lT.reduce((e,t)=>(e[t+"Error"]=lF[t],e),{}),lV=lR.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=lF[t]),e),{});function lU(){}function lW(e){return e}function lK(e,t){return null==e||e===lW?t:function(r){return t(e(r))}}function lz(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function lH(e,t){return e===lU?t:function(){var r=e.apply(this,arguments);void 0!==r&&(arguments[0]=r);var n=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?lz(n,this.onsuccess):n),o&&(this.onerror=this.onerror?lz(o,this.onerror):o),void 0!==i?i:r}}function lG(e,t){return e===lU?t:function(){e.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?lz(r,this.onsuccess):r),n&&(this.onerror=this.onerror?lz(n,this.onerror):n)}}function lq(e,t){return e===lU?t:function(r){var n=e.apply(this,arguments);u4(r,n);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?lz(o,this.onsuccess):o),i&&(this.onerror=this.onerror?lz(i,this.onerror):i),void 0===n?void 0===a?void 0:a:u4(n,a)}}function lY(e,t){return e===lU?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function lZ(e,t){return e===lU?t:function(){var r=e.apply(this,arguments);if(r&&"function"==typeof r.then){for(var n=this,o=arguments.length,i=Array(o);o--;)i[o]=arguments[o];return r.then(function(){return t.apply(n,i)})}return t.apply(this,arguments)}}lV.ModifyError=lM,lV.DexieError=lN,lV.BulkError=l$;var lJ={};let[lX,lQ,l0]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,u6(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,u6(t),e]})(),l1=lQ&&lQ.then,l2=lX&&lX.constructor,l3=!!l0;var l4=!1,l6=l0?()=>{l0.then(cy)}:u1.setImmediate?setImmediate.bind(null,cy):u1.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{cy(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(cy,0)},l5=function(e,t){ci.push([e,t]),l9&&(l6(),l9=!1)},l8=!0,l9=!0,l7=[],ce=[],ct=null,cr=lW,cn={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:cF,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{cF(e[0],e[1])}catch(e){}})}},co=cn,ci=[],ca=0,cs=[];function cu(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=lU,this._lib=!1;var t=this._PSD=co;if(lD&&(this._stackHolder=lC(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==lJ)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&cd(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,r){try{r(r=>{if(null===t._state){if(r===t)throw TypeError("A promise cannot be resolved with itself.");var n=t._lib&&cg();r&&"function"==typeof r.then?e(t,(e,t)=>{r instanceof cu?r._then(e,t):r.then(e,t)}):(t._state=!0,t._value=r,cf(t)),n&&cb()}},cd.bind(null,t))}catch(e){cd(t,e)}}(this,e)}let cl={get:function(){var e=co,t=cD;function r(r,n){var o=!e.global&&(e!==co||t!==cD);let i=o&&!cj();var a=new cu((t,a)=>{cp(this,new cc(c$(r,e,o,i),c$(n,e,o,i),t,a,e))});return lD&&cm(a,this),a}return r.prototype=lJ,r},set:function(e){le(this,"then",e&&e.prototype===lJ?cl:{get:function(){return e},set:cl.set})}};function cc(e,t,r,n,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=r,this.reject=n,this.psd=o}function cd(e,t){if(ce.push(t),null===e._state){var r=e._lib&&cg();t=cr(t),e._state=!1,e._value=t,lD&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var r=ln(t,"stack");t._promise=e,le(t,"stack",{get:()=>l4?r&&(r.get?r.get.apply(t):r.value):e.stack})}),l7.some(t=>t._value===e._value)||l7.push(e),cf(e),r&&cb()}}function cf(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)cp(e,t[r]);var o=e._PSD;--o.ref||o.finalize(),0===ca&&(++ca,l5(()=>{0==--ca&&cv()},[]))}function cp(e,t){if(null!==e._state){var r=e._state?t.onFulfilled:t.onRejected;if(null===r)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++ca,l5(ch,[r,e,t])}else e._listeners.push(t)}function ch(e,t,r){try{ct=t;var n,o=t._value;t._state?n=e(o):(ce.length&&(ce=[]),n=e(o),-1===ce.indexOf(o)&&function(e){for(var t=l7.length;t;)if(l7[--t]._value===e._value)return void l7.splice(t,1)}(t)),r.resolve(n)}catch(e){r.reject(e)}finally{ct=null,0==--ca&&cv(),--r.psd.ref||r.psd.finalize()}}function cm(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function cy(){cg()&&cb()}function cg(){var e=l8;return l8=!1,l9=!1,e}function cb(){var e,t,r;do for(;ci.length>0;)for(e=ci,ci=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(ci.length>0);l8=!0,l9=!0}function cv(){var e=l7;l7=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=cs.slice(0),r=t.length;r;)t[--r]()}function c_(e){return new cu(lJ,!1,e)}function cw(e,t){var r=co;return function(){var n=cg(),o=co;try{return cN(r,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{cN(o,!1),n&&cb()}}}u9(cu.prototype,{then:cl,_then:function(e,t){cp(this,new cc(null,null,e,t,co))},catch:function(e){if(1==arguments.length)return this.then(null,e);var t=arguments[0],r=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?r(e):c_(e)):this.then(null,e=>e&&e.name===t?r(e):c_(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),c_(t)))},stack:{get:function(){if(this._stack)return this._stack;try{l4=!0;var e=(function e(t,r,n){if(r.length===n)return r;var o="";if(!1===t._state){var i,a,s=t._value;null!=s?(i=s.name||"Error",a=s.message||s,o=lj(s,0)):(i=s,a=""),r.push(i+(a?": "+a:"")+o)}return lD&&((o=lj(t._stackHolder,2))&&-1===r.indexOf(o)&&r.push(o),t._prev&&e(t._prev,r,n)),r})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{l4=!1}}},timeout:function(e,t){return e<1/0?new cu((r,n)=>{var o=setTimeout(()=>n(new lF.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&le(cu.prototype,Symbol.toStringTag,"Dexie.Promise"),cn.env=cI(),u9(cu,{all:function(){var e=lS.apply(null,arguments).map(cT);return new cu(function(t,r){0===e.length&&t([]);var n=e.length;e.forEach((o,i)=>cu.resolve(o).then(r=>{e[i]=r,--n||t(e)},r))})},resolve:e=>{if(e instanceof cu)return e;if(e&&"function"==typeof e.then)return new cu((t,r)=>{e.then(t,r)});var t=new cu(lJ,!0,e);return cm(t,ct),t},reject:c_,race:function(){var e=lS.apply(null,arguments).map(cT);return new cu((t,r)=>{e.map(e=>cu.resolve(e).then(t,r))})},PSD:{get:()=>co,set:e=>co=e},totalEchoes:{get:()=>cD},newPSD:ck,usePSD:cM,scheduler:{get:()=>l5,set:e=>{l5=e}},rejectionMapper:{get:()=>cr,set:e=>{cr=e}},follow:(e,t)=>new cu((r,n)=>ck((t,r)=>{var n=co;n.unhandleds=[],n.onunhandled=r,n.finalize=lz(function(){var e;e=()=>{0===this.unhandleds.length?t():r(this.unhandleds[0])},cs.push(function t(){e(),cs.splice(cs.indexOf(t),1)}),++ca,l5(()=>{0==--ca&&cv()},[])},n.finalize),e()},t,r,n))}),l2&&(l2.allSettled&&le(cu,"allSettled",function(){let e=lS.apply(null,arguments).map(cT);return new cu(t=>{0===e.length&&t([]);let r=e.length,n=Array(r);e.forEach((e,o)=>cu.resolve(e).then(e=>n[o]={status:"fulfilled",value:e},e=>n[o]={status:"rejected",reason:e}).then(()=>--r||t(n)))})}),l2.any&&"u">typeof AggregateError&&le(cu,"any",function(){let e=lS.apply(null,arguments).map(cT);return new cu((t,r)=>{0===e.length&&r(AggregateError([]));let n=e.length,o=Array(n);e.forEach((e,i)=>cu.resolve(e).then(e=>t(e),e=>{o[i]=e,--n||r(AggregateError(o))}))})}));let cx={awaits:0,echoes:0,id:0};var cE=0,cS=[],cO=0,cD=0,cP=0;function ck(e,t,r,n){var o=co,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++cP;var a=cn.env;i.env=l3?{Promise:cu,PromiseProp:{value:cu,configurable:!0,writable:!0},all:cu.all,race:cu.race,allSettled:cu.allSettled,any:cu.any,resolve:cu.resolve,reject:cu.reject,nthen:cL(a.nthen,i),gthen:cL(a.gthen,i)}:{},t&&u4(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=cM(i,e,r,n);return 0===i.ref&&i.finalize(),s}function cC(){return cx.id||(cx.id=++cE),++cx.awaits,cx.echoes+=100,cx.id}function cj(){return!!cx.awaits&&(0==--cx.awaits&&(cx.id=0),cx.echoes=100*cx.awaits,!0)}function cT(e){return cx.echoes&&e&&e.constructor===l2?(cC(),e.then(e=>(cj(),e),e=>(cj(),cB(e)))):e}function cR(e){++cD,cx.echoes&&0!=--cx.echoes||(cx.echoes=cx.id=0),cS.push(co),cN(e,!0)}function cA(){var e=cS[cS.length-1];cS.pop(),cN(e,!1)}function cN(e,t){var r,n=co;if((t?!cx.echoes||cO++&&e===co:!cO||--cO&&e===co)||(r=t?cR.bind(null,e):cA,l1.call(lX,r)),e!==co&&(co=e,n===cn&&(cn.env=cI()),l3)){var o=cn.env.Promise,i=e.env;lQ.then=i.nthen,o.prototype.then=i.gthen,(n.global||e.global)&&(Object.defineProperty(u1,"Promise",i.PromiseProp),o.all=i.all,o.race=i.race,o.resolve=i.resolve,o.reject=i.reject,i.allSettled&&(o.allSettled=i.allSettled),i.any&&(o.any=i.any))}}function cI(){var e=u1.Promise;return l3?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(u1,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:lQ.then,gthen:e.prototype.then}:{}}function cM(e,t,r,n,o){var i=co;try{return cN(e,!0),t(r,n,o)}finally{cN(i,!1)}}function c$(e,t,r,n){return"function"!=typeof e?e:function(){var o,i=co;r&&cC(),cN(t,!0);try{return e.apply(this,arguments)}finally{cN(i,!1),n&&(o=cj,l1.call(lX,o))}}}function cL(e,t){return function(r,n){return e.call(this,c$(r,t),c$(n,t))}}function cF(e,t){var r;try{r=t.onuncatched(e)}catch(e){}if(!1!==r)try{var n,o={promise:t,reason:e};if(u1.document&&document.createEvent?((n=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),u4(n,o)):u1.CustomEvent&&u4(n=new CustomEvent("unhandledrejection",{detail:o}),o),n&&u1.dispatchEvent&&(dispatchEvent(n),!u1.PromiseRejectionEvent&&u1.onunhandledrejection))try{u1.onunhandledrejection(n)}catch(e){}lD&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+l1).indexOf("[native code]")&&(cC=cj=lU);var cB=cu.reject;let cV=String.fromCharCode(65535),cU="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",cW=[],cK="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),cz=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function cH(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let cG={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function cq(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=lb(t))[e],t)}class cY{_trans(e,t,r){let n=this._tx||co.trans,o=this.name;function i(e,r,n){if(!n.schema[o])throw new lF.NotFound("Table "+o+" not part of transaction");return t(n.idbtrans,n)}let a=cg();try{return n&&n.db===this.db?n===co.trans?n._promise(e,i,r):ck(()=>n._promise(e,i,r),{trans:n,transless:co.transless||co}):function e(t,r,n,o){if(t.idbdb&&(t._state.openComplete||co.letThrough||t._vip)){var i=t._createTransaction(r,n,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===lL.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,o))):cB(i)}return i._promise(r,(e,t)=>ck(()=>(co.trans=i,o(e,t,i)))).then(e=>i._completion.then(()=>e))}if(t._state.openComplete)return cB(new lF.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return cB(new lF.DatabaseClosed);t.open().catch(lU)}return t._state.dbReadyPromise.then(()=>e(t,r,n,o))}(this.db,e,[this.name],i)}finally{a&&cb()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(u3(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=u2(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let r=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)&&e.keyPath.every(e=>t.indexOf(e)>=0))[0];if(r&&this.db._maxKey!==cV)return this.where(r.name).equals(r.keyPath.map(t=>e[t]));!r&&lD&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:n}=this.schema,o=this.db._deps.indexedDB;function i(e,t){try{return 0===o.cmp(e,t)}catch(e){return!1}}let[a,s]=t.reduce(([t,r],o)=>{let a=n[o],s=e[o];return[t||a,t||!a?cH(r,a&&a.multi?e=>{let t=lc(e,o);return u3(t)&&t.some(e=>i(s,e))}:e=>i(s,lc(e,o))):r]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):r?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,u3(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let r=Object.create(e.prototype);for(var n in t)if(u8(t,n))try{r[n]=t[n]}catch(e){}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){u4(this,e)})}add(e,t){let{auto:r,keyPath:n}=this.schema.primKey,o=e;return n&&r&&(o=cq(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[o]})).then(e=>e.numFailures?cu.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{ld(e,n,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||u3(e))return this.where(":id").equals(e).modify(t);{let r=lc(e,this.schema.primKey.keyPath);if(void 0===r)return cB(new lF.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?u2(t).forEach(r=>{ld(e,r,t[r])}):t(e,{value:e,primKey:r})}catch(e){}return this.where(":id").equals(r).modify(t)}}put(e,t){let{auto:r,keyPath:n}=this.schema.primKey,o=e;return n&&r&&(o=cq(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=t?[t]:null})).then(e=>e.numFailures?cu.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{ld(e,n,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?cu.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:cG})).then(e=>e.numFailures?cu.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,r){let n=Array.isArray(t)?t:void 0,o=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new lF.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new lF.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&r?e.map(cq(i)):e;return this.core.mutate({trans:t,type:"add",keys:n,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return o?t:r;throw new l$(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,n)})})}bulkPut(e,t,r){let n=Array.isArray(t)?t:void 0,o=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new lF.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new lF.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&r?e.map(cq(i)):e;return this.core.mutate({trans:t,type:"put",keys:n,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return o?t:r;throw new l$(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,n)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:r,failures:n})=>{if(0===e)return r;throw new l$(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,n)})}}function cZ(e){var t={},r=function(r,n){if(n){for(var o=arguments.length,i=Array(o-1);--o;)i[o-1]=arguments[o];return t[r].subscribe.apply(null,i),e}if("string"==typeof r)return t[r]};r.addEventType=i;for(var n=1,o=arguments.length;n<o;++n)i(arguments[n]);return r;function i(e,n,o){if("object"==typeof e){var a;return void u2(a=e).forEach(function(e){var t=a[e];if(u3(t))i(e,a[e][0],a[e][1]);else{if("asap"!==t)throw new lF.InvalidArgument("Invalid event config");var r=i(e,lW,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];r.subscribers.forEach(function(e){lu(function(){e.apply(null,t)})})})}})}n||(n=lY),o||(o=lU);var s={subscribers:[],fire:o,subscribe:function(e){-1===s.subscribers.indexOf(e)&&(s.subscribers.push(e),s.fire=n(s.fire,e))},unsubscribe:function(e){s.subscribers=s.subscribers.filter(function(t){return t!==e}),s.fire=s.subscribers.reduce(n,o)}};return t[e]=r[e]=s,s}}function cJ(e,t){return lt(t).from({prototype:e}),t}function cX(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function cQ(e,t){e.filter=cH(e.filter,t)}function c0(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>cH(n(),t()):t,e.justLimit=r&&!n}function c1(e,t){if(e.isPrimKey)return t.primaryKey;let r=t.getIndexByKeyPath(e.index);if(!r)throw new lF.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function c2(e,t,r){let n=c1(e,t.schema);return t.openCursor({trans:r,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:n,range:e.range}})}function c3(e,t,r,n){let o=e.replayFilter?cH(e.filter,e.replayFilter()):e.filter;if(e.or){let i={},a=(e,r,n)=>{if(!o||o(r,n,e=>r.stop(e),e=>r.fail(e))){var a=r.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),u8(i,s)||(i[s]=!0,t(e,r,n))}};return Promise.all([e.or._iterate(a,r),c4(c2(e,n,r),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return c4(c2(e,n,r),cH(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function c4(e,t,r,n){var o=cw(n?(e,t,o)=>r(n(e),t,o):r);return e.then(e=>{if(e)return e.start(()=>{var r=()=>e.continue();t&&!t(e,e=>r=e,t=>{e.stop(t),r=lU},t=>{e.fail(t),r=lU})||o(e.value,e,e=>r=e),r()})})}function c6(e,t){try{let r=c5(e),n=c5(t);if(r!==n)return"Array"===r?1:"Array"===n?-1:"binary"===r?1:"binary"===n?-1:"string"===r?1:"string"===n?-1:"Date"===r?1:"Date"!==n?NaN:-1;switch(r){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let r=e.length,n=t.length,o=r<n?r:n;for(let r=0;r<o;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return r===n?0:r<n?-1:1}(c8(e),c8(t));case"Array":return function(e,t){let r=e.length,n=t.length,o=r<n?r:n;for(let r=0;r<o;++r){let n=c6(e[r],t[r]);if(0!==n)return n}return r===n?0:r<n?-1:1}(e,t)}}catch(e){}return NaN}function c5(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let r=l_(e);return"ArrayBuffer"===r?"binary":r}function c8(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class c9{_read(e,t){var r=this._ctx;return r.error?r.table._trans(null,cB.bind(null,r.error)):r.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,cB.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=cH(t.algorithm,e)}_iterate(e,t){return c3(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&u4(r,e),t._ctx=r,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(r=>c3(t,e,r,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,r=t.table.core;if(cX(t,!0))return r.count({trans:e,query:{index:c1(t,r.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var n=0;return c3(t,()=>(++n,!1),e,r).then(()=>n)}).then(e)}sortBy(e,t){let r=e.split(".").reverse(),n=r[0],o=r.length-1;function i(e,t){return t?i(e[r[t]],t-1):e[n]}var a="next"===this._ctx.dir?1:-1;function s(e,t){var r=i(e,o),n=i(t,o);return r<n?-a:r>n?a:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&cX(t,!0)&&t.limit>0){let{valueMapper:r}=t,n=c1(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:n,range:t.range}}).then(({result:e})=>r?e.map(r):e)}{let r=[];return c3(t,e=>r.push(e),e,t.table.core).then(()=>r)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,cX(t)?c0(t,()=>{var t=e;return(e,r)=>0===t||(1===t?--t:r(()=>{e.advance(t),t=0}),!1)}):c0(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),c0(this._ctx,()=>{var t=e;return function(e,r,n){return--t<=0&&r(n),t>=0}},!0),this}until(e,t){return cQ(this._ctx,function(r,n,o){return!e(r.value)||(n(o),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return cQ(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=cH(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.key,r)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.primaryKey,r)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.key)}).then(function(){return r}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&cX(t,!0)&&t.limit>0)return this._read(e=>{var r=c1(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:r,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var r={};return cQ(this._ctx,function(e){var t=e.primaryKey.toString(),n=u8(r,t);return r[t]=!0,!n}),this}modify(e){var t=this._ctx;return this._write(r=>{var n;if("function"==typeof e)n=e;else{var o=u2(e),i=o.length;n=function(t){for(var r=!1,n=0;n<i;++n){var a=o[n],s=e[a];lc(t,a)!==s&&(ld(t,a,s),r=!0)}return r}}let a=t.table.core,{outbound:s,extractKey:u}=a.schema.primaryKey,l=this.db._options.modifyChunkSize||200,c=[],d=0,f=[],p=(e,t)=>{let{failures:r,numFailures:n}=t;for(let t of(d+=e-n,u2(r)))c.push(r[t])};return this.clone().primaryKeys().then(o=>{let i=c=>{let d=Math.min(l,o.length-c);return a.getMany({trans:r,keys:o.slice(c,c+d),cache:"immutable"}).then(f=>{let h=[],m=[],y=s?[]:null,g=[];for(let e=0;e<d;++e){let t=f[e],r={value:lb(t),primKey:o[c+e]};!1!==n.call(r,r.value,r)&&(null==r.value?g.push(o[c+e]):s||0===c6(u(t),u(r.value))?(m.push(r.value),s&&y.push(o[c+e])):(g.push(o[c+e]),h.push(r.value)))}let b=cX(t)&&t.limit===1/0&&("function"!=typeof e||e===c7)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&a.mutate({trans:r,type:"add",values:h}).then(e=>{for(let t in e.failures)g.splice(parseInt(t),1);p(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:y,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>p(m.length,e))).then(()=>(g.length>0||b&&e===c7)&&a.mutate({trans:r,type:"delete",keys:g,criteria:b}).then(e=>p(g.length,e))).then(()=>o.length>c+d&&i(c+l))})};return i(0).then(()=>{if(c.length>0)throw new lM("Error modifying one or more objects",c,d,f);return o.length})})})}delete(){var e=this._ctx,t=e.range;return cX(e)&&(e.isPrimKey&&!cK||3===t.type)?this._write(r=>{let{primaryKey:n}=e.table.core.schema;return e.table.core.count({trans:r,query:{index:n,range:t}}).then(n=>e.table.core.mutate({trans:r,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:r,numFailures:o})=>{if(o)throw new lM("Could not delete some values",Object.keys(e).map(t=>e[t]),n-o);return n-o}))}):this.modify(c7)}}let c7=(e,t)=>t.value=null;function de(e,t){return e<t?-1:+(e!==t)}function dt(e,t){return e>t?-1:+(e!==t)}function dr(e,t,r){var n=e instanceof du?new e.Collection(e):e;return n._ctx.error=r?new r(t):TypeError(t),n}function dn(e){return new e.Collection(e,()=>ds("")).limit(0)}function di(e,t,r,n){var o,i,a,s,u,l,c,d=r.length;if(!r.every(e=>"string"==typeof e))return dr(e,"String expected.");function f(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),i="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?de:dt;var t=r.map(function(e){return{lower:i(e),upper:o(e)}}).sort(function(e,t){return a(e.lower,t.lower)});s=t.map(function(e){return e.upper}),u=t.map(function(e){return e.lower}),l=e,c="next"===e?"":n}f("next");var p=new e.Collection(e,()=>da(s[0],u[d-1]+n));p._ondirectionchange=function(e){f(e)};var h=0;return p._addAlgorithm(function(e,r,n){var o=e.key;if("string"!=typeof o)return!1;var f=i(o);if(t(f,u,h))return!0;for(var p=null,m=h;m<d;++m){var y=function(e,t,r,n,o,i){for(var a=Math.min(e.length,n.length),s=-1,u=0;u<a;++u){var l=t[u];if(l!==n[u])return 0>o(e[u],r[u])?e.substr(0,u)+r[u]+r.substr(u+1):0>o(e[u],n[u])?e.substr(0,u)+n[u]+r.substr(u+1):s>=0?e.substr(0,s)+t[s]+r.substr(s+1):null;0>o(e[u],l)&&(s=u)}return a<n.length&&"next"===i?e+r.substr(e.length):a<e.length&&"prev"===i?e.substr(0,r.length):s<0?null:e.substr(0,s)+n[s]+r.substr(s+1)}(o,f,s[m],u[m],a,l);null===y&&null===p?h=m+1:(null===p||a(p,y)>0)&&(p=y)}return r(null!==p?function(){e.continue(p+c)}:n),!1}),p}function da(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function ds(e){return{type:1,lower:e,upper:e}}class du{get Collection(){return this._ctx.table.db.Collection}between(e,t,r,n){r=!1!==r,n=!0===n;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(r||n)&&(!r||!n)?dn(this):new this.Collection(this,()=>da(e,t,!r,!n))}catch(e){return dr(this,cU)}}equals(e){return null==e?dr(this,cU):new this.Collection(this,()=>ds(e))}above(e){return null==e?dr(this,cU):new this.Collection(this,()=>da(e,void 0,!0))}aboveOrEqual(e){return null==e?dr(this,cU):new this.Collection(this,()=>da(e,void 0,!1))}below(e){return null==e?dr(this,cU):new this.Collection(this,()=>da(void 0,e,!1,!0))}belowOrEqual(e){return null==e?dr(this,cU):new this.Collection(this,()=>da(void 0,e))}startsWith(e){return"string"!=typeof e?dr(this,"String expected."):this.between(e,e+cV,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):di(this,(e,t)=>0===e.indexOf(t[0]),[e],cV)}equalsIgnoreCase(e){return di(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=lS.apply(lE,arguments);return 0===e.length?dn(this):di(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=lS.apply(lE,arguments);return 0===e.length?dn(this):di(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,cV)}anyOf(){let e=lS.apply(lE,arguments),t=this._cmp;try{e.sort(t)}catch(e){return dr(this,cU)}if(0===e.length)return dn(this);let r=new this.Collection(this,()=>da(e[0],e[e.length-1]));r._ondirectionchange=r=>{t="next"===r?this._ascending:this._descending,e.sort(t)};let n=0;return r._addAlgorithm((r,o,i)=>{let a=r.key;for(;t(a,e[n])>0;)if(++n===e.length)return o(i),!1;return 0===t(a,e[n])||(o(()=>{r.continue(e[n])}),!1)}),r}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=lS.apply(lE,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return dr(this,cU)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let r=this._cmp,n=this._ascending,o=this._descending,i=this._min,a=this._max;if(0===e.length)return dn(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=n(e[0],e[1])))return dr(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",lF.InvalidArgument);let s=!t||!1!==t.includeLowers,u=t&&!0===t.includeUppers,l,c=n;function d(e,t){return c(e[0],t[0])}try{(l=e.reduce(function(e,t){let n=0,o=e.length;for(;n<o;++n){let o=e[n];if(0>r(t[0],o[1])&&r(t[1],o[0])>0){o[0]=i(o[0],t[0]),o[1]=a(o[1],t[1]);break}}return n===o&&e.push(t),e},[])).sort(d)}catch(e){return dr(this,cU)}let f=0,p=u?e=>n(e,l[f][1])>0:e=>n(e,l[f][1])>=0,h=s?e=>o(e,l[f][0])>0:e=>o(e,l[f][0])>=0,m=p,y=new this.Collection(this,()=>da(l[0][0],l[l.length-1][1],!s,!u));return y._ondirectionchange=e=>{"next"===e?(m=p,c=n):(m=h,c=o),l.sort(d)},y._addAlgorithm((e,t,r)=>{for(var o=e.key;m(o);)if(++f===l.length)return t(r),!1;return!!(!p(o)&&!h(o))||(0===this._cmp(o,l[f][1])||0===this._cmp(o,l[f][0])||t(()=>{c===n?e.continue(l[f][0]):e.continue(l[f][1])}),!1)}),y}startsWithAnyOf(){let e=lS.apply(lE,arguments);return e.every(e=>"string"==typeof e)?0===e.length?dn(this):this.inAnyRange(e.map(e=>[e,e+cV])):dr(this,"startsWithAnyOf() only works with strings")}}function dl(e){return cw(function(t){return dc(t),e(t.target.error),!1})}function dc(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let dd=cZ(null,"storagemutated");class df{_lock(){return ls(!co.global),++this._reculock,1!==this._reculock||co.global||(co.lockOwnerFor=this),this}_unlock(){if(ls(!co.global),0==--this._reculock)for(co.global||(co.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{cM(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&co.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,r=this.db._state.dbOpenError;if(ls(!this.idbtrans),!e&&!t)switch(r&&r.name){case"DatabaseClosedError":throw new lF.DatabaseClosed(r);case"MissingAPIError":throw new lF.MissingAPI(r.message,r);default:throw new lF.OpenFailed(r)}if(!this.active)throw new lF.TransactionInactive;return ls(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=cw(t=>{dc(t),this._reject(e.error)}),e.onabort=cw(t=>{dc(t),this.active&&this._reject(new lF.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=cw(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&dd.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,r){if("readwrite"===e&&"readwrite"!==this.mode)return cB(new lF.ReadOnly("Transaction is readonly"));if(!this.active)return cB(new lF.TransactionInactive);if(this._locked())return new cu((n,o)=>{this._blockedFuncs.push([()=>{this._promise(e,t,r).then(n,o)},co])});if(r)return ck(()=>{var e=new cu((e,r)=>{this._lock();let n=t(e,r,this);n&&n.then&&n.then(e,r)});return e.finally(()=>this._unlock()),e._lib=!0,e});var n=new cu((e,r)=>{var n=t(e,r,this);n&&n.then&&n.then(e,r)});return n._lib=!0,n}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let r=cu.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>r);else{t._waitingFor=r,t._waitingQueue=[];var n=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(n.get(-1/0).onsuccess=e)}()}var o=t._waitingFor;return new cu((e,n)=>{r.then(r=>t._waitingQueue.push(cw(e.bind(null,r))),e=>t._waitingQueue.push(cw(n.bind(null,e)))).finally(()=>{t._waitingFor===o&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new lF.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(u8(t,e))return t[e];let r=this.schema[e];if(!r)throw new lF.NotFound("Table "+e+" not part of transaction");let n=new this.db.Table(e,r,this);return n.core=this.db.core.table(e),t[e]=n,n}}function dp(e,t,r,n,o,i,a){return{name:e,keyPath:t,unique:r,multi:n,auto:o,compound:i,src:(r&&!a?"&":"")+(n?"*":"")+(o?"++":"")+dh(t)}}function dh(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function dm(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:ll(r,e=>[e.name,e])}}let dy=e=>{try{return e.only([[]]),dy=()=>[[]],[[]]}catch(e){return dy=()=>cV,cV}};function dg(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>lc(t,e):t=>lc(t,e)}function db(e){return[].slice.call(e)}let dv=0;function d_(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function dw({_novip:e},t){let r=t.db,n=function(e,t,{IDBKeyRange:r,indexedDB:n},o){var i;return{dbcore:(i=function(e,t,r){let n;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:r,upper:n,lowerOpen:o,upperOpen:i}=e;return void 0===r?void 0===n?null:t.upperBound(n,!!i):void 0===n?t.lowerBound(r,!!o):t.bound(r,n,!!o,!!i)}let{schema:i,hasGetAll:a}=(n=db(e.objectStoreNames),{schema:{name:e.name,tables:n.map(e=>r.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:r}=e,n=u3(t),o=null==t,i={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:n,keyPath:t,autoIncrement:r,unique:!0,extractKey:dg(t)},indexes:db(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:r,multiEntry:n,keyPath:o}=e,a={name:t,compound:u3(o),keyPath:o,unique:r,multiEntry:n,extractKey:dg(o)};return i[d_(o)]=a,a}),getIndexByKeyPath:e=>i[d_(e)]};return i[":id"]=a.primaryKey,null!=t&&(i[d_(t)]=a.primaryKey),a})},hasGetAll:n.length>0&&"getAll"in r.objectStore(n[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=i.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:r,keys:n,values:i,range:a}){return new Promise((s,u)=>{let l;s=cw(s);let c=e.objectStore(t),d=null==c.keyPath,f="put"===r||"add"===r;if(!f&&"delete"!==r&&"deleteRange"!==r)throw Error("Invalid operation type: "+r);let{length:p}=n||i||{length:1};if(n&&i&&n.length!==i.length)throw Error("Given keys array must have same length as given values array.");if(0===p)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],y=0,g=e=>{++y,dc(e)};if("deleteRange"===r){if(4===a.type)return s({numFailures:y,failures:m,results:[],lastResult:void 0});3===a.type?h.push(l=c.clear()):h.push(l=c.delete(o(a)))}else{let[e,t]=f?d?[i,n]:[i,null]:[n,null];if(f)for(let n=0;n<p;++n)h.push(l=t&&void 0!==t[n]?c[r](e[n],t[n]):c[r](e[n])),l.onerror=g;else for(let t=0;t<p;++t)h.push(l=c[r](e[t])),l.onerror=g}let b=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:y,failures:m,results:"delete"===r?n:h.map(e=>e.result),lastResult:t})};l.onerror=e=>{g(e),b(e)},l.onsuccess=b})},getMany:({trans:e,keys:r})=>new Promise((n,o)=>{n=cw(n);let i=e.objectStore(t),a=r.length,s=Array(a),u,l=0,c=0,d=e=>{let t=e.target;s[t._pos]=t.result,++c===l&&n(s)},f=dl(o);for(let e=0;e<a;++e)null!=r[e]&&((u=i.get(r[e]))._pos=e,u.onsuccess=d,u.onerror=f,++l);0===l&&n(s)}),get:({trans:e,key:r})=>new Promise((n,o)=>{n=cw(n);let i=e.objectStore(t).get(r);i.onsuccess=e=>n(e.target.result),i.onerror=dl(o)}),query:e=>new Promise((r,n)=>{r=cw(r);let{trans:i,values:s,limit:u,query:l}=e,c=u===1/0?void 0:u,{index:d,range:f}=l,p=i.objectStore(t),h=d.isPrimaryKey?p:p.index(d.name),m=o(f);if(0===u)return r({result:[]});if(a){let e=s?h.getAll(m,c):h.getAllKeys(m,c);e.onsuccess=e=>r({result:e.target.result}),e.onerror=dl(n)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];t.onsuccess=n=>{let i=t.result;return i?(o.push(s?i.value:i.primaryKey),++e===u?r({result:o}):void i.continue()):r({result:o})},t.onerror=dl(n)}}),openCursor:function({trans:e,values:r,query:n,reverse:i,unique:a}){return new Promise((s,u)=>{s=cw(s);let{index:l,range:c}=n,d=e.objectStore(t),f=l.isPrimaryKey?d:d.index(l.name),p=i?a?"prevunique":"prev":a?"nextunique":"next",h=!r&&"openKeyCursor"in f?f.openKeyCursor(o(c),p):f.openCursor(o(c),p);h.onerror=dl(u),h.onsuccess=cw(t=>{let r=h.result;if(!r)return void s(null);r.___id=++dv,r.done=!1;let n=r.continue.bind(r),o=r.continuePrimaryKey;o&&(o=o.bind(r));let i=r.advance.bind(r),a=()=>{throw Error("Cursor not stopped")};r.trans=e,r.stop=r.continue=r.continuePrimaryKey=r.advance=()=>{throw Error("Cursor not started")},r.fail=cw(u),r.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},r.start=e=>{let t=new Promise((e,t)=>{e=cw(e),h.onerror=dl(t),r.fail=t,r.stop=t=>{r.stop=r.continue=r.continuePrimaryKey=r.advance=a,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){r.fail(e)}else r.done=!0,r.start=()=>{throw Error("Cursor behind last entry")},r.stop()};return h.onsuccess=cw(e=>{h.onsuccess=s,s()}),r.continue=n,r.continuePrimaryKey=o,r.advance=i,s(),t},s(r)},u)})},count({query:e,trans:r}){let{index:n,range:i}=e;return new Promise((e,a)=>{let s=r.objectStore(t),u=n.isPrimaryKey?s:s.index(n.name),l=o(i),c=l?u.count(l):u.count();c.onsuccess=cw(t=>e(t.target.result)),c.onerror=dl(a)})}}}),u={};return s.forEach(e=>u[e.name]=e),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!u[e])throw Error(`Table '${e}' not found`);return u[e]},MIN_KEY:-1/0,MAX_KEY:dy(t),schema:i}}(t,r,o),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),i))}}(e._middlewares,r,e._deps,t);e.core=n.dbcore,e.tables.forEach(t=>{let r=t.name;e.core.schema.tables.some(e=>e.name===r)&&(t.core=e.core.table(r),e[r]instanceof e.Table&&(e[r].core=t.core))})}function dx({_novip:e},t,r,n){r.forEach(r=>{let o=n[r];t.forEach(t=>{let n=ln(t,r);(!n||"value"in n&&void 0===n.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?le(t,r,{get(){return this.table(r)},set(e){u7(this,r,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[r]=new e.Table(r,o))})})}function dE({_novip:e},t){t.forEach(t=>{for(let r in t)t[r]instanceof e.Table&&delete t[r]})}function dS(e,t){return e._cfg.version-t._cfg.version}function dO(e,t){let r,n={del:[],add:[],change:[]};for(r in e)t[r]||n.del.push(r);for(r in t){let o=e[r],i=t[r];if(o){let e={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(i.primKey.keyPath||"")&&(o.primKey.auto===i.primKey.auto||cK)){let t,r=o.idxByName,a=i.idxByName;for(t in r)a[t]||e.del.push(t);for(t in a){let n=r[t],o=a[t];n?n.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}else e.recreate=!0,n.change.push(e)}else n.add.push([r,i])}return n}function dD(e,t,r,n){let o=e.db.createObjectStore(t,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(e=>dP(o,e)),o}function dP(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function dk(e,t,r){let n={};return li(t.objectStoreNames,0).forEach(e=>{let t=r.objectStore(e),o=t.keyPath,i=dp(dh(o),o||"",!1,!1,!!t.autoIncrement,o&&"string"!=typeof o,!0),a=[];for(let e=0;e<t.indexNames.length;++e){let r=t.index(t.indexNames[e]);o=r.keyPath;var s=dp(r.name,o,!!r.unique,!!r.multiEntry,!1,o&&"string"!=typeof o,!1);a.push(s)}n[e]=dm(e,i,a)}),n}function dC({_novip:e},t,r){let n=r.db.objectStoreNames;for(let o=0;o<n.length;++o){let i=n[o],a=r.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let r=a.indexNames[e],n=a.index(r).keyPath,o="string"==typeof n?n:"["+li(n).join("+")+"]";if(t[i]){let e=t[i].idxByName[o];e&&(e.name=r,delete t[i].idxByName[o],t[i].idxByName[r]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&u1.WorkerGlobalScope&&u1 instanceof u1.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class dj{_parseStoresSpec(e,t){u2(e).forEach(r=>{if(null!==e[r]){var n=e[r].split(",").map((e,t)=>{let r=(e=e.trim()).replace(/([&*]|\+\+)/g,""),n=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return dp(r,n||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),u3(n),0===t)}),o=n.shift();if(o.multi)throw new lF.Schema("Primary key cannot be multi-valued");n.forEach(e=>{if(e.auto)throw new lF.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new lF.Schema("Index must have a name and cannot be an empty string")}),t[r]=dm(r,o,n)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?u4(this._cfg.storesSource,e):e;let r=t._versions,n={},o={};return r.forEach(e=>{u4(n,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(n,o)}),t._dbSchema=o,dE(t,[t._allTables,t,t.Transaction.prototype]),dx(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],u2(o),o),t._storeNames=u2(o),this}upgrade(e){return this._cfg.contentUpgrade=lZ(this._cfg.contentUpgrade||lU,e),this}}function dT(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new dZ("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),r.table("dbnames")}function dR(e){return e&&"function"==typeof e.databases}function dA(e){return ck(function(){return co.letThrough=!0,e()})}function dN(e){var t=t=>e.next(t),r=o(t),n=o(t=>e.throw(t));function o(e){return t=>{var o=e(t),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(r,n):u3(i)?Promise.all(i).then(r,n):r(i)}}return o(t)()}function dI(e,t,r){var n=arguments.length;if(n<2)throw new lF.InvalidArgument("Too few arguments");for(var o=Array(n-1);--n;)o[n-1]=arguments[n];return r=o.pop(),[e,lh(o),r]}function dM(e,t,r){let n=u3(e)?e.slice():[e];for(let e=0;e<r;++e)n.push(t);return n}let d$={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let r=e.table(t),{schema:n}=r,o={},i=[];function a(e,t,r){let n=d_(e),s=o[n]=o[n]||[],u=null==e?0:"string"==typeof e?1:e.length,l=t>0,c={...r,isVirtual:l,keyTail:t,keyLength:u,extractKey:dg(e),unique:!l&&r.unique};return s.push(c),c.isPrimaryKey||i.push(c),u>1&&a(2===u?e[0]:e.slice(0,u-1),t+1,r),s.sort((e,t)=>e.keyTail-t.keyTail),c}let s=a(n.primaryKey.keyPath,0,n.primaryKey);for(let e of(o[":id"]=[s],n.indexes))a(e.keyPath,0,e);function u(t){var r,n;let o=t.query.index;return o.isVirtual?{...t,query:{index:o,range:(r=t.query.range,n=o.keyTail,{type:1===r.type?2:r.type,lower:dM(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,n),lowerOpen:!0,upper:dM(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,n),upperOpen:!0})}}:t}return{...r,schema:{...n,primaryKey:s,indexes:i,getIndexByKeyPath:function(e){let t=o[d_(e)];return t&&t[0]}},count:e=>r.count(u(e)),query:e=>r.query(u(e)),openCursor(t){let{keyTail:n,isVirtual:o,keyLength:i}=t.query.index;return o?r.openCursor(u(t)).then(r=>r&&Object.create(r,{continue:{value:function(o){null!=o?r.continue(dM(o,t.reverse?e.MAX_KEY:e.MIN_KEY,n)):t.unique?r.continue(r.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,n)):r.continue()}},continuePrimaryKey:{value(t,o){r.continuePrimaryKey(dM(t,e.MAX_KEY,n),o)}},primaryKey:{get:()=>r.primaryKey},key:{get(){let e=r.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>r.value}})):r.openCursor(t)}}}}}};function dL(e,t,r,n){return r=r||{},n=n||"",u2(e).forEach(o=>{if(u8(t,o)){var i=e[o],a=t[o];if("object"==typeof i&&"object"==typeof a&&i&&a){let e=l_(i);e!==l_(a)?r[n+o]=t[o]:"Object"===e?dL(i,a,r,n+o+"."):i!==a&&(r[n+o]=t[o])}else i!==a&&(r[n+o]=t[o])}else r[n+o]=void 0}),u2(t).forEach(o=>{u8(e,o)||(r[n+o]=t[o])}),r}let dF={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let r=e.table(t),{primaryKey:n}=r.schema;return{...r,mutate(e){let o=co.trans,{deleting:i,creating:a,updating:s}=o.table(t).hook;switch(e.type){case"add":if(a.fire===lU)break;return o._promise("readwrite",()=>u(e),!0);case"put":if(a.fire===lU&&s.fire===lU)break;return o._promise("readwrite",()=>u(e),!0);case"delete":if(i.fire===lU)break;return o._promise("readwrite",()=>u(e),!0);case"deleteRange":if(i.fire===lU)break;return o._promise("readwrite",()=>(function e(t,o,i){return r.query({trans:t,values:!1,query:{index:n,range:o},limit:i}).then(({result:r})=>u({type:"delete",keys:r,trans:t}).then(n=>n.numFailures>0?Promise.reject(n.failures[0]):r.length<i?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...o,lower:r[r.length-1],lowerOpen:!0},i)))})(e.trans,e.range,1e4),!0)}return r.mutate(e);function u(e){var t,o;let u=co.trans,l=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(n.extractKey));if(!l)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:l}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(o=e).type?Promise.resolve([]):r.getMany({trans:o.trans,keys:l,cache:"immutable"})).then(t=>{let o=l.map((r,o)=>{let l=t[o],c={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(c,r,l,u);else if("add"===e.type||void 0===l){let t=a.fire.call(c,r,e.values[o],u);null==r&&null!=t&&(r=t,e.keys[o]=r,n.outbound||ld(e.values[o],n.keyPath,r))}else{let t=dL(l,e.values[o]),n=s.fire.call(c,t,r,l,u);if(n){let t=e.values[o];Object.keys(n).forEach(e=>{u8(t,e)?t[e]=n[e]:ld(t,e,n[e])})}}return c});return r.mutate(e).then(({failures:r,results:n,numFailures:i,lastResult:a})=>{for(let i=0;i<l.length;++i){let a=n?n[i]:l[i],s=o[i];null==a?s.onerror&&s.onerror(r[i]):s.onsuccess&&s.onsuccess("put"===e.type&&t[i]?e.values[i]:a)}return{failures:r,results:n,numFailures:i,lastResult:a}}).catch(e=>(o.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function dB(e,t,r){try{if(!t||t.keys.length<e.length)return null;let n=[];for(let o=0,i=0;o<t.keys.length&&i<e.length;++o)0===c6(t.keys[o],e[i])&&(n.push(r?lb(t.values[o]):t.values[o]),++i);return n.length===e.length?n:null}catch(e){return null}}let dV={stack:"dbcore",level:-1,create:e=>({table:t=>{let r=e.table(t);return{...r,getMany:e=>{if(!e.cache)return r.getMany(e);let t=dB(e.keys,e.trans._cache,"clone"===e.cache);return t?cu.resolve(t):r.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?lb(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),r.mutate(e))}}})};function dU(e){return!("from"in e)}let dW=function(e,t){if(!this){let t=new dW;return e&&"d"in e&&u4(t,e),t}u4(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function dK(e,t,r){let n=c6(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(dU(e))return u4(e,{from:t,to:r,d:1});let o=e.l,i=e.r;if(0>c6(r,e.from))return o?dK(o,t,r):e.l={from:t,to:r,d:1,l:null,r:null},dG(e);if(c6(t,e.to)>0)return i?dK(i,t,r):e.r={from:t,to:r,d:1,l:null,r:null},dG(e);0>c6(t,e.from)&&(e.from=t,e.l=null,e.d=i?i.d+1:1),c6(r,e.to)>0&&(e.to=r,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;o&&!e.l&&dz(e,o),i&&a&&dz(e,i)}function dz(e,t){dU(t)||function e(t,{from:r,to:n,l:o,r:i}){dK(t,r,n),o&&e(t,o),i&&e(t,i)}(e,t)}function dH(e){let t=dU(e)?null:{s:0,n:e};return{next(e){let r=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&0>c6(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||0>=c6(e,t.n.to))return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function dG(e){var t,r;let n=((null==(t=e.r)?void 0:t.d)||0)-((null==(r=e.l)?void 0:r.d)||0),o=n>1?"r":n<-1?"l":"";if(o){let t="r"===o?"l":"r",r={...e},n=e[o];e.from=n.from,e.to=n.to,e[o]=n[o],r[o]=n[t],e[t]=r,r.d=dq(r)}e.d=dq(e)}function dq({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}u9(dW.prototype,{add(e){return dz(this,e),this},addKey(e){return dK(this,e,e),this},addKeys(e){return e.forEach(e=>dK(this,e,e)),this},[lw](){return dH(this)}});let dY={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,r=new dW(e.MIN_KEY,e.MAX_KEY);return{...e,table:n=>{let o=e.table(n),{schema:i}=o,{primaryKey:a}=i,{extractKey:s,outbound:u}=a,l={...o,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),u=e=>{let r=`idb://${t}/${n}/${e}`;return s[r]||(s[r]=new dW)},l=u(""),c=u(":dels"),{type:d}=e,[f,p]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return o.mutate(e).then(e=>{if(u3(f)){"delete"!==d&&(f=e.results),l.addKeys(f);let t=dB(f,h);t||"add"===d||c.addKeys(f),(t||p)&&i.indexes.forEach(function(e){let r=u(e.name||"");function n(t){return null!=t?e.extractKey(t):null}let o=t=>e.multiEntry&&u3(t)?t.forEach(e=>r.addKey(e)):r.addKey(t);(t||p).forEach((e,r)=>{let i=t&&n(t[r]),a=p&&n(p[r]);0!==c6(i,a)&&(null!=i&&o(i),null!=a&&o(a))})})}else if(f){let e={from:f.lower,to:f.upper};c.add(e),l.add(e)}else l.add(r),c.add(r),i.indexes.forEach(e=>u(e.name).add(r));return e})}},c=({query:{index:t,range:r}})=>{var n,o;return[t,new dW(null!=(n=r.lower)?n:e.MIN_KEY,null!=(o=r.upper)?o:e.MAX_KEY)]},d={get:e=>[a,new dW(e.key)],getMany:e=>[a,(new dW).addKeys(e.keys)],count:c,query:c,openCursor:c};return u2(d).forEach(e=>{l[e]=function(i){let{subscr:a}=co;if(a){let l=e=>{let r=`idb://${t}/${n}/${e}`;return a[r]||(a[r]=new dW)},c=l(""),f=l(":dels"),[p,h]=d[e](i);if(l(p.name||"").add(h),!p.isPrimaryKey){if("count"!==e){let t="query"===e&&u&&i.values&&o.query({...i,values:!1});return o[e].apply(this,arguments).then(r=>{if("query"===e){if(u&&i.values)return t.then(({result:e})=>(c.addKeys(e),r));let e=i.values?r.result.map(s):r.result;i.values?c.addKeys(e):f.addKeys(e)}else if("openCursor"===e){let e=i.values;return r&&Object.create(r,{key:{get:()=>(f.addKey(r.primaryKey),r.key)},primaryKey:{get(){let e=r.primaryKey;return f.addKey(e),e}},value:{get:()=>(e&&c.addKey(r.primaryKey),r.value)}})}return r})}f.add(r)}}return o[e].apply(this,arguments)}}),l}}}};class dZ{constructor(e,t){var r;this._middlewares={},this.verno=0;const n=dZ.dependencies;this._options=t={addons:dZ.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:o}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:lU,dbReadyPromise:null,cancelOpen:lU,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};i.dbReadyPromise=new cu(e=>{i.dbReadyResolve=e}),i.openCanceller=new cu((e,t)=>{i.cancelOpen=t}),this._state=i,this.name=e,this.on=cZ(this,"populate","blocked","versionchange","close",{ready:[lZ,lU]}),this.on.ready.subscribe=la(this.on.ready.subscribe,e=>(t,r)=>{dZ.vip(()=>{let n=this._state;if(n.openComplete)n.dbOpenError||cu.resolve().then(t),r&&e(t);else if(n.onReadyBeingFired)n.onReadyBeingFired.push(t),r&&e(t);else{e(t);let n=this;r||e(function e(){n.on.ready.unsubscribe(t),n.on.ready.unsubscribe(e)})}})}),this.Collection=(r=this,cJ(c9.prototype,function(e,t){this.db=r;let n=cG,o=null;if(t)try{n=t()}catch(e){o=e}let i=e._ctx,a=i.table,s=a.hook.reading.fire;this._ctx={table:a,index:i.index,isPrimKey:!i.index||a.schema.primKey.keyPath&&i.index===a.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:i.or,valueMapper:s!==lW?s:null}})),this.Table=function(e){return cJ(cY.prototype,function(t,r,n){this.db=e,this._tx=n,this.name=t,this.schema=r,this.hook=e._allTables[t]?e._allTables[t].hook:cZ(null,{creating:[lH,lU],reading:[lK,lW],updating:[lq,lU],deleting:[lG,lU]})})}(this),this.Transaction=function(e){return cJ(df.prototype,function(t,r,n,o,i){this.db=e,this.mode=t,this.storeNames=r,this.schema=n,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=cZ(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new cu((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),cB(e)})})}(this),this.Version=function(e){return cJ(dj.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return cJ(du.prototype,function(t,r,n){this.db=e,this._ctx={table:t,index:":id"===r?null:r,or:n};let o=e._deps.indexedDB;if(!o)throw new lF.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,t)=>o.cmp(t,e),this._max=(e,t)=>o.cmp(e,t)>0?e:t,this._min=(e,t)=>0>o.cmp(e,t)?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=dy(t.IDBKeyRange),this._createTransaction=(e,t,r,n)=>new this.Transaction(e,t,r,this._options.chromeTransactionDurability,n),this._fireOnBlocked=e=>{this.on("blocked").fire(e),cW.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(d$),this.use(dF),this.use(dY),this.use(dV),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new lF.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new lF.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let t=this._versions;var r=t.filter(t=>t._cfg.version===e)[0];return r||(r=new this.Version(e),t.push(r),t.sort(dS),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||co.letThrough||this._vip)?e():new cu((e,t)=>{if(this._state.openComplete)return t(new lF.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new lF.DatabaseClosed);this.open().catch(lU)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:r,name:n}){n&&this.unuse({stack:e,name:n});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:t,level:null==r?10:r,name:n}),o.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>r?e.create!==r:!!t&&e.name!==t)),this}open(){return function(e){var t;let r=e._state,{indexedDB:n}=e._deps;if(r.isBeingOpened||e.idbdb)return r.dbReadyPromise.then(()=>r.dbOpenError?cB(r.dbOpenError):e);lD&&(r.openCanceller._stackHolder=lC()),r.isBeingOpened=!0,r.dbOpenError=null,r.openComplete=!1;let o=r.openCanceller;function i(){if(r.openCanceller!==o)throw new lF.DatabaseClosed("db.open() was cancelled")}let a=r.dbReadyResolve,s=null,u=!1;return cu.race([o,("u"<typeof navigator?cu.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var r=function(){return indexedDB.databases().finally(e)};t=setInterval(r,100),r()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(()=>new cu((t,o)=>{if(i(),!n)throw new lF.MissingAPI;let a=e.name,l=r.autoSchema?n.open(a):n.open(a,Math.round(10*e.verno));if(!l)throw new lF.MissingAPI;l.onerror=dl(o),l.onblocked=cw(e._fireOnBlocked),l.onupgradeneeded=cw(t=>{if(s=l.transaction,r.autoSchema&&!e._options.allowEmptyDB){l.onerror=dc,s.abort(),l.result.close();let e=n.deleteDatabase(a);e.onsuccess=e.onerror=cw(()=>{o(new lF.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let r,n,a,f;s.onerror=dl(o);var i,c,d=t.oldVersion>0x4000000000000000?0:t.oldVersion;u=d<1,e._novip.idbdb=l.result,i=d/10,c=s,r=e._dbSchema,(n=e._createTransaction("readwrite",e._storeNames,r)).create(c),n._completion.catch(o),a=n._reject.bind(n),f=co.transless||co,ck(()=>{co.trans=n,co.transless=f,0===i?(u2(r).forEach(e=>{dD(c,e,r[e].primKey,r[e].indexes)}),dw(e,c),cu.follow(()=>e.on.populate.fire(n)).catch(a)):(function({_novip:e},t,r,n){let o=[],i=e._versions,a=e._dbSchema=dk(e,e.idbdb,n),s=!1;return i.filter(e=>e._cfg.version>=t).forEach(i=>{o.push(()=>{let o=a,u=i._cfg.dbschema;dC(e,o,n),dC(e,u,n),a=e._dbSchema=u;let l=dO(o,u);l.add.forEach(e=>{dD(n,e[0],e[1].primKey,e[1].indexes)}),l.change.forEach(e=>{if(e.recreate)throw new lF.Upgrade("Not yet support for changing primary key");{let t=n.objectStore(e.name);e.add.forEach(e=>dP(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),dP(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=i._cfg.contentUpgrade;if(c&&i._cfg.version>t){let t;dw(e,n),r._memoizedTables={},s=!0;let i=lf(u);l.del.forEach(e=>{i[e]=o[e]}),dE(e,[e.Transaction.prototype]),dx(e,[e.Transaction.prototype],u2(i),i),r.schema=i;let a=lO(c);a&&cC();let d=cu.follow(()=>{if((t=c(r))&&a){var e=cj.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?cu.resolve(t):d.then(()=>t)}}),o.push(t=>{var n;s&&cK||(n=i._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==n[e]&&t.db.deleteObjectStore(e))),dE(e,[e.Transaction.prototype]),dx(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema})}),(function e(){return o.length?cu.resolve(o.shift()(r.idbtrans)).then(e):cu.resolve()})().then(()=>{var e;u2(e=a).forEach(t=>{n.db.objectStoreNames.contains(t)||dD(n,t,e[t].primKey,e[t].indexes)})})})(e,i,n,c).catch(a)})}},o),l.onsuccess=cw(()=>{s=null;let n=e._novip.idbdb=l.result,o=li(n.objectStoreNames);if(o.length>0)try{let t,i=n.transaction(1===o.length?o[0]:o,"readonly");r.autoSchema?function({_novip:e},t,r){e.verno=t.version/10;let n=e._dbSchema=dk(0,t,r);e._storeNames=li(t.objectStoreNames,0),dx(e,[e._allTables],u2(n),n)}(e,n,i):(dC(e,e._dbSchema,i),((t=dO(dk(0,e.idbdb,i),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),dw(e,i)}catch(e){}cW.push(e),n.onversionchange=cw(t=>{r.vcFired=!0,e.on("versionchange").fire(t)}),n.onclose=cw(t=>{e.on("close").fire(t)}),u&&function({indexedDB:e,IDBKeyRange:t},r){dR(e)||"__dbnames"===r||dT(e,t).put({name:r}).catch(lU)}(e._deps,a),t()},o)}))]).then(()=>(i(),r.onReadyBeingFired=[],cu.resolve(dA(()=>e.on.ready.fire(e.vip))).then(function t(){if(r.onReadyBeingFired.length>0){let n=r.onReadyBeingFired.reduce(lZ,lU);return r.onReadyBeingFired=[],cu.resolve(dA(()=>n(e.vip))).then(t)}}))).finally(()=>{r.onReadyBeingFired=null,r.isBeingOpened=!1}).then(()=>e).catch(t=>{r.dbOpenError=t;try{s&&s.abort()}catch(e){}return o===r.openCanceller&&e._close(),cB(t)}).finally(()=>{r.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=cW.indexOf(this);if(t>=0&&cW.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new cu(t=>{e.dbReadyResolve=t}),e.openCanceller=new cu((t,r)=>{e.cancelOpen=r})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new lF.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new cu((r,n)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=cw(()=>{!function({indexedDB:e,IDBKeyRange:t},r){dR(e)||"__dbnames"===r||dT(e,t).delete(r).catch(lU)}(this._deps,this.name),r()}),e.onerror=dl(n),e.onblocked=this._fireOnBlocked};if(e)throw new lF.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){let e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return u2(this._allTables).map(e=>this._allTables[e])}transaction(){let e=dI.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,r){let n,o,i=co.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||"readonly"===e)n="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new lF.InvalidArgument("Invalid transaction mode: "+e);n="readwrite"}if(i){if("readonly"===i.mode&&"readwrite"===n){if(!a)throw new lF.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&o.forEach(e=>{if(i&&-1===i.storeNames.indexOf(e)){if(!a)throw new lF.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),a&&i&&!i.active&&(i=null)}}catch(e){return i?i._promise(null,(t,r)=>{r(e)}):cB(e)}let s=(function e(t,r,n,o,i){return cu.resolve().then(()=>{let a,s=co.transless||co,u=t._createTransaction(r,n,t._dbSchema,o);if(o)u.idbtrans=o.idbtrans;else try{u.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===lL.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,null,i))):cB(o)}let l=lO(i);l&&cC();let c=cu.follow(()=>{if(a=i.call(u,u))if(l){var e=cj.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=dN(a))},{trans:u,transless:s});return(a&&"function"==typeof a.then?cu.resolve(a).then(e=>u.active?e:cB(new lF.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>a)).then(e=>(o&&u._resolve(),u._completion.then(()=>e))).catch(e=>(u._reject(e),cB(e)))})}).bind(null,this,n,o,i,r);return i?i._promise(n,s,"lock"):co.trans?cM(co.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!u8(this._allTables,e))throw new lF.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let dJ="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class dX{constructor(e){this._subscribe=e}subscribe(e,t,r){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:r})}[dJ](){return this}}function dQ(e,t){return u2(t).forEach(r=>{dz(e[r]||(e[r]=new dW),t[r])}),e}try{i={indexedDB:u1.indexedDB||u1.mozIndexedDB||u1.webkitIndexedDB||u1.msIndexedDB,IDBKeyRange:u1.IDBKeyRange||u1.webkitIDBKeyRange}}catch(e){i={indexedDB:null,IDBKeyRange:null}}function d0(e){let t=d1;try{d1=!0,dd.storagemutated.fire(e)}finally{d1=t}}u9(dZ,{...lV,delete:e=>new dZ(e,{addons:[]}).delete(),exists:e=>new dZ(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return dR(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>"__dbnames"!==e)):dT(e,t).toCollection().primaryKeys()})(dZ.dependencies).then(e)}catch(e){return cB(new lF.MissingAPI)}},defineClass:()=>function(e){u4(this,e)},ignoreTransaction:e=>co.trans?cM(co.transless,e):e(),vip:dA,async:function(e){return function(){try{var t=dN(e.apply(this,arguments));return t&&"function"==typeof t.then?t:cu.resolve(t)}catch(e){return cB(e)}}},spawn:function(e,t,r){try{var n=dN(e.apply(r,t||[]));return n&&"function"==typeof n.then?n:cu.resolve(n)}catch(e){return cB(e)}},currentTransaction:{get:()=>co.trans||null},waitFor:function(e,t){let r=cu.resolve("function"==typeof e?dZ.ignoreTransaction(e):e).timeout(t||6e4);return co.trans?co.trans.waitFor(r):r},Promise:cu,debug:{get:()=>lD,set:e=>{lD=e,lP="dexie"===e?()=>!0:cz}},derive:lt,extend:u4,props:u9,override:la,Events:cZ,on:dd,liveQuery:function(e){return new dX(t=>{let r=lO(e),n=!1,o={},i={},a={get closed(){return n},unsubscribe:()=>{n=!0,dd.storagemutated.unsubscribe(c)}};t.start&&t.start(a);let s=!1,u=!1;function l(){return u2(i).some(e=>o[e]&&function(e,t){let r=dH(t),n=r.next();if(n.done)return!1;let o=n.value,i=dH(e),a=i.next(o.from),s=a.value;for(;!n.done&&!a.done;){if(0>=c6(s.from,o.to)&&c6(s.to,o.from)>=0)return!0;0>c6(o.from,s.from)?o=(n=r.next(s.from)).value:s=(a=i.next(o.from)).value}return!1}(o[e],i[e]))}let c=e=>{dQ(o,e),l()&&d()},d=()=>{let f,p;if(s||n)return;o={};let h={},m=(r&&cC(),f=()=>ck(e,{subscr:h,trans:null}),p=co.trans?cM(co.transless,f):f(),r&&p.then(cj,cj),p);u||(dd("storagemutated",c),u=!0),s=!0,Promise.resolve(m).then(e=>{s=!1,n||(l()?d():(o={},i=h,t.next&&t.next(e)))},e=>{s=!1,t.error&&t.error(e),a.unsubscribe()})};return d(),a})},extendObservabilitySet:dQ,getByKeyPath:lc,setByKeyPath:ld,delByKeyPath:function(e,t){"string"==typeof t?ld(e,t,void 0):"length"in t&&[].map.call(t,function(t){ld(e,t,void 0)})},shallowClone:lf,deepClone:lb,getObjectDiff:dL,cmp:c6,asap:lu,minKey:-1/0,addons:[],connections:cW,errnames:lL,dependencies:i,semVer:"3.2.2",version:"3.2.2".split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),dZ.maxKey=dy(dZ.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(dd("storagemutated",e=>{if(!d1){let t;cK?(t=document.createEvent("CustomEvent")).initCustomEvent("x-storagemutated-1",!0,!0,e):t=new CustomEvent("x-storagemutated-1",{detail:e}),d1=!0,dispatchEvent(t),d1=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{d1||d0(e)}));let d1=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel("x-storagemutated-1");dd("storagemutated",t=>{d1||e.postMessage(t)}),e.onmessage=e=>{e.data&&d0(e.data)}}else if("u">typeof self&&"u">typeof navigator){dd("storagemutated",e=>{try{d1||("u">typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:"x-storagemutated-1",changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if("x-storagemutated-1"===e.key){let t=JSON.parse(e.newValue);t&&d0(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&"x-storagemutated-1"===e.type&&d0(e.changedParts)})}function d2(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}cu.rejectionMapper=function(e,t){if(!e||e instanceof lN||e instanceof TypeError||e instanceof SyntaxError||!e.name||!lB[e.name])return e;var r=new lB[e.name](t||e.message,e);return"stack"in e&&le(r,"stack",{get:function(){return this.inner.stack}}),r},lP=cz;class d3 extends dZ{constructor(){super("EsmOffline"),d2(this,"syncQueue",void 0),d2(this,"dynamicOfflineData",void 0),this.version(4).stores({syncQueue:"++id,userId,type,[userId+type]",dynamicOfflineData:"++id,type,identifier,*users,&[type+identifier]"}),this.syncQueue=this.table("syncQueue"),this.dynamicOfflineData=this.table("dynamicOfflineData")}}function d4(){return new d3}let d6=new d3,d5={},d8=q("offline-synchronization",{});function d9(){return d8}async function d7(){if(d8.getState().synchronization)return;let e=await d6.syncQueue.count(),t={},r=Object.entries(d5),n=r.length,o={},i=new AbortController,a=()=>{let e=d8.getState().synchronization;d8.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{d8.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<n&&r.length>0;e++)for(let e=r.length;e--;){let[n,s]=r[e],u=s.dependsOn.map(e=>t[e]);u.every(Boolean)&&(o[n]={},await Promise.all(u),t[n]=fe(s,o,i,a),r.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{d8.setState({synchronization:void 0})}}async function fe({type:e,dependsOn:t,process:r},n,o,i){let a=[],s=[],u=await ft();await d6.syncQueue.where({type:e,userId:u}).each((e,t)=>{a.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let l=0;l<a.length;l++){let[c,d,{id:f,dependencies:p=[]}]=a[l];try{let i=await r(d,{abort:o,index:l,items:s,userId:u,dependencies:p.map(({id:e,type:r})=>t.includes(r)?n[r][e]:void 0)});void 0!==f&&(n[e][f]=i),await d6.syncQueue.delete(c)}catch(e){await d6.syncQueue.update(c,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function ft(){let e=await aN();return e?.uuid||"*"}async function fr(e,t,r,n){let o=n&&n.id;return void 0!==o&&await d6.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(dZ.errnames.DatabaseClosed),await d6.syncQueue.add({type:t,content:r,userId:e,descriptor:n||{},createdOn:new Date}).catch(dZ.errnames.DatabaseClosed,()=>-1)}async function fn(e,t,r){let n=await ft();return await fr(n,e,t,r)}async function fo(e,t){return(await fi(e,t)).map(e=>e.content)}async function fi(e,t){return await d6.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(dZ.errnames.DatabaseClosed,()=>[])}async function fa(e){let t=await ft();return await fo(t,e)}async function fs(e){let t=await ft();return await fi(t,e)}async function fu(e){return await d6.syncQueue.get(e).catch(dZ.errnames.DatabaseClosed,()=>void 0)}function fl(e){return!!d5[e]?.options.onBeginEditSyncItem}async function fc(e){let t=await fu(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let r=d5[t.type]?.options.onBeginEditSyncItem;if(!r)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);r(t)}async function fd(e){await d6.syncQueue.delete(e).catch(dZ.errnames.DatabaseClosed)}function ff(e,t,r,n={}){d5[e]={type:e,dependsOn:t,process:r,options:n}}let fp="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),fh=new Uint8Array(16),fm=[];for(let e=0;e<256;++e)fm.push((e+256).toString(16).slice(1));let fy=function(e,t,r){if(fp&&!t&&!e)return fp();let n=(e=e||{}).random||(e.rng||function(){if(!a&&!(a="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(fh)})();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return fm[e[t+0]]+fm[e[t+1]]+fm[e[t+2]]+fm[e[t+3]]+"-"+fm[e[t+4]]+fm[e[t+5]]+"-"+fm[e[t+6]]+fm[e[t+7]]+"-"+fm[e[t+8]]+fm[e[t+9]]+"-"+fm[e[t+10]]+fm[e[t+11]]+fm[e[t+12]]+fm[e[t+13]]+fm[e[t+14]]+fm[e[t+15]]}(n)},fg="OFFLINE+";function fb(){return fg+fy()}function fv(e){return e.startsWith(fg)}let f_={};function fw(){return Object.values(f_)}function fx(e){f_[e.id]&&console.warn(`[setupDynamicOfflineDataHandler] Another second handler with the ID "${e.id}" was registered. This handler will override the previous one. This could be unintended as the previous handler might run different flows than the newly registered one. If this is the case, ensure that you are setting up the handlers with different IDs.`),f_[e.id]=e}async function fE(e){let t=await fT();return await fS(t,e)}async function fS(e,t){let r=new d3;return await r.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(dZ.errnames.DatabaseClosed,()=>[])}async function fO(e,t){let r=await fT();return await fD(r,e,t)}async function fD(e,t,r){let n=new d3,o=await n.dynamicOfflineData.get({type:t,identifier:r}).catch(dZ.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await n.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(dZ.errnames.DatabaseClosed):await n.dynamicOfflineData.add({users:[e],type:t,identifier:r}).catch(dZ.errnames.DatabaseClosed)}async function fP(e,t){let r=await fT();return await fk(r,e,t)}async function fk(e,t,r){let n=new d3,o=await n.dynamicOfflineData.get({type:t,identifier:r,users:e}).catch(dZ.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await n.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(dZ.errnames.DatabaseClosed):await n.dynamicOfflineData.delete(o.id).catch(dZ.errnames.DatabaseClosed))}async function fC(e,t){let r=await fE(e);await Promise.all(r.map(async e=>fj(e.type,e.identifier,t)))}async function fj(e,t,r){await fO(e,t);let n=new d3,o=await fT(),i=await n.dynamicOfflineData.get({type:e,identifier:t}).catch(dZ.errnames.DatabaseClosed,()=>void 0),a=fw().filter(t=>t.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,r),{id:e.id,error:void 0}}catch(r){let t=r.message?.toString()??r.toString();return{id:e.id,error:t}}})),u=s.filter(e=>!e.error).map(e=>e.id),l=s.filter(e=>e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),d={syncedOn:new Date,syncedBy:o,succeededHandlers:u,erroredHandlers:l,errors:c};i.id&&await n.dynamicOfflineData.update(i.id,{syncState:d}).catch(dZ.errnames.DatabaseClosed)}async function fT(){let e=(await aN()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let fR=q("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function fA(){return fM(),fR}function fN(e,t){fM(),fx({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,r)=>t.onOfflinePatientAdded({patientUuid:e,signal:r??new AbortController().signal})})}async function fI(e){fM(),await fj("patient",e)}function fM(){console.warn("The offline patient API has been deprecated and will be removed in a future release. To prevent future crashes, the functions remain available for the moment, but any invocations should be migrated ASAP.")}async function f$(e,t,r=!0){if(e){let n=null,[o,i]=await Promise.all([aE(`${a_}/Patient/${e}`,t).catch(e=>n=e),r?fL(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(n)throw n}return null}async function fL(e){let t=(await fa("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function fF(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function fB(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}var fV=r(6170);function fU(e){return{uuid:e.uuid,display:e.display}}function fW(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return aS(`${av}/location${n?"?"+n:""}`).pipe((0,fV.map)(e=>e.data.results.map(fU))).pipe((0,fV.take)(1))}function fK(e){return{uuid:e.uuid,display:e.display,name:e.name}}function fz(){return aS(`${av}/visittype`).pipe((0,fV.map)(e=>e.data.results.map(fK))).pipe((0,fV.take)(1))}var fH=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),fG=function(e){function t(t,r){var n=e.call(this)||this;return n.subject=t,n.subscriber=r,n.closed=!1,n}return em(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var r=t.indexOf(this.subscriber);-1!==r&&t.splice(r,1)}}},t}(eE),fq=function(e){function t(t){var r=e.call(this,t)||this;return r.destination=t,r}return em(t,e),t}(eD),fY=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return em(t,e),t.prototype[eO]=function(){return new fq(this)},t.prototype.lift=function(e){var t=new fZ(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new fH;if(!this.isStopped)for(var t=this.observers,r=t.length,n=t.slice(),o=0;o<r;o++)n[o].next(e)},t.prototype.error=function(e){if(this.closed)throw new fH;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,r=t.length,n=t.slice(),o=0;o<r;o++)n[o].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new fH;this.isStopped=!0;for(var e=this.observers,t=e.length,r=e.slice(),n=0;n<t;n++)r[n].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new fH},t.prototype._subscribe=function(e){if(this.closed)throw new fH;return this.hasError?(e.error(this.thrownError),eE.EMPTY):this.isStopped?(e.complete(),eE.EMPTY):(this.observers.push(e),new fG(this,e))},t.prototype.asObservable=function(){var e=new eC;return e.source=this,e},t.create=function(e,t){return new fZ(e,t)},t}(eC),fZ=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return em(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):eE.EMPTY},t}(fY),fJ=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return em(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return r&&!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new fH},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(fY),fX=((eu={}).NEWVISIT="startVisit",eu.EDITVISIT="editVisit",eu.LOADING="loadingVisit",eu),fQ=((el={}).NOTSTARTED="notStarted",el.ONGOING="ongoing",el);let f0="custom:(uuid,display,voided,indication,startDatetime,stopDatetime,encounters:(uuid,display,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,display),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display))",f1=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function f2(){return Z("visit",f1)}function f3(e,t){f2().setState({patientUuid:e,manuallySetVisitUuid:t})}function f4(e,t){return aE(`${av}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function f6(e,t,r){return aE(`${av}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function f5(e,t,r){return aE(`${av}/visit?patient=${e}&v=${r??f0}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}f2().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let f8=new fJ(null);class f9{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+f9.version}static addUnaryOp(e){return f9.max_unop_len=Math.max(e.length,f9.max_unop_len),f9.unary_ops[e]=1,f9}static addBinaryOp(e,t,r){return f9.max_binop_len=Math.max(e.length,f9.max_binop_len),f9.binary_ops[e]=t,r?f9.right_associative.add(e):f9.right_associative.delete(e),f9}static addIdentifierChar(e){return f9.additional_identifier_chars.add(e),f9}static addLiteral(e,t){return f9.literals[e]=t,f9}static removeUnaryOp(e){return delete f9.unary_ops[e],e.length===f9.max_unop_len&&(f9.max_unop_len=f9.getMaxKeyLen(f9.unary_ops)),f9}static removeAllUnaryOps(){return f9.unary_ops={},f9.max_unop_len=0,f9}static removeIdentifierChar(e){return f9.additional_identifier_chars.delete(e),f9}static removeBinaryOp(e){return delete f9.binary_ops[e],e.length===f9.max_binop_len&&(f9.max_binop_len=f9.getMaxKeyLen(f9.binary_ops)),f9.right_associative.delete(e),f9}static removeAllBinaryOps(){return f9.binary_ops={},f9.max_binop_len=0,f9}static removeLiteral(e){return delete f9.literals[e],f9}static removeAllLiterals(){return f9.literals={},f9}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new f9(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(e=>e.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return f9.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!f9.binary_ops[String.fromCharCode(e)]||f9.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return f9.isIdentifierStart(e)||f9.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(f9.hooks[e]){let r={context:this,node:t};return f9.hooks.run(e,r),r.node}return t}searchHook(e){if(f9.hooks[e]){let t={context:this};return f9.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===f9.SPACE_CODE||e===f9.TAB_CODE||e===f9.LF_CODE||e===f9.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:f9.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===f9.SEMCOL_CODE||r===f9.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,f9.max_binop_len),t=e.length;for(;t>0;){if(f9.binary_ops.hasOwnProperty(e)&&(!f9.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!f9.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,o,i,a,s,u;if(!(i=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return i;for(o={value:t,prec:f9.binaryPrecedence(t),right_a:f9.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[i,o,a];t=this.gobbleBinaryOp();){if(0===(r=f9.binaryPrecedence(t))){this.index-=t.length;break}o={value:t,prec:r,right_a:f9.right_associative.has(t)},u=t;let s=e=>o.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)a=n.pop(),t=n.pop().value,i=n.pop(),e={type:f9.BINARY_EXP,operator:t,left:i,right:a},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+u),n.push(o,e)}for(s=n.length-1,e=n[s];s>1;)e={type:f9.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,f9.isDecimalDigit(e)||e===f9.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===f9.SQUOTE_CODE||e===f9.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===f9.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,f9.max_unop_len)).length;r>0;){if(f9.unary_ops.hasOwnProperty(t)&&(!f9.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!f9.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:f9.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}f9.isIdentifierStart(e)?(n=this.gobbleIdentifier(),f9.literals.hasOwnProperty(n.name)?n={type:f9.LITERAL,value:f9.literals[n.name],raw:n.name}:n.name===f9.this_str&&(n={type:f9.THIS_EXP})):e===f9.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===f9.PERIOD_CODE||t===f9.OBRACK_CODE||t===f9.OPAREN_CODE||t===f9.QUMARK_CODE;){let r;if(t===f9.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==f9.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===f9.OBRACK_CODE?((e={type:f9.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==f9.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===f9.OPAREN_CODE?e={type:f9.CALL_EXP,arguments:this.gobbleArguments(f9.CPAREN_CODE),callee:e}:(t===f9.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:f9.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;f9.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===f9.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);f9.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));f9.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);f9.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,f9.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===f9.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===f9.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:f9.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:f9.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(f9.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,f9.isIdentifierPart(e))this.index++;else break;return{type:f9.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){r=!0,this.index++,e===f9.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===f9.COMMA_CODE){if(this.index++,++n!==t.length){if(e===f9.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===f9.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==f9.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(f9.CPAREN_CODE);if(this.code===f9.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:f9.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:f9.ARRAY_EXP,elements:this.gobbleArguments(f9.CBRACK_CODE)}}}Object.assign(f9,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(f9),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),f9.max_unop_len=f9.getMaxKeyLen(f9.unary_ops),f9.max_binop_len=f9.getMaxKeyLen(f9.binary_ops);let f7=e=>new f9(e).parse(),pe=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(f9).filter(e=>!pe.includes(e)&&void 0===f7[e]).forEach(e=>{f7[e]=f9[e]}),f7.Jsep=f9,f7.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:o},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let pt="ArrowFunctionExpression",pr={Array,Boolean,Symbol,Infinity,NaN,Math,Number,BigInt,String,RegExp,JSON,isFinite,isNaN,parseFloat,parseInt,decodeURI,encodeURI,encodeURIComponent,Object:{__proto__:void 0,assign:Object.assign.bind(null),fromEntries:Object.fromEntries.bind(null),hasOwn:Object.hasOwn.bind(null),keys:Object.keys.bind(null),is:Object.is.bind(null),values:Object.values.bind(null)}},pn={...pr,Promise};function po(e,t={}){return pc(e,t,pp)}async function pi(e,t={}){return pd(e,t,pp)}function pa(e,t={}){return pc(e,t,ph)}function ps(e,t={}){return pd(e,t,ph)}function pu(e,t={}){return pc(e,t,pm)}function pl(e,t={}){return pd(e,t,pm)}function pc(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=pb(t,pr),o=py("string"==typeof e?f7(e):e,n);if(r(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function pd(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=pb(t,pn);return Promise.resolve(py("string"==typeof e?f7(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function pf(e){return f7(e)}function pp(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function ph(e){return"boolean"==typeof e}function pm(e){return"number"==typeof e}function py(e,t){switch(e.type){case"UnaryExpression":var r,n,o,i,a,s,u,l,c,d,f,p,h=e,m=t;let y=py(h.argument,m);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var g=e,b=t;let v=py(g.left,b),w=py(g.right,b);switch(g.operator){case"+":return v+w;case"-":return v-w;case"*":return v*w;case"/":return v/w;case"%":return v%w;case"**":return v**w;case"==":return v==w;case"===":return v===w;case"!=":return v!=w;case"!==":return v!==w;case">":return v>w;case">=":return v>=w;case"<":return v<w;case"<=":return v<=w;case"in":return v in w;case"&&":return v&&w;case"||":return v||w;case"??":return v??w;default:throw`Expression evaluator does not support operator '${g.operator}' operator`}case"ConditionalExpression":return r=e,n=t,py(r.test,n)?py(r.consequent,n):py(r.alternate,n);case"CallExpression":var x=e,E=t;let S=x.arguments?.map(pv(E)),O=py(x.callee,E);if(O){if("function"!=typeof O)throw`${pw(x.callee)} is not a function`}else throw`No function named ${pw(x.callee)} is defined in this context`;return O(...S);case"ArrowFunctionExpression":let D;return o=e,i=t,D=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<D.length)throw`Required argument(s) ${D.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(D.reduce((t,r,n)=>{let o=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(o)&&t.push([r,o]),t},[]));return py(o.body,i.addVariables(t))}).bind(i.thisObj??null);case"MemberExpression":return function(e,t){let r,n=py(e.object,t);if(void 0===n)switch(e.object.type){case"Identifier":{let r=pg(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":{let r=pg(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${r}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=n;if("string"==typeof n)o=String.prototype;else if("number"==typeof n)o=Number.prototype;else if("function"==typeof n);else if("object"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":r=py(e.property,t);break;default:{let o=py(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};p_(o),r=n[o]}}return"function"==typeof r?r.bind(n):r}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(pv(s));case"SequenceExpression":let P;return u=e,l=t,(P=u.expressions.map(pv(l)))[P.length-1];case"NewExpression":var k=e,C=t;if(k.callee&&"Identifier"===k.callee.type){let e=k.arguments?.map(pv(C));switch(k.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${k.callee.name}`}}if(k.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return p_((c=e).value),c.value;case"Identifier":var j=e,T=t;p_(j.name);let R=T.thisObj;if(R&&("object"==typeof R||"function"==typeof R)&&j.name in R){let e=R[j.name];return p_(e),e}if(T.variables&&j.name in T.variables){let e=T.variables[j.name];return p_(e),e}return j.name in T.globals?T.globals[j.name]:void 0;case"TemplateLiteral":let A,N;return d=e,f=t,A=d.expressions?.map(pv(f))??[],(N=d.quasis?.map(pv(f))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+A.join("")+N.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function pg(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return pg(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function pb(e,t){let r={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}function pv(e){return function(t){return null===t?null:py(t,e)}}function p_(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function pw(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function px(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...pn},isLocalExpression:!1,variables:new Set};return pE("string"==typeof e?f7(e):e,t),[...t.variables]}function pE(e,t){switch(e.type){case"UnaryExpression":return n=e,o=t,pE(n.argument,o);case"BinaryExpression":return i=e,a=t,[pE(i.left,a),pE(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,u=t,[pE(s.consequent,u),pE(s.test,u),pE(s.alternate,u)].filter(Boolean);case"CallExpression":let r;return l=e,c=t,r=pE(l.callee,c),l.arguments?.map(pS(c)),r;case"ArrowFunctionExpression":var n,o,i,a,s,u,l,c,d,f,p,h,m,y,g,b,v,w,x=e,E=t;let S={...E};S.isLocalExpression=!0;let O=x.params?.map(pS(S))??[],D=pE(x.body,S)??[];if(D&&Array.isArray(D))for(let e of D)O.includes(e)||E.variables.add(e);return;case"MemberExpression":let P;return d=e,f=t,pE(d.object,f),void((P={...f}).isLocalExpression=!0,pE(d.property,P));case"ArrayExpression":return p=e,h=t,void p.elements?.map(pS(h));case"SequenceExpression":return m=e,y=t,void m.expressions?.map(pS(y));case"NewExpression":return g=e,b=t,void g.arguments?.map(pS(b));case"Literal":case"TemplateElement":return;case"Identifier":var k=e,C=t;if(!(k.name in C.globals))if(C.isLocalExpression)return k.name;else C.variables.add(k.name);return;case"TemplateLiteral":return v=e,w=t,void(v.expressions?.map(pS(w)),v.quasis?.map(pS(w)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function pS(e){return function(t){return null===t?null:pE(t,e)}}f7.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:pt,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=pt,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),f7.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),f7.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),o());let i=this.char;("e"===i||"E"===i)&&(n+=this.expr.charAt(this.index++),("+"===(i=this.char)||"-"===i)&&(n+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(a===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var o,i,a;let s=this.index,u=this.expr.charAt(this.index+1),l=t.call(this,u);if(!l)return;let c="";for(;o=this.code,i=l,95===o||i.some(([e,t])=>o>=e&&o<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(u.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(a=u)||"X"===a?16:"b"===a||"B"===a?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&r.call(this,n)})}}),f7.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,o=this.expr.slice(r,this.index),i="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)i+=this.char;else break}try{n=new RegExp(o,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),f7.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:o},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),f7.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",o="",i=!1,a=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:o,cooked:n},tail:i});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,i=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(o+=a,a=this.expr.charAt(++this.index),o+=a,a){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=a}else n+=a,o+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),f7.addBinaryOp("in",7),f7.addBinaryOp("??",1);let pO=Z("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function pD(e,t,r){pO.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function pP(){let e=pO.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function pk(e){return pO.getState().flags[e].enabled}function pC(e,t){pO.subscribe(r=>{t(r.flags[e].enabled)})}function pj(e,t){pO.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}function pT(e){return!window.offlineEnabled||(e??navigator.onLine)}pO.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var pR=re(function(e,t,r){t2(e,t,r)});function pA(e=!0,t=!1){return pN(pT(),e,t)}function pN(e,t=!0,r=!1){return!!(e?t:r)}let pI=q("extensionsInternal",{slots:{},extensions:{}}),pM=q("extensionRenderings",{renderings:new Map}),p$=()=>Z("extensionsInternal",{slots:{},extensions:{}}),pL=()=>Z("extensionRenderings",{renderings:new Map});function pF(e){let t=pI.getState(),r=e(t);r!==t&&pI.setState(r)}let pB=null,pV=null;function pU(){let e=pM.getState();return pB&&e===pV||(pB=new Map(e.renderings),pV=e,function(e){for(let t of(pX.clear(),e.values()))p0(t,1);pQ=!0}(pB)),pB}function pW(e){pV={renderings:e},pM.setState(pV,!0)}function pK(e){let t=pU();t.has(e.renderingId)||(t.set(e.renderingId,e),p0(e,1),pW(t))}function pz(e){let t=pU(),r=t.get(e);r&&(t.delete(e),p0(r,-1),pW(t))}let pH=()=>Z("extensions",{slots:{}}),pG=0,pq=new Set;function pY(e){pG++;try{return e()}finally{if(0==--pG&&pq.size>0){let e=Array.from(pq);for(let t of(pq.clear(),e))pZ(t)}}}function pZ(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function pJ(e){pG>0?pq.add(e):pZ(e)}let pX=new Map,pQ=!1;function p0(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=pX.get(r);if(!n){if(t<0)return;pX.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),pQ=!0;return}n.count+=t,n.count<1&&(pX.delete(r),pQ=!0)}function p1(){var e,t;if(pU(),!pQ)return;pQ=!1;let r=Array.from(pX.values(),({record:e})=>e);r.sort(p2),e=nF.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===p2(e,t[r]))||nF.setState({mountedExtensions:r})}function p2(e,t){return p3(e.slotName,t.slotName)||p3(e.extensionId,t.extensionId)||p3(e.slotModuleName,t.slotModuleName)||p3(e.extensionModuleName,t.extensionModuleName)}function p3(e,t){return e===t?0:e<t?-1:1}p1(),pM.subscribe(()=>pJ(p1));let p4=p$(),p6=pH(),p5=nV(),p8=nK(),p9=new Set,p7=!1;function he(e){if(null===e)p9=null;else if(null!==p9)for(let t of e)p9.add(t);pJ(ht)}function ht(){if(!p7){p7=!0;try{for(let e=1;;e++){let t=p9;if(null!==t&&0===t.size)return;p9=new Set;try{!function(e,t,r,n,o,i=null){let a=p6.getState().slots,s={},u=!1,l=pT(),c=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,d]of Object.entries(e.slots)){let f=a[n];if(f&&i&&!i.has(n)){s[n]=f;continue}let{config:p}=nW(t,d.name),h=function(e,t,r,n,o,i,a){let s=function(e,t){let r=e.add||[],n=e.remove||[],o=e.order||[],{extensions:i}=p4.getState();return[...t,...r].filter(e=>!n.includes(e)).sort((e,r)=>hf(e,o,i[hi(e)]?.order,t)-hf(r,o,i[hi(r)]?.order,t))}(r,t.slots[e].attachedIds),u=[];for(let l of s){let{config:s}=nH(n,e,l),c=nG(r,e,l),d=c?pR({},s,c):s,f=hi(l),p=t.extensions[f];if(p){let e=d?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!aA(e,a.user))||p.featureFlag&&!o.includes(p.featureFlag)||window.offlineEnabled&&!pN(i,p.online,p.offline))continue;u.push({id:l,name:f,moduleName:p.moduleName,config:d,featureFlag:p.featureFlag,meta:p.meta,online:d?.["Display conditions"]?.online??p.online??!0,offline:d?.["Display conditions"]?.offline??p.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||p.displayExpression})}}return u}(n,e,p,r,c,l,o.session);f&&f.moduleName===d.moduleName&&rH(f.candidateExtensions,h)?s[n]=f:(s[n]={moduleName:d.moduleName,candidateExtensions:h},u=!0)}(u||Object.keys(a).length!==Object.keys(s).length)&&p6.setState({slots:s})}(p4.getState(),p5.getState(),p8.getState(),pO.getState(),aD.getState(),t)}catch(e){throw p9=null===t||null===p9?null:new Set([...t,...p9]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{p7=!1}}}function hr(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function hn(){he(null)}function ho(e,t){return{moduleName:t,name:e,attachedIds:[]}}function hi(e){let[t]=e.split("#");return t}function ha(e,t){let r=hi(t);return e.extensions[r]}function hs(e){return ha(p4.getState(),e)}p4.subscribe((e,t)=>{he(e.extensions!==t.extensions?null:hr(e.slots,t.slots))}),p5.subscribe((e,t)=>{he(hr(e.slots,t.slots))}),p8.subscribe((e,t)=>{he(hr(e.configs,t.configs))}),pO.subscribe(()=>he(null)),aD.subscribe(()=>he(null)),hn(),g(hn);let hu=e=>pF(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function hl(e,t){pF(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...ho(e),attachedIds:[t]}}}})}function hc(e,t){pF(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function hd(e){pF(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function hf(e,t,r,n){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==r)return 1e3+r;let t=n.indexOf(e);return -1!==t?2e3+t:3e3}}function hp(e,t){return function(e,t,r=null,n){let o;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;o??(o=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!pa(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(hh(e),t,aD.getState().session,e)}function hh(e){return p6.getState().slots[e]?.candidateExtensions??[]}let hm=(e,t)=>p4.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let o=ho(t,e);return{...r,slots:{...r.slots,[t]:{...o}}}}),hy=()=>{p9=null,pF(()=>({slots:{},extensions:{}})),pL().setState({renderings:new Map}),p6.setState({slots:{}})},hg=q("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function hb({name:e,basePath:t,mode:r,componentContext:n,state:o}){hg.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:o})}function hv(e){hg.getState().slotName===e&&hg.setState(hg.getInitialState(),!0)}let h_=q("modalRegistry",{modals:{}});function hw(e){h_.setState(t=>(t.modals[e.name]=e,t))}function hx(e){let t=h_.getState().modals[e];if(!t){let r=hs(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),hw(t))}return t}let hE=q("workspaceRegistrations",{workspaces:{}}),hS=q("workspaceGroups",{workspaceGroups:{}});function hO(e){hE.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function hD(e){hS.setState(t=>{let r=t.workspaceGroups[e.name];return r?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...r,members:Array.from(new Set([...r.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let hP=new Set;function hk(e){let t=hE.getState().workspaces;if(t[e])return t[e];{let t=hs(e);if(t){var r;let n;return hP.has(e)||(console.warn(`The workspace '${e}' is registered as an extension. This is deprecated. Please register it in the "workspaces" section of the routes.json file.`),hP.add(e)),{name:t.name,title:(r=t,"string"==typeof(n=r?.meta?.title)?n:n&&"object"==typeof n?sF(r.moduleName,n.key,n.default):r.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function hC(e){let t=hS.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let hj=q("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function hT(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=hj.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function hR(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=hj.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function hA(e){let{openedWindows:t}=hj.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function hN(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=hj.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}hj.setState({registeredGroupsByName:n})}function hI(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=hj.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}hj.setState({registeredWindowsByName:n})}function hM(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=hj.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}hj.setState({registeredWorkspacesByName:n})}let h$=0,hL=null,hF={bootstrap:15e3,mount:15e3,unmount:15e3};function hB(e){if(e.timeouts)return e;let t=e.name??"parcel",r=Object.fromEntries(Object.keys(hF).filter(t=>e[t]).map(r=>{var n,o;let i,a;return[r,(n=e[r],o=hF[r],i=Array.isArray(n)?n:[n],a=e=>i.reduce((n,o,i)=>n.then(()=>{let n=o(e);return"function"==typeof n?.then&&"function"==typeof n?.catch?n:Promise.reject(Error(`Lifecycle function ${r} at array index ${i} for parcel ${t} did not return a promise`))}),Promise.resolve(void 0)),e=>{let n,i=new Promise((e,i)=>{n=setTimeout(()=>i(Error(`Lifecycle function ${r} for parcel ${t} did not settle within ${o}ms`)),o)});return Promise.race([a(e),i]).finally(()=>clearTimeout(n))})]}));return{...e,...r}}async function hV(e,t){return(await (hL??(hL=new Promise((e,t)=>{iw({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),iw))),hL))("function"==typeof e?()=>e().then(hB):hB(e),t)}function hU(){return hW}function hW(e,t){let r,n=hV(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function hK(e,t,r,n,o=e=>e,i={}){let a=hi(n),s=hs(n),u=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:l,moduleName:c,online:d,offline:f,load:p}=s;if(pA(d,f)){let s,d=h$++,f=`${t}/${n}-${d}`;e.dataset.extensionRenderingId=f;let h=e=>{try{pz(f)}catch(t){console.error(e,t)}};try{pK({renderingId:f,extensionName:a,extensionModuleName:c,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{s=await p()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{u=await hV(o({...s,name:`${t}/${a}-${d}`}),{...i,_meta:l,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}u.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),u.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return u}var hz=r(4923),hH=r.n(hz);let hG=(0,hz.createContext)({moduleName:"",featureName:""});function hq({to:e,templateParams:t,onBeforeNavigate:r,children:n,...o}){return(0,hz.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),hH().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),al({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:as(e,t),...o},n)}let hY=({state:e,children:t,...r})=>{let{extension:n}=(0,hz.useContext)(hG),o=(0,hz.useRef)(null),i=(0,hz.useRef)(Promise.resolve()),a=(0,hz.useRef)(!1),s=(0,hz.useRef)(!1),u=(0,hz.useRef)(e),l=(0,hz.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":i.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,hz.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...t})}).catch(e=>{let t=o.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,hz.useCallback)(t=>{t&&!o.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,hK(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,o.current=t,a.current)?l(t):t&&u.current!==e&&c(t,u.current)},()=>{s.current=!1}))},[]);return(0,hz.useEffect)(()=>(a.current=!1,()=>{a.current=!0,l(o.current)}),[]),(0,hz.useEffect)(()=>{u.current=e,o.current&&c(o.current,e)},[e]),n?hH().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function hZ(e){let t=(0,hz.useRef)(e);return L(t.current,e)||(t.current=e),t.current}function hJ(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};r[n]=t}return r}let hX=e=>e;function hQ(e,t=hX,r){let n=(0,hz.useCallback)(t=>e.subscribe(t),[e]),o=(0,hz.useCallback)(()=>t(e.getState()),[e,t]),i=(0,hz.useSyncExternalStore)(n,o,o),a=(0,hz.useMemo)(()=>r?hJ(e,r):null,[e,r]);return(0,hz.useMemo)(()=>a?{...i,...a}:i,[i,a])}function h0(e,t){return hQ(e,hX,t)}function h1(e){return function(t){let r=(0,hz.useCallback)(t=>e.subscribe(t),[]),n=(0,hz.useCallback)(()=>e.getState(),[]),o=(0,hz.useSyncExternalStore)(r,n,n),i=(0,hz.useMemo)(()=>t?hJ(e,t):null,[t]);return(0,hz.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let h2=[];Object.freeze(h2);let h3={candidateExtensions:h2};Object.freeze(h3);let h4=e=>{let t=(0,hz.useCallback)(t=>t.slots?.[e]??h3,[e]);return hQ(pH(),t)},h6=e=>e.session;function h5(e,t){let{candidateExtensions:r}=h4(e),n=hQ(aD,h6),o=hZ(t);return(0,hz.useMemo)(()=>hp(e,o),[e,o,n,r])}function h8(e,t){let{moduleName:r}=(0,hz.useContext)(hG);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,hz.useEffect)(()=>{hm(r,e)},[r,e]),{extensions:h5(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function h9(e){return e}function h7({name:e,extensionSlotName:t,select:r=h9,children:n,state:o,style:i,...a}){if(n&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,u=(0,hz.useRef)(null),{extensions:l,extensionSlotModuleName:c}=h8(s,o),d=(0,hz.useMemo)(()=>r(l),[r,l]),f=(0,hz.useMemo)(()=>{if("function"==typeof n&&!hH().isValidElement(n))return d.map(e=>n(e,o))},[n,d]);return hH().createElement("div",{ref:u,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...i,position:"relative"},...a},s&&d?.map((e,t)=>hH().createElement(hG.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},f?.[t]??("function"!=typeof n?n:null)??hH().createElement(hY,{state:o}))))}var me=r(5338);function mt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function mr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?mt(Object(r),!0).forEach(function(t){var n,o,i;n=e,o=t,i=r[t],o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function mn(e){return(mn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mo(e){return(mo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mi(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(mo(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(mo(e)));return e}}var ma=null;try{ma=require("react").createContext()}catch(e){}var ms={React:null,ReactDOM:null,ReactDOMClient:null,rootComponent:null,loadRootComponent:null,errorBoundary:null,errorBoundaryClass:null,domElementGetter:null,parcelCanUpdate:!0,suppressComponentDidCatchWarning:!1,domElements:{},renderResults:{},updateResolves:{},unmountResolves:{}};function mu(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function ml(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var o,i=mp(e,t,function(){r(this)}),a=mi(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,o=e.domElement,i=t[r];if("function"!=typeof i)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=i(o);return a.render(n),a;case"hydrateRoot":return i(o,n);default:return i(n,o),null}}({elementToRender:i,domElement:a,reactDom:mf(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function mc(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():mf(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function md(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=mp(e,t,null),o=e.renderResults[t.name];if(o&&o.render)o.render(n);else{var i=mi(e,t)();mf(e).render(n,i)}})}function mf(e){return e.ReactDOMClient||e.ReactDOM}function mp(e,t,r){var n=e.React.createElement(e.rootComponent,t),o=ma?e.React.createElement(ma.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),o=e.React.createElement(e.errorBoundaryClass,t,o)),o=e.React.createElement(e.SingleSpaRoot,mr(mr({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),o)}var mh=r(202),mm=r(9324),my=r(4993);let mg={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},mb=new Map;(0,my.r2)(mb);let mv={errorRetryCount:3,fetcher:aE,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof aO){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>mb};function m_(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},mg,e),r={...mv,...t.swrConfig};return function(e){var n,o,i,a,s;return i=o=class extends(n=hH().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return hH().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=hH().createElement(hz.Suspense,{fallback:null},hH().createElement(mm.BE,{value:r},hH().createElement(hG.Provider,{value:this.state.config},t.disableTranslations?hH().createElement(e,this.props):hH().createElement(mh.I18nextProvider,{i18n:window.i18next,defaultNS:this.state.config.extension?`${this.state.config.moduleName}___${this.state.config.extension.extensionSlotName}___${this.state.config.extension.extensionId}`:this.state.config.moduleName},hH().createElement(e,this.props)))));return t.strictMode&&hH().StrictMode?hH().createElement(hH().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}}function mw(e,t){return function(e){if("object"!==mn(e))throw Error("single-spa-react requires a configuration object");var t,r=mr(mr({},ms),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!ma&&r.React.createContext&&(ma=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:mu.bind(null,r),mount:ml.bind(null,r),unmount:mc.bind(null,r)};return r.parcelCanUpdate&&(n.update=md.bind(null,r)),n}({React:hH(),ReactDOMClient:me,rootComponent:m_(t)(e)})}function mx(e,t){return()=>e().then(({default:e})=>mw(e,t))}function mE(e,t){return()=>Promise.resolve(mw(e,t))}let mS=mx,mO=U()(()=>({}));Y("openmrs-app-context",mO);let mD={};function mP(e,t=e=>e){let r=mO.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function mk(e,t){mO.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function mC(e){return null===e?null:Object.freeze(Object.assign({},e))}let mj=new Map;function mT(e,t){let r=(0,hz.useRef)(t??{}),n=(0,hz.useRef)(t=>mk(e,t)),o=(0,hz.useRef)(Symbol());return(0,hz.useEffect)(()=>{let r=t??{},n=o.current;return null===mP(e)?!function(e,t=mD){mO.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===mD?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),mk(e,()=>r)),mj.set(e,n),()=>{mj.get(e)===n&&(mO.setState(t=>(e in t&&delete t[e],t)),mj.delete(e))}},[e]),(0,hz.useEffect)(()=>{let n=t??{};L(r.current,n)||(mk(e,()=>n),r.current=n)},[t]),n.current}function mR({namespace:e,value:t}){return mT(e,t),null}let mA=({children:e,value:t,fallback:r})=>t?hH().createElement(hH().Fragment,null,e):r?hH().createElement(hH().Fragment,null,r):null;function mN(){let e=(0,hz.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,hz.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function mI(e,t=e=>e??{}){let[r,n]=(0,hz.useState)(()=>{if(mM(e))return;let r=mP(e);if(null!==r)return t?t(r):r});return(0,hz.useEffect)(()=>{if(mM(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,hz.useEffect)(()=>{var r;let o;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>L(e,r)?e:r)})(mC(o=mP(e))),mO.subscribe(t=>{let n=e in t?t[e]:null;n!==o&&(o=n,r(mC(n)))})},[e,t]),r}function mM(e){return"string"!=typeof e||0===e.trim().length}function m$(e){let t=h5(e);return(0,hz.useMemo)(()=>t.map(e=>e.id),[t])}function mL(e){return h4(e).candidateExtensions}function mF(e,t){let{data:r,error:n,mutate:o,isLoading:i,isValidating:a}=(0,mm.Ay)(`${uS}?patient=${e}&includeEncounterless=${t}`,aE);return(0,hz.useMemo)(()=>({isLoading:i,data:r?.data.results??[],error:n,mutate:o,isValidating:a}),[r,n,i,a,o])}function mB(e){(0,hz.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let mV={},mU=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let aD=q("session",{loaded:!1,session:null}),aP=0;function ak(e={includeAuthStatus:!0}){return(aP<Date.now()-6e4||!aD.getState().loaded)&&aT(),new eC(t=>{let r=r=>{r.loaded&&(e.includeAuthStatus?t.next(r.session):t.next(r.session?.user))};return r(aD.getState()),aD.subscribe(r)})}function aC(){return(aP<Date.now()-6e4||!aD.getState().loaded)&&aT(),aD}function aj(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function aT(e,t){aP=Date.now();let r={};return e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),aL(aE(aw,{headers:r}))}function aR(){aD.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function aA(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!Q(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!Q(n.privileges.find(t=>e===t.display))):(Q(r)||console.error(`Could not understand privileges "${r}"`),!0))||!Q(t.roles.find(e=>"System Developer"===e.display))}function aN(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(aD.getState()),e||(t=aD.subscribe(n))})}function aI(){return new Promise((e,t)=>{ak().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function aM(e,t){return aL(aE(aw,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function a$(e,t,r){return r||(r=new AbortController),await aE(`${av}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),aT()}function aL(e){return new Promise((t,r)=>{e.then(e=>{let n;"object"==typeof e?.data?(n={loaded:!0,session:e.data},aD.setState(n),t(n)):(n={loaded:!1,session:null},aD.setState(n),r(n))}).catch(e=>{I(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};aD.setState(t),r(t)})})}function aF(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}aD.subscribe(e=>{e.loaded&&e.session&&aj(e.session)});let aB={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function aV(){ot("@openmrs/esm-api",ag),aT()}let aU={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var aW=r(2284),aK=r(3029),az=r(2901);function aH(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function aG(e,t){return(aG=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function aq(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&aG(e,t)}function aY(e,t){if(t&&("object"==(0,aW.A)(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return aH(e)}function aZ(e){return(aZ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var aJ=r(4467),aX=r(6369),aQ=r(3612),a0=r(6562);function a1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function a2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a1(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a1(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var a3={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},a4=new(function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,aK.A)(this,e),this.init(t,r)}return(0,az.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||a3,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,r,n){return n&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(r).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,a2(a2({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),a6=function(){function e(){(0,aK.A)(this,e),this.observers={}}return(0,az.A)(e,[{key:"on",value:function(e,t){var r=this;return e.split(" ").forEach(function(e){r.observers[e]=r.observers[e]||[],r.observers[e].push(t)}),this}},{key:"off",value:function(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e]=this.observers[e].filter(function(e){return e!==t})}}},{key:"emit",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.observers[e]&&[].concat(this.observers[e]).forEach(function(e){e.apply(void 0,r)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(t){t.apply(t,[e].concat(r))})}}]),e}();function a5(){var e,t,r=new Promise(function(r,n){e=r,t=n});return r.resolve=e,r.reject=t,r}function a8(e){return null==e?"":""+e}function a9(e,t,r){function n(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function o(){return!e||"string"==typeof e}for(var i="string"!=typeof t?[].concat(t):t.split(".");i.length>1;){if(o())return{};var a=n(i.shift());!e[a]&&r&&(e[a]=new r),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return o()?{}:{obj:e,k:n(i.shift())}}function a7(e,t,r){var n=a9(e,t,Object);n.obj[n.k]=r}function se(e,t){var r=a9(e,t),n=r.obj,o=r.k;if(n)return n[o]}function st(e,t,r){var n=se(e,r);return void 0!==n?n:se(t,r)}function sr(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var sn={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function so(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return sn[e]}):e}var si="u">typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,sa=[" ",",","?","!",";"];function ss(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function su(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ss(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ss(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var sl=function(e){aq(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=aZ(n);return e=t?Reflect.construct(r,arguments,aZ(this).constructor):r.apply(this,arguments),aY(this,e)});function n(e){var t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return(0,aK.A)(this,n),t=r.call(this),si&&a6.call(aH(t)),t.data=e||{},t.options=o,void 0===t.options.keySeparator&&(t.options.keySeparator="."),void 0===t.options.ignoreJSONStructure&&(t.options.ignoreJSONStructure=!0),t}return(0,az.A)(n,[{key:"addNamespaces",value:function(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,i=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure,a=[e,t];r&&"string"!=typeof r&&(a=a.concat(r)),r&&"string"==typeof r&&(a=a.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(a=e.split("."));var s=se(this.data,a);return s||!i||"string"!=typeof r?s:function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(t){if(t[r])return t[r];for(var o=r.split(n),i=t,a=0;a<o.length;++a){if(!i||"string"==typeof i[o[a]]&&a+1<o.length)return;if(void 0===i[o[a]]){for(var s=2,u=o.slice(a,a+s).join(n),l=i[u];void 0===l&&o.length>a+s;)s++,l=i[u=o.slice(a,a+s).join(n)];if(void 0===l)return;if(null===l)return null;if(r.endsWith(u)){if("string"==typeof l)return l;if(u&&"string"==typeof l[u])return l[u]}var c=o.slice(a+s).join(n);if(c)return e(l,c,n);return}i=i[o[a]]}return i}}(this.data&&this.data[e]&&this.data[e][t],r,o)}},{key:"addResource",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},i=this.options.keySeparator;void 0===i&&(i=".");var a=[e,t];r&&(a=a.concat(i?r.split(i):r)),e.indexOf(".")>-1&&(a=e.split("."),n=t,t=a[1]),this.addNamespaces(t),a7(this.data,a,n),o.silent||this.emit("added",e,t,r,n)}},{key:"addResources",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var o in r)("string"==typeof r[o]||"[object Array]"===Object.prototype.toString.apply(r[o]))&&this.addResource(e,t,o,r[o],{silent:!0});n.silent||this.emit("added",e,t,r)}},{key:"addResourceBundle",value:function(e,t,r,n,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),n=r,r=t,t=a[1]),this.addNamespaces(t);var s=se(this.data,a)||{};n?function e(t,r,n){for(var o in r)"__proto__"!==o&&"constructor"!==o&&(o in t?"string"==typeof t[o]||t[o]instanceof String||"string"==typeof r[o]||r[o]instanceof String?n&&(t[o]=r[o]):e(t[o],r[o],n):t[o]=r[o]);return t}(s,r,o):s=su(su({},s),r),a7(this.data,a,s),i.silent||this.emit("added",e,t,r)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return(t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI)?su(su({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(function(e){return t[e]&&Object.keys(t[e]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),n}(a6),sc={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,r,n,o){var i=this;return e.forEach(function(e){i.processors[e]&&(t=i.processors[e].process(t,r,n,o))}),t}};function sd(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sd(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sd(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var sp={},sh=function(e){aq(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=aZ(n);return e=t?Reflect.construct(r,arguments,aZ(this).constructor):r.apply(this,arguments),aY(this,e)});function n(e){var t,o,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,aK.A)(this,n),i=r.call(this),si&&a6.call(aH(i)),t=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],o=aH(i),t.forEach(function(t){e[t]&&(o[t]=e[t])}),i.options=a,void 0===i.options.keySeparator&&(i.options.keySeparator="."),i.logger=a4.create("translator"),i}return(0,az.A)(n,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var r=this.resolve(e,t);return r&&void 0!==r.res}},{key:"extractFromKey",value:function(e,t){var r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");var n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS||[],i=r&&e.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!function(e,t,r){t=t||"",r=r||"";var n=sa.filter(function(e){return 0>t.indexOf(e)&&0>r.indexOf(e)});if(0===n.length)return!0;var o=new RegExp("(".concat(n.map(function(e){return"?"===e?"\\?":e}).join("|"),")")),i=!o.test(e);if(!i){var a=e.indexOf(r);a>0&&!o.test(e.substring(0,a))&&(i=!0)}return i}(e,r,n);if(i&&!a){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:o};var u=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),e=u.join(n)}return"string"==typeof o&&(o=[o]),{key:e,namespaces:o}}},{key:"translate",value:function(e,t,r){var o=this;if("object"!==(0,aW.A)(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var i=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(e[e.length-1],t),u=s.key,l=s.namespaces,c=l[l.length-1],d=t.lng||this.language,f=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&"cimode"===d.toLowerCase()){if(f){var p=t.nsSeparator||this.options.nsSeparator;return i?(h.res="".concat(c).concat(p).concat(u),h):"".concat(c).concat(p).concat(u)}return i?(h.res=u,h):u}var h=this.resolve(e,t),m=h&&h.res,y=h&&h.usedKey||u,g=h&&h.exactUsedKey||u,b=Object.prototype.toString.apply(m),v=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,x="string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m;if(w&&m&&x&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(b)&&("string"!=typeof v||"[object Array]"!==b)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var E=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,m,sf(sf({},t),{},{ns:l})):"key '".concat(u," (").concat(this.language,")' returned an object instead of string.");return i?(h.res=E,h):E}if(a){var S="[object Array]"===b,O=S?[]:{},D=S?g:y;for(var P in m)if(Object.prototype.hasOwnProperty.call(m,P)){var k="".concat(D).concat(a).concat(P);O[P]=this.translate(k,sf(sf({},t),{joinArrays:!1,ns:l})),O[P]===k&&(O[P]=m[P])}m=O}}else if(w&&"string"==typeof v&&"[object Array]"===b)(m=m.join(v))&&(m=this.extendTranslation(m,e,t,r));else{var C=!1,j=!1,T=void 0!==t.count&&"string"!=typeof t.count,R=n.hasDefaultValue(t),A=T?this.pluralResolver.getSuffix(d,t.count,t):"",N=t["defaultValue".concat(A)]||t.defaultValue;!this.isValidLookup(m)&&R&&(C=!0,m=N),this.isValidLookup(m)||(j=!0,m=u);var I=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:m,M=R&&N!==m&&this.options.updateMissing;if(j||C||M){if(this.logger.log(M?"updateKey":"missingKey",d,c,u,M?N:m),a){var $=this.resolve(u,sf(sf({},t),{},{keySeparator:!1}));$&&$.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var L=[],F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&F&&F[0])for(var B=0;B<F.length;B++)L.push(F[B]);else"all"===this.options.saveMissingTo?L=this.languageUtils.toResolveHierarchy(t.lng||this.language):L.push(t.lng||this.language);var V=function(e,r,n){var i=R&&n!==m?n:I;o.options.missingKeyHandler?o.options.missingKeyHandler(e,c,r,i,M,t):o.backendConnector&&o.backendConnector.saveMissing&&o.backendConnector.saveMissing(e,c,r,i,M,t),o.emit("missingKey",e,c,r,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?L.forEach(function(e){o.pluralResolver.getSuffixes(e,t).forEach(function(r){V([e],u+r,t["defaultValue".concat(r)]||N)})}):V(L,u,N))}m=this.extendTranslation(m,e,t,h,r),j&&m===u&&this.options.appendNamespaceToMissingKey&&(m="".concat(c,":").concat(u)),(j||C)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(c,":").concat(u):u,C?m:void 0):this.options.parseMissingKeyHandler(m))}return i?(h.res=m,h):m}},{key:"extendTranslation",value:function(e,t,r,n,o){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,sf(sf({},this.options.interpolation.defaultVariables),r),n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init(sf(sf({},r),{interpolation:sf(sf({},this.options.interpolation),r.interpolation)}));var a,s="string"==typeof e&&(r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(s){var u=e.match(this.interpolator.nestingRegexp);a=u&&u.length}var l=r.replace&&"string"!=typeof r.replace?r.replace:r;if(this.options.interpolation.defaultVariables&&(l=sf(sf({},this.options.interpolation.defaultVariables),l)),e=this.interpolator.interpolate(e,l,r.lng||this.language,r),s){var c=e.match(this.interpolator.nestingRegexp);a<(c&&c.length)&&(r.nest=!1)}!1!==r.nest&&(e=this.interpolator.nest(e,function(){for(var e=arguments.length,n=Array(e),a=0;a<e;a++)n[a]=arguments[a];return o&&o[0]===n[0]&&!r.context?(i.logger.warn("It seems you are nesting recursively key: ".concat(n[0]," in key: ").concat(t[0])),null):i.translate.apply(i,n.concat([t]))},r)),r.interpolation&&this.interpolator.reset()}var d=r.postProcess||this.options.postProcess,f="string"==typeof d?[d]:d;return null!=e&&f&&f.length&&!1!==r.applyPostProcessor&&(e=sc.handle(f,e,t,this.options&&this.options.postProcessPassResolved?sf({i18nResolved:n},r):r,this)),e}},{key:"resolve",value:function(e){var t,r,n,o,i,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!a.isValidLookup(t)){var u=a.extractFromKey(e,s),l=u.key;r=l;var c=u.namespaces;a.options.fallbackNS&&(c=c.concat(a.options.fallbackNS));var d=void 0!==s.count&&"string"!=typeof s.count,f=d&&!s.ordinal&&0===s.count&&a.pluralResolver.shouldUseIntlApi(),p=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,h=s.lngs?s.lngs:a.languageUtils.toResolveHierarchy(s.lng||a.language,s.fallbackLng);c.forEach(function(e){a.isValidLookup(t)||(i=e,!sp["".concat(h[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(i)&&(sp["".concat(h[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(r,'" for languages "').concat(h.join(", "),'" won\'t get resolved as namespace "').concat(i,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),h.forEach(function(r){if(!a.isValidLookup(t)){o=r;var i,u=[l];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(u,l,r,e,s);else{d&&(c=a.pluralResolver.getSuffix(r,s.count,s));var c,h="".concat(a.options.pluralSeparator,"zero");if(d&&(u.push(l+c),f&&u.push(l+h)),p){var m="".concat(l).concat(a.options.contextSeparator).concat(s.context);u.push(m),d&&(u.push(m+c),f&&u.push(m+h))}}for(;i=u.pop();)a.isValidLookup(t)||(n=i,t=a.getResource(r,e,i,s))}}))})}}),{res:t,usedKey:r,exactUsedKey:n,usedLng:o,usedNS:i}}},{key:"isValidLookup",value:function(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}]),n}(a6);function sm(e){return e.charAt(0).toUpperCase()+e.slice(1)}var sy=function(){function e(t){(0,aK.A)(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=a4.create("languageUtils")}return(0,az.A)(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return null;var t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],r=e.split("-");return this.options.lowerCaseLng?r=r.map(function(e){return e.toLowerCase()}):2===r.length?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=sm(r[1].toLowerCase()))):3===r.length&&(r[0]=r[0].toLowerCase(),2===r[1].length&&(r[1]=r[1].toUpperCase()),"sgn"!==r[0]&&2===r[2].length&&(r[2]=r[2].toUpperCase()),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=sm(r[1].toLowerCase())),t.indexOf(r[2].toLowerCase())>-1&&(r[2]=sm(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,r=this;return e?(e.forEach(function(e){if(!t){var n=r.formatLanguageCode(e);(!r.options.supportedLngs||r.isSupportedCode(n))&&(t=n)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var n=r.getLanguagePartFromCode(e);if(r.isSupportedCode(n))return t=n;t=r.options.supportedLngs.find(function(e){if(0===e.indexOf(n))return e})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}},{key:"toResolveHierarchy",value:function(e,t){var r=this,n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),o=[],i=function(e){e&&(r.isSupportedCode(e)?o.push(e):r.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&i(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&i(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&i(this.getLanguagePartFromCode(e))):"string"==typeof e&&i(this.formatLanguageCode(e)),n.forEach(function(e){0>o.indexOf(e)&&i(r.formatLanguageCode(e))}),o}}]),e}(),sg=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],sb={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(+(1!=e&&(e%10!=1||e%100==11)))},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:3*(e%100==3||e%100==4))},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},sv=["v1","v2","v3"],s_={zero:0,one:1,two:2,few:3,many:4,other:5},sw=function(){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,aK.A)(this,e),this.languageUtils=t,this.options=n,this.logger=a4.create("pluralResolver"),(!this.options.compatibilityJSON||"v4"===this.options.compatibilityJSON)&&("u"<typeof Intl||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(r={},sg.forEach(function(e){e.lngs.forEach(function(t){r[t]={numbers:e.nr,plurals:sb[e.fc]}})}),r)}return(0,az.A)(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.getRule(e,t);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,r).map(function(e){return"".concat(t).concat(e)})}},{key:"getSuffixes",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,r);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort(function(e,t){return s_[e]-s_[t]}).map(function(e){return"".concat(t.options.prepend).concat(e)}):n.numbers.map(function(n){return t.getSuffix(e,n,r)}):[]}},{key:"getSuffix",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getRule(e,r);return n?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(n.select(t)):this.getSuffixRetroCompatible(n,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var r=this,n=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),o=e.numbers[n];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===o?o="plural":1===o&&(o=""));var i=function(){return r.options.prepend&&o.toString()?r.options.prepend+o.toString():o.toString()};return"v1"===this.options.compatibilityJSON?1===o?"":"number"==typeof o?"_plural_".concat(o.toString()):i():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?i():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}},{key:"shouldUseIntlApi",value:function(){return!sv.includes(this.options.compatibilityJSON)}}]),e}();function sx(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sE(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sx(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sx(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var sS=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,aK.A)(this,e),this.logger=a4.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return(0,az.A)(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:so,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?sr(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?sr(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?sr(t.nestingPrefix):t.nestingPrefixEscaped||sr("$t("),this.nestingSuffix=t.nestingSuffix?sr(t.nestingSuffix):t.nestingSuffixEscaped||sr(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=RegExp(t,"g");var r="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=RegExp(r,"g")}},{key:"interpolate",value:function(e,t,r,n){var o,i,a,s=this,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function l(e){return e.replace(/\$/g,"$$$$")}var c=function(e){if(0>e.indexOf(s.formatSeparator)){var o=st(t,u,e);return s.alwaysFormat?s.format(o,void 0,r,sE(sE(sE({},n),t),{},{interpolationkey:e})):o}var i=e.split(s.formatSeparator),a=i.shift().trim(),l=i.join(s.formatSeparator).trim();return s.format(st(t,u,a),l,r,sE(sE(sE({},n),t),{},{interpolationkey:a}))};this.resetRegExp();var d=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,f=n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return l(e)}},{regex:this.regexp,safeValue:function(e){return s.escapeValue?l(s.escape(e)):l(e)}}].forEach(function(t){for(a=0;o=t.regex.exec(e);){var r=o[1].trim();if(void 0===(i=c(r)))if("function"==typeof d){var u=d(e,o,n);i="string"==typeof u?u:""}else if(n&&n.hasOwnProperty(r))i="";else if(f){i=o[0];continue}else s.logger.warn("missed to pass in variable ".concat(r," for interpolating ").concat(e)),i="";else"string"==typeof i||s.useRawValueToEscape||(i=a8(i));var l=t.safeValue(i);if(e=e.replace(o[0],l),f?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,++a>=s.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var r,n,o=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=sE({},i);function s(e,t){var r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;var n=e.split(new RegExp("".concat(r,"[ ]*{"))),o="{".concat(n[1]);e=n[0];var i=(o=this.interpolate(o,a)).match(/'/g),s=o.match(/"/g);(i&&i.length%2==0&&!s||s.length%2!=0)&&(o=o.replace(/'/g,'"'));try{a=JSON.parse(o),t&&(a=sE(sE({},t),a))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(r).concat(o)}return delete a.defaultValue,e}for(a.applyPostProcessor=!1,delete a.defaultValue;r=this.nestingRegexp.exec(e);){var u=[],l=!1;if(-1!==r[0].indexOf(this.formatSeparator)&&!/{.*}/.test(r[1])){var c=r[1].split(this.formatSeparator).map(function(e){return e.trim()});r[1]=c.shift(),u=c,l=!0}if((n=t(s.call(this,r[1].trim(),a),a))&&r[0]===e&&"string"!=typeof n)return n;"string"!=typeof n&&(n=a8(n)),n||(this.logger.warn("missed to resolve ".concat(r[1]," for nesting ").concat(e)),n=""),l&&(n=u.reduce(function(e,t){return o.format(e,t,i.lng,sE(sE({},i),{},{interpolationkey:r[1].trim()}))},n.trim())),e=e.replace(r[0],n),this.regexp.lastIndex=0}return e}}]),e}();function sO(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sD(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sO(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sO(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function sP(e){var t={};return function(r,n,o){var i=n+JSON.stringify(o),a=t[i];return a||(a=e(n,o),t[i]=a),a(r)}}var sk=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,aK.A)(this,e),this.logger=a4.create("formatter"),this.options=t,this.formats={number:sP(function(e,t){var r=new Intl.NumberFormat(e,t);return function(e){return r.format(e)}}),currency:sP(function(e,t){var r=new Intl.NumberFormat(e,sD(sD({},t),{},{style:"currency"}));return function(e){return r.format(e)}}),datetime:sP(function(e,t){var r=new Intl.DateTimeFormat(e,sD({},t));return function(e){return r.format(e)}}),relativetime:sP(function(e,t){var r=new Intl.RelativeTimeFormat(e,sD({},t));return function(e){return r.format(e,t.range||"day")}}),list:sP(function(e,t){var r=new Intl.ListFormat(e,sD({},t));return function(e){return r.format(e)}})},this.init(t)}return(0,az.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},r=t.interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=sP(t)}},{key:"format",value:function(e,t,r,n){var o=this;return t.split(this.formatSeparator).reduce(function(e,t){var i=function(e){var t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){var n=e.split("(");t=n[0].toLowerCase().trim();var o=n[1].substring(0,n[1].length-1);"currency"===t&&0>o.indexOf(":")?r.currency||(r.currency=o.trim()):"relativetime"===t&&0>o.indexOf(":")?r.range||(r.range=o.trim()):o.split(";").forEach(function(e){if(e){var t,n=(t=e.split(":"),(0,aX.A)(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||(0,aQ.A)(t)||(0,a0.A)()),o=n[0],i=n.slice(1).join(":").trim().replace(/^'+|'+$/g,"");r[o.trim()]||(r[o.trim()]=i),"false"===i&&(r[o.trim()]=!1),"true"===i&&(r[o.trim()]=!0),isNaN(i)||(r[o.trim()]=parseInt(i,10))}})}return{formatName:t,formatOptions:r}}(t),a=i.formatName,s=i.formatOptions;if(o.formats[a]){var u=e;try{var l=n&&n.formatParams&&n.formatParams[n.interpolationkey]||{},c=l.locale||l.lng||n.locale||n.lng||r;u=o.formats[a](e,c,sD(sD(sD({},s),n),l))}catch(e){o.logger.warn(e)}return u}return o.logger.warn("there was no format function for ".concat(a)),e},e)}}]),e}();function sC(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sj(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sC(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sC(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var sT=function(e){aq(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=aZ(n);return e=t?Reflect.construct(r,arguments,aZ(this).constructor):r.apply(this,arguments),aY(this,e)});function n(e,t,o){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,aK.A)(this,n),i=r.call(this),si&&a6.call(aH(i)),i.backend=e,i.store=t,i.services=o,i.languageUtils=o.languageUtils,i.options=a,i.logger=a4.create("backendConnector"),i.waitingReads=[],i.maxParallelReads=a.maxParallelReads||10,i.readingCalls=0,i.maxRetries=a.maxRetries>=0?a.maxRetries:5,i.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,i.state={},i.queue=[],i.backend&&i.backend.init&&i.backend.init(o,a.backend,a),i}return(0,az.A)(n,[{key:"queueLoad",value:function(e,t,r,n){var o=this,i={},a={},s={},u={};return e.forEach(function(e){var n=!0;t.forEach(function(t){var s="".concat(e,"|").concat(t);!r.reload&&o.store.hasResourceBundle(e,t)?o.state[s]=2:o.state[s]<0||(1===o.state[s]?void 0===a[s]&&(a[s]=!0):(o.state[s]=1,n=!1,void 0===a[s]&&(a[s]=!0),void 0===i[s]&&(i[s]=!0),void 0===u[t]&&(u[t]=!0)))}),n||(s[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(u)}}},{key:"loaded",value:function(e,t,r){var n=e.split("|"),o=n[0],i=n[1];t&&this.emit("failedLoading",o,i,t),r&&this.store.addResourceBundle(o,i,r),this.state[e]=t?-1:2;var a={};this.queue.forEach(function(r){var n,s,u,l;n=r.loaded,(u=(s=a9(n,[o],Object)).obj)[l=s.k]=u[l]||[],u[l].push(i),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(function(e){a[e]||(a[e]={});var t=r.loaded[e];t.length&&t.forEach(function(t){void 0===a[e][t]&&(a[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,r){var n=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:o,wait:i,callback:a}):(this.readingCalls++,this.backend[r](e,t,function(s,u){if(n.readingCalls--,n.waitingReads.length>0){var l=n.waitingReads.shift();n.read(l.lng,l.ns,l.fcName,l.tried,l.wait,l.callback)}s&&u&&o<n.maxRetries?setTimeout(function(){n.read.call(n,e,t,r,o+1,2*i,a)},i):a(s,u)})):a(null,{})}},{key:"prepareLoading",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var i=this.queueLoad(e,t,n,o);if(!i.toLoad.length)return i.pending.length||o(),null;i.toLoad.forEach(function(e){r.loadOne(e)})}},{key:"load",value:function(e,t,r){this.prepareLoading(e,t,{},r)}},{key:"reload",value:function(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}},{key:"loadOne",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e.split("|"),o=n[0],i=n[1];this.read(o,i,"read",void 0,void 0,function(n,a){n&&t.logger.warn("".concat(r,"loading namespace ").concat(i," for language ").concat(o," failed"),n),!n&&a&&t.logger.log("".concat(r,"loaded namespace ").concat(i," for language ").concat(o),a),t.loaded(e,n,a)})}},{key:"saveMissing",value:function(e,t,r,n,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(r,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null==r||""===r||(this.backend&&this.backend.create&&this.backend.create(e,t,r,n,null,sj(sj({},i),{},{isUpdate:o})),e&&e[0]&&this.store.addResource(e[0],t,r,n))}}]),n}(a6);function sR(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&0>e.supportedLngs.indexOf("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function sA(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sN(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sA(Object(r),!0).forEach(function(t){(0,aJ.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sA(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function sI(){}var sM=function(e){aq(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=aZ(n);return e=t?Reflect.construct(r,arguments,aZ(this).constructor):r.apply(this,arguments),aY(this,e)});function n(){var e,t,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if((0,aK.A)(this,n),t=r.call(this),si&&a6.call(aH(t)),t.options=sR(o),t.services={},t.logger=a4,t.modules={external:[]},Object.getOwnPropertyNames(Object.getPrototypeOf(e=aH(t))).forEach(function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}),i&&!t.isInitialized&&!o.isClone){if(!t.options.initImmediate)return t.init(o,i),aY(t,aH(t));setTimeout(function(){t.init(o,i)},0)}return t}return(0,az.A)(n,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(r=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:0>t.ns.indexOf("translation")&&(t.defaultNS=t.ns[0]));var n={debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===(0,aW.A)(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===(0,aW.A)(e[2])||"object"===(0,aW.A)(e[3])){var r=e[3]||e[2];Object.keys(r).forEach(function(e){t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:function(e,t,r,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}};function o(e){return e?"function"==typeof e?new e:e:null}if(this.options=sN(sN(sN({},n),this.options),sR(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=sN(sN({},n.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){this.modules.logger?a4.init(o(this.modules.logger),this.options):a4.init(null,this.options),this.modules.formatter?i=this.modules.formatter:"u">typeof Intl&&(i=sk);var i,a=new sy(this.options);this.store=new sl(this.options.resources,this.options);var s=this.services;s.logger=a4,s.resourceStore=this.store,s.languageUtils=a,s.pluralResolver=new sw(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),i&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(s.formatter=o(i),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new sS(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new sT(o(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",function(t){for(var r=arguments.length,n=Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];e.emit.apply(e,[t].concat(n))}),this.modules.languageDetector&&(s.languageDetector=o(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=o(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new sh(this.services,this.options),this.translator.on("*",function(t){for(var r=arguments.length,n=Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];e.emit.apply(e,[t].concat(n))}),this.modules.external.forEach(function(t){t.init&&t.init(e)})}if(this.format=this.options.interpolation.format,r||(r=sI),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&"dev"!==u[0]&&(this.options.lng=u[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments),e}});var l=a5(),c=function(){var t=function(t,n){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),l.resolve(n),r(t,n)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),l}},{key:"loadResources",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:sI,n=r,o="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(o&&"cimode"===o.toLowerCase())return n();var i=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){0>i.indexOf(e)&&i.push(e)})};o?a(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(e){return a(e)}),this.options.preload&&this.options.preload.forEach(function(e){return a(e)}),this.services.backendConnector.load(i,this.options.ns,function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),n(e)})}else n(null)}},{key:"reloadResources",value:function(e,t,r){var n=a5();return e||(e=this.languages),t||(t=this.options.ns),r||(r=sI),this.services.backendConnector.reload(e,t,function(e){n.resolve(),r(e)}),n}},{key:"use",value:function(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&sc.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var r=this.languages[t];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}},{key:"changeLanguage",value:function(e,t){var r=this;this.isLanguageChangingTo=e;var n=a5();this.emit("languageChanging",e);var o=function(e){r.language=e,r.languages=r.services.languageUtils.toResolveHierarchy(e),r.resolvedLanguage=void 0,r.setResolvedLanguage(e)},i=function(e,i){i?(o(i),r.translator.changeLanguage(i),r.isLanguageChangingTo=void 0,r.emit("languageChanged",i),r.logger.log("languageChanged",i)):r.isLanguageChangingTo=void 0,n.resolve(function(){return r.t.apply(r,arguments)}),t&&t(e,function(){return r.t.apply(r,arguments)})},a=function(t){e||t||!r.services.languageDetector||(t=[]);var n="string"==typeof t?t:r.services.languageUtils.getBestMatchFromCodes(t);n&&(r.language||o(n),r.translator.language||r.translator.changeLanguage(n),r.services.languageDetector&&r.services.languageDetector.cacheUserLanguage(n)),r.loadResources(n,function(e){i(e,n)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),n}},{key:"getFixedT",value:function(e,t,r){var n=this,o=function e(t,o){if("object"!==(0,aW.A)(o)){for(var i,a=arguments.length,s=Array(a>2?a-2:0),u=2;u<a;u++)s[u-2]=arguments[u];i=n.options.overloadTranslationOptionHandler([t,o].concat(s))}else i=sN({},o);i.lng=i.lng||e.lng,i.lngs=i.lngs||e.lngs,i.ns=i.ns||e.ns,i.keyPrefix=i.keyPrefix||r||e.keyPrefix;var l=n.options.keySeparator||".",c=i.keyPrefix?"".concat(i.keyPrefix).concat(l).concat(t):t;return n.t(c,i)};return"string"==typeof e?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=r,o}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var n=this.resolvedLanguage||this.languages[0],o=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var a=function(e,r){var n=t.services.backendConnector.state["".concat(e,"|").concat(r)];return -1===n||2===n};if(r.precheck){var s=r.precheck(this,a);if(void 0!==s)return s}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!o||a(i,e)))}},{key:"loadNamespaces",value:function(e,t){var r=this,n=a5();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){0>r.options.ns.indexOf(e)&&r.options.ns.push(e)}),this.loadResources(function(e){n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var r=a5();"string"==typeof e&&(e=[e]);var n=this.options.preload||[],o=e.filter(function(e){return 0>n.indexOf(e)});return o.length?(this.options.preload=n.concat(o),this.loadResources(function(e){r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),e)?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr":"rtl"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:sI,o=sN(sN(sN({},this.options),t),{isClone:!0}),i=new n(o);return(void 0!==t.debug||void 0!==t.prefix)&&(i.logger=i.logger.clone(t)),["store","services","language"].forEach(function(t){i[t]=e[t]}),i.services=sN({},this.services),i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i.translator=new sh(i.services,i.options),i.translator.on("*",function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];i.emit.apply(i,[e].concat(r))}),i.init(o,r),i.translator.options=i.options,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),n}(a6);(0,aJ.A)(sM,"createInstance",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new sM(e,t)});var s$=sM.createInstance();s$.createInstance=sM.createInstance,s$.createInstance,s$.init,s$.loadResources,s$.reloadResources,s$.use,s$.changeLanguage,s$.getFixedT,s$.t,s$.exists,s$.setDefaultNamespace,s$.hasLoadedNamespace,s$.loadNamespaces,s$.loadLanguages;let sL=s$.default||s$;function sF(e,t,r,n){return sL.t(t,{ns:e,defaultValue:r,...n})}function sB(e,t,r){return aU[e]?sF("core",e,t??aU[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}sL.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let sV="import-map-override:",sU="import-map-overrides-disabled",sW="import-map-overrides:change",sK=!1,sz=null,sH=null;async function sG(){return sH??(sH=sq().then(({map:e,complete:t})=>(t||(sH=null),e))),sH}async function sq(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let o=e[n];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else o.textContent&&t.push(JSON.parse(o.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:sY(t),complete:r}}function sY(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function sZ(){let e={};try{let t=s1();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(sV)){let r=n.slice(sV.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function sJ(){let e=await sG();return sK?sY([e,sz??sZ()]):e}async function sX(){return sG()}async function sQ(){return sK?sY([await sG(),sZ()]):sG()}function s0(e){if(!sK)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sV)){let t=localStorage.getItem(r);t&&(e[r.slice(sV.length)]=t)}}return{imports:e}}return sZ()}function s1(){if(!sK)return[];try{let e=localStorage.getItem(sU);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function s2(e){return!!sK&&s1().includes(e)}function s3(e,t){if(!sK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sV+e,t),window.dispatchEvent(new CustomEvent(sW))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function s4(e){if(!sK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sV+e);let t=s1().filter(t=>t!==e);t.length>0?localStorage.setItem(sU,JSON.stringify(t)):localStorage.removeItem(sU),window.dispatchEvent(new CustomEvent(sW))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function s6(){if(!sK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(sV)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(sU),window.dispatchEvent(new CustomEvent(sW))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function s5(e){if(!sK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=s1().filter(t=>t!==e);t.length>0?localStorage.setItem(sU,JSON.stringify(t)):localStorage.removeItem(sU),window.dispatchEvent(new CustomEvent(sW))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let s8=!1;function s9(){!s8&&(s8=!0,(sK="development"===window.spaEnv)&&(sz=sZ()))}function s7(e){return e.replace(/[\/\-@]/g,"_")}async function ue(e,t="./start",n){var o;let i,a=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([ut(e,n?.importMap),new Promise((t,r)=>{i=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=a)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},a)})]),i&&clearTimeout(i);let s=s7(e),u=window[s];if(!("object"==typeof(o=u)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}u.init(r.S.default);let l=(await u.get(t))();if("object"!=typeof l||null===l){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return l}async function ut(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=s7(e);if(!window[r]){let r=t??await ur();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let o=e in s0().imports;try{return await function(e){var t;let r=(t=window)[un]??(t[un]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let o=document.createElement("script");o.src=e,o.type="text/javascript",o.async=!0;let i=new Promise((t,n)=>{let i=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function a(){clearTimeout(i),o.removeEventListener("load",s),o.removeEventListener("error",u)}function s(){a(),t()}function u(t){a(),r.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),n(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",u),document.head.appendChild(o)});return r.set(e,i),i}(n)}catch(e){return o&&j({kind:"error",title:sB("scriptLoadingFailed","Error: Script failed to load"),description:sB("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:sB("resetOverrides","Reset overrides"),onActionButtonClick(){s6(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function ur(){return sJ()}let un=Symbol.for("__openmrs_script_loading");function uo(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function ui(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&uo(t))}let ua="openmrs-routes:",us="openmrs-routes:change",uu=!1,ul=null,uc=null;async function ud(){return uc??(uc=uf().then(({map:e,complete:t})=>(t||(uc=null),e))),uc}async function uf(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let o=e[n];try{let e;if(o.src){let t=await fetch(o.src);if(!t.ok)throw Error(`Request for ${o.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&ui(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:up(t),complete:r}}function up(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function uh(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(ua)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(ua.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(uo(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(uo(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function um(){let e=await ud();return uu?up([e,ul??await uh()]):e}async function uy(){return ud()}async function ug(){return uu?up([await ud(),await uh()]):ud()}function ub(){if(!uu)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(ua)){let t=localStorage.getItem(r);t&&(e[r.slice(ua.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function uv(e,t){if(!uu)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(ua+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!uo(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(ua+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(ua+e,JSON.stringify(t.toString()));else{if(!uo(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(ua+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(us))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function u_(e){if(!uu)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(ua+e),window.dispatchEvent(new CustomEvent(us))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function uw(){if(!uu)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(ua)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(us))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let ux=null;function uE(){return ux||(ux=(uu="development"===window.spaEnv)?uh().then(e=>{ul=e}):Promise.resolve())}let uS=`${av}/attachment`;function uO(e,t){return aE(`${uS}/${e}`,{signal:t.signal})}function uD(e,t,r){return aE(`${uS}?patient=${e}&includeEncounterless=${t}`,{signal:r.signal})}async function uP(e,t){let r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),aE(`${uS}`,{method:"POST",body:r})}function uk(e,t){return aE(`${uS}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function uC(e,t){return new Promise(function(r){var n=new MessageChannel;n.port1.onmessage=function(e){r(e.data)},e.postMessage(t,[n.port2])})}function uj(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function uT(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var uR=function(){var e=this;this.promise=new Promise(function(t,r){e.resolve=t,e.reject=r})};function uA(e,t){var r=location.href;return new URL(e,r).href===new URL(t,r).href}var uN=function(e,t){this.type=e,Object.assign(this,t)};function uI(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function uM(){}var u$={type:"SKIP_WAITING"};function uL(e,t){if(!t)return e&&e.then?e.then(uM):Promise.resolve()}var uF=function(e){function t(t,r){var n,o;return void 0===r&&(r={}),(n=e.call(this)||this).nn={},n.tn=0,n.rn=new uR,n.en=new uR,n.on=new uR,n.un=0,n.an=new Set,n.cn=function(){var e=n.fn,t=e.installing;n.tn>0||!uA(t.scriptURL,n.sn.toString())||performance.now()>n.un+6e4?(n.vn=t,e.removeEventListener("updatefound",n.cn)):(n.hn=t,n.an.add(t),n.rn.resolve(t)),++n.tn,t.addEventListener("statechange",n.ln)},n.ln=function(e){var t=n.fn,r=e.target,o=r.state,i=r===n.vn,a={sw:r,isExternal:i,originalEvent:e};!i&&n.mn&&(a.isUpdate=!0),n.dispatchEvent(new uN(o,a)),"installed"===o?n.wn=self.setTimeout(function(){"installed"===o&&t.waiting===r&&n.dispatchEvent(new uN("waiting",a))},200):"activating"===o&&(clearTimeout(n.wn),i||n.en.resolve(r))},n.dn=function(e){var t=n.hn,r=t!==navigator.serviceWorker.controller;n.dispatchEvent(new uN("controlling",{isExternal:r,originalEvent:e,sw:t,isUpdate:n.mn})),r||n.on.resolve(t)},o=function(e){var t=e.data,r=e.ports,o=e.source;return uI(n.getSW(),function(){n.an.has(o)&&n.dispatchEvent(new uN("message",{data:t,originalEvent:e,ports:r,sw:o}))})},n.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},n.sn=t,n.nn=r,navigator.serviceWorker.addEventListener("message",n.gn),n}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var r,n,o=t.prototype;return o.register=function(e){var t=(void 0===e?{}:e).immediate,r=void 0!==t&&t;try{var n,o,i,a=this;return n=function(){if(!r&&"complete"!==document.readyState)return uL(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),uI(a.bn(),function(e){a.fn=e,a.yn&&(a.hn=a.yn,a.en.resolve(a.yn),a.on.resolve(a.yn),a.yn.addEventListener("statechange",a.ln,{once:!0}));var t=a.fn.waiting;return t&&uA(t.scriptURL,a.sn.toString())&&(a.hn=t,Promise.resolve().then(function(){a.dispatchEvent(new uN("waiting",{sw:t,wasWaitingBeforeRegister:!0}))}).then(function(){})),a.hn&&(a.rn.resolve(a.hn),a.an.add(a.hn)),a.fn.addEventListener("updatefound",a.cn),navigator.serviceWorker.addEventListener("controllerchange",a.dn),a.fn})},(i=n())&&i.then?i.then(o):o(i)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?uL(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},o.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},o.messageSW=function(e){try{return uI(this.getSW(),function(t){return uC(t,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&uC(this.fn.waiting,u$)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&uA(e.scriptURL,this.sn.toString())?e:void 0},o.bn=function(){try{var e=this;return function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return uI(navigator.serviceWorker.register(e.sn,e.nn),function(t){return e.un=performance.now(),t})},function(e){throw e})}catch(e){return Promise.reject(e)}},r=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],uj(t.prototype,r),n&&uj(t,n),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,r=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return uT(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?uT(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=r()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function uB(e,t){if(void 0!==f)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),f;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let r=new uF(e,t);return f=r.register().then(()=>r.controlling.then(()=>r))}function uV(){return f??Promise.resolve(void 0)}let uU="x-omrs-offline-response-body",uW="x-omrs-offline-response-status",uK="x-omrs-offline-caching-strategy";async function uz(e){let t=await uV();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function uH(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function uG(){return!window.indexedDB}async function uq(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function uY(){return await uq()||await uG()||await uH()}let uZ="openmrs3:offline-mode",uJ="unavailable";function uX(){return{current:uJ,notAvailable:"unavailable"===uJ,active:"on"===uJ}}function uQ(e){"unavailable"!==uJ&&"unavailable"!==e&&(localStorage.setItem(uZ,"on"===e?"active":"disabled"),uJ=e)}async function u0(){await uY()||(uJ="active"===localStorage.getItem(uZ)?"on":"off"),navigator.onLine}let u1="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,u2=Object.keys,u3=Array.isArray;function u4(e,t){return"object"!=typeof t||u2(t).forEach(function(r){e[r]=t[r]}),e}"u"<typeof Promise||u1.Promise||(u1.Promise=Promise);let u6=Object.getPrototypeOf,u5={}.hasOwnProperty;function u8(e,t){return u5.call(e,t)}function u9(e,t){"function"==typeof t&&(t=t(u6(e))),("u"<typeof Reflect?u2:Reflect.ownKeys)(t).forEach(r=>{le(e,r,t[r])})}let u7=Object.defineProperty;function le(e,t,r,n){u7(e,t,u4(r&&u8(r,"get")&&"function"==typeof r.get?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function lt(e){return{from:function(t){return e.prototype=Object.create(t.prototype),le(e.prototype,"constructor",e),{extend:u9.bind(null,e.prototype)}}}}let lr=Object.getOwnPropertyDescriptor;function ln(e,t){let r;return lr(e,t)||(r=u6(e))&&ln(r,t)}let lo=[].slice;function li(e,t,r){return lo.call(e,t,r)}function la(e,t){return t(e)}function ls(e){if(!e)throw Error("Assertion Failed")}function lu(e){u1.setImmediate?setImmediate(e):setTimeout(e,0)}function ll(e,t){return e.reduce((e,r,n)=>{var o=t(r,n);return o&&(e[o[0]]=o[1]),e},{})}function lc(e,t){if(u8(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var r=[],n=0,o=t.length;n<o;++n){var i=lc(e,t[n]);r.push(i)}return r}var a=t.indexOf(".");if(-1!==a){var s=e[t.substr(0,a)];return void 0===s?void 0:lc(s,t.substr(a+1))}}function ld(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){ls("string"!=typeof r&&"length"in r);for(var n=0,o=t.length;n<o;++n)ld(e,t[n],r[n])}else{var i=t.indexOf(".");if(-1!==i){var a=t.substr(0,i),s=t.substr(i+1);if(""===s)void 0===r?u3(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=r;else{var u=e[a];u&&u8(e,a)||(u=e[a]={}),ld(u,s,r)}}else void 0===r?u3(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function lf(e){var t={};for(var r in e)u8(e,r)&&(t[r]=e[r]);return t}let lp=[].concat;function lh(e){return lp.apply([],e)}let lm="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(lh([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>u1[e]),ly=lm.map(e=>u1[e]);ll(lm,e=>[e,!0]);let lg=null;function lb(e){lg="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let r=lg&&lg.get(t);if(r)return r;if(u3(t)){r=[],lg&&lg.set(t,r);for(var n=0,o=t.length;n<o;++n)r.push(e(t[n]))}else if(ly.indexOf(t.constructor)>=0)r=t;else{let n=u6(t);for(var i in r=n===Object.prototype?{}:Object.create(n),lg&&lg.set(t,r),t)u8(t,i)&&(r[i]=e(t[i]))}return r}(e);return lg=null,t}let{toString:lv}={};function l_(e){return lv.call(e).slice(8,-1)}let lw="u">typeof Symbol?Symbol.iterator:"@@iterator",lx="symbol"==typeof lw?function(e){var t;return null!=e&&(t=e[lw])&&t.apply(e)}:function(){return null},lE={};function lS(e){var t,r,n,o;if(1==arguments.length){if(u3(e))return e.slice();if(this===lE&&"string"==typeof e)return[e];if(o=lx(e)){for(r=[];!(n=o.next()).done;)r.push(n.value);return r}if(null==e)return[e];if("number"==typeof(t=e.length)){for(r=Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=Array(t);t--;)r[t]=arguments[t];return r}let lO="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var lD="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),lP=()=>!0;let lk=!Error("").stack;function lC(){if(lk)try{throw lC.arguments,Error()}catch(e){return e}return Error()}function lj(e,t){var r=e.stack;return r?(t=t||0,0===r.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),r.split("\n").slice(t).filter(lP).map(e=>"\n"+e).join("")):""}var lT=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],lR=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(lT),lA={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function lN(e,t){this._e=lC(),this.name=e,this.message=t}function lI(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,r)=>r.indexOf(e)===t).join("\n")}function lM(e,t,r,n){this._e=lC(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=lI(e,t)}function l$(e,t){this._e=lC(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=lI(e,t)}lt(lN).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+lj(this._e,2))}},toString:function(){return this.name+": "+this.message}}),lt(lM).from(lN),lt(l$).from(lN);var lL=lR.reduce((e,t)=>(e[t]=t+"Error",e),{}),lF=lR.reduce((e,t)=>{var r=t+"Error";function n(e,n){this._e=lC(),this.name=r,e?"string"==typeof e?(this.message=`${e}${n?"\n "+n:""}`,this.inner=n||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=lA[t]||r,this.inner=null)}return lt(n).from(lN),e[t]=n,e},{});lF.Syntax=SyntaxError,lF.Type=TypeError,lF.Range=RangeError;var lB=lT.reduce((e,t)=>(e[t+"Error"]=lF[t],e),{}),lV=lR.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=lF[t]),e),{});function lU(){}function lW(e){return e}function lK(e,t){return null==e||e===lW?t:function(r){return t(e(r))}}function lz(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function lH(e,t){return e===lU?t:function(){var r=e.apply(this,arguments);void 0!==r&&(arguments[0]=r);var n=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?lz(n,this.onsuccess):n),o&&(this.onerror=this.onerror?lz(o,this.onerror):o),void 0!==i?i:r}}function lG(e,t){return e===lU?t:function(){e.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?lz(r,this.onsuccess):r),n&&(this.onerror=this.onerror?lz(n,this.onerror):n)}}function lq(e,t){return e===lU?t:function(r){var n=e.apply(this,arguments);u4(r,n);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?lz(o,this.onsuccess):o),i&&(this.onerror=this.onerror?lz(i,this.onerror):i),void 0===n?void 0===a?void 0:a:u4(n,a)}}function lY(e,t){return e===lU?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function lZ(e,t){return e===lU?t:function(){var r=e.apply(this,arguments);if(r&&"function"==typeof r.then){for(var n=this,o=arguments.length,i=Array(o);o--;)i[o]=arguments[o];return r.then(function(){return t.apply(n,i)})}return t.apply(this,arguments)}}lV.ModifyError=lM,lV.DexieError=lN,lV.BulkError=l$;var lJ={};let[lX,lQ,l0]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,u6(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,u6(t),e]})(),l1=lQ&&lQ.then,l2=lX&&lX.constructor,l3=!!l0;var l4=!1,l6=l0?()=>{l0.then(cy)}:u1.setImmediate?setImmediate.bind(null,cy):u1.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{cy(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(cy,0)},l5=function(e,t){ci.push([e,t]),l9&&(l6(),l9=!1)},l8=!0,l9=!0,l7=[],ce=[],ct=null,cr=lW,cn={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:cF,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{cF(e[0],e[1])}catch(e){}})}},co=cn,ci=[],ca=0,cs=[];function cu(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=lU,this._lib=!1;var t=this._PSD=co;if(lD&&(this._stackHolder=lC(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==lJ)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&cd(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,r){try{r(r=>{if(null===t._state){if(r===t)throw TypeError("A promise cannot be resolved with itself.");var n=t._lib&&cg();r&&"function"==typeof r.then?e(t,(e,t)=>{r instanceof cu?r._then(e,t):r.then(e,t)}):(t._state=!0,t._value=r,cf(t)),n&&cb()}},cd.bind(null,t))}catch(e){cd(t,e)}}(this,e)}let cl={get:function(){var e=co,t=cD;function r(r,n){var o=!e.global&&(e!==co||t!==cD);let i=o&&!cj();var a=new cu((t,a)=>{cp(this,new cc(c$(r,e,o,i),c$(n,e,o,i),t,a,e))});return lD&&cm(a,this),a}return r.prototype=lJ,r},set:function(e){le(this,"then",e&&e.prototype===lJ?cl:{get:function(){return e},set:cl.set})}};function cc(e,t,r,n,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=r,this.reject=n,this.psd=o}function cd(e,t){if(ce.push(t),null===e._state){var r=e._lib&&cg();t=cr(t),e._state=!1,e._value=t,lD&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var r=ln(t,"stack");t._promise=e,le(t,"stack",{get:()=>l4?r&&(r.get?r.get.apply(t):r.value):e.stack})}),l7.some(t=>t._value===e._value)||l7.push(e),cf(e),r&&cb()}}function cf(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)cp(e,t[r]);var o=e._PSD;--o.ref||o.finalize(),0===ca&&(++ca,l5(()=>{0==--ca&&cv()},[]))}function cp(e,t){if(null!==e._state){var r=e._state?t.onFulfilled:t.onRejected;if(null===r)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++ca,l5(ch,[r,e,t])}else e._listeners.push(t)}function ch(e,t,r){try{ct=t;var n,o=t._value;t._state?n=e(o):(ce.length&&(ce=[]),n=e(o),-1===ce.indexOf(o)&&function(e){for(var t=l7.length;t;)if(l7[--t]._value===e._value)return void l7.splice(t,1)}(t)),r.resolve(n)}catch(e){r.reject(e)}finally{ct=null,0==--ca&&cv(),--r.psd.ref||r.psd.finalize()}}function cm(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function cy(){cg()&&cb()}function cg(){var e=l8;return l8=!1,l9=!1,e}function cb(){var e,t,r;do for(;ci.length>0;)for(e=ci,ci=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(ci.length>0);l8=!0,l9=!0}function cv(){var e=l7;l7=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=cs.slice(0),r=t.length;r;)t[--r]()}function c_(e){return new cu(lJ,!1,e)}function cw(e,t){var r=co;return function(){var n=cg(),o=co;try{return cN(r,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{cN(o,!1),n&&cb()}}}u9(cu.prototype,{then:cl,_then:function(e,t){cp(this,new cc(null,null,e,t,co))},catch:function(e){if(1==arguments.length)return this.then(null,e);var t=arguments[0],r=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?r(e):c_(e)):this.then(null,e=>e&&e.name===t?r(e):c_(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),c_(t)))},stack:{get:function(){if(this._stack)return this._stack;try{l4=!0;var e=(function e(t,r,n){if(r.length===n)return r;var o="";if(!1===t._state){var i,a,s=t._value;null!=s?(i=s.name||"Error",a=s.message||s,o=lj(s,0)):(i=s,a=""),r.push(i+(a?": "+a:"")+o)}return lD&&((o=lj(t._stackHolder,2))&&-1===r.indexOf(o)&&r.push(o),t._prev&&e(t._prev,r,n)),r})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{l4=!1}}},timeout:function(e,t){return e<1/0?new cu((r,n)=>{var o=setTimeout(()=>n(new lF.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&le(cu.prototype,Symbol.toStringTag,"Dexie.Promise"),cn.env=cI(),u9(cu,{all:function(){var e=lS.apply(null,arguments).map(cT);return new cu(function(t,r){0===e.length&&t([]);var n=e.length;e.forEach((o,i)=>cu.resolve(o).then(r=>{e[i]=r,--n||t(e)},r))})},resolve:e=>{if(e instanceof cu)return e;if(e&&"function"==typeof e.then)return new cu((t,r)=>{e.then(t,r)});var t=new cu(lJ,!0,e);return cm(t,ct),t},reject:c_,race:function(){var e=lS.apply(null,arguments).map(cT);return new cu((t,r)=>{e.map(e=>cu.resolve(e).then(t,r))})},PSD:{get:()=>co,set:e=>co=e},totalEchoes:{get:()=>cD},newPSD:ck,usePSD:cM,scheduler:{get:()=>l5,set:e=>{l5=e}},rejectionMapper:{get:()=>cr,set:e=>{cr=e}},follow:(e,t)=>new cu((r,n)=>ck((t,r)=>{var n=co;n.unhandleds=[],n.onunhandled=r,n.finalize=lz(function(){var e;e=()=>{0===this.unhandleds.length?t():r(this.unhandleds[0])},cs.push(function t(){e(),cs.splice(cs.indexOf(t),1)}),++ca,l5(()=>{0==--ca&&cv()},[])},n.finalize),e()},t,r,n))}),l2&&(l2.allSettled&&le(cu,"allSettled",function(){let e=lS.apply(null,arguments).map(cT);return new cu(t=>{0===e.length&&t([]);let r=e.length,n=Array(r);e.forEach((e,o)=>cu.resolve(e).then(e=>n[o]={status:"fulfilled",value:e},e=>n[o]={status:"rejected",reason:e}).then(()=>--r||t(n)))})}),l2.any&&"u">typeof AggregateError&&le(cu,"any",function(){let e=lS.apply(null,arguments).map(cT);return new cu((t,r)=>{0===e.length&&r(AggregateError([]));let n=e.length,o=Array(n);e.forEach((e,i)=>cu.resolve(e).then(e=>t(e),e=>{o[i]=e,--n||r(AggregateError(o))}))})}));let cx={awaits:0,echoes:0,id:0};var cE=0,cS=[],cO=0,cD=0,cP=0;function ck(e,t,r,n){var o=co,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++cP;var a=cn.env;i.env=l3?{Promise:cu,PromiseProp:{value:cu,configurable:!0,writable:!0},all:cu.all,race:cu.race,allSettled:cu.allSettled,any:cu.any,resolve:cu.resolve,reject:cu.reject,nthen:cL(a.nthen,i),gthen:cL(a.gthen,i)}:{},t&&u4(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=cM(i,e,r,n);return 0===i.ref&&i.finalize(),s}function cC(){return cx.id||(cx.id=++cE),++cx.awaits,cx.echoes+=100,cx.id}function cj(){return!!cx.awaits&&(0==--cx.awaits&&(cx.id=0),cx.echoes=100*cx.awaits,!0)}function cT(e){return cx.echoes&&e&&e.constructor===l2?(cC(),e.then(e=>(cj(),e),e=>(cj(),cB(e)))):e}function cR(e){++cD,cx.echoes&&0!=--cx.echoes||(cx.echoes=cx.id=0),cS.push(co),cN(e,!0)}function cA(){var e=cS[cS.length-1];cS.pop(),cN(e,!1)}function cN(e,t){var r,n=co;if((t?!cx.echoes||cO++&&e===co:!cO||--cO&&e===co)||(r=t?cR.bind(null,e):cA,l1.call(lX,r)),e!==co&&(co=e,n===cn&&(cn.env=cI()),l3)){var o=cn.env.Promise,i=e.env;lQ.then=i.nthen,o.prototype.then=i.gthen,(n.global||e.global)&&(Object.defineProperty(u1,"Promise",i.PromiseProp),o.all=i.all,o.race=i.race,o.resolve=i.resolve,o.reject=i.reject,i.allSettled&&(o.allSettled=i.allSettled),i.any&&(o.any=i.any))}}function cI(){var e=u1.Promise;return l3?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(u1,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:lQ.then,gthen:e.prototype.then}:{}}function cM(e,t,r,n,o){var i=co;try{return cN(e,!0),t(r,n,o)}finally{cN(i,!1)}}function c$(e,t,r,n){return"function"!=typeof e?e:function(){var o,i=co;r&&cC(),cN(t,!0);try{return e.apply(this,arguments)}finally{cN(i,!1),n&&(o=cj,l1.call(lX,o))}}}function cL(e,t){return function(r,n){return e.call(this,c$(r,t),c$(n,t))}}function cF(e,t){var r;try{r=t.onuncatched(e)}catch(e){}if(!1!==r)try{var n,o={promise:t,reason:e};if(u1.document&&document.createEvent?((n=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),u4(n,o)):u1.CustomEvent&&u4(n=new CustomEvent("unhandledrejection",{detail:o}),o),n&&u1.dispatchEvent&&(dispatchEvent(n),!u1.PromiseRejectionEvent&&u1.onunhandledrejection))try{u1.onunhandledrejection(n)}catch(e){}lD&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+l1).indexOf("[native code]")&&(cC=cj=lU);var cB=cu.reject;let cV=String.fromCharCode(65535),cU="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",cW=[],cK="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),cz=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function cH(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let cG={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function cq(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=lb(t))[e],t)}class cY{_trans(e,t,r){let n=this._tx||co.trans,o=this.name;function i(e,r,n){if(!n.schema[o])throw new lF.NotFound("Table "+o+" not part of transaction");return t(n.idbtrans,n)}let a=cg();try{return n&&n.db===this.db?n===co.trans?n._promise(e,i,r):ck(()=>n._promise(e,i,r),{trans:n,transless:co.transless||co}):function e(t,r,n,o){if(t.idbdb&&(t._state.openComplete||co.letThrough||t._vip)){var i=t._createTransaction(r,n,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===lL.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,o))):cB(i)}return i._promise(r,(e,t)=>ck(()=>(co.trans=i,o(e,t,i)))).then(e=>i._completion.then(()=>e))}if(t._state.openComplete)return cB(new lF.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return cB(new lF.DatabaseClosed);t.open().catch(lU)}return t._state.dbReadyPromise.then(()=>e(t,r,n,o))}(this.db,e,[this.name],i)}finally{a&&cb()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(u3(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=u2(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let r=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)&&e.keyPath.every(e=>t.indexOf(e)>=0))[0];if(r&&this.db._maxKey!==cV)return this.where(r.name).equals(r.keyPath.map(t=>e[t]));!r&&lD&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:n}=this.schema,o=this.db._deps.indexedDB;function i(e,t){try{return 0===o.cmp(e,t)}catch(e){return!1}}let[a,s]=t.reduce(([t,r],o)=>{let a=n[o],s=e[o];return[t||a,t||!a?cH(r,a&&a.multi?e=>{let t=lc(e,o);return u3(t)&&t.some(e=>i(s,e))}:e=>i(s,lc(e,o))):r]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):r?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,u3(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let r=Object.create(e.prototype);for(var n in t)if(u8(t,n))try{r[n]=t[n]}catch(e){}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){u4(this,e)})}add(e,t){let{auto:r,keyPath:n}=this.schema.primKey,o=e;return n&&r&&(o=cq(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[o]})).then(e=>e.numFailures?cu.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{ld(e,n,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||u3(e))return this.where(":id").equals(e).modify(t);{let r=lc(e,this.schema.primKey.keyPath);if(void 0===r)return cB(new lF.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?u2(t).forEach(r=>{ld(e,r,t[r])}):t(e,{value:e,primKey:r})}catch(e){}return this.where(":id").equals(r).modify(t)}}put(e,t){let{auto:r,keyPath:n}=this.schema.primKey,o=e;return n&&r&&(o=cq(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=t?[t]:null})).then(e=>e.numFailures?cu.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{ld(e,n,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?cu.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:cG})).then(e=>e.numFailures?cu.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,r){let n=Array.isArray(t)?t:void 0,o=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new lF.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new lF.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&r?e.map(cq(i)):e;return this.core.mutate({trans:t,type:"add",keys:n,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return o?t:r;throw new l$(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,n)})})}bulkPut(e,t,r){let n=Array.isArray(t)?t:void 0,o=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new lF.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new lF.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&r?e.map(cq(i)):e;return this.core.mutate({trans:t,type:"put",keys:n,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return o?t:r;throw new l$(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,n)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:r,failures:n})=>{if(0===e)return r;throw new l$(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,n)})}}function cZ(e){var t={},r=function(r,n){if(n){for(var o=arguments.length,i=Array(o-1);--o;)i[o-1]=arguments[o];return t[r].subscribe.apply(null,i),e}if("string"==typeof r)return t[r]};r.addEventType=i;for(var n=1,o=arguments.length;n<o;++n)i(arguments[n]);return r;function i(e,n,o){if("object"==typeof e){var a;return void u2(a=e).forEach(function(e){var t=a[e];if(u3(t))i(e,a[e][0],a[e][1]);else{if("asap"!==t)throw new lF.InvalidArgument("Invalid event config");var r=i(e,lW,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];r.subscribers.forEach(function(e){lu(function(){e.apply(null,t)})})})}})}n||(n=lY),o||(o=lU);var s={subscribers:[],fire:o,subscribe:function(e){-1===s.subscribers.indexOf(e)&&(s.subscribers.push(e),s.fire=n(s.fire,e))},unsubscribe:function(e){s.subscribers=s.subscribers.filter(function(t){return t!==e}),s.fire=s.subscribers.reduce(n,o)}};return t[e]=r[e]=s,s}}function cJ(e,t){return lt(t).from({prototype:e}),t}function cX(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function cQ(e,t){e.filter=cH(e.filter,t)}function c0(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>cH(n(),t()):t,e.justLimit=r&&!n}function c1(e,t){if(e.isPrimKey)return t.primaryKey;let r=t.getIndexByKeyPath(e.index);if(!r)throw new lF.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function c2(e,t,r){let n=c1(e,t.schema);return t.openCursor({trans:r,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:n,range:e.range}})}function c3(e,t,r,n){let o=e.replayFilter?cH(e.filter,e.replayFilter()):e.filter;if(e.or){let i={},a=(e,r,n)=>{if(!o||o(r,n,e=>r.stop(e),e=>r.fail(e))){var a=r.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),u8(i,s)||(i[s]=!0,t(e,r,n))}};return Promise.all([e.or._iterate(a,r),c4(c2(e,n,r),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return c4(c2(e,n,r),cH(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function c4(e,t,r,n){var o=cw(n?(e,t,o)=>r(n(e),t,o):r);return e.then(e=>{if(e)return e.start(()=>{var r=()=>e.continue();t&&!t(e,e=>r=e,t=>{e.stop(t),r=lU},t=>{e.fail(t),r=lU})||o(e.value,e,e=>r=e),r()})})}function c6(e,t){try{let r=c5(e),n=c5(t);if(r!==n)return"Array"===r?1:"Array"===n?-1:"binary"===r?1:"binary"===n?-1:"string"===r?1:"string"===n?-1:"Date"===r?1:"Date"!==n?NaN:-1;switch(r){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let r=e.length,n=t.length,o=r<n?r:n;for(let r=0;r<o;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return r===n?0:r<n?-1:1}(c8(e),c8(t));case"Array":return function(e,t){let r=e.length,n=t.length,o=r<n?r:n;for(let r=0;r<o;++r){let n=c6(e[r],t[r]);if(0!==n)return n}return r===n?0:r<n?-1:1}(e,t)}}catch(e){}return NaN}function c5(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let r=l_(e);return"ArrayBuffer"===r?"binary":r}function c8(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class c9{_read(e,t){var r=this._ctx;return r.error?r.table._trans(null,cB.bind(null,r.error)):r.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,cB.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=cH(t.algorithm,e)}_iterate(e,t){return c3(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&u4(r,e),t._ctx=r,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(r=>c3(t,e,r,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,r=t.table.core;if(cX(t,!0))return r.count({trans:e,query:{index:c1(t,r.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var n=0;return c3(t,()=>(++n,!1),e,r).then(()=>n)}).then(e)}sortBy(e,t){let r=e.split(".").reverse(),n=r[0],o=r.length-1;function i(e,t){return t?i(e[r[t]],t-1):e[n]}var a="next"===this._ctx.dir?1:-1;function s(e,t){var r=i(e,o),n=i(t,o);return r<n?-a:r>n?a:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&cX(t,!0)&&t.limit>0){let{valueMapper:r}=t,n=c1(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:n,range:t.range}}).then(({result:e})=>r?e.map(r):e)}{let r=[];return c3(t,e=>r.push(e),e,t.table.core).then(()=>r)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,cX(t)?c0(t,()=>{var t=e;return(e,r)=>0===t||(1===t?--t:r(()=>{e.advance(t),t=0}),!1)}):c0(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),c0(this._ctx,()=>{var t=e;return function(e,r,n){return--t<=0&&r(n),t>=0}},!0),this}until(e,t){return cQ(this._ctx,function(r,n,o){return!e(r.value)||(n(o),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return cQ(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=cH(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.key,r)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.primaryKey,r)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.key)}).then(function(){return r}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&cX(t,!0)&&t.limit>0)return this._read(e=>{var r=c1(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:r,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var r={};return cQ(this._ctx,function(e){var t=e.primaryKey.toString(),n=u8(r,t);return r[t]=!0,!n}),this}modify(e){var t=this._ctx;return this._write(r=>{var n;if("function"==typeof e)n=e;else{var o=u2(e),i=o.length;n=function(t){for(var r=!1,n=0;n<i;++n){var a=o[n],s=e[a];lc(t,a)!==s&&(ld(t,a,s),r=!0)}return r}}let a=t.table.core,{outbound:s,extractKey:u}=a.schema.primaryKey,l=this.db._options.modifyChunkSize||200,c=[],d=0,f=[],p=(e,t)=>{let{failures:r,numFailures:n}=t;for(let t of(d+=e-n,u2(r)))c.push(r[t])};return this.clone().primaryKeys().then(o=>{let i=c=>{let d=Math.min(l,o.length-c);return a.getMany({trans:r,keys:o.slice(c,c+d),cache:"immutable"}).then(f=>{let h=[],m=[],y=s?[]:null,g=[];for(let e=0;e<d;++e){let t=f[e],r={value:lb(t),primKey:o[c+e]};!1!==n.call(r,r.value,r)&&(null==r.value?g.push(o[c+e]):s||0===c6(u(t),u(r.value))?(m.push(r.value),s&&y.push(o[c+e])):(g.push(o[c+e]),h.push(r.value)))}let b=cX(t)&&t.limit===1/0&&("function"!=typeof e||e===c7)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&a.mutate({trans:r,type:"add",values:h}).then(e=>{for(let t in e.failures)g.splice(parseInt(t),1);p(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:y,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>p(m.length,e))).then(()=>(g.length>0||b&&e===c7)&&a.mutate({trans:r,type:"delete",keys:g,criteria:b}).then(e=>p(g.length,e))).then(()=>o.length>c+d&&i(c+l))})};return i(0).then(()=>{if(c.length>0)throw new lM("Error modifying one or more objects",c,d,f);return o.length})})})}delete(){var e=this._ctx,t=e.range;return cX(e)&&(e.isPrimKey&&!cK||3===t.type)?this._write(r=>{let{primaryKey:n}=e.table.core.schema;return e.table.core.count({trans:r,query:{index:n,range:t}}).then(n=>e.table.core.mutate({trans:r,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:r,numFailures:o})=>{if(o)throw new lM("Could not delete some values",Object.keys(e).map(t=>e[t]),n-o);return n-o}))}):this.modify(c7)}}let c7=(e,t)=>t.value=null;function de(e,t){return e<t?-1:+(e!==t)}function dt(e,t){return e>t?-1:+(e!==t)}function dr(e,t,r){var n=e instanceof du?new e.Collection(e):e;return n._ctx.error=r?new r(t):TypeError(t),n}function dn(e){return new e.Collection(e,()=>ds("")).limit(0)}function di(e,t,r,n){var o,i,a,s,u,l,c,d=r.length;if(!r.every(e=>"string"==typeof e))return dr(e,"String expected.");function f(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),i="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?de:dt;var t=r.map(function(e){return{lower:i(e),upper:o(e)}}).sort(function(e,t){return a(e.lower,t.lower)});s=t.map(function(e){return e.upper}),u=t.map(function(e){return e.lower}),l=e,c="next"===e?"":n}f("next");var p=new e.Collection(e,()=>da(s[0],u[d-1]+n));p._ondirectionchange=function(e){f(e)};var h=0;return p._addAlgorithm(function(e,r,n){var o=e.key;if("string"!=typeof o)return!1;var f=i(o);if(t(f,u,h))return!0;for(var p=null,m=h;m<d;++m){var y=function(e,t,r,n,o,i){for(var a=Math.min(e.length,n.length),s=-1,u=0;u<a;++u){var l=t[u];if(l!==n[u])return 0>o(e[u],r[u])?e.substr(0,u)+r[u]+r.substr(u+1):0>o(e[u],n[u])?e.substr(0,u)+n[u]+r.substr(u+1):s>=0?e.substr(0,s)+t[s]+r.substr(s+1):null;0>o(e[u],l)&&(s=u)}return a<n.length&&"next"===i?e+r.substr(e.length):a<e.length&&"prev"===i?e.substr(0,r.length):s<0?null:e.substr(0,s)+n[s]+r.substr(s+1)}(o,f,s[m],u[m],a,l);null===y&&null===p?h=m+1:(null===p||a(p,y)>0)&&(p=y)}return r(null!==p?function(){e.continue(p+c)}:n),!1}),p}function da(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function ds(e){return{type:1,lower:e,upper:e}}class du{get Collection(){return this._ctx.table.db.Collection}between(e,t,r,n){r=!1!==r,n=!0===n;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(r||n)&&(!r||!n)?dn(this):new this.Collection(this,()=>da(e,t,!r,!n))}catch(e){return dr(this,cU)}}equals(e){return null==e?dr(this,cU):new this.Collection(this,()=>ds(e))}above(e){return null==e?dr(this,cU):new this.Collection(this,()=>da(e,void 0,!0))}aboveOrEqual(e){return null==e?dr(this,cU):new this.Collection(this,()=>da(e,void 0,!1))}below(e){return null==e?dr(this,cU):new this.Collection(this,()=>da(void 0,e,!1,!0))}belowOrEqual(e){return null==e?dr(this,cU):new this.Collection(this,()=>da(void 0,e))}startsWith(e){return"string"!=typeof e?dr(this,"String expected."):this.between(e,e+cV,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):di(this,(e,t)=>0===e.indexOf(t[0]),[e],cV)}equalsIgnoreCase(e){return di(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=lS.apply(lE,arguments);return 0===e.length?dn(this):di(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=lS.apply(lE,arguments);return 0===e.length?dn(this):di(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,cV)}anyOf(){let e=lS.apply(lE,arguments),t=this._cmp;try{e.sort(t)}catch(e){return dr(this,cU)}if(0===e.length)return dn(this);let r=new this.Collection(this,()=>da(e[0],e[e.length-1]));r._ondirectionchange=r=>{t="next"===r?this._ascending:this._descending,e.sort(t)};let n=0;return r._addAlgorithm((r,o,i)=>{let a=r.key;for(;t(a,e[n])>0;)if(++n===e.length)return o(i),!1;return 0===t(a,e[n])||(o(()=>{r.continue(e[n])}),!1)}),r}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=lS.apply(lE,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return dr(this,cU)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let r=this._cmp,n=this._ascending,o=this._descending,i=this._min,a=this._max;if(0===e.length)return dn(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=n(e[0],e[1])))return dr(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",lF.InvalidArgument);let s=!t||!1!==t.includeLowers,u=t&&!0===t.includeUppers,l,c=n;function d(e,t){return c(e[0],t[0])}try{(l=e.reduce(function(e,t){let n=0,o=e.length;for(;n<o;++n){let o=e[n];if(0>r(t[0],o[1])&&r(t[1],o[0])>0){o[0]=i(o[0],t[0]),o[1]=a(o[1],t[1]);break}}return n===o&&e.push(t),e},[])).sort(d)}catch(e){return dr(this,cU)}let f=0,p=u?e=>n(e,l[f][1])>0:e=>n(e,l[f][1])>=0,h=s?e=>o(e,l[f][0])>0:e=>o(e,l[f][0])>=0,m=p,y=new this.Collection(this,()=>da(l[0][0],l[l.length-1][1],!s,!u));return y._ondirectionchange=e=>{"next"===e?(m=p,c=n):(m=h,c=o),l.sort(d)},y._addAlgorithm((e,t,r)=>{for(var o=e.key;m(o);)if(++f===l.length)return t(r),!1;return!!(!p(o)&&!h(o))||(0===this._cmp(o,l[f][1])||0===this._cmp(o,l[f][0])||t(()=>{c===n?e.continue(l[f][0]):e.continue(l[f][1])}),!1)}),y}startsWithAnyOf(){let e=lS.apply(lE,arguments);return e.every(e=>"string"==typeof e)?0===e.length?dn(this):this.inAnyRange(e.map(e=>[e,e+cV])):dr(this,"startsWithAnyOf() only works with strings")}}function dl(e){return cw(function(t){return dc(t),e(t.target.error),!1})}function dc(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let dd=cZ(null,"storagemutated");class df{_lock(){return ls(!co.global),++this._reculock,1!==this._reculock||co.global||(co.lockOwnerFor=this),this}_unlock(){if(ls(!co.global),0==--this._reculock)for(co.global||(co.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{cM(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&co.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,r=this.db._state.dbOpenError;if(ls(!this.idbtrans),!e&&!t)switch(r&&r.name){case"DatabaseClosedError":throw new lF.DatabaseClosed(r);case"MissingAPIError":throw new lF.MissingAPI(r.message,r);default:throw new lF.OpenFailed(r)}if(!this.active)throw new lF.TransactionInactive;return ls(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=cw(t=>{dc(t),this._reject(e.error)}),e.onabort=cw(t=>{dc(t),this.active&&this._reject(new lF.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=cw(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&dd.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,r){if("readwrite"===e&&"readwrite"!==this.mode)return cB(new lF.ReadOnly("Transaction is readonly"));if(!this.active)return cB(new lF.TransactionInactive);if(this._locked())return new cu((n,o)=>{this._blockedFuncs.push([()=>{this._promise(e,t,r).then(n,o)},co])});if(r)return ck(()=>{var e=new cu((e,r)=>{this._lock();let n=t(e,r,this);n&&n.then&&n.then(e,r)});return e.finally(()=>this._unlock()),e._lib=!0,e});var n=new cu((e,r)=>{var n=t(e,r,this);n&&n.then&&n.then(e,r)});return n._lib=!0,n}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let r=cu.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>r);else{t._waitingFor=r,t._waitingQueue=[];var n=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(n.get(-1/0).onsuccess=e)}()}var o=t._waitingFor;return new cu((e,n)=>{r.then(r=>t._waitingQueue.push(cw(e.bind(null,r))),e=>t._waitingQueue.push(cw(n.bind(null,e)))).finally(()=>{t._waitingFor===o&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new lF.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(u8(t,e))return t[e];let r=this.schema[e];if(!r)throw new lF.NotFound("Table "+e+" not part of transaction");let n=new this.db.Table(e,r,this);return n.core=this.db.core.table(e),t[e]=n,n}}function dp(e,t,r,n,o,i,a){return{name:e,keyPath:t,unique:r,multi:n,auto:o,compound:i,src:(r&&!a?"&":"")+(n?"*":"")+(o?"++":"")+dh(t)}}function dh(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function dm(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:ll(r,e=>[e.name,e])}}let dy=e=>{try{return e.only([[]]),dy=()=>[[]],[[]]}catch(e){return dy=()=>cV,cV}};function dg(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>lc(t,e):t=>lc(t,e)}function db(e){return[].slice.call(e)}let dv=0;function d_(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function dw({_novip:e},t){let r=t.db,n=function(e,t,{IDBKeyRange:r,indexedDB:n},o){var i;return{dbcore:(i=function(e,t,r){let n;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:r,upper:n,lowerOpen:o,upperOpen:i}=e;return void 0===r?void 0===n?null:t.upperBound(n,!!i):void 0===n?t.lowerBound(r,!!o):t.bound(r,n,!!o,!!i)}let{schema:i,hasGetAll:a}=(n=db(e.objectStoreNames),{schema:{name:e.name,tables:n.map(e=>r.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:r}=e,n=u3(t),o=null==t,i={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:n,keyPath:t,autoIncrement:r,unique:!0,extractKey:dg(t)},indexes:db(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:r,multiEntry:n,keyPath:o}=e,a={name:t,compound:u3(o),keyPath:o,unique:r,multiEntry:n,extractKey:dg(o)};return i[d_(o)]=a,a}),getIndexByKeyPath:e=>i[d_(e)]};return i[":id"]=a.primaryKey,null!=t&&(i[d_(t)]=a.primaryKey),a})},hasGetAll:n.length>0&&"getAll"in r.objectStore(n[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=i.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:r,keys:n,values:i,range:a}){return new Promise((s,u)=>{let l;s=cw(s);let c=e.objectStore(t),d=null==c.keyPath,f="put"===r||"add"===r;if(!f&&"delete"!==r&&"deleteRange"!==r)throw Error("Invalid operation type: "+r);let{length:p}=n||i||{length:1};if(n&&i&&n.length!==i.length)throw Error("Given keys array must have same length as given values array.");if(0===p)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],y=0,g=e=>{++y,dc(e)};if("deleteRange"===r){if(4===a.type)return s({numFailures:y,failures:m,results:[],lastResult:void 0});3===a.type?h.push(l=c.clear()):h.push(l=c.delete(o(a)))}else{let[e,t]=f?d?[i,n]:[i,null]:[n,null];if(f)for(let n=0;n<p;++n)h.push(l=t&&void 0!==t[n]?c[r](e[n],t[n]):c[r](e[n])),l.onerror=g;else for(let t=0;t<p;++t)h.push(l=c[r](e[t])),l.onerror=g}let b=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:y,failures:m,results:"delete"===r?n:h.map(e=>e.result),lastResult:t})};l.onerror=e=>{g(e),b(e)},l.onsuccess=b})},getMany:({trans:e,keys:r})=>new Promise((n,o)=>{n=cw(n);let i=e.objectStore(t),a=r.length,s=Array(a),u,l=0,c=0,d=e=>{let t=e.target;s[t._pos]=t.result,++c===l&&n(s)},f=dl(o);for(let e=0;e<a;++e)null!=r[e]&&((u=i.get(r[e]))._pos=e,u.onsuccess=d,u.onerror=f,++l);0===l&&n(s)}),get:({trans:e,key:r})=>new Promise((n,o)=>{n=cw(n);let i=e.objectStore(t).get(r);i.onsuccess=e=>n(e.target.result),i.onerror=dl(o)}),query:e=>new Promise((r,n)=>{r=cw(r);let{trans:i,values:s,limit:u,query:l}=e,c=u===1/0?void 0:u,{index:d,range:f}=l,p=i.objectStore(t),h=d.isPrimaryKey?p:p.index(d.name),m=o(f);if(0===u)return r({result:[]});if(a){let e=s?h.getAll(m,c):h.getAllKeys(m,c);e.onsuccess=e=>r({result:e.target.result}),e.onerror=dl(n)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];t.onsuccess=n=>{let i=t.result;return i?(o.push(s?i.value:i.primaryKey),++e===u?r({result:o}):void i.continue()):r({result:o})},t.onerror=dl(n)}}),openCursor:function({trans:e,values:r,query:n,reverse:i,unique:a}){return new Promise((s,u)=>{s=cw(s);let{index:l,range:c}=n,d=e.objectStore(t),f=l.isPrimaryKey?d:d.index(l.name),p=i?a?"prevunique":"prev":a?"nextunique":"next",h=!r&&"openKeyCursor"in f?f.openKeyCursor(o(c),p):f.openCursor(o(c),p);h.onerror=dl(u),h.onsuccess=cw(t=>{let r=h.result;if(!r)return void s(null);r.___id=++dv,r.done=!1;let n=r.continue.bind(r),o=r.continuePrimaryKey;o&&(o=o.bind(r));let i=r.advance.bind(r),a=()=>{throw Error("Cursor not stopped")};r.trans=e,r.stop=r.continue=r.continuePrimaryKey=r.advance=()=>{throw Error("Cursor not started")},r.fail=cw(u),r.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},r.start=e=>{let t=new Promise((e,t)=>{e=cw(e),h.onerror=dl(t),r.fail=t,r.stop=t=>{r.stop=r.continue=r.continuePrimaryKey=r.advance=a,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){r.fail(e)}else r.done=!0,r.start=()=>{throw Error("Cursor behind last entry")},r.stop()};return h.onsuccess=cw(e=>{h.onsuccess=s,s()}),r.continue=n,r.continuePrimaryKey=o,r.advance=i,s(),t},s(r)},u)})},count({query:e,trans:r}){let{index:n,range:i}=e;return new Promise((e,a)=>{let s=r.objectStore(t),u=n.isPrimaryKey?s:s.index(n.name),l=o(i),c=l?u.count(l):u.count();c.onsuccess=cw(t=>e(t.target.result)),c.onerror=dl(a)})}}}),u={};return s.forEach(e=>u[e.name]=e),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!u[e])throw Error(`Table '${e}' not found`);return u[e]},MIN_KEY:-1/0,MAX_KEY:dy(t),schema:i}}(t,r,o),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),i))}}(e._middlewares,r,e._deps,t);e.core=n.dbcore,e.tables.forEach(t=>{let r=t.name;e.core.schema.tables.some(e=>e.name===r)&&(t.core=e.core.table(r),e[r]instanceof e.Table&&(e[r].core=t.core))})}function dx({_novip:e},t,r,n){r.forEach(r=>{let o=n[r];t.forEach(t=>{let n=ln(t,r);(!n||"value"in n&&void 0===n.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?le(t,r,{get(){return this.table(r)},set(e){u7(this,r,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[r]=new e.Table(r,o))})})}function dE({_novip:e},t){t.forEach(t=>{for(let r in t)t[r]instanceof e.Table&&delete t[r]})}function dS(e,t){return e._cfg.version-t._cfg.version}function dO(e,t){let r,n={del:[],add:[],change:[]};for(r in e)t[r]||n.del.push(r);for(r in t){let o=e[r],i=t[r];if(o){let e={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(i.primKey.keyPath||"")&&(o.primKey.auto===i.primKey.auto||cK)){let t,r=o.idxByName,a=i.idxByName;for(t in r)a[t]||e.del.push(t);for(t in a){let n=r[t],o=a[t];n?n.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}else e.recreate=!0,n.change.push(e)}else n.add.push([r,i])}return n}function dD(e,t,r,n){let o=e.db.createObjectStore(t,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(e=>dP(o,e)),o}function dP(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function dk(e,t,r){let n={};return li(t.objectStoreNames,0).forEach(e=>{let t=r.objectStore(e),o=t.keyPath,i=dp(dh(o),o||"",!1,!1,!!t.autoIncrement,o&&"string"!=typeof o,!0),a=[];for(let e=0;e<t.indexNames.length;++e){let r=t.index(t.indexNames[e]);o=r.keyPath;var s=dp(r.name,o,!!r.unique,!!r.multiEntry,!1,o&&"string"!=typeof o,!1);a.push(s)}n[e]=dm(e,i,a)}),n}function dC({_novip:e},t,r){let n=r.db.objectStoreNames;for(let o=0;o<n.length;++o){let i=n[o],a=r.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let r=a.indexNames[e],n=a.index(r).keyPath,o="string"==typeof n?n:"["+li(n).join("+")+"]";if(t[i]){let e=t[i].idxByName[o];e&&(e.name=r,delete t[i].idxByName[o],t[i].idxByName[r]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&u1.WorkerGlobalScope&&u1 instanceof u1.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class dj{_parseStoresSpec(e,t){u2(e).forEach(r=>{if(null!==e[r]){var n=e[r].split(",").map((e,t)=>{let r=(e=e.trim()).replace(/([&*]|\+\+)/g,""),n=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return dp(r,n||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),u3(n),0===t)}),o=n.shift();if(o.multi)throw new lF.Schema("Primary key cannot be multi-valued");n.forEach(e=>{if(e.auto)throw new lF.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new lF.Schema("Index must have a name and cannot be an empty string")}),t[r]=dm(r,o,n)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?u4(this._cfg.storesSource,e):e;let r=t._versions,n={},o={};return r.forEach(e=>{u4(n,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(n,o)}),t._dbSchema=o,dE(t,[t._allTables,t,t.Transaction.prototype]),dx(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],u2(o),o),t._storeNames=u2(o),this}upgrade(e){return this._cfg.contentUpgrade=lZ(this._cfg.contentUpgrade||lU,e),this}}function dT(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new dZ("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),r.table("dbnames")}function dR(e){return e&&"function"==typeof e.databases}function dA(e){return ck(function(){return co.letThrough=!0,e()})}function dN(e){var t=t=>e.next(t),r=o(t),n=o(t=>e.throw(t));function o(e){return t=>{var o=e(t),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(r,n):u3(i)?Promise.all(i).then(r,n):r(i)}}return o(t)()}function dI(e,t,r){var n=arguments.length;if(n<2)throw new lF.InvalidArgument("Too few arguments");for(var o=Array(n-1);--n;)o[n-1]=arguments[n];return r=o.pop(),[e,lh(o),r]}function dM(e,t,r){let n=u3(e)?e.slice():[e];for(let e=0;e<r;++e)n.push(t);return n}let d$={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let r=e.table(t),{schema:n}=r,o={},i=[];function a(e,t,r){let n=d_(e),s=o[n]=o[n]||[],u=null==e?0:"string"==typeof e?1:e.length,l=t>0,c={...r,isVirtual:l,keyTail:t,keyLength:u,extractKey:dg(e),unique:!l&&r.unique};return s.push(c),c.isPrimaryKey||i.push(c),u>1&&a(2===u?e[0]:e.slice(0,u-1),t+1,r),s.sort((e,t)=>e.keyTail-t.keyTail),c}let s=a(n.primaryKey.keyPath,0,n.primaryKey);for(let e of(o[":id"]=[s],n.indexes))a(e.keyPath,0,e);function u(t){var r,n;let o=t.query.index;return o.isVirtual?{...t,query:{index:o,range:(r=t.query.range,n=o.keyTail,{type:1===r.type?2:r.type,lower:dM(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,n),lowerOpen:!0,upper:dM(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,n),upperOpen:!0})}}:t}return{...r,schema:{...n,primaryKey:s,indexes:i,getIndexByKeyPath:function(e){let t=o[d_(e)];return t&&t[0]}},count:e=>r.count(u(e)),query:e=>r.query(u(e)),openCursor(t){let{keyTail:n,isVirtual:o,keyLength:i}=t.query.index;return o?r.openCursor(u(t)).then(r=>r&&Object.create(r,{continue:{value:function(o){null!=o?r.continue(dM(o,t.reverse?e.MAX_KEY:e.MIN_KEY,n)):t.unique?r.continue(r.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,n)):r.continue()}},continuePrimaryKey:{value(t,o){r.continuePrimaryKey(dM(t,e.MAX_KEY,n),o)}},primaryKey:{get:()=>r.primaryKey},key:{get(){let e=r.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>r.value}})):r.openCursor(t)}}}}}};function dL(e,t,r,n){return r=r||{},n=n||"",u2(e).forEach(o=>{if(u8(t,o)){var i=e[o],a=t[o];if("object"==typeof i&&"object"==typeof a&&i&&a){let e=l_(i);e!==l_(a)?r[n+o]=t[o]:"Object"===e?dL(i,a,r,n+o+"."):i!==a&&(r[n+o]=t[o])}else i!==a&&(r[n+o]=t[o])}else r[n+o]=void 0}),u2(t).forEach(o=>{u8(e,o)||(r[n+o]=t[o])}),r}let dF={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let r=e.table(t),{primaryKey:n}=r.schema;return{...r,mutate(e){let o=co.trans,{deleting:i,creating:a,updating:s}=o.table(t).hook;switch(e.type){case"add":if(a.fire===lU)break;return o._promise("readwrite",()=>u(e),!0);case"put":if(a.fire===lU&&s.fire===lU)break;return o._promise("readwrite",()=>u(e),!0);case"delete":if(i.fire===lU)break;return o._promise("readwrite",()=>u(e),!0);case"deleteRange":if(i.fire===lU)break;return o._promise("readwrite",()=>(function e(t,o,i){return r.query({trans:t,values:!1,query:{index:n,range:o},limit:i}).then(({result:r})=>u({type:"delete",keys:r,trans:t}).then(n=>n.numFailures>0?Promise.reject(n.failures[0]):r.length<i?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...o,lower:r[r.length-1],lowerOpen:!0},i)))})(e.trans,e.range,1e4),!0)}return r.mutate(e);function u(e){var t,o;let u=co.trans,l=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(n.extractKey));if(!l)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:l}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(o=e).type?Promise.resolve([]):r.getMany({trans:o.trans,keys:l,cache:"immutable"})).then(t=>{let o=l.map((r,o)=>{let l=t[o],c={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(c,r,l,u);else if("add"===e.type||void 0===l){let t=a.fire.call(c,r,e.values[o],u);null==r&&null!=t&&(r=t,e.keys[o]=r,n.outbound||ld(e.values[o],n.keyPath,r))}else{let t=dL(l,e.values[o]),n=s.fire.call(c,t,r,l,u);if(n){let t=e.values[o];Object.keys(n).forEach(e=>{u8(t,e)?t[e]=n[e]:ld(t,e,n[e])})}}return c});return r.mutate(e).then(({failures:r,results:n,numFailures:i,lastResult:a})=>{for(let i=0;i<l.length;++i){let a=n?n[i]:l[i],s=o[i];null==a?s.onerror&&s.onerror(r[i]):s.onsuccess&&s.onsuccess("put"===e.type&&t[i]?e.values[i]:a)}return{failures:r,results:n,numFailures:i,lastResult:a}}).catch(e=>(o.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function dB(e,t,r){try{if(!t||t.keys.length<e.length)return null;let n=[];for(let o=0,i=0;o<t.keys.length&&i<e.length;++o)0===c6(t.keys[o],e[i])&&(n.push(r?lb(t.values[o]):t.values[o]),++i);return n.length===e.length?n:null}catch(e){return null}}let dV={stack:"dbcore",level:-1,create:e=>({table:t=>{let r=e.table(t);return{...r,getMany:e=>{if(!e.cache)return r.getMany(e);let t=dB(e.keys,e.trans._cache,"clone"===e.cache);return t?cu.resolve(t):r.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?lb(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),r.mutate(e))}}})};function dU(e){return!("from"in e)}let dW=function(e,t){if(!this){let t=new dW;return e&&"d"in e&&u4(t,e),t}u4(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function dK(e,t,r){let n=c6(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(dU(e))return u4(e,{from:t,to:r,d:1});let o=e.l,i=e.r;if(0>c6(r,e.from))return o?dK(o,t,r):e.l={from:t,to:r,d:1,l:null,r:null},dG(e);if(c6(t,e.to)>0)return i?dK(i,t,r):e.r={from:t,to:r,d:1,l:null,r:null},dG(e);0>c6(t,e.from)&&(e.from=t,e.l=null,e.d=i?i.d+1:1),c6(r,e.to)>0&&(e.to=r,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;o&&!e.l&&dz(e,o),i&&a&&dz(e,i)}function dz(e,t){dU(t)||function e(t,{from:r,to:n,l:o,r:i}){dK(t,r,n),o&&e(t,o),i&&e(t,i)}(e,t)}function dH(e){let t=dU(e)?null:{s:0,n:e};return{next(e){let r=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&0>c6(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||0>=c6(e,t.n.to))return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function dG(e){var t,r;let n=((null==(t=e.r)?void 0:t.d)||0)-((null==(r=e.l)?void 0:r.d)||0),o=n>1?"r":n<-1?"l":"";if(o){let t="r"===o?"l":"r",r={...e},n=e[o];e.from=n.from,e.to=n.to,e[o]=n[o],r[o]=n[t],e[t]=r,r.d=dq(r)}e.d=dq(e)}function dq({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}u9(dW.prototype,{add(e){return dz(this,e),this},addKey(e){return dK(this,e,e),this},addKeys(e){return e.forEach(e=>dK(this,e,e)),this},[lw](){return dH(this)}});let dY={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,r=new dW(e.MIN_KEY,e.MAX_KEY);return{...e,table:n=>{let o=e.table(n),{schema:i}=o,{primaryKey:a}=i,{extractKey:s,outbound:u}=a,l={...o,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),u=e=>{let r=`idb://${t}/${n}/${e}`;return s[r]||(s[r]=new dW)},l=u(""),c=u(":dels"),{type:d}=e,[f,p]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return o.mutate(e).then(e=>{if(u3(f)){"delete"!==d&&(f=e.results),l.addKeys(f);let t=dB(f,h);t||"add"===d||c.addKeys(f),(t||p)&&i.indexes.forEach(function(e){let r=u(e.name||"");function n(t){return null!=t?e.extractKey(t):null}let o=t=>e.multiEntry&&u3(t)?t.forEach(e=>r.addKey(e)):r.addKey(t);(t||p).forEach((e,r)=>{let i=t&&n(t[r]),a=p&&n(p[r]);0!==c6(i,a)&&(null!=i&&o(i),null!=a&&o(a))})})}else if(f){let e={from:f.lower,to:f.upper};c.add(e),l.add(e)}else l.add(r),c.add(r),i.indexes.forEach(e=>u(e.name).add(r));return e})}},c=({query:{index:t,range:r}})=>{var n,o;return[t,new dW(null!=(n=r.lower)?n:e.MIN_KEY,null!=(o=r.upper)?o:e.MAX_KEY)]},d={get:e=>[a,new dW(e.key)],getMany:e=>[a,(new dW).addKeys(e.keys)],count:c,query:c,openCursor:c};return u2(d).forEach(e=>{l[e]=function(i){let{subscr:a}=co;if(a){let l=e=>{let r=`idb://${t}/${n}/${e}`;return a[r]||(a[r]=new dW)},c=l(""),f=l(":dels"),[p,h]=d[e](i);if(l(p.name||"").add(h),!p.isPrimaryKey){if("count"!==e){let t="query"===e&&u&&i.values&&o.query({...i,values:!1});return o[e].apply(this,arguments).then(r=>{if("query"===e){if(u&&i.values)return t.then(({result:e})=>(c.addKeys(e),r));let e=i.values?r.result.map(s):r.result;i.values?c.addKeys(e):f.addKeys(e)}else if("openCursor"===e){let e=i.values;return r&&Object.create(r,{key:{get:()=>(f.addKey(r.primaryKey),r.key)},primaryKey:{get(){let e=r.primaryKey;return f.addKey(e),e}},value:{get:()=>(e&&c.addKey(r.primaryKey),r.value)}})}return r})}f.add(r)}}return o[e].apply(this,arguments)}}),l}}}};class dZ{constructor(e,t){var r;this._middlewares={},this.verno=0;const n=dZ.dependencies;this._options=t={addons:dZ.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:o}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:lU,dbReadyPromise:null,cancelOpen:lU,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};i.dbReadyPromise=new cu(e=>{i.dbReadyResolve=e}),i.openCanceller=new cu((e,t)=>{i.cancelOpen=t}),this._state=i,this.name=e,this.on=cZ(this,"populate","blocked","versionchange","close",{ready:[lZ,lU]}),this.on.ready.subscribe=la(this.on.ready.subscribe,e=>(t,r)=>{dZ.vip(()=>{let n=this._state;if(n.openComplete)n.dbOpenError||cu.resolve().then(t),r&&e(t);else if(n.onReadyBeingFired)n.onReadyBeingFired.push(t),r&&e(t);else{e(t);let n=this;r||e(function e(){n.on.ready.unsubscribe(t),n.on.ready.unsubscribe(e)})}})}),this.Collection=(r=this,cJ(c9.prototype,function(e,t){this.db=r;let n=cG,o=null;if(t)try{n=t()}catch(e){o=e}let i=e._ctx,a=i.table,s=a.hook.reading.fire;this._ctx={table:a,index:i.index,isPrimKey:!i.index||a.schema.primKey.keyPath&&i.index===a.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:i.or,valueMapper:s!==lW?s:null}})),this.Table=function(e){return cJ(cY.prototype,function(t,r,n){this.db=e,this._tx=n,this.name=t,this.schema=r,this.hook=e._allTables[t]?e._allTables[t].hook:cZ(null,{creating:[lH,lU],reading:[lK,lW],updating:[lq,lU],deleting:[lG,lU]})})}(this),this.Transaction=function(e){return cJ(df.prototype,function(t,r,n,o,i){this.db=e,this.mode=t,this.storeNames=r,this.schema=n,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=cZ(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new cu((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),cB(e)})})}(this),this.Version=function(e){return cJ(dj.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return cJ(du.prototype,function(t,r,n){this.db=e,this._ctx={table:t,index:":id"===r?null:r,or:n};let o=e._deps.indexedDB;if(!o)throw new lF.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,t)=>o.cmp(t,e),this._max=(e,t)=>o.cmp(e,t)>0?e:t,this._min=(e,t)=>0>o.cmp(e,t)?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=dy(t.IDBKeyRange),this._createTransaction=(e,t,r,n)=>new this.Transaction(e,t,r,this._options.chromeTransactionDurability,n),this._fireOnBlocked=e=>{this.on("blocked").fire(e),cW.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(d$),this.use(dF),this.use(dY),this.use(dV),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new lF.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new lF.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let t=this._versions;var r=t.filter(t=>t._cfg.version===e)[0];return r||(r=new this.Version(e),t.push(r),t.sort(dS),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||co.letThrough||this._vip)?e():new cu((e,t)=>{if(this._state.openComplete)return t(new lF.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new lF.DatabaseClosed);this.open().catch(lU)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:r,name:n}){n&&this.unuse({stack:e,name:n});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:t,level:null==r?10:r,name:n}),o.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>r?e.create!==r:!!t&&e.name!==t)),this}open(){return function(e){var t;let r=e._state,{indexedDB:n}=e._deps;if(r.isBeingOpened||e.idbdb)return r.dbReadyPromise.then(()=>r.dbOpenError?cB(r.dbOpenError):e);lD&&(r.openCanceller._stackHolder=lC()),r.isBeingOpened=!0,r.dbOpenError=null,r.openComplete=!1;let o=r.openCanceller;function i(){if(r.openCanceller!==o)throw new lF.DatabaseClosed("db.open() was cancelled")}let a=r.dbReadyResolve,s=null,u=!1;return cu.race([o,("u"<typeof navigator?cu.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var r=function(){return indexedDB.databases().finally(e)};t=setInterval(r,100),r()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(()=>new cu((t,o)=>{if(i(),!n)throw new lF.MissingAPI;let a=e.name,l=r.autoSchema?n.open(a):n.open(a,Math.round(10*e.verno));if(!l)throw new lF.MissingAPI;l.onerror=dl(o),l.onblocked=cw(e._fireOnBlocked),l.onupgradeneeded=cw(t=>{if(s=l.transaction,r.autoSchema&&!e._options.allowEmptyDB){l.onerror=dc,s.abort(),l.result.close();let e=n.deleteDatabase(a);e.onsuccess=e.onerror=cw(()=>{o(new lF.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let r,n,a,f;s.onerror=dl(o);var i,c,d=t.oldVersion>0x4000000000000000?0:t.oldVersion;u=d<1,e._novip.idbdb=l.result,i=d/10,c=s,r=e._dbSchema,(n=e._createTransaction("readwrite",e._storeNames,r)).create(c),n._completion.catch(o),a=n._reject.bind(n),f=co.transless||co,ck(()=>{co.trans=n,co.transless=f,0===i?(u2(r).forEach(e=>{dD(c,e,r[e].primKey,r[e].indexes)}),dw(e,c),cu.follow(()=>e.on.populate.fire(n)).catch(a)):(function({_novip:e},t,r,n){let o=[],i=e._versions,a=e._dbSchema=dk(e,e.idbdb,n),s=!1;return i.filter(e=>e._cfg.version>=t).forEach(i=>{o.push(()=>{let o=a,u=i._cfg.dbschema;dC(e,o,n),dC(e,u,n),a=e._dbSchema=u;let l=dO(o,u);l.add.forEach(e=>{dD(n,e[0],e[1].primKey,e[1].indexes)}),l.change.forEach(e=>{if(e.recreate)throw new lF.Upgrade("Not yet support for changing primary key");{let t=n.objectStore(e.name);e.add.forEach(e=>dP(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),dP(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=i._cfg.contentUpgrade;if(c&&i._cfg.version>t){let t;dw(e,n),r._memoizedTables={},s=!0;let i=lf(u);l.del.forEach(e=>{i[e]=o[e]}),dE(e,[e.Transaction.prototype]),dx(e,[e.Transaction.prototype],u2(i),i),r.schema=i;let a=lO(c);a&&cC();let d=cu.follow(()=>{if((t=c(r))&&a){var e=cj.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?cu.resolve(t):d.then(()=>t)}}),o.push(t=>{var n;s&&cK||(n=i._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==n[e]&&t.db.deleteObjectStore(e))),dE(e,[e.Transaction.prototype]),dx(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema})}),(function e(){return o.length?cu.resolve(o.shift()(r.idbtrans)).then(e):cu.resolve()})().then(()=>{var e;u2(e=a).forEach(t=>{n.db.objectStoreNames.contains(t)||dD(n,t,e[t].primKey,e[t].indexes)})})})(e,i,n,c).catch(a)})}},o),l.onsuccess=cw(()=>{s=null;let n=e._novip.idbdb=l.result,o=li(n.objectStoreNames);if(o.length>0)try{let t,i=n.transaction(1===o.length?o[0]:o,"readonly");r.autoSchema?function({_novip:e},t,r){e.verno=t.version/10;let n=e._dbSchema=dk(0,t,r);e._storeNames=li(t.objectStoreNames,0),dx(e,[e._allTables],u2(n),n)}(e,n,i):(dC(e,e._dbSchema,i),((t=dO(dk(0,e.idbdb,i),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),dw(e,i)}catch(e){}cW.push(e),n.onversionchange=cw(t=>{r.vcFired=!0,e.on("versionchange").fire(t)}),n.onclose=cw(t=>{e.on("close").fire(t)}),u&&function({indexedDB:e,IDBKeyRange:t},r){dR(e)||"__dbnames"===r||dT(e,t).put({name:r}).catch(lU)}(e._deps,a),t()},o)}))]).then(()=>(i(),r.onReadyBeingFired=[],cu.resolve(dA(()=>e.on.ready.fire(e.vip))).then(function t(){if(r.onReadyBeingFired.length>0){let n=r.onReadyBeingFired.reduce(lZ,lU);return r.onReadyBeingFired=[],cu.resolve(dA(()=>n(e.vip))).then(t)}}))).finally(()=>{r.onReadyBeingFired=null,r.isBeingOpened=!1}).then(()=>e).catch(t=>{r.dbOpenError=t;try{s&&s.abort()}catch(e){}return o===r.openCanceller&&e._close(),cB(t)}).finally(()=>{r.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=cW.indexOf(this);if(t>=0&&cW.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new cu(t=>{e.dbReadyResolve=t}),e.openCanceller=new cu((t,r)=>{e.cancelOpen=r})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new lF.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new cu((r,n)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=cw(()=>{!function({indexedDB:e,IDBKeyRange:t},r){dR(e)||"__dbnames"===r||dT(e,t).delete(r).catch(lU)}(this._deps,this.name),r()}),e.onerror=dl(n),e.onblocked=this._fireOnBlocked};if(e)throw new lF.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){let e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return u2(this._allTables).map(e=>this._allTables[e])}transaction(){let e=dI.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,r){let n,o,i=co.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||"readonly"===e)n="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new lF.InvalidArgument("Invalid transaction mode: "+e);n="readwrite"}if(i){if("readonly"===i.mode&&"readwrite"===n){if(!a)throw new lF.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&o.forEach(e=>{if(i&&-1===i.storeNames.indexOf(e)){if(!a)throw new lF.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),a&&i&&!i.active&&(i=null)}}catch(e){return i?i._promise(null,(t,r)=>{r(e)}):cB(e)}let s=(function e(t,r,n,o,i){return cu.resolve().then(()=>{let a,s=co.transless||co,u=t._createTransaction(r,n,t._dbSchema,o);if(o)u.idbtrans=o.idbtrans;else try{u.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===lL.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,null,i))):cB(o)}let l=lO(i);l&&cC();let c=cu.follow(()=>{if(a=i.call(u,u))if(l){var e=cj.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=dN(a))},{trans:u,transless:s});return(a&&"function"==typeof a.then?cu.resolve(a).then(e=>u.active?e:cB(new lF.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>a)).then(e=>(o&&u._resolve(),u._completion.then(()=>e))).catch(e=>(u._reject(e),cB(e)))})}).bind(null,this,n,o,i,r);return i?i._promise(n,s,"lock"):co.trans?cM(co.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!u8(this._allTables,e))throw new lF.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let dJ="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class dX{constructor(e){this._subscribe=e}subscribe(e,t,r){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:r})}[dJ](){return this}}function dQ(e,t){return u2(t).forEach(r=>{dz(e[r]||(e[r]=new dW),t[r])}),e}try{i={indexedDB:u1.indexedDB||u1.mozIndexedDB||u1.webkitIndexedDB||u1.msIndexedDB,IDBKeyRange:u1.IDBKeyRange||u1.webkitIDBKeyRange}}catch(e){i={indexedDB:null,IDBKeyRange:null}}function d0(e){let t=d1;try{d1=!0,dd.storagemutated.fire(e)}finally{d1=t}}u9(dZ,{...lV,delete:e=>new dZ(e,{addons:[]}).delete(),exists:e=>new dZ(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return dR(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>"__dbnames"!==e)):dT(e,t).toCollection().primaryKeys()})(dZ.dependencies).then(e)}catch(e){return cB(new lF.MissingAPI)}},defineClass:()=>function(e){u4(this,e)},ignoreTransaction:e=>co.trans?cM(co.transless,e):e(),vip:dA,async:function(e){return function(){try{var t=dN(e.apply(this,arguments));return t&&"function"==typeof t.then?t:cu.resolve(t)}catch(e){return cB(e)}}},spawn:function(e,t,r){try{var n=dN(e.apply(r,t||[]));return n&&"function"==typeof n.then?n:cu.resolve(n)}catch(e){return cB(e)}},currentTransaction:{get:()=>co.trans||null},waitFor:function(e,t){let r=cu.resolve("function"==typeof e?dZ.ignoreTransaction(e):e).timeout(t||6e4);return co.trans?co.trans.waitFor(r):r},Promise:cu,debug:{get:()=>lD,set:e=>{lD=e,lP="dexie"===e?()=>!0:cz}},derive:lt,extend:u4,props:u9,override:la,Events:cZ,on:dd,liveQuery:function(e){return new dX(t=>{let r=lO(e),n=!1,o={},i={},a={get closed(){return n},unsubscribe:()=>{n=!0,dd.storagemutated.unsubscribe(c)}};t.start&&t.start(a);let s=!1,u=!1;function l(){return u2(i).some(e=>o[e]&&function(e,t){let r=dH(t),n=r.next();if(n.done)return!1;let o=n.value,i=dH(e),a=i.next(o.from),s=a.value;for(;!n.done&&!a.done;){if(0>=c6(s.from,o.to)&&c6(s.to,o.from)>=0)return!0;0>c6(o.from,s.from)?o=(n=r.next(s.from)).value:s=(a=i.next(o.from)).value}return!1}(o[e],i[e]))}let c=e=>{dQ(o,e),l()&&d()},d=()=>{let f,p;if(s||n)return;o={};let h={},m=(r&&cC(),f=()=>ck(e,{subscr:h,trans:null}),p=co.trans?cM(co.transless,f):f(),r&&p.then(cj,cj),p);u||(dd("storagemutated",c),u=!0),s=!0,Promise.resolve(m).then(e=>{s=!1,n||(l()?d():(o={},i=h,t.next&&t.next(e)))},e=>{s=!1,t.error&&t.error(e),a.unsubscribe()})};return d(),a})},extendObservabilitySet:dQ,getByKeyPath:lc,setByKeyPath:ld,delByKeyPath:function(e,t){"string"==typeof t?ld(e,t,void 0):"length"in t&&[].map.call(t,function(t){ld(e,t,void 0)})},shallowClone:lf,deepClone:lb,getObjectDiff:dL,cmp:c6,asap:lu,minKey:-1/0,addons:[],connections:cW,errnames:lL,dependencies:i,semVer:"3.2.2",version:"3.2.2".split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),dZ.maxKey=dy(dZ.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(dd("storagemutated",e=>{if(!d1){let t;cK?(t=document.createEvent("CustomEvent")).initCustomEvent("x-storagemutated-1",!0,!0,e):t=new CustomEvent("x-storagemutated-1",{detail:e}),d1=!0,dispatchEvent(t),d1=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{d1||d0(e)}));let d1=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel("x-storagemutated-1");dd("storagemutated",t=>{d1||e.postMessage(t)}),e.onmessage=e=>{e.data&&d0(e.data)}}else if("u">typeof self&&"u">typeof navigator){dd("storagemutated",e=>{try{d1||("u">typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:"x-storagemutated-1",changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if("x-storagemutated-1"===e.key){let t=JSON.parse(e.newValue);t&&d0(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&"x-storagemutated-1"===e.type&&d0(e.changedParts)})}function d2(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}cu.rejectionMapper=function(e,t){if(!e||e instanceof lN||e instanceof TypeError||e instanceof SyntaxError||!e.name||!lB[e.name])return e;var r=new lB[e.name](t||e.message,e);return"stack"in e&&le(r,"stack",{get:function(){return this.inner.stack}}),r},lP=cz;class d3 extends dZ{constructor(){super("EsmOffline"),d2(this,"syncQueue",void 0),d2(this,"dynamicOfflineData",void 0),this.version(4).stores({syncQueue:"++id,userId,type,[userId+type]",dynamicOfflineData:"++id,type,identifier,*users,&[type+identifier]"}),this.syncQueue=this.table("syncQueue"),this.dynamicOfflineData=this.table("dynamicOfflineData")}}function d4(){return new d3}let d6=new d3,d5={},d8=q("offline-synchronization",{});function d9(){return d8}async function d7(){if(d8.getState().synchronization)return;let e=await d6.syncQueue.count(),t={},r=Object.entries(d5),n=r.length,o={},i=new AbortController,a=()=>{let e=d8.getState().synchronization;d8.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{d8.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<n&&r.length>0;e++)for(let e=r.length;e--;){let[n,s]=r[e],u=s.dependsOn.map(e=>t[e]);u.every(Boolean)&&(o[n]={},await Promise.all(u),t[n]=fe(s,o,i,a),r.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{d8.setState({synchronization:void 0})}}async function fe({type:e,dependsOn:t,process:r},n,o,i){let a=[],s=[],u=await ft();await d6.syncQueue.where({type:e,userId:u}).each((e,t)=>{a.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let l=0;l<a.length;l++){let[c,d,{id:f,dependencies:p=[]}]=a[l];try{let i=await r(d,{abort:o,index:l,items:s,userId:u,dependencies:p.map(({id:e,type:r})=>t.includes(r)?n[r][e]:void 0)});void 0!==f&&(n[e][f]=i),await d6.syncQueue.delete(c)}catch(e){await d6.syncQueue.update(c,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function ft(){let e=await aN();return e?.uuid||"*"}async function fr(e,t,r,n){let o=n&&n.id;return void 0!==o&&await d6.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(dZ.errnames.DatabaseClosed),await d6.syncQueue.add({type:t,content:r,userId:e,descriptor:n||{},createdOn:new Date}).catch(dZ.errnames.DatabaseClosed,()=>-1)}async function fn(e,t,r){let n=await ft();return await fr(n,e,t,r)}async function fo(e,t){return(await fi(e,t)).map(e=>e.content)}async function fi(e,t){return await d6.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(dZ.errnames.DatabaseClosed,()=>[])}async function fa(e){let t=await ft();return await fo(t,e)}async function fs(e){let t=await ft();return await fi(t,e)}async function fu(e){return await d6.syncQueue.get(e).catch(dZ.errnames.DatabaseClosed,()=>void 0)}function fl(e){return!!d5[e]?.options.onBeginEditSyncItem}async function fc(e){let t=await fu(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let r=d5[t.type]?.options.onBeginEditSyncItem;if(!r)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);r(t)}async function fd(e){await d6.syncQueue.delete(e).catch(dZ.errnames.DatabaseClosed)}function ff(e,t,r,n={}){d5[e]={type:e,dependsOn:t,process:r,options:n}}let fp="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),fh=new Uint8Array(16),fm=[];for(let e=0;e<256;++e)fm.push((e+256).toString(16).slice(1));let fy=function(e,t,r){if(fp&&!t&&!e)return fp();let n=(e=e||{}).random||(e.rng||function(){if(!a&&!(a="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(fh)})();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return fm[e[t+0]]+fm[e[t+1]]+fm[e[t+2]]+fm[e[t+3]]+"-"+fm[e[t+4]]+fm[e[t+5]]+"-"+fm[e[t+6]]+fm[e[t+7]]+"-"+fm[e[t+8]]+fm[e[t+9]]+"-"+fm[e[t+10]]+fm[e[t+11]]+fm[e[t+12]]+fm[e[t+13]]+fm[e[t+14]]+fm[e[t+15]]}(n)},fg="OFFLINE+";function fb(){return fg+fy()}function fv(e){return e.startsWith(fg)}let f_={};function fw(){return Object.values(f_)}function fx(e){f_[e.id]&&console.warn(`[setupDynamicOfflineDataHandler] Another second handler with the ID "${e.id}" was registered. This handler will override the previous one. This could be unintended as the previous handler might run different flows than the newly registered one. If this is the case, ensure that you are setting up the handlers with different IDs.`),f_[e.id]=e}async function fE(e){let t=await fT();return await fS(t,e)}async function fS(e,t){let r=new d3;return await r.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(dZ.errnames.DatabaseClosed,()=>[])}async function fO(e,t){let r=await fT();return await fD(r,e,t)}async function fD(e,t,r){let n=new d3,o=await n.dynamicOfflineData.get({type:t,identifier:r}).catch(dZ.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await n.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(dZ.errnames.DatabaseClosed):await n.dynamicOfflineData.add({users:[e],type:t,identifier:r}).catch(dZ.errnames.DatabaseClosed)}async function fP(e,t){let r=await fT();return await fk(r,e,t)}async function fk(e,t,r){let n=new d3,o=await n.dynamicOfflineData.get({type:t,identifier:r,users:e}).catch(dZ.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await n.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(dZ.errnames.DatabaseClosed):await n.dynamicOfflineData.delete(o.id).catch(dZ.errnames.DatabaseClosed))}async function fC(e,t){let r=await fE(e);await Promise.all(r.map(async e=>fj(e.type,e.identifier,t)))}async function fj(e,t,r){await fO(e,t);let n=new d3,o=await fT(),i=await n.dynamicOfflineData.get({type:e,identifier:t}).catch(dZ.errnames.DatabaseClosed,()=>void 0),a=fw().filter(t=>t.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,r),{id:e.id,error:void 0}}catch(r){let t=r.message?.toString()??r.toString();return{id:e.id,error:t}}})),u=s.filter(e=>!e.error).map(e=>e.id),l=s.filter(e=>e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),d={syncedOn:new Date,syncedBy:o,succeededHandlers:u,erroredHandlers:l,errors:c};i.id&&await n.dynamicOfflineData.update(i.id,{syncState:d}).catch(dZ.errnames.DatabaseClosed)}async function fT(){let e=(await aN()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let fR=q("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function fA(){return fM(),fR}function fN(e,t){fM(),fx({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,r)=>t.onOfflinePatientAdded({patientUuid:e,signal:r??new AbortController().signal})})}async function fI(e){fM(),await fj("patient",e)}function fM(){console.warn("The offline patient API has been deprecated and will be removed in a future release. To prevent future crashes, the functions remain available for the moment, but any invocations should be migrated ASAP.")}async function f$(e,t,r=!0){if(e){let n=null,[o,i]=await Promise.all([aE(`${a_}/Patient/${e}`,t).catch(e=>n=e),r?fL(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(n)throw n}return null}async function fL(e){let t=(await fa("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function fF(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function fB(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}var fV=r(6170);function fU(e){return{uuid:e.uuid,display:e.display}}function fW(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return aS(`${av}/location${n?"?"+n:""}`).pipe((0,fV.map)(e=>e.data.results.map(fU))).pipe((0,fV.take)(1))}function fK(e){return{uuid:e.uuid,display:e.display,name:e.name}}function fz(){return aS(`${av}/visittype`).pipe((0,fV.map)(e=>e.data.results.map(fK))).pipe((0,fV.take)(1))}var fH=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),fG=function(e){function t(t,r){var n=e.call(this)||this;return n.subject=t,n.subscriber=r,n.closed=!1,n}return em(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var r=t.indexOf(this.subscriber);-1!==r&&t.splice(r,1)}}},t}(eE),fq=function(e){function t(t){var r=e.call(this,t)||this;return r.destination=t,r}return em(t,e),t}(eD),fY=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return em(t,e),t.prototype[eO]=function(){return new fq(this)},t.prototype.lift=function(e){var t=new fZ(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new fH;if(!this.isStopped)for(var t=this.observers,r=t.length,n=t.slice(),o=0;o<r;o++)n[o].next(e)},t.prototype.error=function(e){if(this.closed)throw new fH;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,r=t.length,n=t.slice(),o=0;o<r;o++)n[o].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new fH;this.isStopped=!0;for(var e=this.observers,t=e.length,r=e.slice(),n=0;n<t;n++)r[n].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new fH},t.prototype._subscribe=function(e){if(this.closed)throw new fH;return this.hasError?(e.error(this.thrownError),eE.EMPTY):this.isStopped?(e.complete(),eE.EMPTY):(this.observers.push(e),new fG(this,e))},t.prototype.asObservable=function(){var e=new eC;return e.source=this,e},t.create=function(e,t){return new fZ(e,t)},t}(eC),fZ=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return em(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):eE.EMPTY},t}(fY),fJ=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return em(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return r&&!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new fH},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(fY),fX=((eu={}).NEWVISIT="startVisit",eu.EDITVISIT="editVisit",eu.LOADING="loadingVisit",eu),fQ=((el={}).NOTSTARTED="notStarted",el.ONGOING="ongoing",el);let f0="custom:(uuid,display,voided,indication,startDatetime,stopDatetime,encounters:(uuid,display,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,display),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display))",f1=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function f2(){return Z("visit",f1)}function f3(e,t){f2().setState({patientUuid:e,manuallySetVisitUuid:t})}function f4(e,t){return aE(`${av}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function f6(e,t,r){return aE(`${av}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function f5(e,t,r){return aE(`${av}/visit?patient=${e}&v=${r??f0}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}f2().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let f8=new fJ(null);class f9{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+f9.version}static addUnaryOp(e){return f9.max_unop_len=Math.max(e.length,f9.max_unop_len),f9.unary_ops[e]=1,f9}static addBinaryOp(e,t,r){return f9.max_binop_len=Math.max(e.length,f9.max_binop_len),f9.binary_ops[e]=t,r?f9.right_associative.add(e):f9.right_associative.delete(e),f9}static addIdentifierChar(e){return f9.additional_identifier_chars.add(e),f9}static addLiteral(e,t){return f9.literals[e]=t,f9}static removeUnaryOp(e){return delete f9.unary_ops[e],e.length===f9.max_unop_len&&(f9.max_unop_len=f9.getMaxKeyLen(f9.unary_ops)),f9}static removeAllUnaryOps(){return f9.unary_ops={},f9.max_unop_len=0,f9}static removeIdentifierChar(e){return f9.additional_identifier_chars.delete(e),f9}static removeBinaryOp(e){return delete f9.binary_ops[e],e.length===f9.max_binop_len&&(f9.max_binop_len=f9.getMaxKeyLen(f9.binary_ops)),f9.right_associative.delete(e),f9}static removeAllBinaryOps(){return f9.binary_ops={},f9.max_binop_len=0,f9}static removeLiteral(e){return delete f9.literals[e],f9}static removeAllLiterals(){return f9.literals={},f9}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new f9(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(e=>e.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return f9.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!f9.binary_ops[String.fromCharCode(e)]||f9.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return f9.isIdentifierStart(e)||f9.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(f9.hooks[e]){let r={context:this,node:t};return f9.hooks.run(e,r),r.node}return t}searchHook(e){if(f9.hooks[e]){let t={context:this};return f9.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===f9.SPACE_CODE||e===f9.TAB_CODE||e===f9.LF_CODE||e===f9.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:f9.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===f9.SEMCOL_CODE||r===f9.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,f9.max_binop_len),t=e.length;for(;t>0;){if(f9.binary_ops.hasOwnProperty(e)&&(!f9.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!f9.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,o,i,a,s,u;if(!(i=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return i;for(o={value:t,prec:f9.binaryPrecedence(t),right_a:f9.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[i,o,a];t=this.gobbleBinaryOp();){if(0===(r=f9.binaryPrecedence(t))){this.index-=t.length;break}o={value:t,prec:r,right_a:f9.right_associative.has(t)},u=t;let s=e=>o.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)a=n.pop(),t=n.pop().value,i=n.pop(),e={type:f9.BINARY_EXP,operator:t,left:i,right:a},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+u),n.push(o,e)}for(s=n.length-1,e=n[s];s>1;)e={type:f9.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,f9.isDecimalDigit(e)||e===f9.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===f9.SQUOTE_CODE||e===f9.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===f9.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,f9.max_unop_len)).length;r>0;){if(f9.unary_ops.hasOwnProperty(t)&&(!f9.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!f9.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:f9.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}f9.isIdentifierStart(e)?(n=this.gobbleIdentifier(),f9.literals.hasOwnProperty(n.name)?n={type:f9.LITERAL,value:f9.literals[n.name],raw:n.name}:n.name===f9.this_str&&(n={type:f9.THIS_EXP})):e===f9.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===f9.PERIOD_CODE||t===f9.OBRACK_CODE||t===f9.OPAREN_CODE||t===f9.QUMARK_CODE;){let r;if(t===f9.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==f9.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===f9.OBRACK_CODE?((e={type:f9.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==f9.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===f9.OPAREN_CODE?e={type:f9.CALL_EXP,arguments:this.gobbleArguments(f9.CPAREN_CODE),callee:e}:(t===f9.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:f9.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;f9.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===f9.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);f9.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));f9.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);f9.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,f9.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===f9.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===f9.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:f9.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:f9.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(f9.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,f9.isIdentifierPart(e))this.index++;else break;return{type:f9.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){r=!0,this.index++,e===f9.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===f9.COMMA_CODE){if(this.index++,++n!==t.length){if(e===f9.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===f9.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==f9.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(f9.CPAREN_CODE);if(this.code===f9.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:f9.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:f9.ARRAY_EXP,elements:this.gobbleArguments(f9.CBRACK_CODE)}}}Object.assign(f9,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(f9),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),f9.max_unop_len=f9.getMaxKeyLen(f9.unary_ops),f9.max_binop_len=f9.getMaxKeyLen(f9.binary_ops);let f7=e=>new f9(e).parse(),pe=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(f9).filter(e=>!pe.includes(e)&&void 0===f7[e]).forEach(e=>{f7[e]=f9[e]}),f7.Jsep=f9,f7.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:o},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let pt="ArrowFunctionExpression",pr={Array,Boolean,Symbol,Infinity,NaN,Math,Number,BigInt,String,RegExp,JSON,isFinite,isNaN,parseFloat,parseInt,decodeURI,encodeURI,encodeURIComponent,Object:{__proto__:void 0,assign:Object.assign.bind(null),fromEntries:Object.fromEntries.bind(null),hasOwn:Object.hasOwn.bind(null),keys:Object.keys.bind(null),is:Object.is.bind(null),values:Object.values.bind(null)}},pn={...pr,Promise};function po(e,t={}){return pc(e,t,pp)}async function pi(e,t={}){return pd(e,t,pp)}function pa(e,t={}){return pc(e,t,ph)}function ps(e,t={}){return pd(e,t,ph)}function pu(e,t={}){return pc(e,t,pm)}function pl(e,t={}){return pd(e,t,pm)}function pc(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=pb(t,pr),o=py("string"==typeof e?f7(e):e,n);if(r(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function pd(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=pb(t,pn);return Promise.resolve(py("string"==typeof e?f7(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function pf(e){return f7(e)}function pp(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function ph(e){return"boolean"==typeof e}function pm(e){return"number"==typeof e}function py(e,t){switch(e.type){case"UnaryExpression":var r,n,o,i,a,s,u,l,c,d,f,p,h=e,m=t;let y=py(h.argument,m);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var g=e,b=t;let v=py(g.left,b),w=py(g.right,b);switch(g.operator){case"+":return v+w;case"-":return v-w;case"*":return v*w;case"/":return v/w;case"%":return v%w;case"**":return v**w;case"==":return v==w;case"===":return v===w;case"!=":return v!=w;case"!==":return v!==w;case">":return v>w;case">=":return v>=w;case"<":return v<w;case"<=":return v<=w;case"in":return v in w;case"&&":return v&&w;case"||":return v||w;case"??":return v??w;default:throw`Expression evaluator does not support operator '${g.operator}' operator`}case"ConditionalExpression":return r=e,n=t,py(r.test,n)?py(r.consequent,n):py(r.alternate,n);case"CallExpression":var x=e,E=t;let S=x.arguments?.map(pv(E)),O=py(x.callee,E);if(O){if("function"!=typeof O)throw`${pw(x.callee)} is not a function`}else throw`No function named ${pw(x.callee)} is defined in this context`;return O(...S);case"ArrowFunctionExpression":let D;return o=e,i=t,D=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<D.length)throw`Required argument(s) ${D.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(D.reduce((t,r,n)=>{let o=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(o)&&t.push([r,o]),t},[]));return py(o.body,i.addVariables(t))}).bind(i.thisObj??null);case"MemberExpression":return function(e,t){let r,n=py(e.object,t);if(void 0===n)switch(e.object.type){case"Identifier":{let r=pg(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":{let r=pg(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${r}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=n;if("string"==typeof n)o=String.prototype;else if("number"==typeof n)o=Number.prototype;else if("function"==typeof n);else if("object"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":r=py(e.property,t);break;default:{let o=py(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};p_(o),r=n[o]}}return"function"==typeof r?r.bind(n):r}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(pv(s));case"SequenceExpression":let P;return u=e,l=t,(P=u.expressions.map(pv(l)))[P.length-1];case"NewExpression":var k=e,C=t;if(k.callee&&"Identifier"===k.callee.type){let e=k.arguments?.map(pv(C));switch(k.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${k.callee.name}`}}if(k.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return p_((c=e).value),c.value;case"Identifier":var j=e,T=t;p_(j.name);let R=T.thisObj;if(R&&("object"==typeof R||"function"==typeof R)&&j.name in R){let e=R[j.name];return p_(e),e}if(T.variables&&j.name in T.variables){let e=T.variables[j.name];return p_(e),e}return j.name in T.globals?T.globals[j.name]:void 0;case"TemplateLiteral":let A,N;return d=e,f=t,A=d.expressions?.map(pv(f))??[],(N=d.quasis?.map(pv(f))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+A.join("")+N.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function pg(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return pg(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function pb(e,t){let r={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}function pv(e){return function(t){return null===t?null:py(t,e)}}function p_(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function pw(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function px(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...pn},isLocalExpression:!1,variables:new Set};return pE("string"==typeof e?f7(e):e,t),[...t.variables]}function pE(e,t){switch(e.type){case"UnaryExpression":return n=e,o=t,pE(n.argument,o);case"BinaryExpression":return i=e,a=t,[pE(i.left,a),pE(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,u=t,[pE(s.consequent,u),pE(s.test,u),pE(s.alternate,u)].filter(Boolean);case"CallExpression":let r;return l=e,c=t,r=pE(l.callee,c),l.arguments?.map(pS(c)),r;case"ArrowFunctionExpression":var n,o,i,a,s,u,l,c,d,f,p,h,m,y,g,b,v,w,x=e,E=t;let S={...E};S.isLocalExpression=!0;let O=x.params?.map(pS(S))??[],D=pE(x.body,S)??[];if(D&&Array.isArray(D))for(let e of D)O.includes(e)||E.variables.add(e);return;case"MemberExpression":let P;return d=e,f=t,pE(d.object,f),void((P={...f}).isLocalExpression=!0,pE(d.property,P));case"ArrayExpression":return p=e,h=t,void p.elements?.map(pS(h));case"SequenceExpression":return m=e,y=t,void m.expressions?.map(pS(y));case"NewExpression":return g=e,b=t,void g.arguments?.map(pS(b));case"Literal":case"TemplateElement":return;case"Identifier":var k=e,C=t;if(!(k.name in C.globals))if(C.isLocalExpression)return k.name;else C.variables.add(k.name);return;case"TemplateLiteral":return v=e,w=t,void(v.expressions?.map(pS(w)),v.quasis?.map(pS(w)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function pS(e){return function(t){return null===t?null:pE(t,e)}}f7.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:pt,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=pt,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),f7.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),f7.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),o());let i=this.char;("e"===i||"E"===i)&&(n+=this.expr.charAt(this.index++),("+"===(i=this.char)||"-"===i)&&(n+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(a===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var o,i,a;let s=this.index,u=this.expr.charAt(this.index+1),l=t.call(this,u);if(!l)return;let c="";for(;o=this.code,i=l,95===o||i.some(([e,t])=>o>=e&&o<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(u.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(a=u)||"X"===a?16:"b"===a||"B"===a?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&r.call(this,n)})}}),f7.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,o=this.expr.slice(r,this.index),i="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)i+=this.char;else break}try{n=new RegExp(o,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),f7.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:o},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),f7.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",o="",i=!1,a=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:o,cooked:n},tail:i});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,i=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(o+=a,a=this.expr.charAt(++this.index),o+=a,a){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=a}else n+=a,o+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),f7.addBinaryOp("in",7),f7.addBinaryOp("??",1);let pO=Z("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function pD(e,t,r){pO.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function pP(){let e=pO.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function pk(e){return pO.getState().flags[e].enabled}function pC(e,t){pO.subscribe(r=>{t(r.flags[e].enabled)})}function pj(e,t){pO.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}function pT(e){return!window.offlineEnabled||(e??navigator.onLine)}pO.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var pR=re(function(e,t,r){t2(e,t,r)});function pA(e=!0,t=!1){return pN(pT(),e,t)}function pN(e,t=!0,r=!1){return!!(e?t:r)}let pI=q("extensionsInternal",{slots:{},extensions:{}}),pM=q("extensionRenderings",{renderings:new Map}),p$=()=>Z("extensionsInternal",{slots:{},extensions:{}}),pL=()=>Z("extensionRenderings",{renderings:new Map});function pF(e){let t=pI.getState(),r=e(t);r!==t&&pI.setState(r)}let pB=null,pV=null;function pU(){let e=pM.getState();return pB&&e===pV||(pB=new Map(e.renderings),pV=e,function(e){for(let t of(pX.clear(),e.values()))p0(t,1);pQ=!0}(pB)),pB}function pW(e){pV={renderings:e},pM.setState(pV,!0)}function pK(e){let t=pU();t.has(e.renderingId)||(t.set(e.renderingId,e),p0(e,1),pW(t))}function pz(e){let t=pU(),r=t.get(e);r&&(t.delete(e),p0(r,-1),pW(t))}let pH=()=>Z("extensions",{slots:{}}),pG=0,pq=new Set;function pY(e){pG++;try{return e()}finally{if(0==--pG&&pq.size>0){let e=Array.from(pq);for(let t of(pq.clear(),e))pZ(t)}}}function pZ(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function pJ(e){pG>0?pq.add(e):pZ(e)}let pX=new Map,pQ=!1;function p0(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=pX.get(r);if(!n){if(t<0)return;pX.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),pQ=!0;return}n.count+=t,n.count<1&&(pX.delete(r),pQ=!0)}function p1(){var e,t;if(pU(),!pQ)return;pQ=!1;let r=Array.from(pX.values(),({record:e})=>e);r.sort(p2),e=nF.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===p2(e,t[r]))||nF.setState({mountedExtensions:r})}function p2(e,t){return p3(e.slotName,t.slotName)||p3(e.extensionId,t.extensionId)||p3(e.slotModuleName,t.slotModuleName)||p3(e.extensionModuleName,t.extensionModuleName)}function p3(e,t){return e===t?0:e<t?-1:1}p1(),pM.subscribe(()=>pJ(p1));let p4=p$(),p6=pH(),p5=nV(),p8=nK(),p9=new Set,p7=!1;function he(e){if(null===e)p9=null;else if(null!==p9)for(let t of e)p9.add(t);pJ(ht)}function ht(){if(!p7){p7=!0;try{for(let e=1;;e++){let t=p9;if(null!==t&&0===t.size)return;p9=new Set;try{!function(e,t,r,n,o,i=null){let a=p6.getState().slots,s={},u=!1,l=pT(),c=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,d]of Object.entries(e.slots)){let f=a[n];if(f&&i&&!i.has(n)){s[n]=f;continue}let{config:p}=nW(t,d.name),h=function(e,t,r,n,o,i,a){let s=function(e,t){let r=e.add||[],n=e.remove||[],o=e.order||[],{extensions:i}=p4.getState();return[...t,...r].filter(e=>!n.includes(e)).sort((e,r)=>hf(e,o,i[hi(e)]?.order,t)-hf(r,o,i[hi(r)]?.order,t))}(r,t.slots[e].attachedIds),u=[];for(let l of s){let{config:s}=nH(n,e,l),c=nG(r,e,l),d=c?pR({},s,c):s,f=hi(l),p=t.extensions[f];if(p){let e=d?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!aA(e,a.user))||p.featureFlag&&!o.includes(p.featureFlag)||window.offlineEnabled&&!pN(i,p.online,p.offline))continue;u.push({id:l,name:f,moduleName:p.moduleName,config:d,featureFlag:p.featureFlag,meta:p.meta,online:d?.["Display conditions"]?.online??p.online??!0,offline:d?.["Display conditions"]?.offline??p.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||p.displayExpression})}}return u}(n,e,p,r,c,l,o.session);f&&f.moduleName===d.moduleName&&rH(f.candidateExtensions,h)?s[n]=f:(s[n]={moduleName:d.moduleName,candidateExtensions:h},u=!0)}(u||Object.keys(a).length!==Object.keys(s).length)&&p6.setState({slots:s})}(p4.getState(),p5.getState(),p8.getState(),pO.getState(),aD.getState(),t)}catch(e){throw p9=null===t||null===p9?null:new Set([...t,...p9]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{p7=!1}}}function hr(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function hn(){he(null)}function ho(e,t){return{moduleName:t,name:e,attachedIds:[]}}function hi(e){let[t]=e.split("#");return t}function ha(e,t){let r=hi(t);return e.extensions[r]}function hs(e){return ha(p4.getState(),e)}p4.subscribe((e,t)=>{he(e.extensions!==t.extensions?null:hr(e.slots,t.slots))}),p5.subscribe((e,t)=>{he(hr(e.slots,t.slots))}),p8.subscribe((e,t)=>{he(hr(e.configs,t.configs))}),pO.subscribe(()=>he(null)),aD.subscribe(()=>he(null)),hn(),g(hn);let hu=e=>pF(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function hl(e,t){pF(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...ho(e),attachedIds:[t]}}}})}function hc(e,t){pF(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function hd(e){pF(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function hf(e,t,r,n){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==r)return 1e3+r;let t=n.indexOf(e);return -1!==t?2e3+t:3e3}}function hp(e,t){return function(e,t,r=null,n){let o;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;o??(o=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!pa(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(hh(e),t,aD.getState().session,e)}function hh(e){return p6.getState().slots[e]?.candidateExtensions??[]}let hm=(e,t)=>p4.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let o=ho(t,e);return{...r,slots:{...r.slots,[t]:{...o}}}}),hy=()=>{p9=null,pF(()=>({slots:{},extensions:{}})),pL().setState({renderings:new Map}),p6.setState({slots:{}})},hg=q("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function hb({name:e,basePath:t,mode:r,componentContext:n,state:o}){hg.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:o})}function hv(e){hg.getState().slotName===e&&hg.setState(hg.getInitialState(),!0)}let h_=q("modalRegistry",{modals:{}});function hw(e){h_.setState(t=>(t.modals[e.name]=e,t))}function hx(e){let t=h_.getState().modals[e];if(!t){let r=hs(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),hw(t))}return t}let hE=q("workspaceRegistrations",{workspaces:{}}),hS=q("workspaceGroups",{workspaceGroups:{}});function hO(e){hE.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function hD(e){hS.setState(t=>{let r=t.workspaceGroups[e.name];return r?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...r,members:Array.from(new Set([...r.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let hP=new Set;function hk(e){let t=hE.getState().workspaces;if(t[e])return t[e];{let t=hs(e);if(t){var r;let n;return hP.has(e)||(console.warn(`The workspace '${e}' is registered as an extension. This is deprecated. Please register it in the "workspaces" section of the routes.json file.`),hP.add(e)),{name:t.name,title:(r=t,"string"==typeof(n=r?.meta?.title)?n:n&&"object"==typeof n?sF(r.moduleName,n.key,n.default):r.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function hC(e){let t=hS.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let hj=q("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function hT(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=hj.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function hR(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=hj.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function hA(e){let{openedWindows:t}=hj.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function hN(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=hj.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}hj.setState({registeredGroupsByName:n})}function hI(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=hj.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}hj.setState({registeredWindowsByName:n})}function hM(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=hj.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}hj.setState({registeredWorkspacesByName:n})}let h$=0,hL=null,hF={bootstrap:15e3,mount:15e3,unmount:15e3};function hB(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(hF).filter(t=>e[t]).map(n=>{var o,i;let a,s;return[n,(o=e[n],i=hF[n],a=Array.isArray(o)?o:[o],s=e=>a.reduce((t,o,i)=>t.then(()=>{let t=o(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${i} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let o,a=new Promise((e,t)=>{o=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${i}ms`)),i)});return Promise.race([s(e),a]).finally(()=>clearTimeout(o)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function hV(e,t){var r,n;let o,i,a,s,u,l=await (hL??(hL=new Promise((e,t)=>{iw({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),iw))),hL),c={...t},d=(o=c,i=!1,{retarget:e=>o={...e},release:a=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(o),onSettled(e,t){switch(e){case"bootstrap":t&&a();return;case"mount":i||(i=t);return;case"unmount":(t||i)&&a();return}}});return n=l((r=d.onSettled,"function"==typeof e?()=>e().then(e=>hB(e,r)):hB(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),u=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>u,set:e=>{u=e&&s(e)}})}function hU(){return hW}function hW(e,t){let r,n=hV(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function hK(e,t,r,n,o=e=>e,i={}){let a=hi(n),s=hs(n),u=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:l,moduleName:c,online:d,offline:f,load:p}=s;if(pA(d,f)){let s,d=h$++,f=`${t}/${n}-${d}`;e.dataset.extensionRenderingId=f;let h=e=>{try{pz(f)}catch(t){console.error(e,t)}};try{pK({renderingId:f,extensionName:a,extensionModuleName:c,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{s=await p()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{u=await hV(o({...s,name:`${t}/${a}-${d}`}),{...i,_meta:l,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}u.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),u.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return u}var hz=r(4923),hH=r.n(hz);let hG=(0,hz.createContext)({moduleName:"",featureName:""});function hq({to:e,templateParams:t,onBeforeNavigate:r,children:n,...o}){return(0,hz.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),hH().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),al({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:as(e,t),...o},n)}let hY=({state:e,children:t,...r})=>{let{extension:n}=(0,hz.useContext)(hG),o=(0,hz.useRef)(null),i=(0,hz.useRef)(Promise.resolve()),a=(0,hz.useRef)(!1),s=(0,hz.useRef)(!1),u=(0,hz.useRef)(e),l=(0,hz.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":i.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,hz.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...t})}).catch(e=>{let t=o.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,hz.useCallback)(t=>{t&&!o.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,hK(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,o.current=t,a.current)?l(t):t&&u.current!==e&&c(t,u.current)},()=>{s.current=!1}))},[]);return(0,hz.useEffect)(()=>(a.current=!1,()=>{a.current=!0,l(o.current)}),[]),(0,hz.useEffect)(()=>{u.current=e,o.current&&c(o.current,e)},[e]),n?hH().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function hZ(e){let t=(0,hz.useRef)(e);return L(t.current,e)||(t.current=e),t.current}function hJ(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};r[n]=t}return r}let hX=e=>e;function hQ(e,t=hX,r){let n=(0,hz.useCallback)(t=>e.subscribe(t),[e]),o=(0,hz.useCallback)(()=>t(e.getState()),[e,t]),i=(0,hz.useSyncExternalStore)(n,o,o),a=(0,hz.useMemo)(()=>r?hJ(e,r):null,[e,r]);return(0,hz.useMemo)(()=>a?{...i,...a}:i,[i,a])}function h0(e,t){return hQ(e,hX,t)}function h1(e){return function(t){let r=(0,hz.useCallback)(t=>e.subscribe(t),[]),n=(0,hz.useCallback)(()=>e.getState(),[]),o=(0,hz.useSyncExternalStore)(r,n,n),i=(0,hz.useMemo)(()=>t?hJ(e,t):null,[t]);return(0,hz.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let h2=[];Object.freeze(h2);let h3={candidateExtensions:h2};Object.freeze(h3);let h4=e=>{let t=(0,hz.useCallback)(t=>t.slots?.[e]??h3,[e]);return hQ(pH(),t)},h6=e=>e.session;function h5(e,t){let{candidateExtensions:r}=h4(e),n=hQ(aD,h6),o=hZ(t);return(0,hz.useMemo)(()=>hp(e,o),[e,o,n,r])}function h8(e,t){let{moduleName:r}=(0,hz.useContext)(hG);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,hz.useEffect)(()=>{hm(r,e)},[r,e]),{extensions:h5(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function h9(e){return e}function h7({name:e,extensionSlotName:t,select:r=h9,children:n,state:o,style:i,...a}){if(n&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,u=(0,hz.useRef)(null),{extensions:l,extensionSlotModuleName:c}=h8(s,o),d=(0,hz.useMemo)(()=>r(l),[r,l]),f=(0,hz.useMemo)(()=>{if("function"==typeof n&&!hH().isValidElement(n))return d.map(e=>n(e,o))},[n,d]);return hH().createElement("div",{ref:u,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...i,position:"relative"},...a},s&&d?.map((e,t)=>hH().createElement(hG.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},f?.[t]??("function"!=typeof n?n:null)??hH().createElement(hY,{state:o}))))}var me=r(5338);function mt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function mr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?mt(Object(r),!0).forEach(function(t){var n,o,i;n=e,o=t,i=r[t],o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function mn(e){return(mn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mo(e){return(mo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mi(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(mo(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(mo(e)));return e}}var ma=null;try{ma=require("react").createContext()}catch(e){}var ms={React:null,ReactDOM:null,ReactDOMClient:null,rootComponent:null,loadRootComponent:null,errorBoundary:null,errorBoundaryClass:null,domElementGetter:null,parcelCanUpdate:!0,suppressComponentDidCatchWarning:!1,domElements:{},renderResults:{},updateResolves:{},unmountResolves:{}};function mu(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function ml(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var o,i=mp(e,t,function(){r(this)}),a=mi(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,o=e.domElement,i=t[r];if("function"!=typeof i)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=i(o);return a.render(n),a;case"hydrateRoot":return i(o,n);default:return i(n,o),null}}({elementToRender:i,domElement:a,reactDom:mf(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function mc(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():mf(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function md(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=mp(e,t,null),o=e.renderResults[t.name];if(o&&o.render)o.render(n);else{var i=mi(e,t)();mf(e).render(n,i)}})}function mf(e){return e.ReactDOMClient||e.ReactDOM}function mp(e,t,r){var n=e.React.createElement(e.rootComponent,t),o=ma?e.React.createElement(ma.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),o=e.React.createElement(e.errorBoundaryClass,t,o)),o=e.React.createElement(e.SingleSpaRoot,mr(mr({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),o)}var mh=r(202),mm=r(9324),my=r(4993);let mg={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},mb=new Map;(0,my.r2)(mb);let mv={errorRetryCount:3,fetcher:aE,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof aO){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>mb};function m_(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},mg,e),r={...mv,...t.swrConfig};return function(e){var n,o,i,a,s;return i=o=class extends(n=hH().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return hH().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=hH().createElement(hz.Suspense,{fallback:null},hH().createElement(mm.BE,{value:r},hH().createElement(hG.Provider,{value:this.state.config},t.disableTranslations?hH().createElement(e,this.props):hH().createElement(mh.I18nextProvider,{i18n:window.i18next,defaultNS:this.state.config.extension?`${this.state.config.moduleName}___${this.state.config.extension.extensionSlotName}___${this.state.config.extension.extensionId}`:this.state.config.moduleName},hH().createElement(e,this.props)))));return t.strictMode&&hH().StrictMode?hH().createElement(hH().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}}function mw(e,t){return function(e){if("object"!==mn(e))throw Error("single-spa-react requires a configuration object");var t,r=mr(mr({},ms),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!ma&&r.React.createContext&&(ma=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:mu.bind(null,r),mount:ml.bind(null,r),unmount:mc.bind(null,r)};return r.parcelCanUpdate&&(n.update=md.bind(null,r)),n}({React:hH(),ReactDOMClient:me,rootComponent:m_(t)(e)})}function mx(e,t){return()=>e().then(({default:e})=>mw(e,t))}function mE(e,t){return()=>Promise.resolve(mw(e,t))}let mS=mx,mO=U()(()=>({}));Y("openmrs-app-context",mO);let mD={};function mP(e,t=e=>e){let r=mO.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function mk(e,t){mO.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function mC(e){return null===e?null:Object.freeze(Object.assign({},e))}let mj=new Map;function mT(e,t){let r=(0,hz.useRef)(t??{}),n=(0,hz.useRef)(t=>mk(e,t)),o=(0,hz.useRef)(Symbol());return(0,hz.useEffect)(()=>{let r=t??{},n=o.current;return null===mP(e)?!function(e,t=mD){mO.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===mD?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),mk(e,()=>r)),mj.set(e,n),()=>{mj.get(e)===n&&(mO.setState(t=>(e in t&&delete t[e],t)),mj.delete(e))}},[e]),(0,hz.useEffect)(()=>{let n=t??{};L(r.current,n)||(mk(e,()=>n),r.current=n)},[t]),n.current}function mR({namespace:e,value:t}){return mT(e,t),null}let mA=({children:e,value:t,fallback:r})=>t?hH().createElement(hH().Fragment,null,e):r?hH().createElement(hH().Fragment,null,r):null;function mN(){let e=(0,hz.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,hz.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function mI(e,t=e=>e??{}){let[r,n]=(0,hz.useState)(()=>{if(mM(e))return;let r=mP(e);if(null!==r)return t?t(r):r});return(0,hz.useEffect)(()=>{if(mM(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,hz.useEffect)(()=>{var r;let o;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>L(e,r)?e:r)})(mC(o=mP(e))),mO.subscribe(t=>{let n=e in t?t[e]:null;n!==o&&(o=n,r(mC(n)))})},[e,t]),r}function mM(e){return"string"!=typeof e||0===e.trim().length}function m$(e){let t=h5(e);return(0,hz.useMemo)(()=>t.map(e=>e.id),[t])}function mL(e){return h4(e).candidateExtensions}function mF(e,t){let{data:r,error:n,mutate:o,isLoading:i,isValidating:a}=(0,mm.Ay)(`${uS}?patient=${e}&includeEncounterless=${t}`,aE);return(0,hz.useMemo)(()=>({isLoading:i,data:r?.data.results??[],error:n,mutate:o,isValidating:a}),[r,n,i,a,o])}function mB(e){(0,hz.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let mV={},mU=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function mW(e){let{moduleName:t,extension:r}=(0,hz.useContext)(hG),n=e?.externalModuleName??t;if(!n&&!r)throw Error(mU);let o=function(e){let t=(0,hz.useMemo)(()=>nB(e),[e]),r=function(e){let[t,r]=(0,hz.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,hz.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw mV[e]||(mV[e]=new Promise(e=>{let r=t.subscribe(t=>{t.loaded&&t.config&&(e(t.config),r())})})),mV[e];return r}(n),i=function(e){let t=(0,hz.useMemo)(nK,[]),r=function(e,t){let[r,n]=(0,hz.useState)(t?()=>{let r=nH(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,hz.useEffect)(()=>{if(t)return e.subscribe(e=>{let o=nH(e,t.extensionSlotName,t.extensionId);o.loaded&&o.config&&!rH(o.config,r)&&n(o.config)})},[e,t,r]),r}(t,e);if(!r&&e){let r=`${e.extensionSlotName}-${e.extensionId}`;throw!mV[r]&&t&&(mV[r]=new Promise(r=>{let n=t.subscribe(t=>{let o=nH(t,e.extensionSlotName,e.extensionId);o.loaded&&o.config&&(r(o.config),n())})})),mV[r]}return r||{}}(r);return(0,hz.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...o}:{...o,...i},[n,e?.externalModuleName,o,i])}let mK=h5;function mz(){let[e,t]=(0,hz.useState)(pT());return(0,hz.useEffect)(()=>g(({online:e})=>t(e)),[]),e}function mH(e,t=300){let[r,n]=(0,hz.useState)(e);return(0,hz.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var mG=r(4225);let mq=`custom:${[["admissionDecisionConcept","ref"],["admissionEncounterType","ref"],["admissionForm","ref"],["atFacilityVisitType","ref"],["bedAssignmentEncounterType","ref"],["cancelADTRequestEncounterType","ref"],["checkInClerkEncounterRole","ref"],["checkInEncounterType","ref"],["clinicianEncounterRole","ref"],["conceptSourcesForDiagnosisSearch","ref"],["consultEncounterType","ref"],["consultFreeTextCommentsConcept","ref"],["denyAdmissionConcept","ref"],["diagnosisMetadata","ref"],["diagnosisSets","ref"],["dischargeForm","ref"],["dispositionDescriptor","ref"],["dispositions","ref"],["emrApiConceptSource","ref"],["exitFromInpatientEncounterType","ref"],["extraPatientIdentifierTypes","ref"],["fullPrivilegeLevel","ref"],["highPrivilegeLevel","ref"],["identifierTypesToSearch","ref"],["inpatientNoteEncounterType","ref"],["lastViewedPatientSizeLimit","ref"],["metadataSourceName","ref"],["motherChildRelationshipType","ref"],["narrowerThanConceptMapType","ref"],["nonDiagnosisConceptSets","ref"],["orderingProviderEncounterRole","ref"],["patientDiedConcept","ref"],["personImageDirectory","ref"],["primaryIdentifierType","ref"],["sameAsConceptMapType","ref"],["suppressedDiagnosisConcepts","ref"],["supportsAdmissionLocationTag","(uuid,display,name,links)"],["supportsLoginLocationTag","(uuid,display,name,links)"],["supportsTransferLocationTag","(uuid,display,name,links)"],["supportsVisitsLocationTag","(uuid,display,name,links)"],["telephoneAttributeType","ref"],["testPatientPersonAttributeType","ref"],["transferForm","ref"],["transferRequestEncounterType","ref"],["transferWithinHospitalEncounterType","ref"],["unknownCauseOfDeathConcept","ref"],["unknownLocation","ref"],["unknownPatientPersonAttributeType","ref"],["unknownProvider","ref"],["visitAssignmentHandlerAdjustEncounterTimeOfDayIfNecessary","ref"],["visitExpireHours","ref"],["visitNoteEncounterType","ref"]].map(([e,t])=>`${e}:${t}`).join(",")}`;function mY(){let e=`${av}/emrapi/configuration?v=${mq}`,t=(0,mG.A)(e,aE);return(0,hz.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}let mZ=h1(p$());function mJ(e){let t=h5(e);return(0,hz.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let mX=h1(pH());function mQ(e){let{flags:t}=hQ(pO);return t[e]?.enabled??!1}function m0(){let[,e]=(0,hz.useState)(0);return(0,hz.useCallback)(()=>{e(e=>e+1)},[])}function m1(e,t,r={}){return m3(e,t,m2,r)}let m2={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(ax(e.toString()),window.location.toString());return n.searchParams.set("limit",""+t),n.searchParams.set("startIndex",""+r),n.searchParams.set("totalCount","true"),n.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function m3(e,t,r,n={}){let{getPaginatedUrl:o,getTotalCount:i,getCurrentPageSize:a,getData:s}=r,{immutable:u,swrConfig:l}=n,c=n.fetcher??aE,[d,f]=(0,hz.useState)(1),p=(0,hz.useRef)(NaN),h=(0,hz.useRef)(NaN),m=(0,hz.useRef)(d),y=(0,hz.useRef)(!1),g=(0,hz.useRef)(!1),b=e?.toString()??"",[v,w]=(0,hz.useState)(b);b!==v&&(w(b),f(1),m.current=1,p.current=NaN,h.current=NaN,y.current=!1,g.current=!1);let x=(d-1)*t,E=(0,hz.useMemo)(()=>o(e,t,x),[e,t,x]),{data:S,...O}=(u?mG.A:mm.Ay)(E,c,l);S?.data&&(p.current=i(S?.data),h.current=a(S?.data),y.current=!0);let D=Math.ceil(p.current/t),P=(0,hz.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(p.current/t);!y.current||Number.isNaN(r)||e<=r?(m.current=e,f(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,hz.useEffect)(()=>{if(!y.current)return;if(Number.isNaN(p.current)){g.current||(g.current=!0,console.warn(`useServerPagination: ${b} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(p.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),m.current=e,f(e))},[d,t,b,S]);let k=(0,hz.useCallback)(()=>{P(m.current+1)},[P]),C=(0,hz.useCallback)(()=>{P(m.current-1)},[P]);return{data:s(S?.data),totalPages:D,totalCount:p.current,currentPage:d,currentPageSize:h.current,paginated:D>1,showNextButton:d<D,showPreviousButton:d>1,goTo:P,goToNext:k,goToPrevious:C,...O}}function m4(e,t,r={}){return m3(e,t,m6(),r)}function m6(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(ax(e.toString()),window.location.toString());return n.searchParams.set("_count",""+t),n.searchParams.set("_getpagesoffset",""+r),n.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var m5=r(9888);let m8=hH().use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;if("rejected"===e.status)throw e.reason;throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}),m9={dedupe:!0};my.qv.defineProperty(my.BE,"defaultValue",{value:my.sb});let m7=(0,my.qm)((e,t,r)=>{let{cache:n,compare:o,suspense:i,fallbackData:a,revalidateOnMount:s,revalidateIfStale:u,refreshInterval:l,refreshWhenHidden:c,refreshWhenOffline:d,keepPreviousData:f}=r,[p,h,m,y]=my.bZ.get(n),[g,b]=(0,my.lK)(e),v=(0,hz.useRef)(!1),w=(0,hz.useRef)(!1),x=(0,hz.useRef)(g),E=(0,hz.useRef)(t),S=(0,hz.useRef)(r),O=()=>S.current.isVisible()&&S.current.isOnline(),[D,P,k,C]=(0,my.r9)(n,g),j=(0,hz.useRef)({}).current,T=(0,my.b0)(a)?r.fallback[g]:a,R=(e,t)=>{for(let r in j)if("data"===r){if(!o(e[r],t[r])&&(!(0,my.b0)(e[r])||!o(V,t[r])))return!1}else if(t[r]!==e[r])return!1;return!0},A=(0,hz.useMemo)(()=>{let e=!!g&&!!t&&((0,my.b0)(s)?!S.current.isPaused()&&!i&&(!!(0,my.b0)(u)||u):s),r=t=>{let r=(0,my.rL)(t);return(delete r._k,e)?{isValidating:!0,isLoading:!0,...r}:r},n=D(),o=C(),a=r(n),l=n===o?a:r(o),c=a;return[()=>{let e=r(D());return R(e,c)?(c.data=e.data,c.isLoading=e.isLoading,c.isValidating=e.isValidating,c.error=e.error,c):(c=e,e)},()=>l]},[n,g]),N=(0,m5.useSyncExternalStore)((0,hz.useCallback)(e=>k(g,(t,r)=>{R(r,t)||e()}),[n,g]),A[0],A[1]),I=!v.current,M=p[g]&&p[g].length>0,$=N.data,L=(0,my.b0)($)?T:$,F=N.error,B=(0,hz.useRef)(L),V=f?(0,my.b0)($)?B.current:$:L,U=(!M||!!(0,my.b0)(F))&&(I&&!(0,my.b0)(s)?s:!S.current.isPaused()&&(i?!(0,my.b0)(L)&&u:(0,my.b0)(L)||u)),W=!!(g&&t&&I&&U),K=(0,my.b0)(N.isValidating)?W:N.isValidating,z=(0,my.b0)(N.isLoading)?W:N.isLoading,H=(0,hz.useCallback)(async e=>{let t,n,i=E.current;if(!g||!i||w.current||S.current.isPaused())return!1;let a=!0,s=e||{},u=!m[g]||!s.dedupe,l=()=>my.dO?!w.current&&g===x.current&&v.current:g===x.current,c={isValidating:!1,isLoading:!1},d=()=>{P(c)},f=()=>{let e=m[g];e&&e[1]===n&&delete m[g]},y={isValidating:!0};(0,my.b0)(D().data)&&(y.isLoading=!0);try{if(u&&(P(y),r.loadingTimeout&&(0,my.b0)(D().data)&&setTimeout(()=>{a&&l()&&S.current.onLoadingSlow(g,r)},r.loadingTimeout),m[g]=[i(b),(0,my.lg)()]),[t,n]=m[g],t=await t,u&&setTimeout(f,r.dedupingInterval),!m[g]||m[g][1]!==n)return u&&l()&&S.current.onDiscarded(g),!1;c.error=my.ZH;let e=h[g];if(!(0,my.b0)(e)&&(n<=e[0]||n<=e[1]||0===e[1]))return d(),u&&l()&&S.current.onDiscarded(g),!1;let s=D().data;c.data=o(s,t)?s:t,u&&l()&&S.current.onSuccess(t,g,r)}catch(r){f();let e=S.current,{shouldRetryOnError:t}=e;!e.isPaused()&&(c.error=r,u&&l()&&(e.onError(r,g,e),(!0===t||(0,my.Tn)(t)&&t(r))&&(!S.current.revalidateOnFocus||!S.current.revalidateOnReconnect||O())&&e.onErrorRetry(r,g,e,e=>{let t=p[g];t&&t[0]&&t[0](my.bu.ERROR_REVALIDATE_EVENT,e)},{retryCount:(s.retryCount||0)+1,dedupe:!0})))}return a=!1,d(),!0},[g,n]),G=(0,hz.useCallback)((...e)=>(0,my.mF)(n,x.current,...e),[]);if((0,my.Es)(()=>{E.current=t,S.current=r,(0,my.b0)($)||(B.current=$)}),(0,my.Es)(()=>{if(!g)return;let e=H.bind(my.ZH,m9),t=0,r=(0,my.aw)(g,p,(r,n={})=>{if(r==my.bu.FOCUS_EVENT){let r=Date.now();S.current.revalidateOnFocus&&r>t&&O()&&(t=r+S.current.focusThrottleInterval,e())}else if(r==my.bu.RECONNECT_EVENT)S.current.revalidateOnReconnect&&O()&&e();else if(r==my.bu.MUTATE_EVENT)return H();else if(r==my.bu.ERROR_REVALIDATE_EVENT)return H(n)});return w.current=!1,x.current=g,v.current=!0,P({_k:b}),U&&((0,my.b0)(L)||my.X3?e():(0,my.mf)(e)),()=>{w.current=!0,r()}},[g]),(0,my.Es)(()=>{let e;function t(){let t=(0,my.Tn)(l)?l(D().data):l;t&&-1!==e&&(e=setTimeout(r,t))}function r(){!D().error&&(c||S.current.isVisible())&&(d||S.current.isOnline())?H(m9).then(t):t()}return t(),()=>{e&&(clearTimeout(e),e=-1)}},[l,c,d,g]),(0,hz.useDebugValue)(V),i&&(0,my.b0)(L)&&g){if(!my.dO&&my.X3)throw Error("Fallback data is required when using suspense in SSR.");E.current=t,S.current=r,w.current=!1;let e=y[g];if((0,my.b0)(e)||m8(G(e)),(0,my.b0)(F)){let e=H(m9);(0,my.b0)(V)||(e.status="fulfilled",e.value=!0),m8(e)}else throw F}return{mutate:G,get data(){return j.data=!0,V},get error(){return j.error=!0,F},get isValidating(){return j.isValidating=!0,K},get isLoading(){return j.isLoading=!0,z}}}),ye=Promise.resolve(),yt=(0,my.Ht)(m7,e=>(t,r,n)=>{let o,i=(0,hz.useRef)(!1),{cache:a,initialSize:s=1,revalidateAll:u=!1,persistSize:l=!1,revalidateFirstPage:c=!0,revalidateOnMount:d=!1,parallel:f=!1}=n,[,,,p]=my.bZ.get(my.PP);try{(o=(0,my.lK)(t?t(0,null):null)[0])&&(o=my.q9+o)}catch(e){}let[h,m,y]=(0,my.r9)(a,o),g=(0,hz.useCallback)(()=>(0,my.b0)(h()._l)?s:h()._l,[a,o,s]);(0,m5.useSyncExternalStore)((0,hz.useCallback)(e=>o?y(o,()=>{e()}):()=>{},[a,o]),g,g);let b=(0,hz.useCallback)(()=>{let e=h()._l;return(0,my.b0)(e)?s:e},[o,s]),v=(0,hz.useRef)(b());(0,my.Es)(()=>{if(!i.current){i.current=!0;return}o&&m({_l:l?v.current:b()})},[o,a]);let w=d&&!i.current,x=e(o,async e=>{let o=h()._i,i=h()._r;m({_r:my.ZH});let s=[],l=b(),[d]=(0,my.r9)(a,e),y=d().data,g=[],v=null;for(let e=0;e<l;++e){let[l,d]=(0,my.lK)(t(e,f?null:v));if(!l)break;let[h,m]=(0,my.r9)(a,l),b=h().data,x=u||o||(0,my.b0)(b)||c&&!e&&!(0,my.b0)(y)||w||y&&!(0,my.b0)(y[e])&&!n.compare(y[e],b);if(r&&("function"==typeof i?i(b,d):x)){let t=async()=>{if(l in p){let e=p[l];delete p[l],b=await e}else b=await r(d);m({data:b,_k:d}),s[e]=b};f?g.push(t):await t()}else s[e]=b;f||(v=b)}return f&&await Promise.all(g.map(e=>e())),m({_i:my.ZH}),s},n),E=(0,hz.useCallback)(function(e,t){let r="boolean"==typeof t?{revalidate:t}:t||{},n=!1!==r.revalidate;return o?(n&&((0,my.b0)(e)?m({_i:!0,_r:r.revalidate}):m({_i:!1,_r:r.revalidate})),arguments.length?x.mutate(e,{...r,revalidate:n}):x.mutate()):ye},[o,a]),S=(0,hz.useCallback)(e=>{let r;if(!o)return ye;let[,n]=(0,my.r9)(a,o);if((0,my.Tn)(e)?r=e(b()):"number"==typeof e&&(r=e),"number"!=typeof r)return ye;n({_l:r}),v.current=r;let i=[],[s]=(0,my.r9)(a,o),u=null;for(let e=0;e<r;++e){let[r]=(0,my.lK)(t(e,u)),[n]=(0,my.r9)(a,r),o=r?n().data:my.ZH;if((0,my.b0)(o))return E(s().data);i.push(o),u=o}return E(i)},[o,a,E,b]);return{size:b(),setSize:S,mutate:E,get data(){return x.data},get error(){return x.error},get isValidating(){return x.isValidating},get isLoading(){return x.isLoading}}});function yr(e,t={}){return yn(e,m2,t)}function yn(e,t,r={}){let{swrInfiniteConfig:n,immutable:o}=r,{getNextUrl:i,getTotalCount:a,getData:s}=t,u=r.fetcher??aE,{data:l,size:c,setSize:d,...f}=yt((0,hz.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),u,{...n,...o?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),p=i(l?.[l.length-1].data),h=a(l?.[0]?.data);return{data:l?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=p,loadMore:()=>{d((l?.length??0)+1)},nextUri:p,...f}}function yo(e,t={}){return yi(e,m2,t)}function yi(e,t,r={}){let n=yn(e,t,r),{hasMore:o,error:i,data:a,loadMore:s,isLoading:u,nextUri:l}=n;return((0,hz.useEffect)(()=>{o&&!i&&s()},[o,l]),r.partialData)?n:{...n,data:o||i?void 0:a,isLoading:u||o}}function ya(e,t={}){return yi(e,m6(),t)}function ys(e,t={}){return yn(e,m6(),t)}function yu(){let e="tablet";return document.body.classList.forEach(t=>{switch(t){case"omrs-breakpoint-lt-tablet":e="phone";break;case"omrs-breakpoint-gt-small-desktop":e="large-desktop";break;case"omrs-breakpoint-gt-tablet":e="small-desktop"}}),e}function yl(){let[e,t]=(0,hz.useState)(yu);return(0,hz.useEffect)(()=>{let e=()=>{t(yu())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let yc=e=>"small-desktop"===e||"large-desktop"===e;function yd(e){let t=(0,hz.useContext)(hG);(0,hz.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),hb(e),()=>{hv(e.name)}),[t,e])}function yf(){return hQ(hg)}function yp(e=null,t=null){let[r,n]=(0,hz.useState)([]);return(0,hz.useEffect)(()=>{let r=fW(e,t).subscribe(e=>{n(e)},e=>{console.error(e)});return()=>r.unsubscribe()},[e,t]),r}function yh(e,t=!0){let r=(0,hz.useRef)(null);return(0,hz.useEffect)(()=>{let n=n=>{t&&r.current&&n.target&&n.target instanceof Node&&(r.current.contains(n.target)||e(n))};return window.addEventListener("mousedown",n),window.addEventListener("touchstart",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("touchstart",n)}},[e,t]),r}function ym(e){let t=(0,hz.useRef)();return(0,hz.useEffect)(()=>{let r=new IntersectionObserver(t=>{for(let r of t)if(r.isIntersecting)return void e()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t.current,e]),t}function yy(e,t={}){let{abortController:r,fetchInit:n,url:o,swrConfig:i}=t,a=mN(),s=(0,hz.useMemo)(()=>n?.signal??r?.signal??a.signal,[r?.signal,n?.signal,a.signal]),u=(0,hz.useCallback)(e=>aE(function(e,t){if(t)return"function"==typeof t?t(e):t;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,o),{...n,signal:s}),[s,n,o]);return(0,mm.Ay)(e,u,i)}function yg(e=[],t=10){let[r,n]=(0,hz.useState)(1),o=(0,hz.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);r>o&&n(o);let i=Math.min(Math.max(1,r),o),a=(0,hz.useMemo)(()=>{let r=(i-1)*t,n=(i+0)*t;return e.slice(r,n)},[e,i,t]),s=(0,hz.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),u=(0,hz.useCallback)(()=>{n(e=>e+1)},[]),l=(0,hz.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,hz.useMemo)(()=>({results:a,totalPages:o,currentPage:i,paginated:e.length>t,showNextButton:i<o,showPreviousButton:i>1,goTo:s,goToNext:u,goToPrevious:l}),[a,o,e.length,t,i,s,u,l])}function yb(e,t,r,n){return{pageSizes:(0,hz.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,hz.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function yv(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function y_(e){let[t,r]=(0,hz.useState)(e??yv()),{data:n,error:o,isValidating:i}=(0,mm.Ay)(t?["patient",t]:null,()=>f$(t,{}));return(0,hz.useEffect)(()=>{let e=()=>{let e=yv();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,hz.useMemo)(()=>({isLoading:i&&!o&&!n,patient:n,patientUuid:t,error:o}),[i,o,n,t])}function yw(){let e=`${av}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=(0,mm.Ay)(e,aE);return(0,hz.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function yx(e){let{extensions:t,extensionSlotModuleName:r}=h8(e);return e?t.map(t=>({state:n})=>hH().createElement(hG.Provider,{value:{moduleName:r,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:r}}},hH().createElement(hY,{state:n}))):[]}function yE(){let e=(0,hz.useRef)(),[t,r]=(0,hz.useState)(null),n=null;if(!t){if(s){let e=aC().getState();e.loaded&&(n=e.session)}else s=new Promise(t=>{let r=({loaded:r,session:o})=>{r&&(t(o),n=o,e.current&&(e.current(),e.current=void 0))};r(aC().getState()),n||(e.current=aC().subscribe(r))});if(n)r(n);else throw s}(0,hz.useEffect)(()=>(e.current||(e.current=aC().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let o=t||n;if(!o)if(s)throw console.warn("useSession is in an unexpected state. Attempting to recover."),s;else throw Error("useSession is in an invalid state.");return o}let yS=({privilege:e,fallback:t,children:r})=>{let[n,o]=(0,hz.useState)(null);return((0,hz.useEffect)(()=>{let e=ak({includeAuthStatus:!1}).subscribe(o);return()=>e.unsubscribe()},[]),n&&aA(e,n))?hH().createElement(hH().Fragment,null,r):t?hH().createElement(hH().Fragment,null,t):null};var yO=r(6734),yD=r.n(yO),yP=r(7581);let yk=new Map;function yC(){for(let e of Array.from(yk.values()))e()}let yj={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function yT(e){let t=(0,hz.useId)();return(0,hz.useEffect)(()=>{if(e)return yk.set(t,e),()=>{yk.delete(t)}},[t,e]),{...h0(f2(),yj),mutateVisit:yC}}function yR(e,t=f0){let r=(0,hz.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:o,setVisitContext:i}=yT((0,hz.useCallback)(()=>r.current?.(),[])),a=e&&n==e?o:null,s=`?patient=${e}&v=${t}&includeInactive=false`,u=`/${a}?v=${t}`,{data:l,error:c,mutate:d,isValidating:f}=(0,mm.Ay)(e?`${av}/visit${s}`:null,aE),{data:p,error:h,mutate:m,isValidating:y}=(0,mm.Ay)(e&&a?`${av}/visit${u}`:null,aE),g=(0,hz.useMemo)(()=>l?.data.results.find(e=>null===e.stopDatetime)??null,[l]),b=(0,hz.useMemo)(()=>a&&p?p.data:null,[p,a]),v=(0,hz.useRef)(null);(0,hz.useEffect)(()=>{!f&&g&&n===e&&null===o&&i(g),y||(v.current&&b&&v.current.uuid===b.uuid&&!v.current.stopDatetime&&b.stopDatetime&&i(null),v.current=b)},[b,o,g,f,y,n]);let w=(0,hz.useCallback)(()=>{d(),m()},[d,m]);(0,hz.useEffect)(()=>{r.current=w},[w]);let x=!!(!l||a&&!p),E=!!(a?h:c);return{error:c||h,mutate:w,isValidating:f||y,activeVisit:g,currentVisit:b,currentVisitIsRetrospective:!!a,isLoading:x&&!E}}function yA(){let[e,t]=(0,hz.useState)([]);return(0,hz.useEffect)(()=>{let e=fz().subscribe(e=>{t(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}yO.extend(yP);let yN=new Map;async function yI(e,t){let r=t.indexOf("#"),n=r>=0,o=n?t.substring(0,r):e,i=n?t.substring(r+1):t,a=await ue(o);return a&&Object.hasOwn(a,i)&&"function"==typeof a[i]?y$(o,a).then(()=>a[i]()):(a?a&&Object.hasOwn(a,i)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${o} does not define a component called "${i}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${o} for ${t} defined in ${e}'s routes.json`),yM)}let yM={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function y$(e,t){if(e in yN)await yN[e];else{let r=t??await ue(e);await (yN[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let o=r.startupApp;if("function"==typeof o)return Promise.resolve(o()).then(()=>{on(e),t(null)}).catch(n)}on(e),t(null)}))}}function yL(e,t){let r=t.name;if(!r)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
|
|
17
17
|
registered. To fix this, ensure that you define the "name" field inside the
|
|
18
18
|
extension definition.`,t);t.slots&&t.slot&&console.warn(`The extension ${r} from ${e} declares both a 'slots' property and
|