@openmrs/esm-openconceptlab-app 4.4.1-pre.673 → 4.4.1-pre.689

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/5019.js CHANGED
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
12
12
  ${n}`)}return o}let o2=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let o=t[n],a=e[n];if(a&&(a.hasOwnProperty("_type")||a.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=a._default);let e=a._elements;if(o&&o3(e)){if(a._type===om.Array&&Array.isArray(o)){let a=o.map(n=>o2(e,n));t[n]=a}else if(a._type===om.Object)for(let n of Object.keys(o))o[n]=o2(e,o[n])}}else if(o5(a)){let e=o??{};o5(e)&&(t[n]=o2(a,e))}}return t};function o3(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function o5(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let o4=new Set;function o6(e,n){let t=`${e}:::${n}`;o4||(o4=new Set),o4.has(t)||(console.error(n),o4.add(t))}function o7(e){e?o4.forEach(n=>{n.startsWith(e)&&o4.delete(n)}):o4.clear()}function o8(){oI.forEach(e=>e()),oI.length=0,oj()}let o9={"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:om.Object,_default:{},_validators:[og(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=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: ${n.join(", ")}.`})]}},ae={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:om.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:om.String,_default:void 0}},...o9},an=(e,n)=>og(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),at=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return og(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,o=t.exec(e);for(;o;){if(!n.includes(o[1]))return!1;o=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},ao=at([]),aa=e=>og(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),ar={inRange:an,isUrl:ao,isUrlWithTemplateParameters:at,oneOf:aa};var ai=t(2034);let as=G("breadcrumbs",[]);function al(e){return ac([e])}function ac(e){let n=[...ap(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ai.pathToRegexp)(e.matcher).regexp:(0,ai.pathToRegexp)(e.path).regexp,settings:e}))];as.setState(n,!0)}function ap(){return as.getState()}function au(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=au(e,t.join("/"));if(n)return n}}(e,n)}function ad(e,n){if(e.length>0){let t=au(e,n);if(t){let n=[t],o=au(e,t.settings.parent);for(;void 0!==o;)n.push(o),o=au(e,o.settings.parent);return n.reverse()}}return[]}function af(e){return ad(ap(),e)}var ah=Object.freeze({__proto__:null,get start(){return rj},get ensureJQuerySupport(){return rf},get setBootstrapMaxTime(){return a5},get setMountMaxTime(){return a4},get setUnmountMaxTime(){return a6},get setUnloadMaxTime(){return a7},get registerApplication(){return rk},get unregisterApplication(){return rC},get getMountedApps(){return rv},get getAppStatus(){return rA},get unloadApplication(){return rE},get checkActivityFunctions(){return rx},get getAppNames(){return r$},get pathToActiveWhen(){return rz},get navigateToUrl(){return ra},get patchHistoryApi(){return rp},get triggerAppChange(){return rT},get addErrorHandler(){return a_},get removeErrorHandler(){return av},get mountRootParcel(){return aQ},get NOT_LOADED(){return aw},get LOADING_SOURCE_CODE(){return ak},get NOT_BOOTSTRAPPED(){return ax},get BOOTSTRAPPING(){return aC},get NOT_MOUNTED(){return aE},get MOUNTING(){return aS},get UPDATING(){return az},get LOAD_ERROR(){return aO},get MOUNTED(){return aD},get UNLOADING(){return aP},get UNMOUNTING(){return aM},get SKIP_BECAUSE_BROKEN(){return aT}}),am=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,ag=!function(){try{var e=new am("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,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:am;let ab=[];function ay(e,n,t){let o=aA(e,n,t);ab.length?ab.forEach(e=>e(o)):setTimeout(()=>{throw o})}function a_(e){if("function"!=typeof e)throw Error(a$(28,!1));ab.push(e)}function av(e){if("function"!=typeof e)throw Error(a$(29,!1));let n=!1;return ab=ab.filter(t=>{let o=t===e;return n=n||o,!o}),n}function a$(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function aA(e,n,t){let o,a=`${aR(n)} '${aB(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}o=e}else{console.warn(a$(30,!1,n.status,aB(n)));try{o=Error(a+JSON.stringify(e))}catch(n){o=e}}return o.appOrParcelName=aB(n),n.status=t,o}let aw="NOT_LOADED",ak="LOADING_SOURCE_CODE",ax="NOT_BOOTSTRAPPED",aC="BOOTSTRAPPING",aE="NOT_MOUNTED",aS="MOUNTING",aD="MOUNTED",az="UPDATING",aM="UNMOUNTING",aP="UNLOADING",aO="LOAD_ERROR",aT="SKIP_BECAUSE_BROKEN";function aN(e){return e.status===aD}function aI(e){try{return e.activeWhen(window.location)}catch(n){return ay(n,e,aT),!1}}function aB(e){return e.name}function aj(e){return!!e.unmountThisParcel}function aR(e){return aj(e)?"parcel":"application"}function aF(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function aL(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function aW(e){return e&&("function"==typeof e||Array.isArray(e)&&!aL(e,e=>"function"!=typeof e))}function aV(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let o=aR(e),a=aB(e);return function(e){return t.reduce((t,r,i)=>t.then(()=>{let t=r(e);return aG(t)?t:Promise.reject(a$(15,!1,o,a,n,i))}),Promise.resolve())}}function aG(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let aU=[];function aq(e,n){return Promise.resolve().then(()=>e.status!==ax?e:(e.status=aC,e.bootstrap?a8(e,"bootstrap").then(t).catch(t=>{if(n)throw aA(t,e,aT);return ay(t,e,aT),e}):Promise.resolve().then(t)));function t(){return e.status=aE,e}}function aH(e,n){return Promise.resolve().then(()=>{if(e.status!==aD)return e;return e.status=aM,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,o=>t().then(()=>{let t=Error(o.message);if(n)throw aA(t,e,aT);ay(t,e,aT)})).then(()=>e);function t(){return a8(e,"unmount").then(()=>{e.status=aE},t=>{if(n)throw aA(t,e,aT);ay(t,e,aT)})}})}let aK=!1,aY=!1;function aZ(e,n){return Promise.resolve().then(()=>e.status!==aE?e:(aK||(window.dispatchEvent(new ag("single-spa:before-first-mount")),aK=!0),e.status=aS,a8(e,"mount").then(()=>(e.status=aD,aY||(window.dispatchEvent(new ag("single-spa:first-mount")),aY=!0),e)).catch(t=>{return e.status=aD,aH(e,!0).then(o,o);function o(){if(n)throw aA(t,e,aT);return ay(t,e,aT),e}})))}let aJ=0,aX={parcels:{}};function aQ(){return a0.apply(aX,arguments)}function a0(e,n){let t,o,a,r=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(a$(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(a$(3,!1,typeof e.name));let i=aJ++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(a$(4,!1,s,typeof n));if(!n.domElement)throw Error(a$(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:i,parcels:{},status:l?ak:ax,customProps:n,parentName:aB(r),unmountThisParcel:()=>f.then(()=>{if(p.status!==aD)throw Error(a$(6,!1,s,p.status));return aH(p,!0)}).then(e=>(p.parentName&&delete r.parcels[p.id],e)).then(e=>(o(e),e)).catch(e=>{throw p.status=aT,a(e),e})};r.parcels[i]=p;let u=c();if(!u||"function"!=typeof u.then)throw Error(a$(7,!1));let d=(u=u.then(e=>{if(!e)throw Error(a$(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!aW(e.bootstrap))throw Error(a$(9,!1,s));if(!aW(e.mount))throw Error(a$(10,!1,s));if(!aW(e.unmount))throw Error(a$(11,!1,s));if(e.update&&!aW(e.update))throw Error(a$(12,!1,s));let n=aV(e,"bootstrap"),o=aV(e,"mount"),a=aV(e,"unmount");p.status=ax,p.name=s,p.bootstrap=n,p.mount=o,p.unmount=a,p.timeouts=a9(e.timeouts),e.update&&(p.update=aV(e,"update"),t.update=function(e){return p.customProps=e,a1(Promise.resolve().then(()=>{if(p.status!==aD)throw Error(a$(32,!1,aB(p)));return p.status=az,a8(p,"update").then(()=>(p.status=aD,p)).catch(e=>{throw aA(e,p,aT)})}))})})).then(()=>aq(p,!0)),f=d.then(()=>aZ(p,!0)),h=new Promise((e,n)=>{o=e,a=n});return t={mount:()=>a1(Promise.resolve().then(()=>{if(p.status!==aE)throw Error(a$(13,!1,s,p.status));return r.parcels[i]=p,aZ(p)})),unmount:()=>a1(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:a1(u),bootstrapPromise:a1(d),mountPromise:a1(f),unmountPromise:a1(h)}}function a1(e){return e.then(()=>null)}function a2(e){let n=aB(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(a$(40,!1),n,t));let o=aF({},t,{name:n,mountParcel:a0.bind(e),singleSpa:ah});return aj(e)&&(o.unmountSelf=e.unmountThisParcel),o}let a3={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 a5(e,n,t){if("number"!=typeof e||e<=0)throw Error(a$(16,!1));a3.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function a4(e,n,t){if("number"!=typeof e||e<=0)throw Error(a$(17,!1));a3.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function a6(e,n,t){if("number"!=typeof e||e<=0)throw Error(a$(18,!1));a3.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function a7(e,n,t){if("number"!=typeof e||e<=0)throw Error(a$(19,!1));a3.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function a8(e,n){let t=e.timeouts[n],o=t.warningMillis,a=aR(e);return new Promise((r,i)=>{let s=!1,l=!1;e[n](a2(e)).then(e=>{s=!0,r(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>p(1),o),setTimeout(()=>p(!0),t.millis);let c=a$(31,!1,n,a,aB(e),t.millis);function p(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*o+o<t.millis&&setTimeout(()=>p(e+1),o)))}})}function a9(e){let n={};for(let t in a3)n[t]=aF({},a3[t],e&&e[t]||{});return n}function re(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==aw&&e.status!==aO?e:(e.status=ak,e.loadPromise=Promise.resolve().then(()=>{let o=e.loadApp(a2(e));if(!aG(o))throw t=!0,Error(a$(33,!1,aB(e)));return o.then(t=>{let o;e.loadErrorTime=null,"object"!=typeof(n=t)&&(o=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!aW(n.bootstrap)&&(o=35),aW(n.mount)||(o=36),aW(n.unmount)||(o=37);let a=aR(n);if(o){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(a$(o,!1,a,aB(e),t),n),ay(void 0,e,aT),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=aF({},e.devtools.overlays,n.devtools.overlays)),e.status=ax,e.bootstrap=aV(n,"bootstrap"),e.mount=aV(n,"mount"),e.unmount=aV(n,"unmount"),e.unload=aV(n,"unload"),e.timeouts=a9(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let o;return delete e.loadPromise,t?o=aT:(o=aO,e.loadErrorTime=(new Date).getTime()),ay(n,e,o),e}))})}let rn="u">typeof window,rt={hashchange:[],popstate:[]},ro=["hashchange","popstate"];function ra(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(a$(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=ru(window.location.href),o=ru(n);0===n.indexOf("#")?window.location.hash=o.hash:t.host!==o.host&&o.host?window.location.href=n:o.pathname===t.pathname&&o.search===t.search?window.location.hash=o.hash:window.history.pushState(null,null,n)}function rr(e){if(e){let n=e[0].type;ro.indexOf(n)>=0&&rt[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function ri(){rN([],arguments)}function rs(e,n){return function(){let t=window.location.href,a=e.apply(this,arguments),r=window.location.href;return o&&t===r||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),a}}let rl=null,rc=!1;function rp(e){if(rc)throw Error(a$(43,!1));o=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,rc=!0,rl=window.history.replaceState,window.addEventListener("hashchange",ri),window.addEventListener("popstate",ri);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&ro.indexOf(e)>=0)||aL(rt[e],e=>e===t))return n.apply(this,arguments);rt[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&ro.indexOf(e)>=0&&(rt[e]=rt[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=rs(window.history.pushState,"pushState"),window.history.replaceState=rs(rl,"replaceState")}function ru(e){let n=document.createElement("a");return n.href=e,n}rn&&(window.singleSpaNavigate?console.warn(a$(41,!1)):window.singleSpaNavigate=ra);let rd=!1;function rf(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!rd){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return rh.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return rh.call(this,t,window.removeEventListener,e,n,arguments)},rd=!0}}function rh(e,n,t,o,a){return"string"!=typeof t?e.apply(this,a):(t.split(/\s+/).forEach(e=>{ro.indexOf(e)>=0&&(n(e,o),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,a))}let rm={};function rg(e){return Promise.resolve().then(()=>{let n=rm[aB(e)];if(!n)return e;if(e.status===aw)return rb(e,n),e;if(e.status===aP)return n.promise.then(()=>e);if(e.status!==aE&&e.status!==aO)return e;let t=e.status===aO?Promise.resolve():a8(e,"unload");return e.status=aP,t.then(()=>(rb(e,n),e)).catch(t=>(delete rm[aB(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,ay(t,e,aT),n.reject(t),e))})}function rb(e,n){delete rm[aB(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=aw,n.resolve()}function ry(e,n,t,o){rm[aB(e)]={app:e,resolve:t,reject:o},Object.defineProperty(rm[aB(e)],"promise",{get:n})}let r_=[];function rv(){return r_.filter(aN).map(aB)}function r$(){return r_.map(aB)}function rA(e){let n=aL(r_,n=>aB(n)===e);return n?n.status:null}let rw=!1;function rk(e,n,t,o){var a,r;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(a$(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(a$(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(a$(20,!1));let o=e=>"string"==typeof e||"function"==typeof e;if(!(o(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(o)))throw Error(a$(24,!1));if(!rD(e.customProps))throw Error(a$(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,o){if("string"!=typeof e||0===e.length)throw Error(a$(20,!1));if(!n)throw Error(a$(23,!1));if("function"!=typeof t)throw Error(a$(24,!1));if(!rD(o))throw Error(a$(22,!1))}(e,n,t,o),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=o),i.loadApp="function"!=typeof(a=i.loadApp)?()=>Promise.resolve(a):a,i.customProps=i.customProps||{},s=(s=Array.isArray(r=i.activeWhen)?r:[r]).map(e=>"function"==typeof e?e:rz(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(rB||rw||(rw=!0,setTimeout(()=>{rB||console.warn(a$(1,!1))},5e3)),-1!==r$().indexOf(l.name))throw Error(a$(21,!1,l.name));r_.push(aF({loadErrorTime:null,status:aw,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),rn&&(rf(),rN())}function rx(e=window.location){return r_.filter(n=>n.activeWhen(e)).map(aB)}function rC(e){if(0===r_.filter(n=>aB(n)===e).length)throw Error(a$(25,!1,e));return(rn?rE(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=r_.map(aB).indexOf(e);r_.splice(n,1)})}function rE(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(a$(26,!1));let t=aL(r_,n=>aB(n)===e);if(!t)throw Error(a$(27,!1,e));let o=rm[aB(t)];if(n&&n.waitForUnmount){if(o)return o.promise;{let e=new Promise((n,o)=>{ry(t,()=>e,n,o)});return e}}{let e;return o?(e=o.promise,rS(t,o.resolve,o.reject)):e=new Promise((n,o)=>{ry(t,()=>e,n,o),rS(t,n,o)}),e}}function rS(e,n,t){Promise.resolve().then(()=>{if(aL(rx(),n=>n===aB(e)))return rT()}).then(()=>aH(e).then(rg).then(()=>{n(),setTimeout(()=>{rN()})})).catch(t)}function rD(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function rz(e,n){let t=function(e,n){let t=0,o=!1,a="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],a=o&&"/"===t;(!o&&":"===t||a)&&r(n)}return r(e.length),RegExp(a,"i");function r(r){let i=e.slice(t,r).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(a+=o?"[^/]+/?":i,r===e.length)if(o)n&&(a+="$");else{let e=n?"":".*";a="/"===a.charAt(a.length-1)?`${a}${e}$`:`${a}(/${e})?(#.*)?$`}o=!o,t=r}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let o=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(o)}}let rM=!1,rP=[],rO=rn&&window.location.href;function rT(){return rN()}function rN(e=[],n,t=!1){let o,a,r,i,s;if(rM)return new Promise((e,t)=>{rP.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:u}=(o=[],a=[],r=[],i=[],s=(new Date).getTime(),r_.forEach(e=>{let n=e.status!==aT&&aI(e);switch(e.status){case aO:n&&s-e.loadErrorTime>=200&&r.push(e);break;case aw:case ak:n&&r.push(e);break;case ax:case aE:!n&&rm[aB(e)]?o.push(e):n&&i.push(e);break;case aD:n||a.push(e)}}),{appsToUnload:o,appsToUnmount:a,appsToLoad:r,appsToMount:i}),d,f=[],h=rO,m=rO=window.location.href;return rB?(rM=!0,d=l.concat(p,c,u),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return rl.call(window.history,history.state,"",h.substring(location.origin.length)),rO=location.href,rM=!1,rN(e,n,!0);let o=l.map(rg),a=Promise.all(c.map(aH).map(e=>e.then(rg)).concat(o));a.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let r=p.map(e=>re(e).then(e=>rI(e,a))),i=u.filter(e=>0>p.indexOf(e)).map(e=>rI(e,a));return a.catch(e=>{throw y(),e}).then(()=>(y(),Promise.all(r.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(b).then(()=>{},e=>{throw e})))})))):(d=p,Promise.resolve().then(()=>Promise.all(p.map(re)).then(y).then(()=>[]).catch(e=>{throw y(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(a$(42,!1))),console.warn(e),!1)))}function b(){let n=rv();e.forEach(e=>e.resolve(n));try{$(0===d.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(rM=!1,rP.length>0){let e=rP;rP=[],rN(e)}return n}function y(){t||(e.forEach(e=>{rr(e.eventArguments)}),rr(n))}function v(e=!1,t){let o={},a={[aD]:[],[aE]:[],[aw]:[],[aT]:[]};e?(p.concat(u).forEach((e,n)=>{i(e,aD)}),l.forEach(e=>{i(e,aw)}),c.forEach(e=>{i(e,aE)})):d.forEach(e=>{i(e)});let r={detail:{newAppStatuses:o,appsByNewStatus:a,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:m}};return t&&aF(r.detail,t),r;function i(e,n){let t=aB(e);n=n||rA(t),o[t]=n,(a[n]=a[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new ag(`single-spa:${e}`,n))}}function rI(e,n){return aI(e)?aq(e).then(e=>n.then(()=>aI(e)?aZ(e):e)):n.then(()=>e)}let rB=!1;function rj(e){rB=!0,rn&&(rp(e),rN())}function rR(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return rF(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function rF(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function rL({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),o=rR(e,n).replace(window.location.origin,"");o.startsWith(t)?ra(o):window.location.assign(o)}rn&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...r_]},reroute:rN,NOT_LOADED:aw,toLoadPromise:re,toBootstrapPromise:aq,unregisterApplication:rC,getProfilerData:function(){return aU}});let rW="openmrs:history";function rV(e){let n=JSON.parse(sessionStorage.getItem(rW)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(rW,JSON.stringify(n))}function rG(){0===JSON.parse(sessionStorage.getItem(rW)??"[]").length&&document.referrer&&rV(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=rU();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(rW,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?rq({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&rV(window.location.href)})}function rU(){return JSON.parse(sessionStorage.getItem(rW)??"[]")}function rq({toUrl:e}){let n=rU(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);rL({to:n[t]}),sessionStorage.setItem(rW,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function rH(){sessionStorage.removeItem(rW)}let rK="${openmrsSpaBase}/login",rY={redirectAuthFailure:{enabled:{_type:om.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:om.String,_default:rK,_validators:[ar.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:om.Array,_default:[401],_elements:{_type:om.Number,_validators:[ar.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:om.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:om.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function rZ(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let rJ="/ws/rest/v1",rX="/ws/fhir2/R4",rQ=`${rJ}/session`;function r0(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function r1(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)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 t=r0(e);if(n.headers||(n.headers={}),eS(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(rJ)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(rX)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let o=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:a}=await oU("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(a&&n&&(t===r0(rQ)||204===e.status)&&rL({to:n}),204===e.status)?(e.data=null,e):e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e})}return t===r0(rQ)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(rH(),rL({to:n.url||e.headers.get("location")||rK}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let a=n;try{a=JSON.parse(n)}catch(e){}throw new r3(t,e,a,o)},n=>{throw new r3(t,e,null,o)})})}function r2(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new el.Observable(o=>{let a=!1;return r1(e,n).then(e=>{a=!0,o.next(e),o.complete()},e=>{a=!0,o.error(e)}),()=>{a||t.abort()}})}class r3 extends Error{constructor(e,n,t,o){super(),rZ(this,"response",void 0),rZ(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,o.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
13
13
  ${o.stack}
14
14
  Stacktrace for incoming response:
15
- ${this.stack}`}}let r5=G("session",{loaded:!1,session:null}),r4=0;function r6(e={includeAuthStatus:!0}){return(r4<Date.now()-6e4||!r5.getState().loaded)&&r9(),new el.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(r5.getState()),r5.subscribe(t)})}function r7(){return(r4<Date.now()-6e4||!r5.getState().loaded)&&r9(),r5}function r8(e){let n=e.locale??e.user?.userProperties?.defaultLocale;n&&n.includes("_")&&(n=n.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(n)&&n!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",n)}function r9(e,n){r4=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),is(r1(rQ,{headers:t}))}function ie(){r5.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function it(e,n){var t,o;if(void 0===n)return!e;if(!e)return!0;return t=e,o=n,("string"==typeof t?!Y(o.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Y(o.privileges.find(n=>e===n.display))):(Y(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Y(n.roles.find(e=>"System Developer"===e.display))}function io(){let e,n;return new Promise(t=>{let o=o=>{o.loaded&&o.session.user&&(e=o.session.user,t(o.session.user),n&&n())};o(r5.getState()),e||(n=r5.subscribe(o))})}function ia(){return new Promise((e,n)=>{r6().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function ir(e,n){return is(r1(rQ,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function ii(e,n,t){return t||(t=new AbortController),await r1(`${rJ}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),r9()}function is(e){return new Promise((n,t)=>{e.then(e=>{let o;"object"==typeof e?.data?(o={loaded:!0,session:e.data},r5.setState(o),n(o)):(o={loaded:!1,session:null},r5.setState(o),t(o))}).catch(e=>{T(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};r5.setState(n),t(n)})})}function il(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}r5.subscribe(e=>{e.loaded&&e.session&&r8(e.session)});let ic={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ip(){oR("@openmrs/esm-api",rY),r9()}let iu={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",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}}",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"},id=e=>"string"==typeof e,ih=()=>{let e,n,t=new Promise((t,o)=>{e=t,n=o});return t.resolve=e,t.reject=n,t},im=e=>null==e?"":""+e,ig=/###/g,ib=e=>e&&e.indexOf("###")>-1?e.replace(ig,"."):e,iy=e=>!e||id(e),i_=(e,n,t)=>{let o=id(n)?n.split("."):n,a=0;for(;a<o.length-1;){if(iy(e))return{};let n=ib(o[a]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++a}return iy(e)?{}:{obj:e,k:ib(o[a])}},iv=(e,n,t)=>{let{obj:o,k:a}=i_(e,n,Object);if(void 0!==o||1===n.length){o[a]=t;return}let r=n[n.length-1],i=n.slice(0,n.length-1),s=i_(e,i,Object);for(;void 0===s.obj&&i.length;)r=`${i[i.length-1]}.${r}`,s=i_(e,i=i.slice(0,i.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${r}`]&&(s.obj=void 0);s.obj[`${s.k}.${r}`]=t},i$=(e,n)=>{let{obj:t,k:o}=i_(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,o))return t[o]},iA=(e,n,t)=>{for(let o in n)"__proto__"!==o&&"constructor"!==o&&(o in e?id(e[o])||e[o]instanceof String||id(n[o])||n[o]instanceof String?t&&(e[o]=n[o]):iA(e[o],n[o],t):e[o]=n[o]);return e};var iw={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let ik=e=>id(e)?e.replace(/[&<>"'\/]/g,e=>iw[e]):e,ix=[" ",",","?","!",";"],iC=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(void 0!==n)return n;let t=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,t),this.regExpQueue.push(e),t}}(20),iE=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let o=n.split(t),a=e;for(let e=0;e<o.length;){let n;if(!a||"object"!=typeof a)return;let r="";for(let i=e;i<o.length;++i)if(i!==e&&(r+=t),r+=o[i],void 0!==(n=a[r])){if(["string","number","boolean"].indexOf(typeof n)>-1&&i<o.length-1)continue;e+=i-e+1;break}a=n}return a},iS=e=>e?.replace("_","-"),iD={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,n){console?.[e]?.apply?.(console,n)}};class iz{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||iD,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,t,o){return o&&!this.debug?null:(id(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new iz(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new iz(this.logger,e)}}var iM=new iz;class iP{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let t=this.observers[e].get(n)||0;this.observers[e].set(n,t+1)}),this}off(e,n){if(this.observers[e]){if(!n)return void delete this.observers[e];this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,t])=>{for(let o=0;o<t;o++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,o])=>{for(let a=0;a<o;a++)t.apply(t,[e,...n])})}}class iO extends iP{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,t,o={}){let a,r=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,i=void 0!==o.ignoreJSONStructure?o.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?a=e.split("."):(a=[e,n],t&&(Array.isArray(t)?a.push(...t):id(t)&&r?a.push(...t.split(r)):a.push(t)));let s=i$(this.data,a);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=a[0],n=a[1],t=a.slice(2).join(".")),!s&&i&&id(t))?iE(this.data?.[e]?.[n],t,r):s}addResource(e,n,t,o,a={silent:!1}){let r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=[e,n];t&&(i=i.concat(r?t.split(r):t)),e.indexOf(".")>-1&&(i=e.split("."),o=n,n=i[1]),this.addNamespaces(n),iv(this.data,i,o),a.silent||this.emit("added",e,n,t,o)}addResources(e,n,t,o={silent:!1}){for(let o in t)(id(t[o])||Array.isArray(t[o]))&&this.addResource(e,n,o,t[o],{silent:!0});o.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,o,a,r={silent:!1,skipCopy:!1}){let i=[e,n];e.indexOf(".")>-1&&(i=e.split("."),o=t,t=n,n=i[1]),this.addNamespaces(n);let s=i$(this.data,i)||{};r.skipCopy||(t=JSON.parse(JSON.stringify(t))),o?iA(s,t,a):s={...s,...t},iv(this.data,i,s),r.silent||this.emit("added",e,n,t)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return void 0!==this.getResource(e,n)}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(e=>n[e]&&Object.keys(n[e]).length>0)}toJSON(){return this.data}}var iT={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,o,a){return e.forEach(e=>{n=this.processors[e]?.process(n,t,o,a)??n}),n}};let iN=Symbol("i18next/PATH_KEY");function iI(e,n){let t,o,a,{[iN]:r}=e((o=[],(a=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===iN)?o:(o.push(n),(t=Proxy.revocable(e,a)).proxy),Proxy.revocable(Object.create(null),a).proxy));return r.join(n?.keySeparator??".")}let iB={},ij=e=>!id(e)&&"boolean"!=typeof e&&"number"!=typeof e;class iR extends iP{constructor(e,n={}){super(),((e,n,t)=>{e.forEach(e=>{n[e]&&(t[e]=n[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=iM.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let o=this.resolve(e,t);if(o?.res===void 0)return!1;let a=ij(o.res);return!1!==t.returnObjects||!a}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,a=n.ns||this.options.defaultNS||[],r=t&&e.indexOf(t)>-1,i=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let o=ix.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===o.length)return!0;let a=iC.getRegExp(`(${o.map(e=>"?"===e?"\\?":e).join("|")})`),r=!a.test(e);if(!r){let n=e.indexOf(t);n>0&&!a.test(e.substring(0,n))&&(r=!0)}return r})(e,t,o);if(r&&!i){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:id(a)?[a]:a};let r=e.split(t);(t!==o||t===o&&this.options.ns.indexOf(r[0])>-1)&&(a=r.shift()),e=r.join(o)}return{key:e,namespaces:id(a)?[a]:a}}translate(e,n,t){let o="object"==typeof n?{...n}:n;if("object"!=typeof o&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof o&&(o={...o}),o||(o={}),null==e)return"";"function"==typeof e&&(e=iI(e,{...this.options,...o})),Array.isArray(e)||(e=[String(e)]);let a=void 0!==o.returnDetails?o.returnDetails:this.options.returnDetails,r=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],o),l=s[s.length-1],c=void 0!==o.nsSeparator?o.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let p=o.lng||this.language,u=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return u?a?{res:`${l}${c}${i}`,usedKey:i,exactUsedKey:i,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:`${l}${c}${i}`:a?{res:i,usedKey:i,exactUsedKey:i,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:i;let d=this.resolve(e,o),f=d?.res,h=d?.usedKey||i,m=d?.exactUsedKey||i,g=void 0!==o.joinArrays?o.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,y=void 0!==o.count&&!id(o.count),v=iR.hasDefaultValue(o),$=y?this.pluralResolver.getSuffix(p,o.count,o):"",A=o.ordinal&&y?this.pluralResolver.getSuffix(p,o.count,{ordinal:!1}):"",w=y&&!o.ordinal&&0===o.count,k=w&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${$}`]||o[`defaultValue${A}`]||o.defaultValue,x=f;b&&!f&&v&&(x=k);let C=ij(x),E=Object.prototype.toString.apply(x);if(b&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(id(g)&&Array.isArray(x))){if(!o.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,x,{...o,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return a?(d.res=e,d.usedParams=this.getUsedParamsDetails(o),d):e}if(r){let e=Array.isArray(x),n=e?[]:{},t=e?m:h;for(let e in x)if(Object.prototype.hasOwnProperty.call(x,e)){let a=`${t}${r}${e}`;v&&!f?n[e]=this.translate(a,{...o,defaultValue:ij(k)?k[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(a,{...o,joinArrays:!1,ns:s}),n[e]===a&&(n[e]=x[e])}f=n}}else if(b&&id(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,o,t));else{let n=!1,a=!1;!this.isValidLookup(f)&&v&&(n=!0,f=k),this.isValidLookup(f)||(a=!0,f=i);let s=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:f,u=v&&k!==f&&this.options.updateMissing;if(a||n||u){if(this.logger.log(u?"updateKey":"missingKey",p,l,i,u?k:f),r){let e=this.resolve(i,{...o,keySeparator:!1});e&&e.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.")}let e=[],n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if("fallback"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t<n.length;t++)e.push(n[t]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(o.lng||this.language):e.push(o.lng||this.language);let t=(e,n,t)=>{let a=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,a,u,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,a,u,o),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&y?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,o);w&&o[`defaultValue${this.options.pluralSeparator}zero`]&&0>n.indexOf(`${this.options.pluralSeparator}zero`)&&n.push(`${this.options.pluralSeparator}zero`),n.forEach(n=>{t([e],i+n,o[`defaultValue${n}`]||k)})}):t(e,i,k))}f=this.extendTranslation(f,e,o,d,t),a&&f===i&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${i}`),(a||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${i}`:i,n?f:void 0,o))}return a?(d.res=f,d.usedParams=this.getUsedParamsDetails(o),d):f}extendTranslation(e,n,t,o,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!t.skipInterpolation){let r;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let i=id(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let n=e.match(this.interpolator.nestingRegexp);r=n&&n.length}let s=t.replace&&!id(t.replace)?t.replace:t;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,t.lng||this.language||o.usedLng,t),i){let n=e.match(this.interpolator.nestingRegexp);r<(n&&n.length)&&(t.nest=!1)}!t.lng&&o&&o.res&&(t.lng=this.language||o.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>a?.[0]!==e[0]||t.context?this.translate(...e,n):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null),t)),t.interpolation&&this.interpolator.reset()}let r=t.postProcess||this.options.postProcess,i=id(r)?[r]:r;return null!=e&&i?.length&&!1!==t.applyPostProcessor&&(e=iT.handle(i,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,o,a,r,i;return id(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;o=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let p=void 0!==n.count&&!id(n.count),u=p&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(id(n.context)||"number"==typeof n.context)&&""!==n.context,f=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(e=>{this.isValidLookup(t)||(i=e,!iB[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(iB[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${o}" for languages "${f.join(", ")}" won't get resolved as namespace "${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!!!")),f.forEach(o=>{let i;if(this.isValidLookup(t))return;r=o;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,o,e,n);else{let e;p&&(e=this.pluralResolver.getSuffix(o,n.count,n));let t=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&0===e.indexOf(a)&&s.push(l+e.replace(a,this.options.pluralSeparator)),s.push(l+e),u&&s.push(l+t)),d){let o=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(o),p&&(n.ordinal&&0===e.indexOf(a)&&s.push(o+e.replace(a,this.options.pluralSeparator)),s.push(o+e),u&&s.push(o+t))}}for(;i=s.pop();)this.isValidLookup(t)||(a=i,t=this.getResource(o,e,i,n))}))})}),{res:t,usedKey:o,exactUsedKey:a,usedLng:r,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,o={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,o):this.resourceStore.getResource(e,n,t,o)}getUsedParamsDetails(e={}){let n=e.replace&&!id(e.replace),t=n?e.replace:e;if(n&&void 0!==e.count&&(t.count=e.count),this.options.interpolation.defaultVariables&&(t={...this.options.interpolation.defaultVariables,...t}),!n)for(let e of(t={...t},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete t[e];return t}static hasDefaultValue(e){let n="defaultValue";for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n===t.substring(0,n.length)&&void 0!==e[t])return!0;return!1}}class iF{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=iM.create("languageUtils")}getScriptPartFromCode(e){if(!(e=iS(e))||0>e.indexOf("-"))return null;let n=e.split("-");return 2===n.length||(n.pop(),"x"===n[n.length-1].toLowerCase())?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(!(e=iS(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(id(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch(e){}return(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)?n:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let n;return e?(e.forEach(e=>{if(n)return;let t=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(t))&&(n=t)}),!n&&this.options.supportedLngs&&e.forEach(e=>{if(n)return;let t=this.getScriptPartFromCode(e);if(this.isSupportedCode(t))return n=t;let o=this.getLanguagePartFromCode(e);if(this.isSupportedCode(o))return n=o;n=this.options.supportedLngs.find(e=>{if(e===o||!(0>e.indexOf("-")&&0>o.indexOf("-"))&&(e.indexOf("-")>0&&0>o.indexOf("-")&&e.substring(0,e.indexOf("-"))===o||0===e.indexOf(o)&&o.length>1))return e})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n):null}getFallbackCodes(e,n){if(!e)return[];if("function"==typeof e&&(e=e(n)),id(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let t=e[n];return t||(t=e[this.getScriptPartFromCode(n)]),t||(t=e[this.formatLanguageCode(n)]),t||(t=e[this.getLanguagePartFromCode(n)]),t||(t=e.default),t||[]}toResolveHierarchy(e,n){let t=this.getFallbackCodes((!1===n?[]:n)||this.options.fallbackLng||[],e),o=[],a=e=>{e&&(this.isSupportedCode(e)?o.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return id(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):id(e)&&a(this.formatLanguageCode(e)),t.forEach(e=>{0>o.indexOf(e)&&a(this.formatLanguageCode(e))}),o}}let iL={zero:0,one:1,two:2,few:3,many:4,other:5},iW={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class iV{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=iM.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,o=iS("dev"===e?"en":e),a=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:o,type:a});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];try{t=new Intl.PluralRules(o,{type:a})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),iW;if(!e.match(/-|_/))return iW;let o=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(o,n)}return this.pluralRulesCache[r]=t,t}needsPlural(e,n={}){let t=this.getRule(e,n);return t||(t=this.getRule("dev",n)),t?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,t={}){return this.getSuffixes(e,t).map(e=>`${n}${e}`)}getSuffixes(e,n={}){let t=this.getRule(e,n);return(t||(t=this.getRule("dev",n)),t)?t.resolvedOptions().pluralCategories.sort((e,n)=>iL[e]-iL[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let o=this.getRule(e,t);return o?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${o.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let iG=(e,n,t,o=".",a=!0)=>{let r,i=void 0!==(r=i$(e,t))?r:i$(n,t);return!i&&a&&id(t)&&void 0===(i=iE(e,t,o))&&(i=iE(n,t,o)),i};class iU{constructor(e={}){this.logger=iM.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:n,escapeValue:t,useRawValueToEscape:o,prefix:a,prefixEscaped:r,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:p,nestingPrefix:u,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:g,alwaysFormat:b}=e.interpolation;this.escape=void 0!==n?n:ik,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==o&&o,this.prefix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):r||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=u?u.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==b&&b,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,n)=>e?.source===n?(e.lastIndex=0,e):RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,t,o){let a,r,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let a=iG(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,t,{...o,...n,interpolationkey:e}):a}let a=e.split(this.formatSeparator),r=a.shift().trim(),i=a.join(this.formatSeparator).trim();return this.format(iG(n,s,r,this.options.keySeparator,this.options.ignoreJSONStructure),i,t,{...o,...n,interpolationkey:r})};this.resetRegExp();let c=o?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(n=>{for(i=0;a=n.regex.exec(e);){let t=a[1].trim();if(void 0===(r=l(t)))if("function"==typeof c){let n=c(e,a,o);r=id(n)?n:""}else if(o&&Object.prototype.hasOwnProperty.call(o,t))r="";else if(p){r=a[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),r="";else id(r)||this.useRawValueToEscape||(r=im(r));let s=n.safeValue(r);if(e=e.replace(a[0],s),p?(n.regex.lastIndex+=r.length,n.regex.lastIndex-=a[0].length):n.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,n,t={}){let o,a,r,i=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let o=e.split(RegExp(`${t}[ ]*{`)),a=`{${o[1]}`;e=o[0];let i=(a=this.interpolate(a,r)).match(/'/g),s=a.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(a=a.replace(/'/g,'"'));try{r=JSON.parse(a),n&&(r={...n,...r})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${a}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,e};for(;o=this.nestingRegexp.exec(e);){let s=[];(r=(r={...t}).replace&&!id(r.replace)?r.replace:r).applyPostProcessor=!1,delete r.defaultValue;let l=/{.*}/.test(o[1])?o[1].lastIndexOf("}")+1:o[1].indexOf(this.formatSeparator);if(-1!==l&&(s=o[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),o[1]=o[1].slice(0,l)),(a=n(i.call(this,o[1].trim(),r),r))&&o[0]===e&&!id(a))return a;id(a)||(a=im(a)),a||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${e}`),a=""),s.length&&(a=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:o[1].trim()}),a.trim())),e=e.replace(o[0],a),this.regexp.lastIndex=0}return e}}let iq=e=>{let n={};return(t,o,a)=>{let r=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(r={...r,[a.interpolationkey]:void 0});let i=o+JSON.stringify(r),s=n[i];return s||(s=e(iS(o),a),n[i]=s),s(t)}},iH=e=>(n,t,o)=>e(iS(t),o)(n);class iK{constructor(e={}){this.logger=iM.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?iq:iH;this.formats={number:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n});return e=>t.format(e)}),currency:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n,style:"currency"});return e=>t.format(e)}),datetime:t((e,n)=>{let t=new Intl.DateTimeFormat(e,{...n});return e=>t.format(e)}),relativetime:t((e,n)=>{let t=new Intl.RelativeTimeFormat(e,{...n});return e=>t.format(e,n.range||"day")}),list:t((e,n)=>{let t=new Intl.ListFormat(e,{...n});return e=>t.format(e)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=iq(n)}format(e,n,t,o={}){let a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&0>a[0].indexOf(")")&&a.find(e=>e.indexOf(")")>-1)){let e=a.findIndex(e=>e.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,e)].join(this.formatSeparator)}return a.reduce((e,n)=>{let{formatName:a,formatOptions:r}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let o=e.split("(");n=o[0].toLowerCase().trim();let a=o[1].substring(0,o[1].length-1);"currency"===n&&0>a.indexOf(":")?t.currency||(t.currency=a.trim()):"relativetime"===n&&0>a.indexOf(":")?t.range||(t.range=a.trim()):a.split(";").forEach(e=>{if(e){let[n,...o]=e.split(":"),a=o.join(":").trim().replace(/^'+|'+$/g,""),r=n.trim();t[r]||(t[r]=a),"false"===a&&(t[r]=!1),"true"===a&&(t[r]=!0),isNaN(a)||(t[r]=parseInt(a,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[a]){let n=e;try{let i=o?.formatParams?.[o.interpolationkey]||{},s=i.locale||i.lng||o.locale||o.lng||t;n=this.formats[a](e,s,{...r,...o,...i})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${a}`),e},e)}}class iY extends iP{constructor(e,n,t,o={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=o,this.logger=iM.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=o.maxParallelReads||10,this.readingCalls=0,this.maxRetries=o.maxRetries>=0?o.maxRetries:5,this.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,o.backend,o)}queueLoad(e,n,t,o){let a={},r={},i={},s={};return e.forEach(e=>{let o=!0;n.forEach(n=>{let i=`${e}|${n}`;!t.reload&&this.store.hasResourceBundle(e,n)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===r[i]&&(r[i]=!0):(this.state[i]=1,o=!1,void 0===r[i]&&(r[i]=!0),void 0===a[i]&&(a[i]=!0),void 0===s[n]&&(s[n]=!0)))}),o||(i[e]=!0)}),(Object.keys(a).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:o}),{toLoad:Object.keys(a),pending:Object.keys(r),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let o=e.split("|"),a=o[0],r=o[1];n&&this.emit("failedLoading",a,r,n),!n&&t&&this.store.addResourceBundle(a,r,t,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&t&&(this.state[e]=0);let i={};this.queue.forEach(t=>{((e,n,t,o)=>{let{obj:a,k:r}=i_(e,n,Object);a[r]=a[r]||[],a[r].push(t)})(t.loaded,[a],r),void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--),n&&t.errors.push(n),0!==t.pendingCount||t.done||(Object.keys(t.loaded).forEach(e=>{i[e]||(i[e]={});let n=t.loaded[e];n.length&&n.forEach(n=>{void 0===i[e][n]&&(i[e][n]=!0)})}),t.done=!0,t.errors.length?t.callback(t.errors):t.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,n,t,o=0,a=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:o,wait:a,callback:r});this.readingCalls++;let i=(i,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}i&&s&&o<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,o+1,2*a,r)},a):r(i,s)},s=this.backend[t].bind(this.backend);if(2===s.length){try{let t=s(e,n);t&&"function"==typeof t.then?t.then(e=>i(null,e)).catch(i):i(null,t)}catch(e){i(e)}return}return s(e,n,i)}prepareLoading(e,n,t={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();id(e)&&(e=this.languageUtils.toResolveHierarchy(e)),id(n)&&(n=[n]);let a=this.queueLoad(e,n,t,o);if(!a.toLoad.length)return a.pending.length||o(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,n,t){this.prepareLoading(e,n,{},t)}reload(e,n,t){this.prepareLoading(e,n,{reload:!0},t)}loadOne(e,n=""){let t=e.split("|"),o=t[0],a=t[1];this.read(o,a,"read",void 0,void 0,(t,r)=>{t&&this.logger.warn(`${n}loading namespace ${a} for language ${o} failed`,t),!t&&r&&this.logger.log(`${n}loaded namespace ${a} for language ${o}`,r),this.loaded(e,t,r)})}saveMissing(e,n,t,o,a,r={},i=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n))return void this.logger.warn(`did not save key "${t}" as the namespace "${n}" 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!!!");if(null!=t&&""!==t){if(this.backend?.create){let s={...r,isUpdate:a},l=this.backend.create.bind(this.backend);if(l.length<6)try{let a;(a=5===l.length?l(e,n,t,o,s):l(e,n,t,o))&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(e){i(e)}else l(e,n,t,o,i,s)}e&&e[0]&&this.store.addResource(e[0],n,t,o)}}}let iZ=()=>({debug:!1,initAsync:!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:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let n={};if("object"==typeof e[1]&&(n=e[1]),id(e[1])&&(n.defaultValue=e[1]),id(e[2])&&(n.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let t=e[3]||e[2];Object.keys(t).forEach(e=>{n[e]=t[e]})}return n},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),iJ=e=>(id(e.ns)&&(e.ns=[e.ns]),id(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),id(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),iX=()=>{};class iQ extends iP{constructor(e={},n){if(super(),this.options=iJ(e),this.services={},this.logger=iM,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{"function"==typeof e[n]&&(e[n]=e[n].bind(e))})})(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,"function"==typeof e&&(n=e,e={}),null==e.defaultNS&&e.ns&&(id(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=iZ();this.options={...t,...this.options,...iJ(e)},this.options.interpolation={...t.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let o=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?iM.init(o(this.modules.logger),this.options):iM.init(null,this.options),e=this.modules.formatter?this.modules.formatter:iK;let n=new iF(this.options);this.store=new iO(this.options.resources,this.options);let a=this.services;a.logger=iM,a.resourceStore=this.store,a.languageUtils=n,a.pluralResolver=new iV(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==t.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===t.interpolation.format)&&(a.formatter=o(e),a.formatter.init&&a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new iU(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new iY(o(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(a.languageDetector=o(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=o(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new iR(this.services,this.options),this.translator.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||(n=iX),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[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(e=>{this[e]=(...n)=>this.store[e](...n)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...n)=>(this.store[e](...n),this)});let a=ih(),r=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(t),n(e,t)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?r():setTimeout(r,0),a}loadResources(e,n=iX){let t=n,o=id(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(o?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return t();let e=[],n=n=>{n&&"cimode"!==n&&this.services.languageUtils.toResolveHierarchy(n).forEach(n=>{"cimode"!==n&&0>e.indexOf(n)&&e.push(n)})};o?n(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>n(e)),this.options.preload?.forEach?.(e=>n(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,n,t){let o=ih();return"function"==typeof e&&(t=e,e=void 0),"function"==typeof n&&(t=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),t||(t=iX),this.services.backendConnector.reload(e,n,e=>{o.resolve(),t(e)}),o}use(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&&iT.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let n=this.languages[e];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;let t=ih();this.emit("languageChanging",e);let o=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(a,r)=>{r?this.isLanguageChangingTo===e&&(o(r),this.translator.changeLanguage(r),this.isLanguageChangingTo=void 0,this.emit("languageChanged",r),this.logger.log("languageChanged",r)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(a,(...e)=>this.t(...e))},r=n=>{e||n||!this.services.languageDetector||(n=[]);let t=id(n)?n:n&&n[0],r=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(id(n)?[n]:n);r&&(this.language||o(r),this.translator.language||this.translator.changeLanguage(r),this.services.languageDetector?.cacheUserLanguage?.(r)),this.loadResources(r,e=>{a(e,r)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e):r(this.services.languageDetector.detect()),t}getFixedT(e,n,t){let o=(e,n,...a)=>{let r,i;(r="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(a)):{...n}).lng=r.lng||o.lng,r.lngs=r.lngs||o.lngs,r.ns=r.ns||o.ns,""!==r.keyPrefix&&(r.keyPrefix=r.keyPrefix||t||o.keyPrefix);let s=this.options.keySeparator||".";return r.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=iI(e,{...this.options,...n})),`${r.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=iI(e,{...this.options,...n})),i=r.keyPrefix?`${r.keyPrefix}${s}${e}`:e),this.t(i,r)};return id(e)?o.lng=e:o.lngs=e,o.ns=n,o.keyPrefix=t,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){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;let t=n.lng||this.resolvedLanguage||this.languages[0],o=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let r=(e,n)=>{let t=this.services.backendConnector.state[`${e}|${n}`];return -1===t||0===t||2===t};if(n.precheck){let e=n.precheck(this,r);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(t,e)&&(!o||r(a,e)))}loadNamespaces(e,n){let t=ih();return this.options.ns?(id(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}loadLanguages(e,n){let t=ih();id(e)&&(e=[e]);let o=this.options.preload||[],a=e.filter(e=>0>o.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=o.concat(a),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let n=new Intl.Locale(e);if(n&&n.getTextInfo){let e=n.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let n=this.services?.languageUtils||new iF(iZ());return e.toLowerCase().indexOf("-latn")>1?"ltr":["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(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){return new iQ(e,n)}cloneInstance(e={},n=iX){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let o={...this.options,...e,isClone:!0},a=new iQ(o);return(void 0!==e.debug||void 0!==e.prefix)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},t&&(a.store=new iO(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,o)=>(t[o]={...e[n][o]},t),e[n]),e),{}),o),a.services.resourceStore=a.store),a.translator=new iR(a.services,o),a.translator.on("*",(e,...n)=>{a.emit(e,...n)}),a.init(o,n),a.translator.options=o,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let i0=iQ.createInstance();i0.createInstance=iQ.createInstance,i0.createInstance,i0.dir,i0.init,i0.loadResources,i0.reloadResources,i0.use,i0.changeLanguage,i0.getFixedT,i0.t,i0.exists,i0.setDefaultNamespace,i0.hasLoadedNamespace,i0.loadNamespaces,i0.loadLanguages;let i1=i0.default||i0;function i2(e,n,t,o){return i1.t(n,{ns:e,defaultValue:t,...o})}function i3(e,n,t){return iu[e]?i2("core",e,n??iu[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}i1.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let i5="import-map-override:",i4="import-map-overrides-disabled",i6="import-map-overrides:change",i7=!1,i8=null;async function i9(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let o=e[t];try{if(o.src){let e=await fetch(o.src);n.push(await e.json())}else o.textContent&&n.push(JSON.parse(o.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return se(n)}function se(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function sn(){let e={};try{let n=si();for(let t=0;t<localStorage.length;t++){let o=localStorage.key(t);if(o?.startsWith(i5)){let t=o.slice(i5.length);if(!n.includes(t)){let n=localStorage.getItem(o);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function st(){let e=await i9();return i7?se([e,i8??sn()]):e}async function so(){return i9()}async function sa(){return i7?se([await i9(),sn()]):i9()}function sr(e){if(!i7)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(i5)){let n=localStorage.getItem(t);n&&(e[t.slice(i5.length)]=n)}}return{imports:e}}return sn()}function si(){if(!i7)return[];try{let e=localStorage.getItem(i4);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function ss(e){return!!i7&&si().includes(e)}function sl(e,n){if(!i7)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(i5+e,n),window.dispatchEvent(new CustomEvent(i6))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sc(e){if(!i7)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(i5+e);let n=si().filter(n=>n!==e);n.length>0?localStorage.setItem(i4,JSON.stringify(n)):localStorage.removeItem(i4),window.dispatchEvent(new CustomEvent(i6))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sp(){if(!i7)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(i5)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(i4),window.dispatchEvent(new CustomEvent(i6))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function su(e){if(!i7)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=si().filter(n=>n!==e);n.length>0?localStorage.setItem(i4,JSON.stringify(n)):localStorage.removeItem(i4),window.dispatchEvent(new CustomEvent(i6))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let sd=!1;function sf(){!sd&&(sd=!0,(i7="development"===window.spaEnv)&&(i8=sn()))}function sh(e){return e.replace(/[\/\-@]/g,"_")}async function sm(e,n="./start",o){var a;let r,i=!o?.maxLoadingTime||o.maxLoadingTime<=0?6e5:o.maxLoadingTime;await Promise.race([sg(e,o?.importMap),new Promise((n,t)=>{r=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=i)<1e3?`${n} milliseconds`:n<6e4?`${Math.floor(n/1e3)} seconds`:n<36e5?`${Math.floor(n/6e4)} minutes`:n<864e5?`${Math.floor(n/36e5)} hours`:`${Math.floor(n/864e5)} days`}.`))},i)})]),r&&clearTimeout(r);let s=sh(e),l=window[s];if(!("object"==typeof(a=l)&&null!==a&&"init"in a&&"function"==typeof a.init&&"get"in a&&"function"==typeof a.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(t.S.default);let c=(await l.get(n))();if("object"!=typeof c||null===c){let n=`Container for ${e} did not return an ESM module as expected`;throw console.error(n),Error(n)}return c}async function sg(e,n){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 t=sh(e);if(!window[t]){let t=n??await sb();if(!t.imports.hasOwnProperty(e)){let n=`Could not find the package ${e} defined in the current importmap`;throw console.error(n),Error(n)}let o=t.imports[e];o.startsWith("./")&&(o=window.spaBase+o.substring(1));let a=e in sr().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let o=document.head.querySelector(`script[src="${e}"]`),a=window[sy];if(a||(a=window[sy]=new Set([])),o)if(a.has(e)){let e,a,r;r=()=>{e&&o.removeEventListener("load",e),a&&o.removeEventListener("error",a)},e=()=>{r(),n(null)},a=e=>{r(),t(e.message)},o.addEventListener("load",e),o.addEventListener("error",a)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(null);else{let o,r,i;a.add(e);let s=document.createElement("script");s.src=e,s.type="text/javascript",s.async=!0;let l=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);i=()=>{clearTimeout(l),a.delete(e),o&&s.removeEventListener("load",o),r&&s.removeEventListener("error",r)},o=()=>{i(),n(null)},r=n=>{i();let o=`Failed to load script from ${e}`;console.error(o,n),t(n.message??o)},s.addEventListener("load",o),s.addEventListener("error",r),document.head.appendChild(s)}}(o,e,n)})}catch(e){return a&&D({kind:"error",title:i3("scriptLoadingFailed","Error: Script failed to load"),description:i3("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:o}),actionButtonLabel:i3("resetOverrides","Reset overrides"),onActionButtonClick(){sp(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function sb(){return st()}let sy=Symbol("__openmrs_script_loading");function s_(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 sv(e){return!!e&&"object"==typeof e&&Object.entries(e).every(([e,n])=>"string"==typeof e&&s_(n))}let s$="openmrs-routes:",sA="openmrs-routes:change",sw=!1,sk=null;async function sx(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[];for(let t=0;t<e.length;t++){let o=e[t];try{let e;if(o.src){let n=await fetch(o.src);e=await n.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&sv(e)&&n.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${t}`,e)}}return sC(n)}function sC(e){let n={};for(let t of e)t&&"object"==typeof t&&Object.assign(n,t);return n}async function sE(){let e={};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(s$)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(s$.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(s_(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),o=await n.json();if(s_(o))return{moduleName:e,routes:o};throw Error(`${t} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===t.status?e[t.value.moduleName]=t.value.routes:console.warn("[route-maps] Failed to load route override",t.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function sS(){let e=await sx();return sw?sC([e,sk??await sE()]):e}async function sD(){return sx()}async function sz(){return sw?sC([await sx(),await sE()]):sx()}function sM(){if(!sw)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(s$)){let n=localStorage.getItem(t);n&&(e[t.slice(s$.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function sP(e,n){if(!sw)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(s$+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!s_(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(s$+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(s$+e,JSON.stringify(n.toString()));else{if(!s_(n))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`,n);localStorage.setItem(s$+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(sA))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function sO(e){if(!sw)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(s$+e),window.dispatchEvent(new CustomEvent(sA))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function sT(){if(!sw)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(s$)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sA))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let sN=null;function sI(){return sN||(sN=(sw="development"===window.spaEnv)?sE().then(e=>{sk=e}):Promise.resolve())}let sB=`${rJ}/attachment`;function sj(e,n){return r1(`${sB}/${e}`,{signal:n.signal})}function sR(e,n,t){return r1(`${sB}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function sF(e,n){let t=new FormData;return t.append("fileCaption",n.fileDescription),t.append("patient",e),n.file?t.append("file",n.file,n.fileName):(t.append("file",new File([""],n.fileName),n.fileName),t.append("base64Content",n.base64Content)),r1(`${sB}`,{method:"POST",body:t})}function sL(e,n){return r1(`${sB}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function sW(e,n){return new Promise(function(t){var o=new MessageChannel;o.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[o.port2])})}function sV(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function sG(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,o=Array(n);t<n;t++)o[t]=e[t];return o}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var sU=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function sq(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var sH=function(e,n){this.type=e,Object.assign(this,n)};function sK(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function sY(){}var sZ={type:"SKIP_WAITING"};function sJ(e,n){if(!n)return e&&e.then?e.then(sY):Promise.resolve()}var sX=function(e){function n(n,t){var o,a;return void 0===t&&(t={}),(o=e.call(this)||this).nn={},o.tn=0,o.rn=new sU,o.en=new sU,o.on=new sU,o.un=0,o.an=new Set,o.cn=function(){var e=o.fn,n=e.installing;o.tn>0||!sq(n.scriptURL,o.sn.toString())||performance.now()>o.un+6e4?(o.vn=n,e.removeEventListener("updatefound",o.cn)):(o.hn=n,o.an.add(n),o.rn.resolve(n)),++o.tn,n.addEventListener("statechange",o.ln)},o.ln=function(e){var n=o.fn,t=e.target,a=t.state,r=t===o.vn,i={sw:t,isExternal:r,originalEvent:e};!r&&o.mn&&(i.isUpdate=!0),o.dispatchEvent(new sH(a,i)),"installed"===a?o.wn=self.setTimeout(function(){"installed"===a&&n.waiting===t&&o.dispatchEvent(new sH("waiting",i))},200):"activating"===a&&(clearTimeout(o.wn),r||o.en.resolve(t))},o.dn=function(e){var n=o.hn,t=n!==navigator.serviceWorker.controller;o.dispatchEvent(new sH("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:o.mn})),t||o.on.resolve(n)},a=function(e){var n=e.data,t=e.ports,a=e.source;return sK(o.getSW(),function(){o.an.has(a)&&o.dispatchEvent(new sH("message",{data:n,originalEvent:e,ports:t,sw:a}))})},o.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(a.apply(this,e))}catch(e){return Promise.reject(e)}},o.sn=n,o.nn=t,navigator.serviceWorker.addEventListener("message",o.gn),o}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,o,a=n.prototype;return a.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var o,a,r,i=this;return o=function(){if(!t&&"complete"!==document.readyState)return sJ(new Promise(function(e){return window.addEventListener("load",e)}))},a=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),sK(i.bn(),function(e){i.fn=e,i.yn&&(i.hn=i.yn,i.en.resolve(i.yn),i.on.resolve(i.yn),i.yn.addEventListener("statechange",i.ln,{once:!0}));var n=i.fn.waiting;return n&&sq(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new sH("waiting",{sw:n,wasWaitingBeforeRegister:!0}))}).then(function(){})),i.hn&&(i.rn.resolve(i.hn),i.an.add(i.hn)),i.fn.addEventListener("updatefound",i.cn),navigator.serviceWorker.addEventListener("controllerchange",i.dn),i.fn})},(r=o())&&r.then?r.then(a):a(r)}catch(e){return Promise.reject(e)}},a.update=function(){try{return this.fn?sJ(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},a.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},a.messageSW=function(e){try{return sK(this.getSW(),function(n){return sW(n,e)})}catch(e){return Promise.reject(e)}},a.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&sW(this.fn.waiting,sZ)},a.pn=function(){var e=navigator.serviceWorker.controller;return e&&sq(e.scriptURL,this.sn.toString())?e:void 0},a.bn=function(){try{var e=this;return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return sK(navigator.serviceWorker.register(e.sn,e.nn),function(n){return e.un=performance.now(),n})},function(e){throw e})}catch(e){return Promise.reject(e)}},t=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],sV(n.prototype,t),o&&sV(n,o),n}(function(){function e(){this.Pn=new Map}var n=e.prototype;return n.addEventListener=function(e,n){this.Sn(e).add(n)},n.removeEventListener=function(e,n){this.Sn(e).delete(n)},n.dispatchEvent=function(e){e.target=this;for(var n,t=function(e){var n;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return sG(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sG(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(this.Sn(e.type));!(n=t()).done;)(0,n.value)(e)},n.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function sQ(e,n){if(void 0!==u)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),u;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new sX(e,n);return u=t.register().then(()=>t.controlling.then(()=>t))}function s0(){return u??Promise.resolve(void 0)}let s1="x-omrs-offline-response-body",s2="x-omrs-offline-response-status",s3="x-omrs-offline-caching-strategy";async function s5(e){let n=await s0();return n?await n.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 s4(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(n){if(n.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function s6(){return!window.indexedDB}async function s7(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function s8(){return await s7()||await s6()||await s4()}let s9="openmrs3:offline-mode",le="unavailable";function ln(){return{current:le,notAvailable:"unavailable"===le,active:"on"===le}}function lt(e){"unavailable"!==le&&"unavailable"!==e&&(localStorage.setItem(s9,"on"===e?"active":"disabled"),le=e)}async function lo(){await s8()||(le="active"===localStorage.getItem(s9)?"on":"off"),navigator.onLine}let la="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,lr=Object.keys,li=Array.isArray;function ls(e,n){return"object"!=typeof n||lr(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||la.Promise||(la.Promise=Promise);let ll=Object.getPrototypeOf,lc={}.hasOwnProperty;function lp(e,n){return lc.call(e,n)}function lu(e,n){"function"==typeof n&&(n=n(ll(e))),("u"<typeof Reflect?lr:Reflect.ownKeys)(n).forEach(t=>{lf(e,t,n[t])})}let ld=Object.defineProperty;function lf(e,n,t,o){ld(e,n,ls(t&&lp(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},o))}function lh(e){return{from:function(n){return e.prototype=Object.create(n.prototype),lf(e.prototype,"constructor",e),{extend:lu.bind(null,e.prototype)}}}}let lm=Object.getOwnPropertyDescriptor;function lg(e,n){let t;return lm(e,n)||(t=ll(e))&&lg(t,n)}let lb=[].slice;function ly(e,n,t){return lb.call(e,n,t)}function l_(e,n){return n(e)}function lv(e){if(!e)throw Error("Assertion Failed")}function l$(e){la.setImmediate?setImmediate(e):setTimeout(e,0)}function lA(e,n){return e.reduce((e,t,o)=>{var a=n(t,o);return a&&(e[a[0]]=a[1]),e},{})}function lw(e,n){if(lp(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],o=0,a=n.length;o<a;++o){var r=lw(e,n[o]);t.push(r)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return void 0===s?void 0:lw(s,n.substr(i+1))}}function lk(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){lv("string"!=typeof t&&"length"in t);for(var o=0,a=n.length;o<a;++o)lk(e,n[o],t[o])}else{var r=n.indexOf(".");if(-1!==r){var i=n.substr(0,r),s=n.substr(r+1);if(""===s)void 0===t?li(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&lp(e,i)||(l=e[i]={}),lk(l,s,t)}}else void 0===t?li(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function lx(e){var n={};for(var t in e)lp(e,t)&&(n[t]=e[t]);return n}let lC=[].concat;function lE(e){return lC.apply([],e)}let lS="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(lE([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>la[e]),lD=lS.map(e=>la[e]);lA(lS,e=>[e,!0]);let lz=null;function lM(e){lz="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=lz&&lz.get(n);if(t)return t;if(li(n)){t=[],lz&&lz.set(n,t);for(var o=0,a=n.length;o<a;++o)t.push(e(n[o]))}else if(lD.indexOf(n.constructor)>=0)t=n;else{let o=ll(n);for(var r in t=o===Object.prototype?{}:Object.create(o),lz&&lz.set(n,t),n)lp(n,r)&&(t[r]=e(n[r]))}return t}(e);return lz=null,n}let{toString:lP}={};function lO(e){return lP.call(e).slice(8,-1)}let lT="u">typeof Symbol?Symbol.iterator:"@@iterator",lN="symbol"==typeof lT?function(e){var n;return null!=e&&(n=e[lT])&&n.apply(e)}:function(){return null},lI={};function lB(e){var n,t,o,a;if(1==arguments.length){if(li(e))return e.slice();if(this===lI&&"string"==typeof e)return[e];if(a=lN(e)){for(t=[];!(o=a.next()).done;)t.push(o.value);return t}if(null==e)return[e];if("number"==typeof(n=e.length)){for(t=Array(n);n--;)t[n]=e[n];return t}return[e]}for(n=arguments.length,t=Array(n);n--;)t[n]=arguments[n];return t}let lj="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var lR="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),lF=()=>!0;let lL=!Error("").stack;function lW(){if(lL)try{throw lW.arguments,Error()}catch(e){return e}return Error()}function lV(e,n){var t=e.stack;return t?(n=n||0,0===t.indexOf(e.name)&&(n+=(e.name+e.message).split("\n").length),t.split("\n").slice(n).filter(lF).map(e=>"\n"+e).join("")):""}var lG=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],lU=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(lG),lq={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 lH(e,n){this._e=lW(),this.name=e,this.message=n}function lK(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function lY(e,n,t,o){this._e=lW(),this.failures=n,this.failedKeys=o,this.successCount=t,this.message=lK(e,n)}function lZ(e,n){this._e=lW(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=lK(e,n)}lh(lH).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+lV(this._e,2))}},toString:function(){return this.name+": "+this.message}}),lh(lY).from(lH),lh(lZ).from(lH);var lJ=lU.reduce((e,n)=>(e[n]=n+"Error",e),{}),lX=lU.reduce((e,n)=>{var t=n+"Error";function o(e,o){this._e=lW(),this.name=t,e?"string"==typeof e?(this.message=`${e}${o?"\n "+o:""}`,this.inner=o||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=lq[n]||t,this.inner=null)}return lh(o).from(lH),e[n]=o,e},{});lX.Syntax=SyntaxError,lX.Type=TypeError,lX.Range=RangeError;var lQ=lG.reduce((e,n)=>(e[n+"Error"]=lX[n],e),{}),l0=lU.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=lX[n]),e),{});function l1(){}function l2(e){return e}function l3(e,n){return null==e||e===l2?n:function(t){return n(e(t))}}function l5(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function l4(e,n){return e===l1?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var o=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var r=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?l5(o,this.onsuccess):o),a&&(this.onerror=this.onerror?l5(a,this.onerror):a),void 0!==r?r:t}}function l6(e,n){return e===l1?n:function(){e.apply(this,arguments);var t=this.onsuccess,o=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?l5(t,this.onsuccess):t),o&&(this.onerror=this.onerror?l5(o,this.onerror):o)}}function l7(e,n){return e===l1?n:function(t){var o=e.apply(this,arguments);ls(t,o);var a=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?l5(a,this.onsuccess):a),r&&(this.onerror=this.onerror?l5(r,this.onerror):r),void 0===o?void 0===i?void 0:i:ls(o,i)}}function l8(e,n){return e===l1?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function l9(e,n){return e===l1?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var o=this,a=arguments.length,r=Array(a);a--;)r[a]=arguments[a];return t.then(function(){return n.apply(o,r)})}return n.apply(this,arguments)}}l0.ModifyError=lY,l0.DexieError=lH,l0.BulkError=lZ;var ce={};let[cn,ct,co]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,ll(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,ll(n),e]})(),ca=ct&&ct.then,cr=cn&&cn.constructor,ci=!!co;var cs=!1,cl=co?()=>{co.then(cD)}:la.setImmediate?setImmediate.bind(null,cD):la.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{cD(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(cD,0)},cc=function(e,n){cy.push([e,n]),cu&&(cl(),cu=!1)},cp=!0,cu=!0,cd=[],cf=[],ch=null,cm=l2,cg={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:cQ,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{cQ(e[0],e[1])}catch(e){}})}},cb=cg,cy=[],c_=0,cv=[];function c$(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=l1,this._lib=!1;var n=this._PSD=cb;if(lR&&(this._stackHolder=lW(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==ce)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&ck(this,this._value))}this._state=null,this._value=null,++n.ref,function e(n,t){try{t(t=>{if(null===n._state){if(t===n)throw TypeError("A promise cannot be resolved with itself.");var o=n._lib&&cz();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof c$?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,cx(n)),o&&cM()}},ck.bind(null,n))}catch(e){ck(n,e)}}(this,e)}let cA={get:function(){var e=cb,n=cR;function t(t,o){var a=!e.global&&(e!==cb||n!==cR);let r=a&&!cV();var i=new c$((n,i)=>{cC(this,new cw(cZ(t,e,a,r),cZ(o,e,a,r),n,i,e))});return lR&&cS(i,this),i}return t.prototype=ce,t},set:function(e){lf(this,"then",e&&e.prototype===ce?cA:{get:function(){return e},set:cA.set})}};function cw(e,n,t,o,a){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=o,this.psd=a}function ck(e,n){if(cf.push(n),null===e._state){var t=e._lib&&cz();n=cm(n),e._state=!1,e._value=n,lR&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=lg(n,"stack");n._promise=e,lf(n,"stack",{get:()=>cs?t&&(t.get?t.get.apply(n):t.value):e.stack})}),cd.some(n=>n._value===e._value)||cd.push(e),cx(e),t&&cM()}}function cx(e){var n=e._listeners;e._listeners=[];for(var t=0,o=n.length;t<o;++t)cC(e,n[t]);var a=e._PSD;--a.ref||a.finalize(),0===c_&&(++c_,cc(()=>{0==--c_&&cP()},[]))}function cC(e,n){if(null!==e._state){var t=e._state?n.onFulfilled:n.onRejected;if(null===t)return(e._state?n.resolve:n.reject)(e._value);++n.psd.ref,++c_,cc(cE,[t,e,n])}else e._listeners.push(n)}function cE(e,n,t){try{ch=n;var o,a=n._value;n._state?o=e(a):(cf.length&&(cf=[]),o=e(a),-1===cf.indexOf(a)&&function(e){for(var n=cd.length;n;)if(cd[--n]._value===e._value)return void cd.splice(n,1)}(n)),t.resolve(o)}catch(e){t.reject(e)}finally{ch=null,0==--c_&&cP(),--t.psd.ref||t.psd.finalize()}}function cS(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function cD(){cz()&&cM()}function cz(){var e=cp;return cp=!1,cu=!1,e}function cM(){var e,n,t;do for(;cy.length>0;)for(e=cy,cy=[],t=e.length,n=0;n<t;++n){var o=e[n];o[0].apply(null,o[1])}while(cy.length>0);cp=!0,cu=!0}function cP(){var e=cd;cd=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=cv.slice(0),t=n.length;t;)n[--t]()}function cO(e){return new c$(ce,!1,e)}function cT(e,n){var t=cb;return function(){var o=cz(),a=cb;try{return cH(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{cH(a,!1),o&&cM()}}}lu(c$.prototype,{then:cA,_then:function(e,n){cC(this,new cw(null,null,e,n,cb))},catch:function(e){if(1==arguments.length)return this.then(null,e);var n=arguments[0],t=arguments[1];return"function"==typeof n?this.then(null,e=>e instanceof n?t(e):cO(e)):this.then(null,e=>e&&e.name===n?t(e):cO(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),cO(n)))},stack:{get:function(){if(this._stack)return this._stack;try{cs=!0;var e=(function e(n,t,o){if(t.length===o)return t;var a="";if(!1===n._state){var r,i,s=n._value;null!=s?(r=s.name||"Error",i=s.message||s,a=lV(s,0)):(r=s,i=""),t.push(r+(i?": "+i:"")+a)}return lR&&((a=lV(n._stackHolder,2))&&-1===t.indexOf(a)&&t.push(a),n._prev&&e(n._prev,t,o)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{cs=!1}}},timeout:function(e,n){return e<1/0?new c$((t,o)=>{var a=setTimeout(()=>o(new lX.Timeout(n)),e);this.then(t,o).finally(clearTimeout.bind(null,a))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&lf(c$.prototype,Symbol.toStringTag,"Dexie.Promise"),cg.env=cK(),lu(c$,{all:function(){var e=lB.apply(null,arguments).map(cG);return new c$(function(n,t){0===e.length&&n([]);var o=e.length;e.forEach((a,r)=>c$.resolve(a).then(t=>{e[r]=t,--o||n(e)},t))})},resolve:e=>{if(e instanceof c$)return e;if(e&&"function"==typeof e.then)return new c$((n,t)=>{e.then(n,t)});var n=new c$(ce,!0,e);return cS(n,ch),n},reject:cO,race:function(){var e=lB.apply(null,arguments).map(cG);return new c$((n,t)=>{e.map(e=>c$.resolve(e).then(n,t))})},PSD:{get:()=>cb,set:e=>cb=e},totalEchoes:{get:()=>cR},newPSD:cL,usePSD:cY,scheduler:{get:()=>cc,set:e=>{cc=e}},rejectionMapper:{get:()=>cm,set:e=>{cm=e}},follow:(e,n)=>new c$((t,o)=>cL((n,t)=>{var o=cb;o.unhandleds=[],o.onunhandled=t,o.finalize=l5(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},cv.push(function n(){e(),cv.splice(cv.indexOf(n),1)}),++c_,cc(()=>{0==--c_&&cP()},[])},o.finalize),e()},n,t,o))}),cr&&(cr.allSettled&&lf(c$,"allSettled",function(){let e=lB.apply(null,arguments).map(cG);return new c$(n=>{0===e.length&&n([]);let t=e.length,o=Array(t);e.forEach((e,a)=>c$.resolve(e).then(e=>o[a]={status:"fulfilled",value:e},e=>o[a]={status:"rejected",reason:e}).then(()=>--t||n(o)))})}),cr.any&&"u">typeof AggregateError&&lf(c$,"any",function(){let e=lB.apply(null,arguments).map(cG);return new c$((n,t)=>{0===e.length&&t(AggregateError([]));let o=e.length,a=Array(o);e.forEach((e,r)=>c$.resolve(e).then(e=>n(e),e=>{a[r]=e,--o||t(AggregateError(a))}))})}));let cN={awaits:0,echoes:0,id:0};var cI=0,cB=[],cj=0,cR=0,cF=0;function cL(e,n,t,o){var a=cb,r=Object.create(a);r.parent=a,r.ref=0,r.global=!1,r.id=++cF;var i=cg.env;r.env=ci?{Promise:c$,PromiseProp:{value:c$,configurable:!0,writable:!0},all:c$.all,race:c$.race,allSettled:c$.allSettled,any:c$.any,resolve:c$.resolve,reject:c$.reject,nthen:cJ(i.nthen,r),gthen:cJ(i.gthen,r)}:{},n&&ls(r,n),++a.ref,r.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=cY(r,e,t,o);return 0===r.ref&&r.finalize(),s}function cW(){return cN.id||(cN.id=++cI),++cN.awaits,cN.echoes+=100,cN.id}function cV(){return!!cN.awaits&&(0==--cN.awaits&&(cN.id=0),cN.echoes=100*cN.awaits,!0)}function cG(e){return cN.echoes&&e&&e.constructor===cr?(cW(),e.then(e=>(cV(),e),e=>(cV(),c0(e)))):e}function cU(e){++cR,cN.echoes&&0!=--cN.echoes||(cN.echoes=cN.id=0),cB.push(cb),cH(e,!0)}function cq(){var e=cB[cB.length-1];cB.pop(),cH(e,!1)}function cH(e,n){var t,o=cb;if((n?!cN.echoes||cj++&&e===cb:!cj||--cj&&e===cb)||(t=n?cU.bind(null,e):cq,ca.call(cn,t)),e!==cb&&(cb=e,o===cg&&(cg.env=cK()),ci)){var a=cg.env.Promise,r=e.env;ct.then=r.nthen,a.prototype.then=r.gthen,(o.global||e.global)&&(Object.defineProperty(la,"Promise",r.PromiseProp),a.all=r.all,a.race=r.race,a.resolve=r.resolve,a.reject=r.reject,r.allSettled&&(a.allSettled=r.allSettled),r.any&&(a.any=r.any))}}function cK(){var e=la.Promise;return ci?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(la,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:ct.then,gthen:e.prototype.then}:{}}function cY(e,n,t,o,a){var r=cb;try{return cH(e,!0),n(t,o,a)}finally{cH(r,!1)}}function cZ(e,n,t,o){return"function"!=typeof e?e:function(){var a,r=cb;t&&cW(),cH(n,!0);try{return e.apply(this,arguments)}finally{cH(r,!1),o&&(a=cV,ca.call(cn,a))}}}function cJ(e,n){return function(t,o){return e.call(this,cZ(t,n),cZ(o,n))}}-1===(""+ca).indexOf("[native code]")&&(cW=cV=l1);let cX="unhandledrejection";function cQ(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var o,a={promise:n,reason:e};if(la.document&&document.createEvent?((o=document.createEvent("Event")).initEvent(cX,!0,!0),ls(o,a)):la.CustomEvent&&ls(o=new CustomEvent(cX,{detail:a}),a),o&&la.dispatchEvent&&(dispatchEvent(o),!la.PromiseRejectionEvent&&la.onunhandledrejection))try{la.onunhandledrejection(o)}catch(e){}lR&&o&&!o.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var c0=c$.reject;let c1="3.2.4",c2=String.fromCharCode(65535),c3=-1/0,c5="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",c4="String expected.",c6=[],c7="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),c8=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),c9="__dbnames",pe="readonly",pn="readwrite";function pt(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let po={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function pa(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=lM(n))[e],n)}class pr{_trans(e,n,t){let o=this._tx||cb.trans,a=this.name;function r(e,t,o){if(!o.schema[a])throw new lX.NotFound("Table "+a+" not part of transaction");return n(o.idbtrans,o)}let i=cz();try{return o&&o.db===this.db?o===cb.trans?o._promise(e,r,t):cL(()=>o._promise(e,r,t),{trans:o,transless:cb.transless||cb}):function e(n,t,o,a){if(n.idbdb&&(n._state.openComplete||cb.letThrough||n._vip)){var r=n._createTransaction(t,o,n._dbSchema);try{r.create(),n._state.PR1398_maxLoop=3}catch(r){return r.name===lJ.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,o,a))):c0(r)}return r._promise(t,(e,n)=>cL(()=>(cb.trans=r,a(e,n,r)))).then(e=>r._completion.then(()=>e))}if(n._state.openComplete)return c0(new lX.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return c0(new lX.DatabaseClosed);n.open().catch(l1)}return n._state.dbReadyPromise.then(()=>e(n,t,o,a))}(this.db,e,[this.name],r)}finally{i&&cM()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(e=>this.hook.reading.fire(e))).then(n)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(li(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=lr(e);if(1===n.length)return this.where(n[0]).equals(e[n[0]]);let t=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)&&e.keyPath.every(e=>n.indexOf(e)>=0))[0];if(t&&this.db._maxKey!==c2)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&lR&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:o}=this.schema,a=this.db._deps.indexedDB;function r(e,n){try{return 0===a.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],a)=>{let i=o[a],s=e[a];return[n||i,n||!i?pt(t,i&&i.multi?e=>{let n=lw(e,a);return li(n)&&n.some(e=>r(s,e))}:e=>r(s,lw(e,a))):t]},[null,null]);return i?this.where(i.name).equals(e[i.keyPath]).filter(s):t?this.filter(s):this.where(n).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,li(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let n=n=>{if(!n)return n;let t=Object.create(e.prototype);for(var o in n)if(lp(n,o))try{t[o]=n[o]}catch(e){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){ls(this,e)})}add(e,n){let{auto:t,keyPath:o}=this.schema.primKey,a=e;return o&&t&&(a=pa(o)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})).then(e=>e.numFailures?c$.reject(e.failures[0]):e.lastResult).then(n=>{if(o)try{lk(e,o,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||li(e))return this.where(":id").equals(e).modify(n);{let t=lw(e,this.schema.primKey.keyPath);if(void 0===t)return c0(new lX.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?lr(n).forEach(t=>{lk(e,t,n[t])}):n(e,{value:e,primKey:t})}catch(e){}return this.where(":id").equals(t).modify(n)}}put(e,n){let{auto:t,keyPath:o}=this.schema.primKey,a=e;return o&&t&&(a=pa(o)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})).then(e=>e.numFailures?c$.reject(e.failures[0]):e.lastResult).then(n=>{if(o)try{lk(e,o,n)}catch(e){}return n})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(e=>e.numFailures?c$.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:po})).then(e=>e.numFailures?c$.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,n,t){let o=Array.isArray(n)?n:void 0,a=(t=t||(o?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&o)throw new lX.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new lX.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(pa(r)):e;return this.core.mutate({trans:n,type:"add",keys:o,values:s,wantResults:a}).then(({numFailures:e,results:n,lastResult:t,failures:o})=>{if(0===e)return a?n:t;throw new lZ(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,o)})})}bulkPut(e,n,t){let o=Array.isArray(n)?n:void 0,a=(t=t||(o?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&o)throw new lX.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new lX.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(pa(r)):e;return this.core.mutate({trans:n,type:"put",keys:o,values:s,wantResults:a}).then(({numFailures:e,results:n,lastResult:t,failures:o})=>{if(0===e)return a?n:t;throw new lZ(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,o)})})}bulkDelete(e){let n=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:e,lastResult:t,failures:o})=>{if(0===e)return t;throw new lZ(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,o)})}}function pi(e){var n={},t=function(t,o){if(o){for(var a=arguments.length,r=Array(a-1);--a;)r[a-1]=arguments[a];return n[t].subscribe.apply(null,r),e}if("string"==typeof t)return n[t]};t.addEventType=r;for(var o=1,a=arguments.length;o<a;++o)r(arguments[o]);return t;function r(e,o,a){if("object"!=typeof e){o||(o=l8),a||(a=l1);var i={subscribers:[],fire:a,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=o(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter(function(n){return n!==e}),i.fire=i.subscribers.reduce(o,a)}};return n[e]=t[e]=i,i}lr(e).forEach(function(n){var t=e[n];if(li(t))r(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new lX.InvalidArgument("Invalid event config");var o=r(n,l2,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];o.subscribers.forEach(function(e){l$(function(){e.apply(null,n)})})})}})}}function ps(e,n){return lh(n).from({prototype:e}),n}function pl(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function pc(e,n){e.filter=pt(e.filter,n)}function pp(e,n,t){var o=e.replayFilter;e.replayFilter=o?()=>pt(o(),n()):n,e.justLimit=t&&!o}function pu(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new lX.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function pd(e,n,t){let o=pu(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:o,range:e.range}})}function pf(e,n,t,o){let a=e.replayFilter?pt(e.filter,e.replayFilter()):e.filter;if(e.or){let r={},i=(e,t,o)=>{if(!a||a(t,o,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),lp(r,s)||(r[s]=!0,n(e,t,o))}};return Promise.all([e.or._iterate(i,t),ph(pd(e,o,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return ph(pd(e,o,t),pt(e.algorithm,a),n,!e.keysOnly&&e.valueMapper)}function ph(e,n,t,o){var a=cT(o?(e,n,a)=>t(o(e),n,a):t);return e.then(e=>{if(e)return e.start(()=>{var t=()=>e.continue();n&&!n(e,e=>t=e,n=>{e.stop(n),t=l1},n=>{e.fail(n),t=l1})||a(e.value,e,e=>t=e),t()})})}function pm(e,n){try{let t=pg(e),o=pg(n);if(t!==o)return"Array"===t?1:"Array"===o?-1:"binary"===t?1:"binary"===o?-1:"string"===t?1:"string"===o?-1:"Date"===t?1:"Date"!==o?NaN:-1;switch(t){case"number":case"Date":case"string":return e>n?1:e<n?-1:0;case"binary":return function(e,n){let t=e.length,o=n.length,a=t<o?t:o;for(let t=0;t<a;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===o?0:t<o?-1:1}(pb(e),pb(n));case"Array":return function(e,n){let t=e.length,o=n.length,a=t<o?t:o;for(let t=0;t<a;++t){let o=pm(e[t],n[t]);if(0!==o)return o}return t===o?0:t<o?-1:1}(e,n)}}catch(e){}return NaN}function pg(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=lO(e);return"ArrayBuffer"===t?"binary":t}function pb(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class py{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,c0.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,c0.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=pt(n.algorithm,e)}_iterate(e,n){return pf(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&ls(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>pf(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(pl(n,!0))return t.count({trans:e,query:{index:pu(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var o=0;return pf(n,()=>(++o,!1),e,t).then(()=>o)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),o=t[0],a=t.length-1;function r(e,n){return n?r(e[t[n]],n-1):e[o]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=r(e,a),o=r(n,a);return t<o?-i:t>o?i:0}return this.toArray(function(e){return e.sort(s)}).then(n)}toArray(e){return this._read(e=>{var n=this._ctx;if("next"===n.dir&&pl(n,!0)&&n.limit>0){let{valueMapper:t}=n,o=pu(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:o,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return pf(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,pl(n)?pp(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):pp(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),pp(this._ctx,()=>{var n=e;return function(e,t,o){return--n<=0&&t(o),n>=0}},!0),this}until(e,n){return pc(this._ctx,function(t,o,a){return!e(t.value)||(o(a),n)}),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 n;return pc(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=pt(n.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 n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.key,t)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.primaryKey,t)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.key)}).then(function(){return t}).then(e)}primaryKeys(e){var n=this._ctx;if("next"===n.dir&&pl(n,!0)&&n.limit>0)return this._read(e=>{var t=pu(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(({result:e})=>e).then(e);n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.primaryKey)}).then(function(){return t}).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,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var t={};return pc(this._ctx,function(e){var n=e.primaryKey.toString(),o=lp(t,n);return t[n]=!0,!o}),this}modify(e){var n=this._ctx;return this._write(t=>{var o;if("function"==typeof e)o=e;else{var a=lr(e),r=a.length;o=function(n){for(var t=!1,o=0;o<r;++o){var i=a[o],s=e[i];lw(n,i)!==s&&(lk(n,i,s),t=!0)}return t}}let i=n.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,p=[],u=0,d=[],f=(e,n)=>{let{failures:t,numFailures:o}=n;for(let n of(u+=e-o,lr(t)))p.push(t[n])};return this.clone().primaryKeys().then(a=>{let r=p=>{let u=Math.min(c,a.length-p);return i.getMany({trans:t,keys:a.slice(p,p+u),cache:"immutable"}).then(d=>{let h=[],m=[],g=s?[]:null,b=[];for(let e=0;e<u;++e){let n=d[e],t={value:lM(n),primKey:a[p+e]};!1!==o.call(t,t.value,t)&&(null==t.value?b.push(a[p+e]):s||0===pm(l(n),l(t.value))?(m.push(t.value),s&&g.push(a[p+e])):(b.push(a[p+e]),h.push(t.value)))}let y=pl(n)&&n.limit===1/0&&("function"!=typeof e||e===p_)&&{index:n.index,range:n.range};return Promise.resolve(h.length>0&&i.mutate({trans:t,type:"add",values:h}).then(e=>{for(let n in e.failures)b.splice(parseInt(n),1);f(h.length,e)})).then(()=>(m.length>0||y&&"object"==typeof e)&&i.mutate({trans:t,type:"put",keys:g,values:m,criteria:y,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(b.length>0||y&&e===p_)&&i.mutate({trans:t,type:"delete",keys:b,criteria:y}).then(e=>f(b.length,e))).then(()=>a.length>p+u&&r(p+c))})};return r(0).then(()=>{if(p.length>0)throw new lY("Error modifying one or more objects",p,u,d);return a.length})})})}delete(){var e=this._ctx,n=e.range;return pl(e)&&(e.isPrimKey&&!c7||3===n.type)?this._write(t=>{let{primaryKey:o}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:o,range:n}}).then(o=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:a})=>{if(a)throw new lY("Could not delete some values",Object.keys(e).map(n=>e[n]),o-a);return o-a}))}):this.modify(p_)}}let p_=(e,n)=>n.value=null;function pv(e,n){return e<n?-1:+(e!==n)}function p$(e,n){return e>n?-1:+(e!==n)}function pA(e,n,t){var o=e instanceof pE?new e.Collection(e):e;return o._ctx.error=t?new t(n):TypeError(n),o}function pw(e){return new e.Collection(e,()=>pC("")).limit(0)}function pk(e,n,t,o){var a,r,i,s,l,c,p,u=t.length;if(!t.every(e=>"string"==typeof e))return pA(e,c4);function d(e){a="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),r="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?pv:p$;var n=t.map(function(e){return{lower:r(e),upper:a(e)}}).sort(function(e,n){return i(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,p="next"===e?"":o}d("next");var f=new e.Collection(e,()=>px(s[0],l[u-1]+o));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,o){var a=e.key;if("string"!=typeof a)return!1;var d=r(a);if(n(d,l,h))return!0;for(var f=null,m=h;m<u;++m){var g=function(e,n,t,o,a,r){for(var i=Math.min(e.length,o.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==o[l])return 0>a(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>a(e[l],o[l])?e.substr(0,l)+o[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>a(e[l],c)&&(s=l)}return i<o.length&&"next"===r?e+t.substr(e.length):i<e.length&&"prev"===r?e.substr(0,t.length):s<0?null:e.substr(0,s)+o[s]+t.substr(s+1)}(a,d,s[m],l[m],i,c);null===g&&null===f?h=m+1:(null===f||i(f,g)>0)&&(f=g)}return t(null!==f?function(){e.continue(f+p)}:o),!1}),f}function px(e,n,t,o){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:o}}function pC(e){return{type:1,lower:e,upper:e}}class pE{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,o){t=!1!==t,o=!0===o;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||o)&&(!t||!o)?pw(this):new this.Collection(this,()=>px(e,n,!t,!o))}catch(e){return pA(this,c5)}}equals(e){return null==e?pA(this,c5):new this.Collection(this,()=>pC(e))}above(e){return null==e?pA(this,c5):new this.Collection(this,()=>px(e,void 0,!0))}aboveOrEqual(e){return null==e?pA(this,c5):new this.Collection(this,()=>px(e,void 0,!1))}below(e){return null==e?pA(this,c5):new this.Collection(this,()=>px(void 0,e,!1,!0))}belowOrEqual(e){return null==e?pA(this,c5):new this.Collection(this,()=>px(void 0,e))}startsWith(e){return"string"!=typeof e?pA(this,c4):this.between(e,e+c2,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):pk(this,(e,n)=>0===e.indexOf(n[0]),[e],c2)}equalsIgnoreCase(e){return pk(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=lB.apply(lI,arguments);return 0===e.length?pw(this):pk(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=lB.apply(lI,arguments);return 0===e.length?pw(this):pk(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,c2)}anyOf(){let e=lB.apply(lI,arguments),n=this._cmp;try{e.sort(n)}catch(e){return pA(this,c5)}if(0===e.length)return pw(this);let t=new this.Collection(this,()=>px(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let o=0;return t._addAlgorithm((t,a,r)=>{let i=t.key;for(;n(i,e[o])>0;)if(++o===e.length)return a(r),!1;return 0===n(i,e[o])||(a(()=>{t.continue(e[o])}),!1)}),t}notEqual(e){return this.inAnyRange([[c3,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=lB.apply(lI,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return pA(this,c5)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[c3,n]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){let t=this._cmp,o=this._ascending,a=this._descending,r=this._min,i=this._max;if(0===e.length)return pw(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=o(e[0],e[1])))return pA(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",lX.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,p=o;function u(e,n){return p(e[0],n[0])}try{(c=e.reduce(function(e,n){let o=0,a=e.length;for(;o<a;++o){let a=e[o];if(0>t(n[0],a[1])&&t(n[1],a[0])>0){a[0]=r(a[0],n[0]),a[1]=i(a[1],n[1]);break}}return o===a&&e.push(n),e},[])).sort(u)}catch(e){return pA(this,c5)}let d=0,f=l?e=>o(e,c[d][1])>0:e=>o(e,c[d][1])>=0,h=s?e=>a(e,c[d][0])>0:e=>a(e,c[d][0])>=0,m=f,g=new this.Collection(this,()=>px(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,p=o):(m=h,p=a),c.sort(u)},g._addAlgorithm((e,n,t)=>{for(var a=e.key;m(a);)if(++d===c.length)return n(t),!1;return!!(!f(a)&&!h(a))||(0===this._cmp(a,c[d][1])||0===this._cmp(a,c[d][0])||n(()=>{p===o?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=lB.apply(lI,arguments);return e.every(e=>"string"==typeof e)?0===e.length?pw(this):this.inAnyRange(e.map(e=>[e,e+c2])):pA(this,"startsWithAnyOf() only works with strings")}}function pS(e){return cT(function(n){return pD(n),e(n.target.error),!1})}function pD(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let pz="storagemutated",pM="x-storagemutated-1",pP=pi(null,pz);class pO{_lock(){return lv(!cb.global),++this._reculock,1!==this._reculock||cb.global||(cb.lockOwnerFor=this),this}_unlock(){if(lv(!cb.global),0==--this._reculock)for(cb.global||(cb.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{cY(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&cb.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(lv(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new lX.DatabaseClosed(t);case"MissingAPIError":throw new lX.MissingAPI(t.message,t);default:throw new lX.OpenFailed(t)}if(!this.active)throw new lX.TransactionInactive;return lv(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=cT(n=>{pD(n),this._reject(e.error)}),e.onabort=cT(n=>{pD(n),this.active&&this._reject(new lX.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=cT(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&pP.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return c0(new lX.ReadOnly("Transaction is readonly"));if(!this.active)return c0(new lX.TransactionInactive);if(this._locked())return new c$((o,a)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(o,a)},cb])});if(t)return cL(()=>{var e=new c$((e,t)=>{this._lock();let o=n(e,t,this);o&&o.then&&o.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var o=new c$((e,t)=>{var o=n(e,t,this);o&&o.then&&o.then(e,t)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=c$.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var o=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=e)}()}var a=n._waitingFor;return new c$((e,o)=>{t.then(t=>n._waitingQueue.push(cT(e.bind(null,t))),e=>n._waitingQueue.push(cT(o.bind(null,e)))).finally(()=>{n._waitingFor===a&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new lX.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(lp(n,e))return n[e];let t=this.schema[e];if(!t)throw new lX.NotFound("Table "+e+" not part of transaction");let o=new this.db.Table(e,t,this);return o.core=this.db.core.table(e),n[e]=o,o}}function pT(e,n,t,o,a,r,i){return{name:e,keyPath:n,unique:t,multi:o,auto:a,compound:r,src:(t&&!i?"&":"")+(o?"*":"")+(a?"++":"")+pN(n)}}function pN(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function pI(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:lA(t,e=>[e.name,e])}}let pB=e=>{try{return e.only([[]]),pB=()=>[[]],[[]]}catch(e){return pB=()=>c2,c2}};function pj(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>lw(n,e):n=>lw(n,e)}function pR(e){return[].slice.call(e)}let pF=0;function pL(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function pW({_novip:e},n){let t=n.db,o=function(e,n,{IDBKeyRange:t,indexedDB:o},a){var r;return{dbcore:(r=function(e,n,t){let o;function a(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:o,lowerOpen:a,upperOpen:r}=e;return void 0===t?void 0===o?null:n.upperBound(o,!!r):void 0===o?n.lowerBound(t,!!a):n.bound(t,o,!!a,!!r)}let{schema:r,hasGetAll:i}=(o=pR(e.objectStoreNames),{schema:{name:e.name,tables:o.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,o=li(n),a=null==n,r={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:a,compound:o,keyPath:n,autoIncrement:t,unique:!0,extractKey:pj(n)},indexes:pR(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:o,keyPath:a}=e,i={name:n,compound:li(a),keyPath:a,unique:t,multiEntry:o,extractKey:pj(a)};return r[pL(a)]=i,i}),getIndexByKeyPath:e=>r[pL(e)]};return r[":id"]=i.primaryKey,null!=n&&(r[pL(n)]=i.primaryKey),i})},hasGetAll:o.length>0&&"getAll"in t.objectStore(o[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=r.tables.map(e=>{let n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:o,values:r,range:i}){return new Promise((s,l)=>{let c;s=cT(s);let p=e.objectStore(n),u=null==p.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=o||r||{length:1};if(o&&r&&o.length!==r.length)throw Error("Given keys array must have same length as given values array.");if(0===f)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],g=0,b=e=>{++g,pD(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===i.type?h.push(c=p.clear()):h.push(c=p.delete(a(i)))}else{let[e,n]=d?u?[r,o]:[r,null]:[o,null];if(d)for(let o=0;o<f;++o)h.push(c=n&&void 0!==n[o]?p[t](e[o],n[o]):p[t](e[o])),c.onerror=b;else for(let n=0;n<f;++n)h.push(c=p[t](e[n])),c.onerror=b}let y=e=>{let n=e.target.result;h.forEach((e,n)=>null!=e.error&&(m[n]=e.error)),s({numFailures:g,failures:m,results:"delete"===t?o:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{b(e),y(e)},c.onsuccess=y})},getMany:({trans:e,keys:t})=>new Promise((o,a)=>{o=cT(o);let r=e.objectStore(n),i=t.length,s=Array(i),l,c=0,p=0,u=e=>{let n=e.target;s[n._pos]=n.result,++p===c&&o(s)},d=pS(a);for(let e=0;e<i;++e)null!=t[e]&&((l=r.get(t[e]))._pos=e,l.onsuccess=u,l.onerror=d,++c);0===c&&o(s)}),get:({trans:e,key:t})=>new Promise((o,a)=>{o=cT(o);let r=e.objectStore(n).get(t);r.onsuccess=e=>o(e.target.result),r.onerror=pS(a)}),query:e=>new Promise((t,o)=>{t=cT(t);let{trans:r,values:s,limit:l,query:c}=e,p=l===1/0?void 0:l,{index:u,range:d}=c,f=r.objectStore(n),h=u.isPrimaryKey?f:f.index(u.name),m=a(d);if(0===l)return t({result:[]});if(i){let e=s?h.getAll(m,p):h.getAllKeys(m,p);e.onsuccess=e=>t({result:e.target.result}),e.onerror=pS(o)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),a=[];n.onsuccess=o=>{let r=n.result;return r?(a.push(s?r.value:r.primaryKey),++e===l?t({result:a}):void r.continue()):t({result:a})},n.onerror=pS(o)}}),openCursor:function({trans:e,values:t,query:o,reverse:r,unique:i}){return new Promise((s,l)=>{s=cT(s);let{index:c,range:p}=o,u=e.objectStore(n),d=c.isPrimaryKey?u:u.index(c.name),f=r?i?"prevunique":"prev":i?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(a(p),f):d.openCursor(a(p),f);h.onerror=pS(l),h.onsuccess=cT(n=>{let t=h.result;if(!t)return void s(null);t.___id=++pF,t.done=!1;let o=t.continue.bind(t),a=t.continuePrimaryKey;a&&(a=a.bind(t));let r=t.advance.bind(t),i=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=cT(l),t.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},t.start=e=>{let n=new Promise((e,n)=>{e=cT(e),h.onerror=pS(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=i,e(n)}}),s=()=>{if(h.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return h.onsuccess=cT(e=>{h.onsuccess=s,s()}),t.continue=o,t.continuePrimaryKey=a,t.advance=r,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:o,range:r}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=o.isPrimaryKey?s:s.index(o.name),c=a(r),p=c?l.count(c):l.count();p.onsuccess=cT(n=>e(n.target.result)),p.onerror=pS(i)})}}}),l={};return s.forEach(e=>l[e.name]=e),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!l[e])throw Error(`Table '${e}' not found`);return l[e]},MIN_KEY:-1/0,MAX_KEY:pB(n),schema:r}}(n,t,a),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),r))}}(e._middlewares,t,e._deps,n);e.core=o.dbcore,e.tables.forEach(n=>{let t=n.name;e.core.schema.tables.some(e=>e.name===t)&&(n.core=e.core.table(t),e[t]instanceof e.Table&&(e[t].core=n.core))})}function pV({_novip:e},n,t,o){t.forEach(t=>{let a=o[t];n.forEach(n=>{let o=lg(n,t);(!o||"value"in o&&void 0===o.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?lf(n,t,{get(){return this.table(t)},set(e){ld(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,a))})})}function pG({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function pU(e,n){return e._cfg.version-n._cfg.version}function pq(e,n){let t,o={del:[],add:[],change:[]};for(t in e)n[t]||o.del.push(t);for(t in n){let a=e[t],r=n[t];if(a){let e={name:t,def:r,recreate:!1,del:[],add:[],change:[]};if(""+(a.primKey.keyPath||"")==""+(r.primKey.keyPath||"")&&(a.primKey.auto===r.primKey.auto||c7)){let n,t=a.idxByName,i=r.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let o=t[n],a=i[n];o?o.src!==a.src&&e.change.push(a):e.add.push(a)}(e.del.length>0||e.add.length>0||e.change.length>0)&&o.change.push(e)}else e.recreate=!0,o.change.push(e)}else o.add.push([t,r])}return o}function pH(e,n,t,o){let a=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return o.forEach(e=>pK(a,e)),a}function pK(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function pY(e,n,t){let o={};return ly(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),a=n.keyPath,r=pT(pN(a),a||"",!1,!1,!!n.autoIncrement,a&&"string"!=typeof a,!0),i=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);a=t.keyPath;var s=pT(t.name,a,!!t.unique,!!t.multiEntry,!1,a&&"string"!=typeof a,!1);i.push(s)}o[e]=pI(e,r,i)}),o}function pZ({_novip:e},n,t){let o=t.db.objectStoreNames;for(let a=0;a<o.length;++a){let r=o[a],i=t.objectStore(r);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],o=i.index(t).keyPath,a="string"==typeof o?o:"["+ly(o).join("+")+"]";if(n[r]){let e=n[r].idxByName[a];e&&(e.name=t,delete n[r].idxByName[a],n[r].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&la.WorkerGlobalScope&&la instanceof la.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class pJ{_parseStoresSpec(e,n){lr(e).forEach(t=>{if(null!==e[t]){var o=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),o=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return pT(t,o||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),li(o),0===n)}),a=o.shift();if(a.multi)throw new lX.Schema("Primary key cannot be multi-valued");o.forEach(e=>{if(e.auto)throw new lX.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new lX.Schema("Index must have a name and cannot be an empty string")}),n[t]=pI(t,a,o)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?ls(this._cfg.storesSource,e):e;let t=n._versions,o={},a={};return t.forEach(e=>{ls(o,e._cfg.storesSource),a=e._cfg.dbschema={},e._parseStoresSpec(o,a)}),n._dbSchema=a,pG(n,[n._allTables,n,n.Transaction.prototype]),pV(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],lr(a),a),n._storeNames=lr(a),this}upgrade(e){return this._cfg.contentUpgrade=l9(this._cfg.contentUpgrade||l1,e),this}}function pX(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new us(c9,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function pQ(e){return e&&"function"==typeof e.databases}function p0(e){return cL(function(){return cb.letThrough=!0,e()})}function p1(e){var n=n=>e.next(n),t=a(n),o=a(n=>e.throw(n));function a(e){return n=>{var a=e(n),r=a.value;return a.done?r:r&&"function"==typeof r.then?r.then(t,o):li(r)?Promise.all(r).then(t,o):t(r)}}return a(n)()}function p2(e,n,t){var o=arguments.length;if(o<2)throw new lX.InvalidArgument("Too few arguments");for(var a=Array(o-1);--o;)a[o-1]=arguments[o];return t=a.pop(),[e,lE(a),t]}function p3(e,n,t){let o=li(e)?e.slice():[e];for(let e=0;e<t;++e)o.push(n);return o}let p5={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:o}=t,a={},r=[];function i(e,n,t){let o=pL(e),s=a[o]=a[o]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,p={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:pj(e),unique:!c&&t.unique};return s.push(p),p.isPrimaryKey||r.push(p),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),p}let s=i(o.primaryKey.keyPath,0,o.primaryKey);for(let e of(a[":id"]=[s],o.indexes))i(e.keyPath,0,e);function l(n){var t,o;let a=n.query.index;return a.isVirtual?{...n,query:{index:a,range:(t=n.query.range,o=a.keyTail,{type:1===t.type?2:t.type,lower:p3(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,o),lowerOpen:!0,upper:p3(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,o),upperOpen:!0})}}:n}return{...t,schema:{...o,primaryKey:s,indexes:r,getIndexByKeyPath:function(e){let n=a[pL(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:o,isVirtual:a,keyLength:r}=n.query.index;return a?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(a){null!=a?t.continue(p3(a,n.reverse?e.MAX_KEY:e.MIN_KEY,o)):n.unique?t.continue(t.key.slice(0,r).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,o)):t.continue()}},continuePrimaryKey:{value(n,a){t.continuePrimaryKey(p3(n,e.MAX_KEY,o),a)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===r?e[0]:e.slice(0,r)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function p4(e,n,t,o){return t=t||{},o=o||"",lr(e).forEach(a=>{if(lp(n,a)){var r=e[a],i=n[a];if("object"==typeof r&&"object"==typeof i&&r&&i){let e=lO(r);e!==lO(i)?t[o+a]=n[a]:"Object"===e?p4(r,i,t,o+a+"."):r!==i&&(t[o+a]=n[a])}else r!==i&&(t[o+a]=n[a])}else t[o+a]=void 0}),lr(n).forEach(a=>{lp(e,a)||(t[o+a]=n[a])}),t}let p6={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:o}=t.schema;return{...t,mutate(e){let a=cb.trans,{deleting:r,creating:i,updating:s}=a.table(n).hook;switch(e.type){case"add":if(i.fire===l1)break;return a._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===l1&&s.fire===l1)break;return a._promise("readwrite",()=>l(e),!0);case"delete":if(r.fire===l1)break;return a._promise("readwrite",()=>l(e),!0);case"deleteRange":if(r.fire===l1)break;return a._promise("readwrite",()=>(function e(n,a,r){return t.query({trans:n,values:!1,query:{index:o,range:a},limit:r}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(o=>o.numFailures>0?Promise.reject(o.failures[0]):t.length<r?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...a,lower:t[t.length-1],lowerOpen:!0},r)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,a;let l=cb.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(o.extractKey));if(!c)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:c}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(a=e).type?Promise.resolve([]):t.getMany({trans:a.trans,keys:c,cache:"immutable"})).then(n=>{let a=c.map((t,a)=>{let c=n[a],p={onerror:null,onsuccess:null};if("delete"===e.type)r.fire.call(p,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(p,t,e.values[a],l);null==t&&null!=n&&(t=n,e.keys[a]=t,o.outbound||lk(e.values[a],o.keyPath,t))}else{let n=p4(c,e.values[a]),o=s.fire.call(p,n,t,c,l);if(o){let n=e.values[a];Object.keys(o).forEach(e=>{lp(n,e)?n[e]=o[e]:lk(n,e,o[e])})}}return p});return t.mutate(e).then(({failures:t,results:o,numFailures:r,lastResult:i})=>{for(let r=0;r<c.length;++r){let i=o?o[r]:c[r],s=a[r];null==i?s.onerror&&s.onerror(t[r]):s.onsuccess&&s.onsuccess("put"===e.type&&n[r]?e.values[r]:i)}return{failures:t,results:o,numFailures:r,lastResult:i}}).catch(e=>(a.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function p7(e,n,t){try{if(!n||n.keys.length<e.length)return null;let o=[];for(let a=0,r=0;a<n.keys.length&&r<e.length;++a)0===pm(n.keys[a],e[r])&&(o.push(t?lM(n.values[a]):n.values[a]),++r);return o.length===e.length?o:null}catch(e){return null}}let p8={stack:"dbcore",level:-1,create:e=>({table:n=>{let t=e.table(n);return{...t,getMany:e=>{if(!e.cache)return t.getMany(e);let n=p7(e.keys,e.trans._cache,"clone"===e.cache);return n?c$.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?lM(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function p9(e){return!("from"in e)}let ue=function(e,n){if(!this){let n=new ue;return e&&"d"in e&&ls(n,e),n}ls(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function un(e,n,t){let o=pm(n,t);if(isNaN(o))return;if(o>0)throw RangeError();if(p9(e))return ls(e,{from:n,to:t,d:1});let a=e.l,r=e.r;if(0>pm(t,e.from))return a?un(a,n,t):e.l={from:n,to:t,d:1,l:null,r:null},ua(e);if(pm(n,e.to)>0)return r?un(r,n,t):e.r={from:n,to:t,d:1,l:null,r:null},ua(e);0>pm(n,e.from)&&(e.from=n,e.l=null,e.d=r?r.d+1:1),pm(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;a&&!e.l&&ut(e,a),r&&i&&ut(e,r)}function ut(e,n){p9(n)||function e(n,{from:t,to:o,l:a,r:r}){un(n,t,o),a&&e(n,a),r&&e(n,r)}(e,n)}function uo(e){let n=p9(e)?null:{s:0,n:e};return{next(e){let t=arguments.length>0;for(;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&0>pm(e,n.n.from);)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||0>=pm(e,n.n.to))return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function ua(e){var n,t;let o=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),a=o>1?"r":o<-1?"l":"";if(a){let n="r"===a?"l":"r",t={...e},o=e[a];e.from=o.from,e.to=o.to,e[a]=o[a],t[a]=o[n],e[n]=t,t.d=ur(t)}e.d=ur(e)}function ur({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}lu(ue.prototype,{add(e){return ut(this,e),this},addKey(e){return un(this,e,e),this},addKeys(e){return e.forEach(e=>un(this,e,e)),this},[lT](){return uo(this)}});let ui={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new ue(e.MIN_KEY,e.MAX_KEY);return{...e,table:o=>{let a=e.table(o),{schema:r}=a,{primaryKey:i}=r,{extractKey:s,outbound:l}=i,c={...a,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let t=`idb://${n}/${o}/${e}`;return s[t]||(s[t]=new ue)},c=l(""),p=l(":dels"),{type:u}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return a.mutate(e).then(e=>{if(li(d)){"delete"!==u&&(d=e.results),c.addKeys(d);let n=p7(d,h);n||"add"===u||p.addKeys(d),(n||f)&&r.indexes.forEach(function(e){let t=l(e.name||"");function o(n){return null!=n?e.extractKey(n):null}let a=n=>e.multiEntry&&li(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let r=n&&o(n[t]),i=f&&o(f[t]);0!==pm(r,i)&&(null!=r&&a(r),null!=i&&a(i))})})}else if(d){let e={from:d.lower,to:d.upper};p.add(e),c.add(e)}else c.add(t),p.add(t),r.indexes.forEach(e=>l(e.name).add(t));return e})}},p=({query:{index:n,range:t}})=>{var o,a;return[n,new ue(null!=(o=t.lower)?o:e.MIN_KEY,null!=(a=t.upper)?a:e.MAX_KEY)]},u={get:e=>[i,new ue(e.key)],getMany:e=>[i,(new ue).addKeys(e.keys)],count:p,query:p,openCursor:p};return lr(u).forEach(e=>{c[e]=function(r){let{subscr:i}=cb;if(i){let c=e=>{let t=`idb://${n}/${o}/${e}`;return i[t]||(i[t]=new ue)},p=c(""),d=c(":dels"),[f,h]=u[e](r);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&r.values&&a.query({...r,values:!1});return a[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&r.values)return n.then(({result:e})=>(p.addKeys(e),t));let e=r.values?t.result.map(s):t.result;r.values?p.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=r.values;return t&&Object.create(t,{key:{get:()=>(d.addKey(t.primaryKey),t.key)},primaryKey:{get(){let e=t.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&p.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return a[e].apply(this,arguments)}}),c}}}};class us{constructor(e,n){var t;this._middlewares={},this.verno=0;const o=us.dependencies;this._options=n={addons:us.addons,autoOpen:!0,indexedDB:o.indexedDB,IDBKeyRange:o.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:a}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const r={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:l1,dbReadyPromise:null,cancelOpen:l1,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};r.dbReadyPromise=new c$(e=>{r.dbReadyResolve=e}),r.openCanceller=new c$((e,n)=>{r.cancelOpen=n}),this._state=r,this.name=e,this.on=pi(this,"populate","blocked","versionchange","close",{ready:[l9,l1]}),this.on.ready.subscribe=l_(this.on.ready.subscribe,e=>(n,t)=>{us.vip(()=>{let o=this._state;if(o.openComplete)o.dbOpenError||c$.resolve().then(n),t&&e(n);else if(o.onReadyBeingFired)o.onReadyBeingFired.push(n),t&&e(n);else{e(n);let o=this;t||e(function e(){o.on.ready.unsubscribe(n),o.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,ps(py.prototype,function(e,n){this.db=t;let o=po,a=null;if(n)try{o=n()}catch(e){a=e}let r=e._ctx,i=r.table,s=i.hook.reading.fire;this._ctx={table:i,index:r.index,isPrimKey:!r.index||i.schema.primKey.keyPath&&r.index===i.schema.primKey.name,range:o,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:a,or:r.or,valueMapper:s!==l2?s:null}})),this.Table=function(e){return ps(pr.prototype,function(n,t,o){this.db=e,this._tx=o,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:pi(null,{creating:[l4,l1],reading:[l3,l2],updating:[l7,l1],deleting:[l6,l1]})})}(this),this.Transaction=function(e){return ps(pO.prototype,function(n,t,o,a,r){this.db=e,this.mode=n,this.storeNames=t,this.schema=o,this.chromeTransactionDurability=a,this.idbtrans=null,this.on=pi(this,"complete","error","abort"),this.parent=r||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 c$((e,n)=>{this._resolve=e,this._reject=n}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var n=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):n&&this.idbtrans&&this.idbtrans.abort(),c0(e)})})}(this),this.Version=function(e){return ps(pJ.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return ps(pE.prototype,function(n,t,o){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:o};let a=e._deps.indexedDB;if(!a)throw new lX.MissingAPI;this._cmp=this._ascending=a.cmp.bind(a),this._descending=(e,n)=>a.cmp(n,e),this._max=(e,n)=>a.cmp(e,n)>0?e:n,this._min=(e,n)=>0>a.cmp(e,n)?e:n,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=pB(n.IDBKeyRange),this._createTransaction=(e,n,t,o)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,o),this._fireOnBlocked=e=>{this.on("blocked").fire(e),c6.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(p5),this.use(p6),this.use(ui),this.use(p8),this.vip=Object.create(this,{_vip:{value:!0}}),a.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new lX.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new lX.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var t=n.filter(n=>n._cfg.version===e)[0];return t||(t=new this.Version(e),n.push(t),n.sort(pU),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||cb.letThrough||this._vip)?e():new c$((e,n)=>{if(this._state.openComplete)return n(new lX.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new lX.DatabaseClosed);this.open().catch(l1)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:o}){o&&this.unuse({stack:e,name:o});let a=this._middlewares[e]||(this._middlewares[e]=[]);return a.push({stack:e,create:n,level:null==t?10:t,name:o}),a.sort((e,n)=>e.level-n.level),this}unuse({stack:e,name:n,create:t}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>t?e.create!==t:!!n&&e.name!==n)),this}open(){return function(e){var n;let t=e._state,{indexedDB:o}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?c0(t.dbOpenError):e);lR&&(t.openCanceller._stackHolder=lW()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let a=t.openCanceller;function r(){if(t.openCanceller!==a)throw new lX.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1;return c$.race([a,("u"<typeof navigator?c$.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var t=function(){return indexedDB.databases().finally(e)};n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(()=>new c$((n,a)=>{if(r(),!o)throw new lX.MissingAPI;let i=e.name,c=t.autoSchema?o.open(i):o.open(i,Math.round(10*e.verno));if(!c)throw new lX.MissingAPI;c.onerror=pS(a),c.onblocked=cT(e._fireOnBlocked),c.onupgradeneeded=cT(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=pD,s.abort(),c.result.close();let e=o.deleteDatabase(i);e.onsuccess=e.onerror=cT(()=>{a(new lX.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,o,i,d;s.onerror=pS(a);var r,p,u=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=u<1,e._novip.idbdb=c.result,r=u/10,p=s,t=e._dbSchema,(o=e._createTransaction("readwrite",e._storeNames,t)).create(p),o._completion.catch(a),i=o._reject.bind(o),d=cb.transless||cb,cL(()=>{cb.trans=o,cb.transless=d,0===r?(lr(t).forEach(e=>{pH(p,e,t[e].primKey,t[e].indexes)}),pW(e,p),c$.follow(()=>e.on.populate.fire(o)).catch(i)):(function({_novip:e},n,t,o){let a=[],r=e._versions,i=e._dbSchema=pY(e,e.idbdb,o),s=!1;return r.filter(e=>e._cfg.version>=n).forEach(r=>{a.push(()=>{let a=i,l=r._cfg.dbschema;pZ(e,a,o),pZ(e,l,o),i=e._dbSchema=l;let c=pq(a,l);c.add.forEach(e=>{pH(o,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new lX.Upgrade("Not yet support for changing primary key");{let n=o.objectStore(e.name);e.add.forEach(e=>pK(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),pK(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let p=r._cfg.contentUpgrade;if(p&&r._cfg.version>n){let n;pW(e,o),t._memoizedTables={},s=!0;let r=lx(l);c.del.forEach(e=>{r[e]=a[e]}),pG(e,[e.Transaction.prototype]),pV(e,[e.Transaction.prototype],lr(r),r),t.schema=r;let i=lj(p);i&&cW();let u=c$.follow(()=>{if((n=p(t))&&i){var e=cV.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?c$.resolve(n):u.then(()=>n)}}),a.push(n=>{var o;s&&c7||(o=r._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==o[e]&&n.db.deleteObjectStore(e))),pG(e,[e.Transaction.prototype]),pV(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return a.length?c$.resolve(a.shift()(t.idbtrans)).then(e):c$.resolve()})().then(()=>{var e;lr(e=i).forEach(n=>{o.db.objectStoreNames.contains(n)||pH(o,n,e[n].primKey,e[n].indexes)})})})(e,r,o,p).catch(i)})}},a),c.onsuccess=cT(()=>{s=null;let o=e._novip.idbdb=c.result,a=ly(o.objectStoreNames);if(a.length>0)try{let n,r=o.transaction(1===a.length?a[0]:a,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let o=e._dbSchema=pY(0,n,t);e._storeNames=ly(n.objectStoreNames,0),pV(e,[e._allTables],lr(o),o)}(e,o,r):(pZ(e,e._dbSchema,r),((n=pq(pY(0,e.idbdb,r),e._dbSchema)).add.length||n.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.")),pW(e,r)}catch(e){}c6.push(e),o.onversionchange=cT(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),o.onclose=cT(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){pQ(e)||t===c9||pX(e,n).put({name:t}).catch(l1)}(e._deps,i),n()},a)}))]).then(()=>(r(),t.onReadyBeingFired=[],c$.resolve(p0(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let o=t.onReadyBeingFired.reduce(l9,l1);return t.onReadyBeingFired=[],c$.resolve(p0(()=>o(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return a===t.openCanceller&&e._close(),c0(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=c6.indexOf(this);if(n>=0&&c6.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new c$(n=>{e.dbReadyResolve=n}),e.openCanceller=new c$((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new lX.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new c$((t,o)=>{let a=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=cT(()=>{!function({indexedDB:e,IDBKeyRange:n},t){pQ(e)||t===c9||pX(e,n).delete(t).catch(l1)}(this._deps,this.name),t()}),e.onerror=pS(o),e.onblocked=this._fireOnBlocked};if(e)throw new lX.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(a):a()})}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 lr(this._allTables).map(e=>this._allTables[e])}transaction(){let e=p2.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let o,a,r=cb.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(a=n.map(e=>{var n=e instanceof this.Table?e.name:e;if("string"!=typeof n)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}),"r"==e||e===pe)o=pe;else{if("rw"!=e&&e!=pn)throw new lX.InvalidArgument("Invalid transaction mode: "+e);o=pn}if(r){if(r.mode===pe&&o===pn){if(!i)throw new lX.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&a.forEach(e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!i)throw new lX.SubTransaction("Table "+e+" not included in parent transaction.");r=null}}),i&&r&&!r.active&&(r=null)}}catch(e){return r?r._promise(null,(n,t)=>{t(e)}):c0(e)}let s=(function e(n,t,o,a,r){return c$.resolve().then(()=>{let i,s=cb.transless||cb,l=n._createTransaction(t,o,n._dbSchema,a);if(a)l.idbtrans=a.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(a){return a.name===lJ.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,o,null,r))):c0(a)}let c=lj(r);c&&cW();let p=c$.follow(()=>{if(i=r.call(l,l))if(c){var e=cV.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=p1(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?c$.resolve(i).then(e=>l.active?e:c0(new lX.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):p.then(()=>i)).then(e=>(a&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),c0(e)))})}).bind(null,this,o,a,r,t);return r?r._promise(o,s,"lock"):cb.trans?cY(cb.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!lp(this._allTables,e))throw new lX.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let ul="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class uc{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[ul](){return this}}function up(e,n){return lr(n).forEach(t=>{ut(e[t]||(e[t]=new ue),n[t])}),e}try{a={indexedDB:la.indexedDB||la.mozIndexedDB||la.webkitIndexedDB||la.msIndexedDB,IDBKeyRange:la.IDBKeyRange||la.webkitIDBKeyRange}}catch(e){a={indexedDB:null,IDBKeyRange:null}}function uu(e){let n=ud;try{ud=!0,pP.storagemutated.fire(e)}finally{ud=n}}lu(us,{...l0,delete:e=>new us(e,{addons:[]}).delete(),exists:e=>new us(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return pQ(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==c9)):pX(e,n).toCollection().primaryKeys()})(us.dependencies).then(e)}catch(e){return c0(new lX.MissingAPI)}},defineClass:()=>function(e){ls(this,e)},ignoreTransaction:e=>cb.trans?cY(cb.transless,e):e(),vip:p0,async:function(e){return function(){try{var n=p1(e.apply(this,arguments));return n&&"function"==typeof n.then?n:c$.resolve(n)}catch(e){return c0(e)}}},spawn:function(e,n,t){try{var o=p1(e.apply(t,n||[]));return o&&"function"==typeof o.then?o:c$.resolve(o)}catch(e){return c0(e)}},currentTransaction:{get:()=>cb.trans||null},waitFor:function(e,n){let t=c$.resolve("function"==typeof e?us.ignoreTransaction(e):e).timeout(n||6e4);return cb.trans?cb.trans.waitFor(t):t},Promise:c$,debug:{get:()=>lR,set:e=>{lR=e,lF="dexie"===e?()=>!0:c8}},derive:lh,extend:ls,props:lu,override:l_,Events:pi,on:pP,liveQuery:function(e){let n,t=!1,o=new uc(o=>{let a=lj(e),r=!1,i={},s={},l={get closed(){return r},unsubscribe:()=>{r=!0,pP.storagemutated.unsubscribe(d)}};o.start&&o.start(l);let c=!1,p=!1;function u(){return lr(s).some(e=>i[e]&&function(e,n){let t=uo(n),o=t.next();if(o.done)return!1;let a=o.value,r=uo(e),i=r.next(a.from),s=i.value;for(;!o.done&&!i.done;){if(0>=pm(s.from,a.to)&&pm(s.to,a.from)>=0)return!0;0>pm(a.from,s.from)?a=(o=t.next(s.from)).value:s=(i=r.next(a.from)).value}return!1}(i[e],s[e]))}let d=e=>{up(i,e),u()&&f()},f=()=>{let h,m;if(c||r)return;i={};let g={},b=(a&&cW(),h=()=>cL(e,{subscr:g,trans:null}),m=cb.trans?cY(cb.transless,h):h(),a&&m.then(cV,cV),m);p||(pP(pz,d),p=!0),c=!0,Promise.resolve(b).then(e=>{t=!0,n=e,c=!1,r||(u()?f():(i={},s=g,o.next&&o.next(e)))},e=>{c=!1,t=!1,o.error&&o.error(e),l.unsubscribe()})};return f(),l});return o.hasValue=()=>t,o.getValue=()=>n,o},extendObservabilitySet:up,getByKeyPath:lw,setByKeyPath:lk,delByKeyPath:function(e,n){"string"==typeof n?lk(e,n,void 0):"length"in n&&[].map.call(n,function(n){lk(e,n,void 0)})},shallowClone:lx,deepClone:lM,getObjectDiff:p4,cmp:pm,asap:l$,minKey:c3,addons:[],connections:c6,errnames:lJ,dependencies:a,semVer:c1,version:c1.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),us.maxKey=pB(us.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(pP(pz,e=>{if(!ud){let n;c7?(n=document.createEvent("CustomEvent")).initCustomEvent(pM,!0,!0,e):n=new CustomEvent(pM,{detail:e}),ud=!0,dispatchEvent(n),ud=!1}}),addEventListener(pM,({detail:e})=>{ud||uu(e)}));let ud=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(pM);"function"==typeof e.unref&&e.unref(),pP(pz,n=>{ud||e.postMessage(n)}),e.onmessage=e=>{e.data&&uu(e.data)}}else if("u">typeof self&&"u">typeof navigator){pP(pz,e=>{try{ud||("u">typeof localStorage&&localStorage.setItem(pM,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:pM,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===pM){let n=JSON.parse(e.newValue);n&&uu(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===pM&&uu(e.changedParts)})}function uf(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}c$.rejectionMapper=function(e,n){if(!e||e instanceof lH||e instanceof TypeError||e instanceof SyntaxError||!e.name||!lQ[e.name])return e;var t=new lQ[e.name](n||e.message,e);return"stack"in e&&lf(t,"stack",{get:function(){return this.inner.stack}}),t},lF=c8;class uh extends us{constructor(){super("EsmOffline"),uf(this,"syncQueue",void 0),uf(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 um(){return new uh}let ug=new uh,ub={},uy=G("offline-synchronization",{});function u_(){return uy}async function uv(){if(uy.getState().synchronization)return;let e=await ug.syncQueue.count(),n={},t=Object.entries(ub),o=t.length,a={},r=new AbortController,i=()=>{let e=uy.getState().synchronization;uy.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{uy.setState({synchronization:{totalCount:e,pendingCount:e,abortController:r}});for(let e=0;e<o&&t.length>0;e++)for(let e=t.length;e--;){let[o,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(a[o]={},await Promise.all(l),n[o]=u$(s,a,r,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{uy.setState({synchronization:void 0})}}async function u$({type:e,dependsOn:n,process:t},o,a,r){let i=[],s=[],l=await uA();await ug.syncQueue.where({type:e,userId:l}).each((e,n)=>{i.push([n.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<i.length;c++){let[p,u,{id:d,dependencies:f=[]}]=i[c];try{let r=await t(u,{abort:a,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?o[t][e]:void 0)});void 0!==d&&(o[e][d]=r),await ug.syncQueue.delete(p)}catch(e){await ug.syncQueue.update(p,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{r()}}}async function uA(){let e=await io();return e?.uuid||"*"}async function uw(e,n,t,o){let a=o&&o.id;return void 0!==a&&await ug.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===a).delete().catch(us.errnames.DatabaseClosed),await ug.syncQueue.add({type:n,content:t,userId:e,descriptor:o||{},createdOn:new Date}).catch(us.errnames.DatabaseClosed,()=>-1)}async function uk(e,n,t){let o=await uA();return await uw(o,e,n,t)}async function ux(e,n){return(await uC(e,n)).map(e=>e.content)}async function uC(e,n){return await ug.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(us.errnames.DatabaseClosed,()=>[])}async function uE(e){let n=await uA();return await ux(n,e)}async function uS(e){let n=await uA();return await uC(n,e)}async function uD(e){return await ug.syncQueue.get(e).catch(us.errnames.DatabaseClosed,()=>void 0)}function uz(e){return!!ub[e]?.options.onBeginEditSyncItem}async function uM(e){let n=await uD(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=ub[n.type]?.options.onBeginEditSyncItem;if(!t)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 "${n.type}" supports editing items.`);t(n)}async function uP(e){await ug.syncQueue.delete(e).catch(us.errnames.DatabaseClosed)}function uO(e,n,t,o={}){ub[e]={type:e,dependsOn:n,process:t,options:o}}let uT="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),uN=new Uint8Array(16),uI=[];for(let e=0;e<256;++e)uI.push((e+256).toString(16).slice(1));let uB=function(e,n,t){if(uT&&!n&&!e)return uT();let o=(e=e||{}).random||(e.rng||function(){if(!r&&!(r="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 r(uN)})();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=o[e];return n}return function(e,n=0){return uI[e[n+0]]+uI[e[n+1]]+uI[e[n+2]]+uI[e[n+3]]+"-"+uI[e[n+4]]+uI[e[n+5]]+"-"+uI[e[n+6]]+uI[e[n+7]]+"-"+uI[e[n+8]]+uI[e[n+9]]+"-"+uI[e[n+10]]+uI[e[n+11]]+uI[e[n+12]]+uI[e[n+13]]+uI[e[n+14]]+uI[e[n+15]]}(o)},uj="OFFLINE+";function uR(){return uj+uB()}function uF(e){return e.startsWith(uj)}let uL={};function uW(){return Object.values(uL)}function uV(e){uL[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.`),uL[e.id]=e}async function uG(e){let n=await uX();return await uU(n,e)}async function uU(e,n){let t=new uh;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(us.errnames.DatabaseClosed,()=>[])}async function uq(e,n){let t=await uX();return await uH(t,e,n)}async function uH(e,n,t){let o=new uh,a=await o.dynamicOfflineData.get({type:n,identifier:t}).catch(us.errnames.DatabaseClosed,()=>void 0);a?a.users.includes(e)||await o.dynamicOfflineData.update(a.id,{users:[...a.users,e]}).catch(us.errnames.DatabaseClosed):await o.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(us.errnames.DatabaseClosed)}async function uK(e,n){let t=await uX();return await uY(t,e,n)}async function uY(e,n,t){let o=new uh,a=await o.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(us.errnames.DatabaseClosed,()=>void 0);a&&(a.users.length>1?await o.dynamicOfflineData.update(a.id,{users:a.users.filter(n=>n!==e)}).catch(us.errnames.DatabaseClosed):await o.dynamicOfflineData.delete(a.id).catch(us.errnames.DatabaseClosed))}async function uZ(e,n){let t=await uG(e);await Promise.all(t.map(async e=>uJ(e.type,e.identifier,n)))}async function uJ(e,n,t){await uq(e,n);let o=new uh,a=await uX(),r=await o.dynamicOfflineData.get({type:e,identifier:n}).catch(us.errnames.DatabaseClosed,()=>void 0),i=uW().filter(n=>n.type===e);if(!r)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(n,t),{id:e.id,error:void 0}}catch(t){let n=t.message?.toString()??t.toString();return{id:e.id,error:n}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),p=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),u={syncedOn:new Date,syncedBy:a,succeededHandlers:l,erroredHandlers:c,errors:p};r.id&&await o.dynamicOfflineData.update(r.id,{syncState:u}).catch(us.errnames.DatabaseClosed)}async function uX(){let e=(await io()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let uQ=G("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function u0(){return u3(),uQ}function u1(e,n){u3(),uV({type:"patient",displayName:n.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,t)=>n.onOfflinePatientAdded({patientUuid:e,signal:t??new AbortController().signal})})}async function u2(e){u3(),await uJ("patient",e)}function u3(){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 u5(e,n,t=!0){if(e){let o=null,[a,r]=await Promise.all([r1(`${rX}/Patient/${e}`,n).catch(e=>o=e),t?u4(e):Promise.resolve(null)]);if(a.ok)return a.data;if(r)return r;if(o)throw o}return null}async function u4(e){let n=(await uE("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function u6(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function u7(e,n){let t=e=>{n("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,t),()=>{window.removeEventListener(`openmrs:${e}`,t)}}var u8=t(9549);function u9(e){return{uuid:e.uuid,display:e.display}}function de(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let o=t.toString();return r2(`${rJ}/location${o?"?"+o:""}`).pipe((0,u8.map)(e=>e.data.results.map(u9))).pipe((0,u8.take)(1))}function dn(e){return{uuid:e.uuid,display:e.display,name:e.name}}function dt(){return r2(`${rJ}/visittype`).pipe((0,u8.map)(e=>e.data.results.map(dn))).pipe((0,u8.take)(1))}var da=((ea={}).NEWVISIT="startVisit",ea.EDITVISIT="editVisit",ea.LOADING="loadingVisit",ea),dr=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let di="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))",ds=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function dl(){return q("visit",ds)}function dc(e,n){dl().setState({patientUuid:e,manuallySetVisitUuid:n})}function dp(e,n){return r1(`${rJ}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function du(e,n,t){return r1(`${rJ}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function dd(e,n,t){return r1(`${rJ}/visit?patient=${e}&v=${t??di}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}dl().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let df=new el.BehaviorSubject(null);class dh{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+dh.version}static addUnaryOp(e){return dh.max_unop_len=Math.max(e.length,dh.max_unop_len),dh.unary_ops[e]=1,dh}static addBinaryOp(e,n,t){return dh.max_binop_len=Math.max(e.length,dh.max_binop_len),dh.binary_ops[e]=n,t?dh.right_associative.add(e):dh.right_associative.delete(e),dh}static addIdentifierChar(e){return dh.additional_identifier_chars.add(e),dh}static addLiteral(e,n){return dh.literals[e]=n,dh}static removeUnaryOp(e){return delete dh.unary_ops[e],e.length===dh.max_unop_len&&(dh.max_unop_len=dh.getMaxKeyLen(dh.unary_ops)),dh}static removeAllUnaryOps(){return dh.unary_ops={},dh.max_unop_len=0,dh}static removeIdentifierChar(e){return dh.additional_identifier_chars.delete(e),dh}static removeBinaryOp(e){return delete dh.binary_ops[e],e.length===dh.max_binop_len&&(dh.max_binop_len=dh.getMaxKeyLen(dh.binary_ops)),dh.right_associative.delete(e),dh}static removeAllBinaryOps(){return dh.binary_ops={},dh.max_binop_len=0,dh}static removeLiteral(e){return delete dh.literals[e],dh}static removeAllLiterals(){return dh.literals={},dh}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 dh(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 dh.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!dh.binary_ops[String.fromCharCode(e)]||dh.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return dh.isIdentifierStart(e)||dh.isDecimalDigit(e)}throwError(e){let n=Error(e+" at character "+this.index);throw n.index=this.index,n.description=e,n}runHook(e,n){if(dh.hooks[e]){let t={context:this,node:n};return dh.hooks.run(e,t),t.node}return n}searchHook(e){if(dh.hooks[e]){let n={context:this};return dh.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===dh.SPACE_CODE||e===dh.TAB_CODE||e===dh.LF_CODE||e===dh.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),n=1===e.length?e[0]:{type:dh.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,o;for(;this.index<this.expr.length;)if((t=this.code)===dh.SEMCOL_CODE||t===dh.COMMA_CODE)this.index++;else if(o=this.gobbleExpression())n.push(o);else if(this.index<this.expr.length){if(t===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}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,dh.max_binop_len),n=e.length;for(;n>0;){if(dh.binary_ops.hasOwnProperty(e)&&(!dh.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!dh.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=n,e;e=e.substr(0,--n)}return!1}gobbleBinaryExpression(){let e,n,t,o,a,r,i,s,l;if(!(r=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return r;for(a={value:n,prec:dh.binaryPrecedence(n),right_a:dh.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),o=[r,a,i];n=this.gobbleBinaryOp();){if(0===(t=dh.binaryPrecedence(n))){this.index-=n.length;break}a={value:n,prec:t,right_a:dh.right_associative.has(n)},l=n;let s=e=>a.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;o.length>2&&s(o[o.length-2]);)i=o.pop(),n=o.pop().value,r=o.pop(),e={type:dh.BINARY_EXP,operator:n,left:r,right:i},o.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),o.push(a,e)}for(s=o.length-1,e=o[s];s>1;)e={type:dh.BINARY_EXP,operator:o[s-1].value,left:o[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,o;if(this.gobbleSpaces(),o=this.searchHook("gobble-token"))return this.runHook("after-token",o);if(e=this.code,dh.isDecimalDigit(e)||e===dh.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===dh.SQUOTE_CODE||e===dh.DQUOTE_CODE)o=this.gobbleStringLiteral();else if(e===dh.OBRACK_CODE)o=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,dh.max_unop_len)).length;t>0;){if(dh.unary_ops.hasOwnProperty(n)&&(!dh.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!dh.isIdentifierPart(this.expr.charCodeAt(this.index+n.length)))){this.index+=t;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:dh.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}dh.isIdentifierStart(e)?(o=this.gobbleIdentifier(),dh.literals.hasOwnProperty(o.name)?o={type:dh.LITERAL,value:dh.literals[o.name],raw:o.name}:o.name===dh.this_str&&(o={type:dh.THIS_EXP})):e===dh.OPAREN_CODE&&(o=this.gobbleGroup())}return o?(o=this.gobbleTokenProperty(o),this.runHook("after-token",o)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===dh.PERIOD_CODE||n===dh.OBRACK_CODE||n===dh.OPAREN_CODE||n===dh.QUMARK_CODE;){let t;if(n===dh.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==dh.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===dh.OBRACK_CODE?((e={type:dh.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==dh.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===dh.OPAREN_CODE?e={type:dh.CALL_EXP,arguments:this.gobbleArguments(dh.CPAREN_CODE),callee:e}:(n===dh.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:dh.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),t&&(e.optional=!0),this.gobbleSpaces(),n=this.code}return e}gobbleNumericLiteral(){let e="",n,t;for(;dh.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===dh.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);dh.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(n=this.char)||"E"===n){for(e+=this.expr.charAt(this.index++),("+"===(n=this.char)||"-"===n)&&(e+=this.expr.charAt(this.index++));dh.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);dh.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,dh.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===dh.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===dh.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:dh.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),o=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){o=!0;break}if("\\"===n)switch(n=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+=n}else e+=n}return o||this.throwError('Unclosed quote after "'+e+'"'),{type:dh.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(dh.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,dh.isIdentifierPart(e))this.index++;else break;return{type:dh.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,o=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){t=!0,this.index++,e===dh.CPAREN_CODE&&o&&o>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===dh.COMMA_CODE){if(this.index++,++o!==n.length){if(e===dh.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===dh.CBRACK_CODE)for(let e=n.length;e<o;e++)n.push(null)}}else if(n.length!==o&&0!==o)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==dh.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(dh.CPAREN_CODE);if(this.code===dh.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:dh.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:dh.ARRAY_EXP,elements:this.gobbleArguments(dh.CBRACK_CODE)}}}Object.assign(dh,{hooks:new class{add(e,n,t){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]||[],n&&this[e][t?"unshift":"push"](n)},this)}run(e,n){this[e]=this[e]||[],this[e].forEach(function(e){e.call(n&&n.context?n.context:n,n)})}},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)})}}(dh),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"}),dh.max_unop_len=dh.getMaxKeyLen(dh.unary_ops),dh.max_binop_len=dh.getMaxKeyLen(dh.binary_ops);let dm=e=>new dh(e).parse(),dg=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(dh).filter(e=>!dg.includes(e)&&void 0===dm[e]).forEach(e=>{dm[e]=dh[e]}),dm.Jsep=dh,dm.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:o,alternate:a},t.operator&&e.binary_ops[t.operator]<=.9){let o=t;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let db="ArrowFunctionExpression",dy={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)}},d_={...dy,Promise};function dv(e,n={}){return dC(e,n,dD)}async function d$(e,n={}){return dE(e,n,dD)}function dA(e,n={}){return dC(e,n,dz)}function dw(e,n={}){return dE(e,n,dz)}function dk(e,n={}){return dC(e,n,dM)}function dx(e,n={}){return dE(e,n,dM)}function dC(e,n={},t){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==n&&(n={});let o=dT(n,dy),a=dP("string"==typeof e?dm(e):e,o);if(t(a))return a;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 dE(e,n={},t){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==n&&(n={});let o=dT(n,d_);return Promise.resolve(dP("string"==typeof e?dm(e):e,o)).then(n=>{if(t(n))return n;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 dS(e){return dm(e)}function dD(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function dz(e){return"boolean"==typeof e}function dM(e){return"number"==typeof e}function dP(e,n){switch(e.type){case"UnaryExpression":var t,o,a,r,i,s,l,c,p,u,d,f,h=e,m=n;let g=dP(h.argument,m);switch(h.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var b=e,y=n;let v=dP(b.left,y),$=dP(b.right,y);switch(b.operator){case"+":return v+$;case"-":return v-$;case"*":return v*$;case"/":return v/$;case"%":return v%$;case"**":return v**$;case"==":return v==$;case"===":return v===$;case"!=":return v!=$;case"!==":return v!==$;case">":return v>$;case">=":return v>=$;case"<":return v<$;case"<=":return v<=$;case"in":return v in $;case"&&":return v&&$;case"||":return v||$;case"??":return v??$;default:throw`Expression evaluator does not support operator '${b.operator}' operator`}case"ConditionalExpression":return t=e,o=n,dP(t.test,o)?dP(t.consequent,o):dP(t.alternate,o);case"CallExpression":var A=e,w=n;let k=A.arguments?.map(dN(w)),x=dP(A.callee,w);if(x){if("function"!=typeof x)throw`${dB(A.callee)} is not a function`}else throw`No function named ${dB(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return a=e,r=n,C=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<C.length)throw`Required argument(s) ${C.slice(e.length,-1).join(", ")} were not provided`;let n=Object.fromEntries(C.reduce((n,t,o)=>{let a=e[o];return function e(n){if("string"==typeof n||"number"==typeof n||"boolean"==typeof n||"function"==typeof n||null===n||n instanceof RegExp)return!0;if("object"==typeof n){for(let t of Object.keys(n))if(!e(n[t]))return!1;return!0}if(Array.isArray(n)){for(let t of n)if(!e(t))break}return!1}(a)&&n.push([t,a]),n},[]));return dP(a.body,r.addVariables(n))}).bind(r.thisObj??null);case"MemberExpression":return function(e,n){let t,o=dP(e.object,n);if(void 0===o)switch(e.object.type){case"Identifier":{let t=dO(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=dO(e.property,n);throw TypeError(`TypeError: cannot read properties of undefined (reading '${t}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let a=o;if("string"==typeof o)a=String.prototype;else if("number"==typeof o)a=Number.prototype;else if("function"==typeof o);else if("object"!=typeof o)throw`VisitMemberExpression does not support member access on type ${typeof o}`;switch(n.thisObj=a,e.property.type){case"Identifier":case"MemberExpression":t=dP(e.property,n);break;default:{let a=dP(e.property,n);if(void 0===a)throw{type:"Illegal property access",message:"No property was supplied to the property access"};dI(a),t=o[a]}}return"function"==typeof t?t.bind(o):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(dN(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(dN(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(dN(D));switch(S.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${S.callee.name}`}}if(S.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return dI((p=e).value),p.value;case"Identifier":var z=e,M=n;dI(z.name);let P=M.thisObj;if(P&&("object"==typeof P||"function"==typeof P)&&z.name in P){let e=P[z.name];return dI(e),e}if(M.variables&&z.name in M.variables){let e=M.variables[z.name];return dI(e),e}return z.name in M.globals?M.globals[z.name]:void 0;case"TemplateLiteral":let O,T;return u=e,d=n,O=u.expressions?.map(dN(d))??[],(T=u.quasis?.map(dN(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+O.join("")+T.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dO(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return dO(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function dT(e,n){let t={thisObj:void 0,variables:{...e},globals:{...n},addVariables(e){return this.variables={...this.variables,...e},this}};return t.addVariables.bind(t),t}function dN(e){return function(n){return null===n?null:dP(n,e)}}function dI(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function dB(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function dj(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 n={globals:{...d_},isLocalExpression:!1,variables:new Set};return dR("string"==typeof e?dm(e):e,n),[...n.variables]}function dR(e,n){switch(e.type){case"UnaryExpression":return o=e,a=n,dR(o.argument,a);case"BinaryExpression":return r=e,i=n,[dR(r.left,i),dR(r.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[dR(s.consequent,l),dR(s.test,l),dR(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,p=n,t=dR(c.callee,p),c.arguments?.map(dF(p)),t;case"ArrowFunctionExpression":var o,a,r,i,s,l,c,p,u,d,f,h,m,g,b,y,v,$,A=e,w=n;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(dF(k))??[],C=dR(A.body,k)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||w.variables.add(e);return;case"MemberExpression":let E;return u=e,d=n,dR(u.object,d),void((E={...d}).isLocalExpression=!0,dR(u.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(dF(h));case"SequenceExpression":return m=e,g=n,void m.expressions?.map(dF(g));case"NewExpression":return b=e,y=n,void b.arguments?.map(dF(y));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=n;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=n,void(v.expressions?.map(dF($)),v.quasis?.map(dF($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dF(e){return function(n){return null===n?null:dR(n,e)}}dm.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(n){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let t=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let t=this.gobbleBinaryExpression();t||this.throwError("Expected expression after "+e),n.node={type:db,params:null,body:t};return}}this.index=t}}),e.hooks.add("after-expression",function(n){!function n(t){t&&(Object.values(t).forEach(e=>{e&&"object"==typeof e&&n(e)}),"=>"===t.operator&&(t.type=db,t.params=t.left?[t.left]:null,t.body=t.right,t.params&&t.params[0].type===e.SEQUENCE_EXP&&(t.params=t.params[0].expressions),delete t.left,delete t.right,delete t.operator))}(n.node)})}}),dm.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(n){let t=n.node;if(t&&"new"===t.operator){t.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(t.argument.type)||this.throwError("Expected new function()"),n.node=t.argument;let o=n.node;for(;o.type===e.MEMBER_EXP||o.type===e.CALL_EXP&&o.callee.type===e.MEMBER_EXP;)o=o.type===e.MEMBER_EXP?o.object:o.callee.object;o.type="NewExpression"}})}}),dm.plugins.register({name:"numbers",init(e){function n(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 t(n){let t=this.index,o="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:o+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(o+=this.expr.charAt(this.index++),a());let r=this.char;("e"===r||"E"===r)&&(o+=this.expr.charAt(this.index++),("+"===(r=this.char)||"-"===r)&&(o+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+o+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+o+this.char+")");else if(i===e.PERIOD_CODE){o.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:o},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(o),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(o){if(48===this.code){var a,r,i;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let p="";for(;a=this.code,r=c,95===a||r.some(([e,n])=>a>=e&&a<=n);)95===this.code?this.index++:p+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,t.call(this,o);return}this.throwError("unexpected char within number")}o.node={type:e.LITERAL,value:parseInt(p,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&t.call(this,o)})}}),dm.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,o=!1;for(;this.index<this.expr.length;){if(47===this.code&&!o){let o,a=this.expr.slice(t,this.index),r="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)r+=this.char;else break}try{o=new RegExp(a,r)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:o,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?o=!0:o&&this.code===e.CBRACK_CODE&&(o=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),dm.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:o,alternate:a},t.operator&&e.binary_ops[t.operator]<=.9){let o=t;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),dm.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},o="",a="",r=!1,i=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:a,cooked:o},tail:r});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,r=!0,s(),e.node=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",o="",n.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(a+=i,i=this.expr.charAt(++this.index),a+=i,i){case"n":o+="\n";break;case"r":o+="\r";break;case"t":o+=" ";break;case"b":o+="\b";break;case"f":o+="\f";break;case"v":o+="\v";break;default:o+=i}else o+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",n),e.hooks.add("after-token",function(t){if((t.node.type===e.IDENTIFIER||t.node.type===e.MEMBER_EXP)&&96===this.code)return t.node={type:"TaggedTemplateExpression",tag:t.node,quasi:n.bind(this)(t,!1)},t.node=this.gobbleTokenProperty(t.node),t.node})}}),dm.addBinaryOp("in",7),dm.addBinaryOp("??",1);let dL=q("feature-flags",{flags:function(){let e={};for(let n of Object.keys(localStorage))if(n.startsWith("openmrs:feature-flag:")){let t=n.replace("openmrs:feature-flag:",""),o=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...o}}return e}()});function dW(e,n,t){dL.setState(o=>({flags:{...o.flags,[e]:{enabled:o.flags[e]?.enabled??!1,label:n,description:t}}}))}function dV(){let e=dL.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(n=>{let t=n.replace("openmrs:feature-flag:","");e[t]||(localStorage.removeItem(n),localStorage.removeItem(`openmrs:feature-flag-meta:${t}`))})}function dG(e){return dL.getState().flags[e].enabled}function dU(e,n){dL.subscribe(t=>{n(t.flags[e].enabled)})}function dq(e,n){dL.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function dH(e){return!window.offlineEnabled||(e??navigator.onLine)}dL.subscribe(e=>{for(let[n,t]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${n}`,t.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${n}`,JSON.stringify({label:t.label,description:t.description}))});var dK=nJ(function(e,n,t){nV(e,n,t)});function dY(e=!0,n=!1){return dZ(dH(),e,n)}function dZ(e,n=!0,t=!1){return!!(e?n:t)}let dJ=G("extensionsInternal",{slots:{},extensions:{}}),dX=()=>q("extensionsInternal",{slots:{},extensions:{}});function dQ(e){let n=dJ.getState(),t=e(n);t!==n&&dJ.setState(t)}let d0=()=>q("extensions",{slots:{}});function d1(e){let n=[];for(let t of Object.values(e.extensions))for(let e of t.instances)n.push({slotModuleName:e.slotModuleName,extensionModuleName:t.moduleName,slotName:e.slotName,extensionId:e.id});tP(ox.getState().mountedExtensions,n)||ox.setState({mountedExtensions:n})}d1(dJ.getState()),dJ.subscribe(d1);let d2=dX(),d3=d0(),d5=oE(),d4=oz();function d6(e,n,t,o,a){let r={},i=dH(),s=Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[o,l]of Object.entries(e.slots)){let{config:c}=oD(n,l.name),p=fs(o,e,c,t,s,i,a.session);r[o]={moduleName:l.moduleName,assignedExtensions:p}}tP(d3.getState().slots,r)||d3.setState({slots:r})}function d7(){d6(d2.getState(),d5.getState(),d4.getState(),dL.getState(),r5.getState())}function d8(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function d9(e){let[n]=e.split("#");return n}function fe(e,n){let t=d9(n);return e.extensions[t]}function fn(e){return fe(d2.getState(),e)}d2.subscribe(e=>{d6(e,d5.getState(),d4.getState(),dL.getState(),r5.getState())}),d5.subscribe(e=>{d6(d2.getState(),e,d4.getState(),dL.getState(),r5.getState())}),d4.subscribe(e=>{d6(d2.getState(),d5.getState(),e,dL.getState(),r5.getState())}),dL.subscribe(e=>{d6(d2.getState(),d5.getState(),d4.getState(),e,r5.getState())}),r5.subscribe(e=>{d6(d2.getState(),d5.getState(),d4.getState(),dL.getState(),e)}),d7(),g(d7);let ft=e=>d2.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function fo(e,n){dQ(t=>{let o=t.slots[e];return o?{...t,slots:{...t.slots,[e]:{...o,attachedIds:[...o.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...d8(e),attachedIds:[n]}}}})}function fa(e,n){dQ(t=>{let o=t.slots[e];return o&&o.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...o,attachedIds:o.attachedIds.filter(e=>e!==n)}}}:t})}function fr(e){dQ(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function fi(e,n,t,o){let a=n.indexOf(e);if(-1!==a)return a;{if(void 0!==t)return 1e3+t;let n=o.indexOf(e);return -1!==n?2e3+n:-1}}function fs(e,n,t,o,a,r,i){let s=function(e,n){let t=e.add||[],o=e.remove||[],a=e.order||[],{extensions:r}=d2.getState();return[...n,...t].filter(e=>!o.includes(e)).sort((e,t)=>{let o=fi(e,a,r[d9(e)]?.order,n),i=fi(t,a,r[d9(t)]?.order,n);return -1===i?-1:-1===o?1:o-i})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,p=c&&"object"==typeof c?{session:i,...c}:{session:i};for(let c of s){let{config:s}=oP(o,e,c),u=dK(s,oO(t,e,c)),d=d9(c),f=n.extensions[d];if(f){let n=u?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!i?.user||!it(n,i.user)))continue;let t=u?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!dA(t,p))continue}catch(n){console.error(`Error while evaluating expression '${t}' for extension ${d} in slot ${e}`,n);continue}if(f.featureFlag&&!a.includes(f.featureFlag)||window.offlineEnabled&&!dZ(r,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:u,featureFlag:f.featureFlag,meta:f.meta,online:u?.["Display conditions"]?.online??f.online??!0,offline:u?.["Display conditions"]?.offline??f.offline??!1})}}return l}function fl(e){let n=d2.getState(),{config:t}=oS(e),o=d4.getState(),a=dL.getState(),r=r5.getState(),i=dH();return fs(e,n,t,o,Object.entries(a.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),i,r.session)}let fc=(e,n,t)=>d2.setState(o=>{let a=o.slots[n]?.moduleName;if(a&&a!=e)return console.warn(`An extension slot with the name '${n}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${a}.`),o;if(a&&a==e)return o;if(o.slots[n])return{...o,slots:{...o.slots,[n]:{...o.slots[n],moduleName:e,state:t}}};let r=d8(n,e,t);return{...o,slots:{...o.slots,[n]:{...r}}}});function fp(e,n,t=!1){d2.setState(o=>{let a=t?dK(o.slots[e].state,n):n;return{...o,slots:{...o.slots,[e]:{...o.slots[e],state:a}}}})}let fu=()=>d3.setState(()=>({slots:{},extensions:{}})),fd=G("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function ff({name:e,basePath:n,mode:t,componentContext:o,state:a}){fd.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:o,state:a})}function fh(e){fd.getState().slotName===e&&fd.setState(fd.getInitialState(),!0)}let fm=G("modalRegistry",{modals:{}});function fg(e){fm.setState(n=>(n.modals[e.name]=e,n))}function fb(e){let n=fm.getState().modals[e];if(!n){let t=fn(e);t&&(n={name:e,load:t.load,moduleName:t.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.`),fg(n))}return n}let fy=G("workspaceRegistrations",{workspaces:{}}),f_=G("workspaceGroups",{workspaceGroups:{}});function fv(e){fy.setState(n=>({workspaces:{...n.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 f$(e){f_.setState(n=>{let t=n.workspaceGroups[e.name];return t?{workspaceGroups:{...n.workspaceGroups,[e.name]:{...t,members:Array.from(new Set([...t.members,...e.members]))}}}:{workspaceGroups:{...n.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let fA=new Set;function fw(e){let n=fy.getState().workspaces;if(n[e])return n[e];{let n=fn(e);if(n){var t;let o;return fA.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.`),fA.add(e)),{name:n.name,title:(t=n,"string"==typeof(o=t?.meta?.title)?o:o&&"object"==typeof o?i2(t.moduleName,o.key,o.default):t.name),moduleName:n.moduleName,preferredWindowSize:n.meta?.screenSize??"normal",load:n.load,type:n.meta?.type??"form",canHide:n.meta?.canHide??!1,canMaximize:n.meta?.canMaximize??!1,width:n.meta?.width??"narrow",groups:n.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function fk(e){let n=f_.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let fx=G("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function fC(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=fx.getState(),o=n[e];if(o){let n=t[o.window];if(n)return n;throw Error(`No workspace window found with name: ${o.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function fE(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=fx.getState(),o=t[e];if(o){let t=n[o.group];if(t)return t;throw Error(`No workspace group found with name: ${o.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function fS(e){let{openedWindows:n}=fx.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function fD(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=fx.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);o[t.name]={...t,moduleName:e}}fx.setState({registeredGroupsByName:o})}function fz(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=fx.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};o[t.name]=n}fx.setState({registeredWindowsByName:o})}function fM(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=fx.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};o[t.name]=n}fx.setState({registeredWorkspacesByName:o})}let fP=0;async function fO(e,n,t,o,a=e=>e,r={}){let i=d9(o),s=fn(o),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:p,online:u,offline:d,load:f}=s;if(dY(u,d)){dQ(a=>({...a,extensions:{...a.extensions,[i]:{...a.extensions[i],instances:[...a.extensions[i].instances,{domElement:e,id:o,slotName:n,slotModuleName:t}]}}}));let s=await f(),u=fP++;l=aQ(a({...s,name:`${n}/${i}-${u}`}),{...r,_meta:c,_extensionContext:{extensionId:o,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:p},domElement:e})}}else console.warn(`Tried to render ${o} into ${n} but no DOM element was available.`);return l}var fT=t(2491),fN=t.n(fT);let fI=(0,fT.createContext)({moduleName:"",featureName:""});function fB({to:e,templateParams:n,onBeforeNavigate:t,children:o,...a}){return(0,fT.useEffect)(()=>{a.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${a.href}'`),a.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),fN().createElement("a",{onClick:o=>{0===o.button&&!o.ctrlKey&&!o.shiftKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),t?.(o),rL({to:e,templateParams:n})),0===o.button&&(o.ctrlKey||o.metaKey)&&t?.(o),0===o.button&&o.shiftKey&&t?.(o),1===o.button&&t?.(o)},href:rR(e,n),...a},o)}let fj=({state:e,children:n,...t})=>{let{extension:o}=(0,fT.useContext)(fI),a=(0,fT.useRef)(null),r=(0,fT.useRef)(Promise.resolve()),i=(0,fT.useCallback)(n=>{o?.extensionSlotName&&o.extensionSlotModuleName&&o.extensionSlotModuleName&&!a.current&&fO(n,o.extensionSlotName,o.extensionSlotModuleName,o.extensionId,void 0,e).then(e=>{a.current=e})},[]);return(0,fT.useEffect)(()=>()=>{if(a&&a.current)switch(a.current.getStatus()){case"MOUNTING":a.current.mountPromise.then(()=>{a.current?.getStatus()==="MOUNTED"&&a.current.unmount()});break;case"MOUNTED":a.current.unmount();break;case"UPDATING":r.current&&r.current.then(()=>{a.current?.getStatus()==="MOUNTED"&&a.current.unmount()})}},[]),(0,fT.useEffect)(()=>{a.current&&a.current.update&&"UNMOUNTING"!==a.current.getStatus()&&Promise.all([a.current.mountPromise,r.current]).then(()=>{a?.current?.getStatus()==="MOUNTED"&&a.current.update&&(r.current=a.current.update({...e}).catch(e=>{if(!(e instanceof Error)||!e.message.includes("minified message #32")||a.current?.getStatus()==="MOUNTED")throw e}))})},[e]),o?fN().createElement("div",{ref:i,"data-extension-id":o?.extensionId,style:{position:"relative"},...t}):null};function fR(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[o,a]of Object.entries(n)){let n=function(...n){e.setState(e=>a(e,...n))};t[o]=n}return t}let fF=()=>e=>e;function fL(e,n=fF(),t){let o=(0,fT.useCallback)(n=>e.subscribe(n),[e]),a=(0,fT.useCallback)(()=>n(e.getState()),[e,n]),r=(0,fT.useSyncExternalStore)(o,a,a),i=(0,fT.useMemo)(()=>t?fR(e,t):{},[e,t]);return{...r,...i}}function fW(e,n){return fL(e,fF(),n)}function fV(e){return function(n){let t=(0,fT.useCallback)(n=>e.subscribe(n),[]),o=(0,fT.useCallback)(()=>e.getState(),[]),a=(0,fT.useSyncExternalStore)(t,o,o),r=(0,fT.useMemo)(()=>n?fR(e,n):{},[n]);return{...a,...r}}}let fG=e=>fL(d0(),n=>n.slots?.[e]);function fU(e){let n=fG(e);return n?.assignedExtensions??[]}function fq(e,n){let{moduleName:t}=(0,fT.useContext)(fI),o=(0,fT.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,fT.useEffect)(()=>{fc(t,e,n),o.current=!1},[]),(0,fT.useEffect)(()=>{o.current||fp(e,n)},[e,n]),{extensions:fU(e),extensionSlotName:e,extensionSlotModuleName:t}}function fH(e){return e}function fK({name:e,extensionSlotName:n,select:t=fH,children:o,state:a,style:r,...i}){if(o&&a)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??n,l=(0,fT.useRef)(null),{extensions:c,extensionSlotModuleName:p}=fq(s,a),u=(0,fT.useMemo)(()=>t(c),[t,c]),d=(0,fT.useMemo)(()=>{if("function"==typeof o&&!fN().isValidElement(o))return u.map(e=>o(e,a))},[o,u]);return fN().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":p,style:{...r,position:"relative"},...i},s&&u?.map((e,n)=>fN().createElement(fI.Provider,{key:e.id,value:{moduleName:p,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:p}}},d?.[n]??("function"!=typeof o?o:null)??fN().createElement(fj,{state:a}))))}var fY=t(5873);function fZ(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,o)}return t}function fJ(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?fZ(Object(t),!0).forEach(function(n){var o,a,r;o=e,a=n,r=t[n],a in o?Object.defineProperty(o,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):o[a]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):fZ(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function fX(e){return(fX="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 fQ(e){return(fQ="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 f0(e,n){var t;if("function"!=typeof(t=n.domElement?function(){return n.domElement}:n.domElementGetter?n.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var n=e.appName||e.name;if(!n)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 t="single-spa-application:".concat(n);return function(){var e=document.getElementById(t);return e||((e=document.createElement("div")).id=t,document.body.appendChild(e)),e}}(n)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(n.name,"'. Expected a function, received ").concat(fQ(t)));return function(){var e=t(n);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(n.name,"'. Expected HTMLElement, received ").concat(fQ(e)));return e}}var f1=null;try{f1=require("react").createContext()}catch(e){}var f2={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 f3(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function f5(e,n){return new Promise(function(t,o){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var n=e.version.slice(0,e.version.indexOf("."));try{return Number(n)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,r=f8(e,n,function(){t(this)}),i=f0(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,o=e.elementToRender,a=e.domElement,r=n[t];if("function"!=typeof r)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=r(a);return i.render(o),i;case"hydrateRoot":return r(a,o);default:return r(o,a),null}}({elementToRender:r,domElement:i,reactDom:f7(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function f4(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var o=e.renderResults[n.name];o&&o.unmount?o.unmount():f7(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function f6(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var o=f8(e,n,null),a=e.renderResults[n.name];if(a&&a.render)a.render(o);else{var r=f0(e,n)();f7(e).render(o,r)}})}function f7(e){return e.ReactDOMClient||e.ReactDOM}function f8(e,n,t){var o=e.React.createElement(e.rootComponent,n),a=f1?e.React.createElement(f1.Provider,{value:n},o):o;return(e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,n){function t(n){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},t.displayName="SingleSpaReactErrorBoundary(".concat(n.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||n.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},t.prototype.componentDidCatch=function(e,n){this.setState({caughtError:e,caughtErrorInfo:n})},t}(e,n),a=e.React.createElement(e.errorBoundaryClass,n,a)),a=e.React.createElement(e.SingleSpaRoot,fJ(fJ({},n),{},{mountFinished:t,updateFinished:function(){e.updateResolves[n.name]&&(e.updateResolves[n.name].forEach(function(e){return e()}),delete e.updateResolves[n.name])},unmountFinished:function(){e.unmountResolves[n.name]&&(e.unmountResolves[n.name](),delete e.unmountResolves[n.name])}}),a)}var f9=t(4011),he=t(1123),hn=t(3780);let ht={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ho=new Map;(0,hn.initCache)(ho);let ha={errorRetryCount:3,fetcher:r1,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof r3){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>ho};function hr(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},ht,e),t={...ha,...n.swrConfig};return function(e){var o,a,r,i,s;return r=a=class extends(o=fN().Component){componentDidCatch(e,t){t&&t.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:t.componentStack})),n.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:t})}render(){if(this.state.caughtError)return fN().createElement("div",null,"An error has occurred. Please try reloading the page.");{let o=fN().createElement(fT.Suspense,{fallback:null},fN().createElement(he.BE,{value:t},fN().createElement(fI.Provider,{value:this.state.config},n.disableTranslations?fN().createElement(e,this.props):fN().createElement(f9.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},fN().createElement(e,this.props)))));return n.strictMode&&fN().StrictMode?fN().createElement(fN().StrictMode,null,o):o}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${n.featureName})`,i in r?Object.defineProperty(r,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[i]=s,a}}function hi(e,n){return function(e){if("object"!==fX(e))throw Error("single-spa-react requires a configuration object");var n,t=fJ(fJ({},f2),e);if(!t.React)throw Error("single-spa-react must be passed opts.React");if(!t.ReactDOM&&!t.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(t.renderType||(null!=(n=t.ReactDOMClient)&&n.createRoot?t.renderType="createRoot":t.renderType="render"),!t.rootComponent&&!t.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(t.errorBoundary&&"function"!=typeof t.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!f1&&t.React.createContext&&(f1=t.React.createContext()),t.SingleSpaRoot=function(e){function n(e){n.displayName="SingleSpaRoot(".concat(e.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},n.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},n.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},n}(t);var o={bootstrap:f3.bind(null,t),mount:f5.bind(null,t),unmount:f4.bind(null,t)};return t.parcelCanUpdate&&(o.update=f6.bind(null,t)),o}({React:fN(),ReactDOMClient:fY,rootComponent:hr(n)(e)})}function hs(e,n){return()=>e().then(({default:e})=>hi(e,n))}function hl(e,n){return()=>Promise.resolve(hi(e,n))}let hc=hs,hp=L()(()=>({}));U("openmrs-app-context",hp);let hu={};function hd(e,n=e=>e){let t=hp.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function hf(e,n){hp.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function hh(e){return null===e?null:Object.freeze(Object.assign({},e))}let hm=new Map;function hg(e,n){let t=(0,fT.useRef)(n??{}),o=(0,fT.useRef)(n=>hf(e,n)),a=(0,fT.useRef)(Symbol());return(0,fT.useEffect)(()=>{let t=n??{},o=a.current;return null===hd(e)?!function(e,n=hu){hp.setState(t=>{if(e in t)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({},t,{[e]:n===hu?{}:n})})}(e,t):(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.`),hf(e,()=>t)),hm.set(e,o),()=>{hm.get(e)===o&&(hp.setState(n=>(e in n&&delete n[e],n)),hm.delete(e))}},[e]),(0,fT.useEffect)(()=>{let o=n??{};B(t.current,o)||(hf(e,()=>o),t.current=o)},[n]),o.current}function hb({namespace:e,value:n}){return hg(e,n),null}let hy=({children:e,value:n,fallback:t})=>n?fN().createElement(fN().Fragment,null,e):t?fN().createElement(fN().Fragment,null,t):null;function h_(){let e=(0,fT.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,fT.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function hv(e,n=e=>e??{}){let[t,o]=(0,fT.useState)(()=>{if(h$(e))return;let t=hd(e);if(null!==t)return n?n(t):t});return(0,fT.useEffect)(()=>{if(h$(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,fT.useEffect)(()=>{var t;let a;return(t=e=>{if(null==e)return void o(void 0);let t=n?n(e):e;o(e=>B(e,t)?e:t)})(hh(a=hd(e))),hp.subscribe(n=>{let o=e in n?n[e]:null;o!==a&&(a=o,t(hh(o)))})},[e,n]),t}function h$(e){return"string"!=typeof e||0===e.trim().length}function hA(e){let[n,t]=(0,fT.useState)([]);return(0,fT.useEffect)(()=>d0().subscribe(o=>{let a=o.slots[e]?.assignedExtensions.map(e=>e.id)??[];tP(a,n)||t(a)}),[]),n}function hw(e,n){let{data:t,error:o,mutate:a,isLoading:r,isValidating:i}=(0,he.Ay)(`${sB}?patient=${e}&includeEncounterless=${n}`,r1);return(0,fT.useMemo)(()=>({isLoading:r,data:t?.data.results??[],error:o,mutate:a,isValidating:i}),[t,o,r,i,a])}function hk(e){(0,fT.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let hx={},hC=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let r5=G("session",{loaded:!1,session:null}),r4=0;function r6(e={includeAuthStatus:!0}){return(r4<Date.now()-6e4||!r5.getState().loaded)&&r9(),new el.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(r5.getState()),r5.subscribe(t)})}function r7(){return(r4<Date.now()-6e4||!r5.getState().loaded)&&r9(),r5}function r8(e){let n=e.locale??e.user?.userProperties?.defaultLocale;n&&n.includes("_")&&(n=n.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(n)&&n!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",n)}function r9(e,n){r4=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),is(r1(rQ,{headers:t}))}function ie(){r5.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function it(e,n){var t,o;if(void 0===n)return!e;if(!e)return!0;return t=e,o=n,("string"==typeof t?!Y(o.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Y(o.privileges.find(n=>e===n.display))):(Y(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Y(n.roles.find(e=>"System Developer"===e.display))}function io(){let e,n;return new Promise(t=>{let o=o=>{o.loaded&&o.session.user&&(e=o.session.user,t(o.session.user),n&&n())};o(r5.getState()),e||(n=r5.subscribe(o))})}function ia(){return new Promise((e,n)=>{r6().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function ir(e,n){return is(r1(rQ,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function ii(e,n,t){return t||(t=new AbortController),await r1(`${rJ}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),r9()}function is(e){return new Promise((n,t)=>{e.then(e=>{let o;"object"==typeof e?.data?(o={loaded:!0,session:e.data},r5.setState(o),n(o)):(o={loaded:!1,session:null},r5.setState(o),t(o))}).catch(e=>{T(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};r5.setState(n),t(n)})})}function il(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}r5.subscribe(e=>{e.loaded&&e.session&&r8(e.session)});let ic={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ip(){oR("@openmrs/esm-api",rY),r9()}let iu={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"},id=e=>"string"==typeof e,ih=()=>{let e,n,t=new Promise((t,o)=>{e=t,n=o});return t.resolve=e,t.reject=n,t},im=e=>null==e?"":""+e,ig=/###/g,ib=e=>e&&e.indexOf("###")>-1?e.replace(ig,"."):e,iy=e=>!e||id(e),i_=(e,n,t)=>{let o=id(n)?n.split("."):n,a=0;for(;a<o.length-1;){if(iy(e))return{};let n=ib(o[a]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++a}return iy(e)?{}:{obj:e,k:ib(o[a])}},iv=(e,n,t)=>{let{obj:o,k:a}=i_(e,n,Object);if(void 0!==o||1===n.length){o[a]=t;return}let r=n[n.length-1],i=n.slice(0,n.length-1),s=i_(e,i,Object);for(;void 0===s.obj&&i.length;)r=`${i[i.length-1]}.${r}`,s=i_(e,i=i.slice(0,i.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${r}`]&&(s.obj=void 0);s.obj[`${s.k}.${r}`]=t},i$=(e,n)=>{let{obj:t,k:o}=i_(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,o))return t[o]},iA=(e,n,t)=>{for(let o in n)"__proto__"!==o&&"constructor"!==o&&(o in e?id(e[o])||e[o]instanceof String||id(n[o])||n[o]instanceof String?t&&(e[o]=n[o]):iA(e[o],n[o],t):e[o]=n[o]);return e};var iw={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let ik=e=>id(e)?e.replace(/[&<>"'\/]/g,e=>iw[e]):e,ix=[" ",",","?","!",";"],iC=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(void 0!==n)return n;let t=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,t),this.regExpQueue.push(e),t}}(20),iE=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let o=n.split(t),a=e;for(let e=0;e<o.length;){let n;if(!a||"object"!=typeof a)return;let r="";for(let i=e;i<o.length;++i)if(i!==e&&(r+=t),r+=o[i],void 0!==(n=a[r])){if(["string","number","boolean"].indexOf(typeof n)>-1&&i<o.length-1)continue;e+=i-e+1;break}a=n}return a},iS=e=>e?.replace("_","-"),iD={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,n){console?.[e]?.apply?.(console,n)}};class iz{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||iD,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,t,o){return o&&!this.debug?null:(id(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new iz(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new iz(this.logger,e)}}var iM=new iz;class iP{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let t=this.observers[e].get(n)||0;this.observers[e].set(n,t+1)}),this}off(e,n){if(this.observers[e]){if(!n)return void delete this.observers[e];this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,t])=>{for(let o=0;o<t;o++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,o])=>{for(let a=0;a<o;a++)t.apply(t,[e,...n])})}}class iO extends iP{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,t,o={}){let a,r=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,i=void 0!==o.ignoreJSONStructure?o.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?a=e.split("."):(a=[e,n],t&&(Array.isArray(t)?a.push(...t):id(t)&&r?a.push(...t.split(r)):a.push(t)));let s=i$(this.data,a);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=a[0],n=a[1],t=a.slice(2).join(".")),!s&&i&&id(t))?iE(this.data?.[e]?.[n],t,r):s}addResource(e,n,t,o,a={silent:!1}){let r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=[e,n];t&&(i=i.concat(r?t.split(r):t)),e.indexOf(".")>-1&&(i=e.split("."),o=n,n=i[1]),this.addNamespaces(n),iv(this.data,i,o),a.silent||this.emit("added",e,n,t,o)}addResources(e,n,t,o={silent:!1}){for(let o in t)(id(t[o])||Array.isArray(t[o]))&&this.addResource(e,n,o,t[o],{silent:!0});o.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,o,a,r={silent:!1,skipCopy:!1}){let i=[e,n];e.indexOf(".")>-1&&(i=e.split("."),o=t,t=n,n=i[1]),this.addNamespaces(n);let s=i$(this.data,i)||{};r.skipCopy||(t=JSON.parse(JSON.stringify(t))),o?iA(s,t,a):s={...s,...t},iv(this.data,i,s),r.silent||this.emit("added",e,n,t)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return void 0!==this.getResource(e,n)}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(e=>n[e]&&Object.keys(n[e]).length>0)}toJSON(){return this.data}}var iT={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,o,a){return e.forEach(e=>{n=this.processors[e]?.process(n,t,o,a)??n}),n}};let iN=Symbol("i18next/PATH_KEY");function iI(e,n){let t,o,a,{[iN]:r}=e((o=[],(a=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===iN)?o:(o.push(n),(t=Proxy.revocable(e,a)).proxy),Proxy.revocable(Object.create(null),a).proxy));return r.join(n?.keySeparator??".")}let iB={},ij=e=>!id(e)&&"boolean"!=typeof e&&"number"!=typeof e;class iR extends iP{constructor(e,n={}){super(),((e,n,t)=>{e.forEach(e=>{n[e]&&(t[e]=n[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=iM.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let o=this.resolve(e,t);if(o?.res===void 0)return!1;let a=ij(o.res);return!1!==t.returnObjects||!a}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,a=n.ns||this.options.defaultNS||[],r=t&&e.indexOf(t)>-1,i=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let o=ix.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===o.length)return!0;let a=iC.getRegExp(`(${o.map(e=>"?"===e?"\\?":e).join("|")})`),r=!a.test(e);if(!r){let n=e.indexOf(t);n>0&&!a.test(e.substring(0,n))&&(r=!0)}return r})(e,t,o);if(r&&!i){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:id(a)?[a]:a};let r=e.split(t);(t!==o||t===o&&this.options.ns.indexOf(r[0])>-1)&&(a=r.shift()),e=r.join(o)}return{key:e,namespaces:id(a)?[a]:a}}translate(e,n,t){let o="object"==typeof n?{...n}:n;if("object"!=typeof o&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof o&&(o={...o}),o||(o={}),null==e)return"";"function"==typeof e&&(e=iI(e,{...this.options,...o})),Array.isArray(e)||(e=[String(e)]);let a=void 0!==o.returnDetails?o.returnDetails:this.options.returnDetails,r=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],o),l=s[s.length-1],c=void 0!==o.nsSeparator?o.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let p=o.lng||this.language,u=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return u?a?{res:`${l}${c}${i}`,usedKey:i,exactUsedKey:i,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:`${l}${c}${i}`:a?{res:i,usedKey:i,exactUsedKey:i,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:i;let d=this.resolve(e,o),f=d?.res,h=d?.usedKey||i,m=d?.exactUsedKey||i,g=void 0!==o.joinArrays?o.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,y=void 0!==o.count&&!id(o.count),v=iR.hasDefaultValue(o),$=y?this.pluralResolver.getSuffix(p,o.count,o):"",A=o.ordinal&&y?this.pluralResolver.getSuffix(p,o.count,{ordinal:!1}):"",w=y&&!o.ordinal&&0===o.count,k=w&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${$}`]||o[`defaultValue${A}`]||o.defaultValue,x=f;b&&!f&&v&&(x=k);let C=ij(x),E=Object.prototype.toString.apply(x);if(b&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(id(g)&&Array.isArray(x))){if(!o.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,x,{...o,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return a?(d.res=e,d.usedParams=this.getUsedParamsDetails(o),d):e}if(r){let e=Array.isArray(x),n=e?[]:{},t=e?m:h;for(let e in x)if(Object.prototype.hasOwnProperty.call(x,e)){let a=`${t}${r}${e}`;v&&!f?n[e]=this.translate(a,{...o,defaultValue:ij(k)?k[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(a,{...o,joinArrays:!1,ns:s}),n[e]===a&&(n[e]=x[e])}f=n}}else if(b&&id(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,o,t));else{let n=!1,a=!1;!this.isValidLookup(f)&&v&&(n=!0,f=k),this.isValidLookup(f)||(a=!0,f=i);let s=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:f,u=v&&k!==f&&this.options.updateMissing;if(a||n||u){if(this.logger.log(u?"updateKey":"missingKey",p,l,i,u?k:f),r){let e=this.resolve(i,{...o,keySeparator:!1});e&&e.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.")}let e=[],n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if("fallback"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t<n.length;t++)e.push(n[t]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(o.lng||this.language):e.push(o.lng||this.language);let t=(e,n,t)=>{let a=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,a,u,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,a,u,o),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&y?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,o);w&&o[`defaultValue${this.options.pluralSeparator}zero`]&&0>n.indexOf(`${this.options.pluralSeparator}zero`)&&n.push(`${this.options.pluralSeparator}zero`),n.forEach(n=>{t([e],i+n,o[`defaultValue${n}`]||k)})}):t(e,i,k))}f=this.extendTranslation(f,e,o,d,t),a&&f===i&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${i}`),(a||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${i}`:i,n?f:void 0,o))}return a?(d.res=f,d.usedParams=this.getUsedParamsDetails(o),d):f}extendTranslation(e,n,t,o,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!t.skipInterpolation){let r;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let i=id(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let n=e.match(this.interpolator.nestingRegexp);r=n&&n.length}let s=t.replace&&!id(t.replace)?t.replace:t;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,t.lng||this.language||o.usedLng,t),i){let n=e.match(this.interpolator.nestingRegexp);r<(n&&n.length)&&(t.nest=!1)}!t.lng&&o&&o.res&&(t.lng=this.language||o.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>a?.[0]!==e[0]||t.context?this.translate(...e,n):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null),t)),t.interpolation&&this.interpolator.reset()}let r=t.postProcess||this.options.postProcess,i=id(r)?[r]:r;return null!=e&&i?.length&&!1!==t.applyPostProcessor&&(e=iT.handle(i,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,o,a,r,i;return id(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;o=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let p=void 0!==n.count&&!id(n.count),u=p&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(id(n.context)||"number"==typeof n.context)&&""!==n.context,f=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(e=>{this.isValidLookup(t)||(i=e,!iB[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(iB[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${o}" for languages "${f.join(", ")}" won't get resolved as namespace "${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!!!")),f.forEach(o=>{let i;if(this.isValidLookup(t))return;r=o;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,o,e,n);else{let e;p&&(e=this.pluralResolver.getSuffix(o,n.count,n));let t=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&0===e.indexOf(a)&&s.push(l+e.replace(a,this.options.pluralSeparator)),s.push(l+e),u&&s.push(l+t)),d){let o=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(o),p&&(n.ordinal&&0===e.indexOf(a)&&s.push(o+e.replace(a,this.options.pluralSeparator)),s.push(o+e),u&&s.push(o+t))}}for(;i=s.pop();)this.isValidLookup(t)||(a=i,t=this.getResource(o,e,i,n))}))})}),{res:t,usedKey:o,exactUsedKey:a,usedLng:r,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,o={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,o):this.resourceStore.getResource(e,n,t,o)}getUsedParamsDetails(e={}){let n=e.replace&&!id(e.replace),t=n?e.replace:e;if(n&&void 0!==e.count&&(t.count=e.count),this.options.interpolation.defaultVariables&&(t={...this.options.interpolation.defaultVariables,...t}),!n)for(let e of(t={...t},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete t[e];return t}static hasDefaultValue(e){let n="defaultValue";for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n===t.substring(0,n.length)&&void 0!==e[t])return!0;return!1}}class iF{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=iM.create("languageUtils")}getScriptPartFromCode(e){if(!(e=iS(e))||0>e.indexOf("-"))return null;let n=e.split("-");return 2===n.length||(n.pop(),"x"===n[n.length-1].toLowerCase())?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(!(e=iS(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(id(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch(e){}return(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)?n:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let n;return e?(e.forEach(e=>{if(n)return;let t=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(t))&&(n=t)}),!n&&this.options.supportedLngs&&e.forEach(e=>{if(n)return;let t=this.getScriptPartFromCode(e);if(this.isSupportedCode(t))return n=t;let o=this.getLanguagePartFromCode(e);if(this.isSupportedCode(o))return n=o;n=this.options.supportedLngs.find(e=>{if(e===o||!(0>e.indexOf("-")&&0>o.indexOf("-"))&&(e.indexOf("-")>0&&0>o.indexOf("-")&&e.substring(0,e.indexOf("-"))===o||0===e.indexOf(o)&&o.length>1))return e})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n):null}getFallbackCodes(e,n){if(!e)return[];if("function"==typeof e&&(e=e(n)),id(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let t=e[n];return t||(t=e[this.getScriptPartFromCode(n)]),t||(t=e[this.formatLanguageCode(n)]),t||(t=e[this.getLanguagePartFromCode(n)]),t||(t=e.default),t||[]}toResolveHierarchy(e,n){let t=this.getFallbackCodes((!1===n?[]:n)||this.options.fallbackLng||[],e),o=[],a=e=>{e&&(this.isSupportedCode(e)?o.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return id(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):id(e)&&a(this.formatLanguageCode(e)),t.forEach(e=>{0>o.indexOf(e)&&a(this.formatLanguageCode(e))}),o}}let iL={zero:0,one:1,two:2,few:3,many:4,other:5},iW={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class iV{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=iM.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,o=iS("dev"===e?"en":e),a=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:o,type:a});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];try{t=new Intl.PluralRules(o,{type:a})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),iW;if(!e.match(/-|_/))return iW;let o=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(o,n)}return this.pluralRulesCache[r]=t,t}needsPlural(e,n={}){let t=this.getRule(e,n);return t||(t=this.getRule("dev",n)),t?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,t={}){return this.getSuffixes(e,t).map(e=>`${n}${e}`)}getSuffixes(e,n={}){let t=this.getRule(e,n);return(t||(t=this.getRule("dev",n)),t)?t.resolvedOptions().pluralCategories.sort((e,n)=>iL[e]-iL[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let o=this.getRule(e,t);return o?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${o.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let iG=(e,n,t,o=".",a=!0)=>{let r,i=void 0!==(r=i$(e,t))?r:i$(n,t);return!i&&a&&id(t)&&void 0===(i=iE(e,t,o))&&(i=iE(n,t,o)),i};class iU{constructor(e={}){this.logger=iM.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:n,escapeValue:t,useRawValueToEscape:o,prefix:a,prefixEscaped:r,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:p,nestingPrefix:u,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:g,alwaysFormat:b}=e.interpolation;this.escape=void 0!==n?n:ik,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==o&&o,this.prefix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):r||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=u?u.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==b&&b,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,n)=>e?.source===n?(e.lastIndex=0,e):RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,t,o){let a,r,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let a=iG(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,t,{...o,...n,interpolationkey:e}):a}let a=e.split(this.formatSeparator),r=a.shift().trim(),i=a.join(this.formatSeparator).trim();return this.format(iG(n,s,r,this.options.keySeparator,this.options.ignoreJSONStructure),i,t,{...o,...n,interpolationkey:r})};this.resetRegExp();let c=o?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(n=>{for(i=0;a=n.regex.exec(e);){let t=a[1].trim();if(void 0===(r=l(t)))if("function"==typeof c){let n=c(e,a,o);r=id(n)?n:""}else if(o&&Object.prototype.hasOwnProperty.call(o,t))r="";else if(p){r=a[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),r="";else id(r)||this.useRawValueToEscape||(r=im(r));let s=n.safeValue(r);if(e=e.replace(a[0],s),p?(n.regex.lastIndex+=r.length,n.regex.lastIndex-=a[0].length):n.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,n,t={}){let o,a,r,i=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let o=e.split(RegExp(`${t}[ ]*{`)),a=`{${o[1]}`;e=o[0];let i=(a=this.interpolate(a,r)).match(/'/g),s=a.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(a=a.replace(/'/g,'"'));try{r=JSON.parse(a),n&&(r={...n,...r})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${a}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,e};for(;o=this.nestingRegexp.exec(e);){let s=[];(r=(r={...t}).replace&&!id(r.replace)?r.replace:r).applyPostProcessor=!1,delete r.defaultValue;let l=/{.*}/.test(o[1])?o[1].lastIndexOf("}")+1:o[1].indexOf(this.formatSeparator);if(-1!==l&&(s=o[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),o[1]=o[1].slice(0,l)),(a=n(i.call(this,o[1].trim(),r),r))&&o[0]===e&&!id(a))return a;id(a)||(a=im(a)),a||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${e}`),a=""),s.length&&(a=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:o[1].trim()}),a.trim())),e=e.replace(o[0],a),this.regexp.lastIndex=0}return e}}let iq=e=>{let n={};return(t,o,a)=>{let r=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(r={...r,[a.interpolationkey]:void 0});let i=o+JSON.stringify(r),s=n[i];return s||(s=e(iS(o),a),n[i]=s),s(t)}},iH=e=>(n,t,o)=>e(iS(t),o)(n);class iK{constructor(e={}){this.logger=iM.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?iq:iH;this.formats={number:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n});return e=>t.format(e)}),currency:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n,style:"currency"});return e=>t.format(e)}),datetime:t((e,n)=>{let t=new Intl.DateTimeFormat(e,{...n});return e=>t.format(e)}),relativetime:t((e,n)=>{let t=new Intl.RelativeTimeFormat(e,{...n});return e=>t.format(e,n.range||"day")}),list:t((e,n)=>{let t=new Intl.ListFormat(e,{...n});return e=>t.format(e)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=iq(n)}format(e,n,t,o={}){let a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&0>a[0].indexOf(")")&&a.find(e=>e.indexOf(")")>-1)){let e=a.findIndex(e=>e.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,e)].join(this.formatSeparator)}return a.reduce((e,n)=>{let{formatName:a,formatOptions:r}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let o=e.split("(");n=o[0].toLowerCase().trim();let a=o[1].substring(0,o[1].length-1);"currency"===n&&0>a.indexOf(":")?t.currency||(t.currency=a.trim()):"relativetime"===n&&0>a.indexOf(":")?t.range||(t.range=a.trim()):a.split(";").forEach(e=>{if(e){let[n,...o]=e.split(":"),a=o.join(":").trim().replace(/^'+|'+$/g,""),r=n.trim();t[r]||(t[r]=a),"false"===a&&(t[r]=!1),"true"===a&&(t[r]=!0),isNaN(a)||(t[r]=parseInt(a,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[a]){let n=e;try{let i=o?.formatParams?.[o.interpolationkey]||{},s=i.locale||i.lng||o.locale||o.lng||t;n=this.formats[a](e,s,{...r,...o,...i})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${a}`),e},e)}}class iY extends iP{constructor(e,n,t,o={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=o,this.logger=iM.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=o.maxParallelReads||10,this.readingCalls=0,this.maxRetries=o.maxRetries>=0?o.maxRetries:5,this.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,o.backend,o)}queueLoad(e,n,t,o){let a={},r={},i={},s={};return e.forEach(e=>{let o=!0;n.forEach(n=>{let i=`${e}|${n}`;!t.reload&&this.store.hasResourceBundle(e,n)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===r[i]&&(r[i]=!0):(this.state[i]=1,o=!1,void 0===r[i]&&(r[i]=!0),void 0===a[i]&&(a[i]=!0),void 0===s[n]&&(s[n]=!0)))}),o||(i[e]=!0)}),(Object.keys(a).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:o}),{toLoad:Object.keys(a),pending:Object.keys(r),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let o=e.split("|"),a=o[0],r=o[1];n&&this.emit("failedLoading",a,r,n),!n&&t&&this.store.addResourceBundle(a,r,t,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&t&&(this.state[e]=0);let i={};this.queue.forEach(t=>{((e,n,t,o)=>{let{obj:a,k:r}=i_(e,n,Object);a[r]=a[r]||[],a[r].push(t)})(t.loaded,[a],r),void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--),n&&t.errors.push(n),0!==t.pendingCount||t.done||(Object.keys(t.loaded).forEach(e=>{i[e]||(i[e]={});let n=t.loaded[e];n.length&&n.forEach(n=>{void 0===i[e][n]&&(i[e][n]=!0)})}),t.done=!0,t.errors.length?t.callback(t.errors):t.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,n,t,o=0,a=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:o,wait:a,callback:r});this.readingCalls++;let i=(i,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}i&&s&&o<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,o+1,2*a,r)},a):r(i,s)},s=this.backend[t].bind(this.backend);if(2===s.length){try{let t=s(e,n);t&&"function"==typeof t.then?t.then(e=>i(null,e)).catch(i):i(null,t)}catch(e){i(e)}return}return s(e,n,i)}prepareLoading(e,n,t={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();id(e)&&(e=this.languageUtils.toResolveHierarchy(e)),id(n)&&(n=[n]);let a=this.queueLoad(e,n,t,o);if(!a.toLoad.length)return a.pending.length||o(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,n,t){this.prepareLoading(e,n,{},t)}reload(e,n,t){this.prepareLoading(e,n,{reload:!0},t)}loadOne(e,n=""){let t=e.split("|"),o=t[0],a=t[1];this.read(o,a,"read",void 0,void 0,(t,r)=>{t&&this.logger.warn(`${n}loading namespace ${a} for language ${o} failed`,t),!t&&r&&this.logger.log(`${n}loaded namespace ${a} for language ${o}`,r),this.loaded(e,t,r)})}saveMissing(e,n,t,o,a,r={},i=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n))return void this.logger.warn(`did not save key "${t}" as the namespace "${n}" 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!!!");if(null!=t&&""!==t){if(this.backend?.create){let s={...r,isUpdate:a},l=this.backend.create.bind(this.backend);if(l.length<6)try{let a;(a=5===l.length?l(e,n,t,o,s):l(e,n,t,o))&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(e){i(e)}else l(e,n,t,o,i,s)}e&&e[0]&&this.store.addResource(e[0],n,t,o)}}}let iZ=()=>({debug:!1,initAsync:!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:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let n={};if("object"==typeof e[1]&&(n=e[1]),id(e[1])&&(n.defaultValue=e[1]),id(e[2])&&(n.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let t=e[3]||e[2];Object.keys(t).forEach(e=>{n[e]=t[e]})}return n},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),iJ=e=>(id(e.ns)&&(e.ns=[e.ns]),id(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),id(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),iX=()=>{};class iQ extends iP{constructor(e={},n){if(super(),this.options=iJ(e),this.services={},this.logger=iM,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{"function"==typeof e[n]&&(e[n]=e[n].bind(e))})})(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,"function"==typeof e&&(n=e,e={}),null==e.defaultNS&&e.ns&&(id(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=iZ();this.options={...t,...this.options,...iJ(e)},this.options.interpolation={...t.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let o=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?iM.init(o(this.modules.logger),this.options):iM.init(null,this.options),e=this.modules.formatter?this.modules.formatter:iK;let n=new iF(this.options);this.store=new iO(this.options.resources,this.options);let a=this.services;a.logger=iM,a.resourceStore=this.store,a.languageUtils=n,a.pluralResolver=new iV(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==t.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===t.interpolation.format)&&(a.formatter=o(e),a.formatter.init&&a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new iU(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new iY(o(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(a.languageDetector=o(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=o(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new iR(this.services,this.options),this.translator.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||(n=iX),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[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(e=>{this[e]=(...n)=>this.store[e](...n)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...n)=>(this.store[e](...n),this)});let a=ih(),r=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(t),n(e,t)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?r():setTimeout(r,0),a}loadResources(e,n=iX){let t=n,o=id(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(o?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return t();let e=[],n=n=>{n&&"cimode"!==n&&this.services.languageUtils.toResolveHierarchy(n).forEach(n=>{"cimode"!==n&&0>e.indexOf(n)&&e.push(n)})};o?n(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>n(e)),this.options.preload?.forEach?.(e=>n(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,n,t){let o=ih();return"function"==typeof e&&(t=e,e=void 0),"function"==typeof n&&(t=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),t||(t=iX),this.services.backendConnector.reload(e,n,e=>{o.resolve(),t(e)}),o}use(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&&iT.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let n=this.languages[e];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;let t=ih();this.emit("languageChanging",e);let o=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(a,r)=>{r?this.isLanguageChangingTo===e&&(o(r),this.translator.changeLanguage(r),this.isLanguageChangingTo=void 0,this.emit("languageChanged",r),this.logger.log("languageChanged",r)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(a,(...e)=>this.t(...e))},r=n=>{e||n||!this.services.languageDetector||(n=[]);let t=id(n)?n:n&&n[0],r=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(id(n)?[n]:n);r&&(this.language||o(r),this.translator.language||this.translator.changeLanguage(r),this.services.languageDetector?.cacheUserLanguage?.(r)),this.loadResources(r,e=>{a(e,r)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e):r(this.services.languageDetector.detect()),t}getFixedT(e,n,t){let o=(e,n,...a)=>{let r,i;(r="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(a)):{...n}).lng=r.lng||o.lng,r.lngs=r.lngs||o.lngs,r.ns=r.ns||o.ns,""!==r.keyPrefix&&(r.keyPrefix=r.keyPrefix||t||o.keyPrefix);let s=this.options.keySeparator||".";return r.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=iI(e,{...this.options,...n})),`${r.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=iI(e,{...this.options,...n})),i=r.keyPrefix?`${r.keyPrefix}${s}${e}`:e),this.t(i,r)};return id(e)?o.lng=e:o.lngs=e,o.ns=n,o.keyPrefix=t,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){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;let t=n.lng||this.resolvedLanguage||this.languages[0],o=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let r=(e,n)=>{let t=this.services.backendConnector.state[`${e}|${n}`];return -1===t||0===t||2===t};if(n.precheck){let e=n.precheck(this,r);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(t,e)&&(!o||r(a,e)))}loadNamespaces(e,n){let t=ih();return this.options.ns?(id(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}loadLanguages(e,n){let t=ih();id(e)&&(e=[e]);let o=this.options.preload||[],a=e.filter(e=>0>o.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=o.concat(a),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let n=new Intl.Locale(e);if(n&&n.getTextInfo){let e=n.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let n=this.services?.languageUtils||new iF(iZ());return e.toLowerCase().indexOf("-latn")>1?"ltr":["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(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){return new iQ(e,n)}cloneInstance(e={},n=iX){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let o={...this.options,...e,isClone:!0},a=new iQ(o);return(void 0!==e.debug||void 0!==e.prefix)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},t&&(a.store=new iO(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,o)=>(t[o]={...e[n][o]},t),e[n]),e),{}),o),a.services.resourceStore=a.store),a.translator=new iR(a.services,o),a.translator.on("*",(e,...n)=>{a.emit(e,...n)}),a.init(o,n),a.translator.options=o,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let i0=iQ.createInstance();i0.createInstance=iQ.createInstance,i0.createInstance,i0.dir,i0.init,i0.loadResources,i0.reloadResources,i0.use,i0.changeLanguage,i0.getFixedT,i0.t,i0.exists,i0.setDefaultNamespace,i0.hasLoadedNamespace,i0.loadNamespaces,i0.loadLanguages;let i1=i0.default||i0;function i2(e,n,t,o){return i1.t(n,{ns:e,defaultValue:t,...o})}function i3(e,n,t){return iu[e]?i2("core",e,n??iu[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}i1.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let i5="import-map-override:",i4="import-map-overrides-disabled",i6="import-map-overrides:change",i7=!1,i8=null;async function i9(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let o=e[t];try{if(o.src){let e=await fetch(o.src);n.push(await e.json())}else o.textContent&&n.push(JSON.parse(o.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return se(n)}function se(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function sn(){let e={};try{let n=si();for(let t=0;t<localStorage.length;t++){let o=localStorage.key(t);if(o?.startsWith(i5)){let t=o.slice(i5.length);if(!n.includes(t)){let n=localStorage.getItem(o);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function st(){let e=await i9();return i7?se([e,i8??sn()]):e}async function so(){return i9()}async function sa(){return i7?se([await i9(),sn()]):i9()}function sr(e){if(!i7)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(i5)){let n=localStorage.getItem(t);n&&(e[t.slice(i5.length)]=n)}}return{imports:e}}return sn()}function si(){if(!i7)return[];try{let e=localStorage.getItem(i4);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function ss(e){return!!i7&&si().includes(e)}function sl(e,n){if(!i7)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(i5+e,n),window.dispatchEvent(new CustomEvent(i6))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sc(e){if(!i7)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(i5+e);let n=si().filter(n=>n!==e);n.length>0?localStorage.setItem(i4,JSON.stringify(n)):localStorage.removeItem(i4),window.dispatchEvent(new CustomEvent(i6))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sp(){if(!i7)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(i5)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(i4),window.dispatchEvent(new CustomEvent(i6))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function su(e){if(!i7)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=si().filter(n=>n!==e);n.length>0?localStorage.setItem(i4,JSON.stringify(n)):localStorage.removeItem(i4),window.dispatchEvent(new CustomEvent(i6))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let sd=!1;function sf(){!sd&&(sd=!0,(i7="development"===window.spaEnv)&&(i8=sn()))}function sh(e){return e.replace(/[\/\-@]/g,"_")}async function sm(e,n="./start",o){var a;let r,i=!o?.maxLoadingTime||o.maxLoadingTime<=0?6e5:o.maxLoadingTime;await Promise.race([sg(e,o?.importMap),new Promise((n,t)=>{r=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=i)<1e3?`${n} milliseconds`:n<6e4?`${Math.floor(n/1e3)} seconds`:n<36e5?`${Math.floor(n/6e4)} minutes`:n<864e5?`${Math.floor(n/36e5)} hours`:`${Math.floor(n/864e5)} days`}.`))},i)})]),r&&clearTimeout(r);let s=sh(e),l=window[s];if(!("object"==typeof(a=l)&&null!==a&&"init"in a&&"function"==typeof a.init&&"get"in a&&"function"==typeof a.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(t.S.default);let c=(await l.get(n))();if("object"!=typeof c||null===c){let n=`Container for ${e} did not return an ESM module as expected`;throw console.error(n),Error(n)}return c}async function sg(e,n){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 t=sh(e);if(!window[t]){let t=n??await sb();if(!t.imports.hasOwnProperty(e)){let n=`Could not find the package ${e} defined in the current importmap`;throw console.error(n),Error(n)}let o=t.imports[e];o.startsWith("./")&&(o=window.spaBase+o.substring(1));let a=e in sr().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let o=document.head.querySelector(`script[src="${e}"]`),a=window[sy];if(a||(a=window[sy]=new Set([])),o)if(a.has(e)){let e,a,r;r=()=>{e&&o.removeEventListener("load",e),a&&o.removeEventListener("error",a)},e=()=>{r(),n(null)},a=e=>{r(),t(e.message)},o.addEventListener("load",e),o.addEventListener("error",a)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(null);else{let o,r,i;a.add(e);let s=document.createElement("script");s.src=e,s.type="text/javascript",s.async=!0;let l=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);i=()=>{clearTimeout(l),a.delete(e),o&&s.removeEventListener("load",o),r&&s.removeEventListener("error",r)},o=()=>{i(),n(null)},r=n=>{i();let o=`Failed to load script from ${e}`;console.error(o,n),t(n.message??o)},s.addEventListener("load",o),s.addEventListener("error",r),document.head.appendChild(s)}}(o,e,n)})}catch(e){return a&&D({kind:"error",title:i3("scriptLoadingFailed","Error: Script failed to load"),description:i3("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:o}),actionButtonLabel:i3("resetOverrides","Reset overrides"),onActionButtonClick(){sp(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function sb(){return st()}let sy=Symbol("__openmrs_script_loading");function s_(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 sv(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,n])=>"string"==typeof e&&s_(n))}let s$="openmrs-routes:",sA="openmrs-routes:change",sw=!1,sk=null;async function sx(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[];for(let t=0;t<e.length;t++){let o=e[t];try{let e;if(o.src){let n=await fetch(o.src);e=await n.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&sv(e)&&n.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${t}`,e)}}return sC(n)}function sC(e){let n={routes:{}};for(let t of e)t&&"object"==typeof t&&!Array.isArray(t)&&(Object.assign(n.routes,t.routes),void 0===n.version&&void 0!==t.version&&(n.version=t.version));return n}async function sE(){let e={version:void 0,routes:{}};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(s$)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(s$.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(s_(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),o=await n.json();if(s_(o))return{moduleName:e,routes:o};throw Error(`${t} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===t.status?e.routes[t.value.moduleName]=t.value.routes:console.warn("[route-maps] Failed to load route override",t.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function sS(){let e=await sx();return sw?sC([e,sk??await sE()]):e}async function sD(){return sx()}async function sz(){return sw?sC([await sx(),await sE()]):sx()}function sM(){if(!sw)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(s$)){let n=localStorage.getItem(t);n&&(e[t.slice(s$.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function sP(e,n){if(!sw)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(s$+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!s_(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(s$+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(s$+e,JSON.stringify(n.toString()));else{if(!s_(n))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`,n);localStorage.setItem(s$+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(sA))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function sO(e){if(!sw)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(s$+e),window.dispatchEvent(new CustomEvent(sA))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function sT(){if(!sw)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(s$)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sA))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let sN=null;function sI(){return sN||(sN=(sw="development"===window.spaEnv)?sE().then(e=>{sk=e}):Promise.resolve())}let sB=`${rJ}/attachment`;function sj(e,n){return r1(`${sB}/${e}`,{signal:n.signal})}function sR(e,n,t){return r1(`${sB}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function sF(e,n){let t=new FormData;return t.append("fileCaption",n.fileDescription),t.append("patient",e),n.file?t.append("file",n.file,n.fileName):(t.append("file",new File([""],n.fileName),n.fileName),t.append("base64Content",n.base64Content)),r1(`${sB}`,{method:"POST",body:t})}function sL(e,n){return r1(`${sB}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function sW(e,n){return new Promise(function(t){var o=new MessageChannel;o.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[o.port2])})}function sV(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function sG(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,o=Array(n);t<n;t++)o[t]=e[t];return o}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var sU=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function sq(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var sH=function(e,n){this.type=e,Object.assign(this,n)};function sK(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function sY(){}var sZ={type:"SKIP_WAITING"};function sJ(e,n){if(!n)return e&&e.then?e.then(sY):Promise.resolve()}var sX=function(e){function n(n,t){var o,a;return void 0===t&&(t={}),(o=e.call(this)||this).nn={},o.tn=0,o.rn=new sU,o.en=new sU,o.on=new sU,o.un=0,o.an=new Set,o.cn=function(){var e=o.fn,n=e.installing;o.tn>0||!sq(n.scriptURL,o.sn.toString())||performance.now()>o.un+6e4?(o.vn=n,e.removeEventListener("updatefound",o.cn)):(o.hn=n,o.an.add(n),o.rn.resolve(n)),++o.tn,n.addEventListener("statechange",o.ln)},o.ln=function(e){var n=o.fn,t=e.target,a=t.state,r=t===o.vn,i={sw:t,isExternal:r,originalEvent:e};!r&&o.mn&&(i.isUpdate=!0),o.dispatchEvent(new sH(a,i)),"installed"===a?o.wn=self.setTimeout(function(){"installed"===a&&n.waiting===t&&o.dispatchEvent(new sH("waiting",i))},200):"activating"===a&&(clearTimeout(o.wn),r||o.en.resolve(t))},o.dn=function(e){var n=o.hn,t=n!==navigator.serviceWorker.controller;o.dispatchEvent(new sH("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:o.mn})),t||o.on.resolve(n)},a=function(e){var n=e.data,t=e.ports,a=e.source;return sK(o.getSW(),function(){o.an.has(a)&&o.dispatchEvent(new sH("message",{data:n,originalEvent:e,ports:t,sw:a}))})},o.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(a.apply(this,e))}catch(e){return Promise.reject(e)}},o.sn=n,o.nn=t,navigator.serviceWorker.addEventListener("message",o.gn),o}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,o,a=n.prototype;return a.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var o,a,r,i=this;return o=function(){if(!t&&"complete"!==document.readyState)return sJ(new Promise(function(e){return window.addEventListener("load",e)}))},a=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),sK(i.bn(),function(e){i.fn=e,i.yn&&(i.hn=i.yn,i.en.resolve(i.yn),i.on.resolve(i.yn),i.yn.addEventListener("statechange",i.ln,{once:!0}));var n=i.fn.waiting;return n&&sq(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new sH("waiting",{sw:n,wasWaitingBeforeRegister:!0}))}).then(function(){})),i.hn&&(i.rn.resolve(i.hn),i.an.add(i.hn)),i.fn.addEventListener("updatefound",i.cn),navigator.serviceWorker.addEventListener("controllerchange",i.dn),i.fn})},(r=o())&&r.then?r.then(a):a(r)}catch(e){return Promise.reject(e)}},a.update=function(){try{return this.fn?sJ(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},a.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},a.messageSW=function(e){try{return sK(this.getSW(),function(n){return sW(n,e)})}catch(e){return Promise.reject(e)}},a.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&sW(this.fn.waiting,sZ)},a.pn=function(){var e=navigator.serviceWorker.controller;return e&&sq(e.scriptURL,this.sn.toString())?e:void 0},a.bn=function(){try{var e=this;return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return sK(navigator.serviceWorker.register(e.sn,e.nn),function(n){return e.un=performance.now(),n})},function(e){throw e})}catch(e){return Promise.reject(e)}},t=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],sV(n.prototype,t),o&&sV(n,o),n}(function(){function e(){this.Pn=new Map}var n=e.prototype;return n.addEventListener=function(e,n){this.Sn(e).add(n)},n.removeEventListener=function(e,n){this.Sn(e).delete(n)},n.dispatchEvent=function(e){e.target=this;for(var n,t=function(e){var n;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return sG(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sG(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(this.Sn(e.type));!(n=t()).done;)(0,n.value)(e)},n.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function sQ(e,n){if(void 0!==u)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),u;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new sX(e,n);return u=t.register().then(()=>t.controlling.then(()=>t))}function s0(){return u??Promise.resolve(void 0)}let s1="x-omrs-offline-response-body",s2="x-omrs-offline-response-status",s3="x-omrs-offline-caching-strategy";async function s5(e){let n=await s0();return n?await n.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 s4(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(n){if(n.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function s6(){return!window.indexedDB}async function s7(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function s8(){return await s7()||await s6()||await s4()}let s9="openmrs3:offline-mode",le="unavailable";function ln(){return{current:le,notAvailable:"unavailable"===le,active:"on"===le}}function lt(e){"unavailable"!==le&&"unavailable"!==e&&(localStorage.setItem(s9,"on"===e?"active":"disabled"),le=e)}async function lo(){await s8()||(le="active"===localStorage.getItem(s9)?"on":"off"),navigator.onLine}let la="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,lr=Object.keys,li=Array.isArray;function ls(e,n){return"object"!=typeof n||lr(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||la.Promise||(la.Promise=Promise);let ll=Object.getPrototypeOf,lc={}.hasOwnProperty;function lp(e,n){return lc.call(e,n)}function lu(e,n){"function"==typeof n&&(n=n(ll(e))),("u"<typeof Reflect?lr:Reflect.ownKeys)(n).forEach(t=>{lf(e,t,n[t])})}let ld=Object.defineProperty;function lf(e,n,t,o){ld(e,n,ls(t&&lp(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},o))}function lh(e){return{from:function(n){return e.prototype=Object.create(n.prototype),lf(e.prototype,"constructor",e),{extend:lu.bind(null,e.prototype)}}}}let lm=Object.getOwnPropertyDescriptor;function lg(e,n){let t;return lm(e,n)||(t=ll(e))&&lg(t,n)}let lb=[].slice;function ly(e,n,t){return lb.call(e,n,t)}function l_(e,n){return n(e)}function lv(e){if(!e)throw Error("Assertion Failed")}function l$(e){la.setImmediate?setImmediate(e):setTimeout(e,0)}function lA(e,n){return e.reduce((e,t,o)=>{var a=n(t,o);return a&&(e[a[0]]=a[1]),e},{})}function lw(e,n){if(lp(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],o=0,a=n.length;o<a;++o){var r=lw(e,n[o]);t.push(r)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return void 0===s?void 0:lw(s,n.substr(i+1))}}function lk(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){lv("string"!=typeof t&&"length"in t);for(var o=0,a=n.length;o<a;++o)lk(e,n[o],t[o])}else{var r=n.indexOf(".");if(-1!==r){var i=n.substr(0,r),s=n.substr(r+1);if(""===s)void 0===t?li(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&lp(e,i)||(l=e[i]={}),lk(l,s,t)}}else void 0===t?li(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function lx(e){var n={};for(var t in e)lp(e,t)&&(n[t]=e[t]);return n}let lC=[].concat;function lE(e){return lC.apply([],e)}let lS="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(lE([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>la[e]),lD=lS.map(e=>la[e]);lA(lS,e=>[e,!0]);let lz=null;function lM(e){lz="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=lz&&lz.get(n);if(t)return t;if(li(n)){t=[],lz&&lz.set(n,t);for(var o=0,a=n.length;o<a;++o)t.push(e(n[o]))}else if(lD.indexOf(n.constructor)>=0)t=n;else{let o=ll(n);for(var r in t=o===Object.prototype?{}:Object.create(o),lz&&lz.set(n,t),n)lp(n,r)&&(t[r]=e(n[r]))}return t}(e);return lz=null,n}let{toString:lP}={};function lO(e){return lP.call(e).slice(8,-1)}let lT="u">typeof Symbol?Symbol.iterator:"@@iterator",lN="symbol"==typeof lT?function(e){var n;return null!=e&&(n=e[lT])&&n.apply(e)}:function(){return null},lI={};function lB(e){var n,t,o,a;if(1==arguments.length){if(li(e))return e.slice();if(this===lI&&"string"==typeof e)return[e];if(a=lN(e)){for(t=[];!(o=a.next()).done;)t.push(o.value);return t}if(null==e)return[e];if("number"==typeof(n=e.length)){for(t=Array(n);n--;)t[n]=e[n];return t}return[e]}for(n=arguments.length,t=Array(n);n--;)t[n]=arguments[n];return t}let lj="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var lR="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),lF=()=>!0;let lL=!Error("").stack;function lW(){if(lL)try{throw lW.arguments,Error()}catch(e){return e}return Error()}function lV(e,n){var t=e.stack;return t?(n=n||0,0===t.indexOf(e.name)&&(n+=(e.name+e.message).split("\n").length),t.split("\n").slice(n).filter(lF).map(e=>"\n"+e).join("")):""}var lG=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],lU=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(lG),lq={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 lH(e,n){this._e=lW(),this.name=e,this.message=n}function lK(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function lY(e,n,t,o){this._e=lW(),this.failures=n,this.failedKeys=o,this.successCount=t,this.message=lK(e,n)}function lZ(e,n){this._e=lW(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=lK(e,n)}lh(lH).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+lV(this._e,2))}},toString:function(){return this.name+": "+this.message}}),lh(lY).from(lH),lh(lZ).from(lH);var lJ=lU.reduce((e,n)=>(e[n]=n+"Error",e),{}),lX=lU.reduce((e,n)=>{var t=n+"Error";function o(e,o){this._e=lW(),this.name=t,e?"string"==typeof e?(this.message=`${e}${o?"\n "+o:""}`,this.inner=o||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=lq[n]||t,this.inner=null)}return lh(o).from(lH),e[n]=o,e},{});lX.Syntax=SyntaxError,lX.Type=TypeError,lX.Range=RangeError;var lQ=lG.reduce((e,n)=>(e[n+"Error"]=lX[n],e),{}),l0=lU.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=lX[n]),e),{});function l1(){}function l2(e){return e}function l3(e,n){return null==e||e===l2?n:function(t){return n(e(t))}}function l5(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function l4(e,n){return e===l1?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var o=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var r=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?l5(o,this.onsuccess):o),a&&(this.onerror=this.onerror?l5(a,this.onerror):a),void 0!==r?r:t}}function l6(e,n){return e===l1?n:function(){e.apply(this,arguments);var t=this.onsuccess,o=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?l5(t,this.onsuccess):t),o&&(this.onerror=this.onerror?l5(o,this.onerror):o)}}function l7(e,n){return e===l1?n:function(t){var o=e.apply(this,arguments);ls(t,o);var a=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?l5(a,this.onsuccess):a),r&&(this.onerror=this.onerror?l5(r,this.onerror):r),void 0===o?void 0===i?void 0:i:ls(o,i)}}function l8(e,n){return e===l1?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function l9(e,n){return e===l1?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var o=this,a=arguments.length,r=Array(a);a--;)r[a]=arguments[a];return t.then(function(){return n.apply(o,r)})}return n.apply(this,arguments)}}l0.ModifyError=lY,l0.DexieError=lH,l0.BulkError=lZ;var ce={};let[cn,ct,co]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,ll(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,ll(n),e]})(),ca=ct&&ct.then,cr=cn&&cn.constructor,ci=!!co;var cs=!1,cl=co?()=>{co.then(cD)}:la.setImmediate?setImmediate.bind(null,cD):la.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{cD(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(cD,0)},cc=function(e,n){cy.push([e,n]),cu&&(cl(),cu=!1)},cp=!0,cu=!0,cd=[],cf=[],ch=null,cm=l2,cg={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:cQ,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{cQ(e[0],e[1])}catch(e){}})}},cb=cg,cy=[],c_=0,cv=[];function c$(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=l1,this._lib=!1;var n=this._PSD=cb;if(lR&&(this._stackHolder=lW(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==ce)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&ck(this,this._value))}this._state=null,this._value=null,++n.ref,function e(n,t){try{t(t=>{if(null===n._state){if(t===n)throw TypeError("A promise cannot be resolved with itself.");var o=n._lib&&cz();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof c$?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,cx(n)),o&&cM()}},ck.bind(null,n))}catch(e){ck(n,e)}}(this,e)}let cA={get:function(){var e=cb,n=cR;function t(t,o){var a=!e.global&&(e!==cb||n!==cR);let r=a&&!cV();var i=new c$((n,i)=>{cC(this,new cw(cZ(t,e,a,r),cZ(o,e,a,r),n,i,e))});return lR&&cS(i,this),i}return t.prototype=ce,t},set:function(e){lf(this,"then",e&&e.prototype===ce?cA:{get:function(){return e},set:cA.set})}};function cw(e,n,t,o,a){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=o,this.psd=a}function ck(e,n){if(cf.push(n),null===e._state){var t=e._lib&&cz();n=cm(n),e._state=!1,e._value=n,lR&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=lg(n,"stack");n._promise=e,lf(n,"stack",{get:()=>cs?t&&(t.get?t.get.apply(n):t.value):e.stack})}),cd.some(n=>n._value===e._value)||cd.push(e),cx(e),t&&cM()}}function cx(e){var n=e._listeners;e._listeners=[];for(var t=0,o=n.length;t<o;++t)cC(e,n[t]);var a=e._PSD;--a.ref||a.finalize(),0===c_&&(++c_,cc(()=>{0==--c_&&cP()},[]))}function cC(e,n){if(null!==e._state){var t=e._state?n.onFulfilled:n.onRejected;if(null===t)return(e._state?n.resolve:n.reject)(e._value);++n.psd.ref,++c_,cc(cE,[t,e,n])}else e._listeners.push(n)}function cE(e,n,t){try{ch=n;var o,a=n._value;n._state?o=e(a):(cf.length&&(cf=[]),o=e(a),-1===cf.indexOf(a)&&function(e){for(var n=cd.length;n;)if(cd[--n]._value===e._value)return void cd.splice(n,1)}(n)),t.resolve(o)}catch(e){t.reject(e)}finally{ch=null,0==--c_&&cP(),--t.psd.ref||t.psd.finalize()}}function cS(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function cD(){cz()&&cM()}function cz(){var e=cp;return cp=!1,cu=!1,e}function cM(){var e,n,t;do for(;cy.length>0;)for(e=cy,cy=[],t=e.length,n=0;n<t;++n){var o=e[n];o[0].apply(null,o[1])}while(cy.length>0);cp=!0,cu=!0}function cP(){var e=cd;cd=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=cv.slice(0),t=n.length;t;)n[--t]()}function cO(e){return new c$(ce,!1,e)}function cT(e,n){var t=cb;return function(){var o=cz(),a=cb;try{return cH(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{cH(a,!1),o&&cM()}}}lu(c$.prototype,{then:cA,_then:function(e,n){cC(this,new cw(null,null,e,n,cb))},catch:function(e){if(1==arguments.length)return this.then(null,e);var n=arguments[0],t=arguments[1];return"function"==typeof n?this.then(null,e=>e instanceof n?t(e):cO(e)):this.then(null,e=>e&&e.name===n?t(e):cO(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),cO(n)))},stack:{get:function(){if(this._stack)return this._stack;try{cs=!0;var e=(function e(n,t,o){if(t.length===o)return t;var a="";if(!1===n._state){var r,i,s=n._value;null!=s?(r=s.name||"Error",i=s.message||s,a=lV(s,0)):(r=s,i=""),t.push(r+(i?": "+i:"")+a)}return lR&&((a=lV(n._stackHolder,2))&&-1===t.indexOf(a)&&t.push(a),n._prev&&e(n._prev,t,o)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{cs=!1}}},timeout:function(e,n){return e<1/0?new c$((t,o)=>{var a=setTimeout(()=>o(new lX.Timeout(n)),e);this.then(t,o).finally(clearTimeout.bind(null,a))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&lf(c$.prototype,Symbol.toStringTag,"Dexie.Promise"),cg.env=cK(),lu(c$,{all:function(){var e=lB.apply(null,arguments).map(cG);return new c$(function(n,t){0===e.length&&n([]);var o=e.length;e.forEach((a,r)=>c$.resolve(a).then(t=>{e[r]=t,--o||n(e)},t))})},resolve:e=>{if(e instanceof c$)return e;if(e&&"function"==typeof e.then)return new c$((n,t)=>{e.then(n,t)});var n=new c$(ce,!0,e);return cS(n,ch),n},reject:cO,race:function(){var e=lB.apply(null,arguments).map(cG);return new c$((n,t)=>{e.map(e=>c$.resolve(e).then(n,t))})},PSD:{get:()=>cb,set:e=>cb=e},totalEchoes:{get:()=>cR},newPSD:cL,usePSD:cY,scheduler:{get:()=>cc,set:e=>{cc=e}},rejectionMapper:{get:()=>cm,set:e=>{cm=e}},follow:(e,n)=>new c$((t,o)=>cL((n,t)=>{var o=cb;o.unhandleds=[],o.onunhandled=t,o.finalize=l5(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},cv.push(function n(){e(),cv.splice(cv.indexOf(n),1)}),++c_,cc(()=>{0==--c_&&cP()},[])},o.finalize),e()},n,t,o))}),cr&&(cr.allSettled&&lf(c$,"allSettled",function(){let e=lB.apply(null,arguments).map(cG);return new c$(n=>{0===e.length&&n([]);let t=e.length,o=Array(t);e.forEach((e,a)=>c$.resolve(e).then(e=>o[a]={status:"fulfilled",value:e},e=>o[a]={status:"rejected",reason:e}).then(()=>--t||n(o)))})}),cr.any&&"u">typeof AggregateError&&lf(c$,"any",function(){let e=lB.apply(null,arguments).map(cG);return new c$((n,t)=>{0===e.length&&t(AggregateError([]));let o=e.length,a=Array(o);e.forEach((e,r)=>c$.resolve(e).then(e=>n(e),e=>{a[r]=e,--o||t(AggregateError(a))}))})}));let cN={awaits:0,echoes:0,id:0};var cI=0,cB=[],cj=0,cR=0,cF=0;function cL(e,n,t,o){var a=cb,r=Object.create(a);r.parent=a,r.ref=0,r.global=!1,r.id=++cF;var i=cg.env;r.env=ci?{Promise:c$,PromiseProp:{value:c$,configurable:!0,writable:!0},all:c$.all,race:c$.race,allSettled:c$.allSettled,any:c$.any,resolve:c$.resolve,reject:c$.reject,nthen:cJ(i.nthen,r),gthen:cJ(i.gthen,r)}:{},n&&ls(r,n),++a.ref,r.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=cY(r,e,t,o);return 0===r.ref&&r.finalize(),s}function cW(){return cN.id||(cN.id=++cI),++cN.awaits,cN.echoes+=100,cN.id}function cV(){return!!cN.awaits&&(0==--cN.awaits&&(cN.id=0),cN.echoes=100*cN.awaits,!0)}function cG(e){return cN.echoes&&e&&e.constructor===cr?(cW(),e.then(e=>(cV(),e),e=>(cV(),c0(e)))):e}function cU(e){++cR,cN.echoes&&0!=--cN.echoes||(cN.echoes=cN.id=0),cB.push(cb),cH(e,!0)}function cq(){var e=cB[cB.length-1];cB.pop(),cH(e,!1)}function cH(e,n){var t,o=cb;if((n?!cN.echoes||cj++&&e===cb:!cj||--cj&&e===cb)||(t=n?cU.bind(null,e):cq,ca.call(cn,t)),e!==cb&&(cb=e,o===cg&&(cg.env=cK()),ci)){var a=cg.env.Promise,r=e.env;ct.then=r.nthen,a.prototype.then=r.gthen,(o.global||e.global)&&(Object.defineProperty(la,"Promise",r.PromiseProp),a.all=r.all,a.race=r.race,a.resolve=r.resolve,a.reject=r.reject,r.allSettled&&(a.allSettled=r.allSettled),r.any&&(a.any=r.any))}}function cK(){var e=la.Promise;return ci?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(la,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:ct.then,gthen:e.prototype.then}:{}}function cY(e,n,t,o,a){var r=cb;try{return cH(e,!0),n(t,o,a)}finally{cH(r,!1)}}function cZ(e,n,t,o){return"function"!=typeof e?e:function(){var a,r=cb;t&&cW(),cH(n,!0);try{return e.apply(this,arguments)}finally{cH(r,!1),o&&(a=cV,ca.call(cn,a))}}}function cJ(e,n){return function(t,o){return e.call(this,cZ(t,n),cZ(o,n))}}-1===(""+ca).indexOf("[native code]")&&(cW=cV=l1);let cX="unhandledrejection";function cQ(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var o,a={promise:n,reason:e};if(la.document&&document.createEvent?((o=document.createEvent("Event")).initEvent(cX,!0,!0),ls(o,a)):la.CustomEvent&&ls(o=new CustomEvent(cX,{detail:a}),a),o&&la.dispatchEvent&&(dispatchEvent(o),!la.PromiseRejectionEvent&&la.onunhandledrejection))try{la.onunhandledrejection(o)}catch(e){}lR&&o&&!o.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var c0=c$.reject;let c1="3.2.4",c2=String.fromCharCode(65535),c3=-1/0,c5="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",c4="String expected.",c6=[],c7="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),c8=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),c9="__dbnames",pe="readonly",pn="readwrite";function pt(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let po={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function pa(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=lM(n))[e],n)}class pr{_trans(e,n,t){let o=this._tx||cb.trans,a=this.name;function r(e,t,o){if(!o.schema[a])throw new lX.NotFound("Table "+a+" not part of transaction");return n(o.idbtrans,o)}let i=cz();try{return o&&o.db===this.db?o===cb.trans?o._promise(e,r,t):cL(()=>o._promise(e,r,t),{trans:o,transless:cb.transless||cb}):function e(n,t,o,a){if(n.idbdb&&(n._state.openComplete||cb.letThrough||n._vip)){var r=n._createTransaction(t,o,n._dbSchema);try{r.create(),n._state.PR1398_maxLoop=3}catch(r){return r.name===lJ.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,o,a))):c0(r)}return r._promise(t,(e,n)=>cL(()=>(cb.trans=r,a(e,n,r)))).then(e=>r._completion.then(()=>e))}if(n._state.openComplete)return c0(new lX.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return c0(new lX.DatabaseClosed);n.open().catch(l1)}return n._state.dbReadyPromise.then(()=>e(n,t,o,a))}(this.db,e,[this.name],r)}finally{i&&cM()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(e=>this.hook.reading.fire(e))).then(n)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(li(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=lr(e);if(1===n.length)return this.where(n[0]).equals(e[n[0]]);let t=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)&&e.keyPath.every(e=>n.indexOf(e)>=0))[0];if(t&&this.db._maxKey!==c2)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&lR&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:o}=this.schema,a=this.db._deps.indexedDB;function r(e,n){try{return 0===a.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],a)=>{let i=o[a],s=e[a];return[n||i,n||!i?pt(t,i&&i.multi?e=>{let n=lw(e,a);return li(n)&&n.some(e=>r(s,e))}:e=>r(s,lw(e,a))):t]},[null,null]);return i?this.where(i.name).equals(e[i.keyPath]).filter(s):t?this.filter(s):this.where(n).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,li(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let n=n=>{if(!n)return n;let t=Object.create(e.prototype);for(var o in n)if(lp(n,o))try{t[o]=n[o]}catch(e){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){ls(this,e)})}add(e,n){let{auto:t,keyPath:o}=this.schema.primKey,a=e;return o&&t&&(a=pa(o)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})).then(e=>e.numFailures?c$.reject(e.failures[0]):e.lastResult).then(n=>{if(o)try{lk(e,o,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||li(e))return this.where(":id").equals(e).modify(n);{let t=lw(e,this.schema.primKey.keyPath);if(void 0===t)return c0(new lX.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?lr(n).forEach(t=>{lk(e,t,n[t])}):n(e,{value:e,primKey:t})}catch(e){}return this.where(":id").equals(t).modify(n)}}put(e,n){let{auto:t,keyPath:o}=this.schema.primKey,a=e;return o&&t&&(a=pa(o)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})).then(e=>e.numFailures?c$.reject(e.failures[0]):e.lastResult).then(n=>{if(o)try{lk(e,o,n)}catch(e){}return n})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(e=>e.numFailures?c$.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:po})).then(e=>e.numFailures?c$.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,n,t){let o=Array.isArray(n)?n:void 0,a=(t=t||(o?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&o)throw new lX.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new lX.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(pa(r)):e;return this.core.mutate({trans:n,type:"add",keys:o,values:s,wantResults:a}).then(({numFailures:e,results:n,lastResult:t,failures:o})=>{if(0===e)return a?n:t;throw new lZ(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,o)})})}bulkPut(e,n,t){let o=Array.isArray(n)?n:void 0,a=(t=t||(o?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&o)throw new lX.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new lX.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(pa(r)):e;return this.core.mutate({trans:n,type:"put",keys:o,values:s,wantResults:a}).then(({numFailures:e,results:n,lastResult:t,failures:o})=>{if(0===e)return a?n:t;throw new lZ(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,o)})})}bulkDelete(e){let n=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:e,lastResult:t,failures:o})=>{if(0===e)return t;throw new lZ(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,o)})}}function pi(e){var n={},t=function(t,o){if(o){for(var a=arguments.length,r=Array(a-1);--a;)r[a-1]=arguments[a];return n[t].subscribe.apply(null,r),e}if("string"==typeof t)return n[t]};t.addEventType=r;for(var o=1,a=arguments.length;o<a;++o)r(arguments[o]);return t;function r(e,o,a){if("object"!=typeof e){o||(o=l8),a||(a=l1);var i={subscribers:[],fire:a,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=o(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter(function(n){return n!==e}),i.fire=i.subscribers.reduce(o,a)}};return n[e]=t[e]=i,i}lr(e).forEach(function(n){var t=e[n];if(li(t))r(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new lX.InvalidArgument("Invalid event config");var o=r(n,l2,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];o.subscribers.forEach(function(e){l$(function(){e.apply(null,n)})})})}})}}function ps(e,n){return lh(n).from({prototype:e}),n}function pl(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function pc(e,n){e.filter=pt(e.filter,n)}function pp(e,n,t){var o=e.replayFilter;e.replayFilter=o?()=>pt(o(),n()):n,e.justLimit=t&&!o}function pu(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new lX.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function pd(e,n,t){let o=pu(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:o,range:e.range}})}function pf(e,n,t,o){let a=e.replayFilter?pt(e.filter,e.replayFilter()):e.filter;if(e.or){let r={},i=(e,t,o)=>{if(!a||a(t,o,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),lp(r,s)||(r[s]=!0,n(e,t,o))}};return Promise.all([e.or._iterate(i,t),ph(pd(e,o,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return ph(pd(e,o,t),pt(e.algorithm,a),n,!e.keysOnly&&e.valueMapper)}function ph(e,n,t,o){var a=cT(o?(e,n,a)=>t(o(e),n,a):t);return e.then(e=>{if(e)return e.start(()=>{var t=()=>e.continue();n&&!n(e,e=>t=e,n=>{e.stop(n),t=l1},n=>{e.fail(n),t=l1})||a(e.value,e,e=>t=e),t()})})}function pm(e,n){try{let t=pg(e),o=pg(n);if(t!==o)return"Array"===t?1:"Array"===o?-1:"binary"===t?1:"binary"===o?-1:"string"===t?1:"string"===o?-1:"Date"===t?1:"Date"!==o?NaN:-1;switch(t){case"number":case"Date":case"string":return e>n?1:e<n?-1:0;case"binary":return function(e,n){let t=e.length,o=n.length,a=t<o?t:o;for(let t=0;t<a;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===o?0:t<o?-1:1}(pb(e),pb(n));case"Array":return function(e,n){let t=e.length,o=n.length,a=t<o?t:o;for(let t=0;t<a;++t){let o=pm(e[t],n[t]);if(0!==o)return o}return t===o?0:t<o?-1:1}(e,n)}}catch(e){}return NaN}function pg(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=lO(e);return"ArrayBuffer"===t?"binary":t}function pb(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class py{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,c0.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,c0.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=pt(n.algorithm,e)}_iterate(e,n){return pf(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&ls(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>pf(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(pl(n,!0))return t.count({trans:e,query:{index:pu(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var o=0;return pf(n,()=>(++o,!1),e,t).then(()=>o)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),o=t[0],a=t.length-1;function r(e,n){return n?r(e[t[n]],n-1):e[o]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=r(e,a),o=r(n,a);return t<o?-i:t>o?i:0}return this.toArray(function(e){return e.sort(s)}).then(n)}toArray(e){return this._read(e=>{var n=this._ctx;if("next"===n.dir&&pl(n,!0)&&n.limit>0){let{valueMapper:t}=n,o=pu(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:o,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return pf(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,pl(n)?pp(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):pp(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),pp(this._ctx,()=>{var n=e;return function(e,t,o){return--n<=0&&t(o),n>=0}},!0),this}until(e,n){return pc(this._ctx,function(t,o,a){return!e(t.value)||(o(a),n)}),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 n;return pc(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=pt(n.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 n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.key,t)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.primaryKey,t)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.key)}).then(function(){return t}).then(e)}primaryKeys(e){var n=this._ctx;if("next"===n.dir&&pl(n,!0)&&n.limit>0)return this._read(e=>{var t=pu(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(({result:e})=>e).then(e);n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.primaryKey)}).then(function(){return t}).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,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var t={};return pc(this._ctx,function(e){var n=e.primaryKey.toString(),o=lp(t,n);return t[n]=!0,!o}),this}modify(e){var n=this._ctx;return this._write(t=>{var o;if("function"==typeof e)o=e;else{var a=lr(e),r=a.length;o=function(n){for(var t=!1,o=0;o<r;++o){var i=a[o],s=e[i];lw(n,i)!==s&&(lk(n,i,s),t=!0)}return t}}let i=n.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,p=[],u=0,d=[],f=(e,n)=>{let{failures:t,numFailures:o}=n;for(let n of(u+=e-o,lr(t)))p.push(t[n])};return this.clone().primaryKeys().then(a=>{let r=p=>{let u=Math.min(c,a.length-p);return i.getMany({trans:t,keys:a.slice(p,p+u),cache:"immutable"}).then(d=>{let h=[],m=[],g=s?[]:null,b=[];for(let e=0;e<u;++e){let n=d[e],t={value:lM(n),primKey:a[p+e]};!1!==o.call(t,t.value,t)&&(null==t.value?b.push(a[p+e]):s||0===pm(l(n),l(t.value))?(m.push(t.value),s&&g.push(a[p+e])):(b.push(a[p+e]),h.push(t.value)))}let y=pl(n)&&n.limit===1/0&&("function"!=typeof e||e===p_)&&{index:n.index,range:n.range};return Promise.resolve(h.length>0&&i.mutate({trans:t,type:"add",values:h}).then(e=>{for(let n in e.failures)b.splice(parseInt(n),1);f(h.length,e)})).then(()=>(m.length>0||y&&"object"==typeof e)&&i.mutate({trans:t,type:"put",keys:g,values:m,criteria:y,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(b.length>0||y&&e===p_)&&i.mutate({trans:t,type:"delete",keys:b,criteria:y}).then(e=>f(b.length,e))).then(()=>a.length>p+u&&r(p+c))})};return r(0).then(()=>{if(p.length>0)throw new lY("Error modifying one or more objects",p,u,d);return a.length})})})}delete(){var e=this._ctx,n=e.range;return pl(e)&&(e.isPrimKey&&!c7||3===n.type)?this._write(t=>{let{primaryKey:o}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:o,range:n}}).then(o=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:a})=>{if(a)throw new lY("Could not delete some values",Object.keys(e).map(n=>e[n]),o-a);return o-a}))}):this.modify(p_)}}let p_=(e,n)=>n.value=null;function pv(e,n){return e<n?-1:+(e!==n)}function p$(e,n){return e>n?-1:+(e!==n)}function pA(e,n,t){var o=e instanceof pE?new e.Collection(e):e;return o._ctx.error=t?new t(n):TypeError(n),o}function pw(e){return new e.Collection(e,()=>pC("")).limit(0)}function pk(e,n,t,o){var a,r,i,s,l,c,p,u=t.length;if(!t.every(e=>"string"==typeof e))return pA(e,c4);function d(e){a="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),r="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?pv:p$;var n=t.map(function(e){return{lower:r(e),upper:a(e)}}).sort(function(e,n){return i(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,p="next"===e?"":o}d("next");var f=new e.Collection(e,()=>px(s[0],l[u-1]+o));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,o){var a=e.key;if("string"!=typeof a)return!1;var d=r(a);if(n(d,l,h))return!0;for(var f=null,m=h;m<u;++m){var g=function(e,n,t,o,a,r){for(var i=Math.min(e.length,o.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==o[l])return 0>a(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>a(e[l],o[l])?e.substr(0,l)+o[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>a(e[l],c)&&(s=l)}return i<o.length&&"next"===r?e+t.substr(e.length):i<e.length&&"prev"===r?e.substr(0,t.length):s<0?null:e.substr(0,s)+o[s]+t.substr(s+1)}(a,d,s[m],l[m],i,c);null===g&&null===f?h=m+1:(null===f||i(f,g)>0)&&(f=g)}return t(null!==f?function(){e.continue(f+p)}:o),!1}),f}function px(e,n,t,o){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:o}}function pC(e){return{type:1,lower:e,upper:e}}class pE{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,o){t=!1!==t,o=!0===o;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||o)&&(!t||!o)?pw(this):new this.Collection(this,()=>px(e,n,!t,!o))}catch(e){return pA(this,c5)}}equals(e){return null==e?pA(this,c5):new this.Collection(this,()=>pC(e))}above(e){return null==e?pA(this,c5):new this.Collection(this,()=>px(e,void 0,!0))}aboveOrEqual(e){return null==e?pA(this,c5):new this.Collection(this,()=>px(e,void 0,!1))}below(e){return null==e?pA(this,c5):new this.Collection(this,()=>px(void 0,e,!1,!0))}belowOrEqual(e){return null==e?pA(this,c5):new this.Collection(this,()=>px(void 0,e))}startsWith(e){return"string"!=typeof e?pA(this,c4):this.between(e,e+c2,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):pk(this,(e,n)=>0===e.indexOf(n[0]),[e],c2)}equalsIgnoreCase(e){return pk(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=lB.apply(lI,arguments);return 0===e.length?pw(this):pk(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=lB.apply(lI,arguments);return 0===e.length?pw(this):pk(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,c2)}anyOf(){let e=lB.apply(lI,arguments),n=this._cmp;try{e.sort(n)}catch(e){return pA(this,c5)}if(0===e.length)return pw(this);let t=new this.Collection(this,()=>px(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let o=0;return t._addAlgorithm((t,a,r)=>{let i=t.key;for(;n(i,e[o])>0;)if(++o===e.length)return a(r),!1;return 0===n(i,e[o])||(a(()=>{t.continue(e[o])}),!1)}),t}notEqual(e){return this.inAnyRange([[c3,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=lB.apply(lI,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return pA(this,c5)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[c3,n]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){let t=this._cmp,o=this._ascending,a=this._descending,r=this._min,i=this._max;if(0===e.length)return pw(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=o(e[0],e[1])))return pA(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",lX.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,p=o;function u(e,n){return p(e[0],n[0])}try{(c=e.reduce(function(e,n){let o=0,a=e.length;for(;o<a;++o){let a=e[o];if(0>t(n[0],a[1])&&t(n[1],a[0])>0){a[0]=r(a[0],n[0]),a[1]=i(a[1],n[1]);break}}return o===a&&e.push(n),e},[])).sort(u)}catch(e){return pA(this,c5)}let d=0,f=l?e=>o(e,c[d][1])>0:e=>o(e,c[d][1])>=0,h=s?e=>a(e,c[d][0])>0:e=>a(e,c[d][0])>=0,m=f,g=new this.Collection(this,()=>px(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,p=o):(m=h,p=a),c.sort(u)},g._addAlgorithm((e,n,t)=>{for(var a=e.key;m(a);)if(++d===c.length)return n(t),!1;return!!(!f(a)&&!h(a))||(0===this._cmp(a,c[d][1])||0===this._cmp(a,c[d][0])||n(()=>{p===o?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=lB.apply(lI,arguments);return e.every(e=>"string"==typeof e)?0===e.length?pw(this):this.inAnyRange(e.map(e=>[e,e+c2])):pA(this,"startsWithAnyOf() only works with strings")}}function pS(e){return cT(function(n){return pD(n),e(n.target.error),!1})}function pD(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let pz="storagemutated",pM="x-storagemutated-1",pP=pi(null,pz);class pO{_lock(){return lv(!cb.global),++this._reculock,1!==this._reculock||cb.global||(cb.lockOwnerFor=this),this}_unlock(){if(lv(!cb.global),0==--this._reculock)for(cb.global||(cb.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{cY(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&cb.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(lv(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new lX.DatabaseClosed(t);case"MissingAPIError":throw new lX.MissingAPI(t.message,t);default:throw new lX.OpenFailed(t)}if(!this.active)throw new lX.TransactionInactive;return lv(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=cT(n=>{pD(n),this._reject(e.error)}),e.onabort=cT(n=>{pD(n),this.active&&this._reject(new lX.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=cT(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&pP.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return c0(new lX.ReadOnly("Transaction is readonly"));if(!this.active)return c0(new lX.TransactionInactive);if(this._locked())return new c$((o,a)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(o,a)},cb])});if(t)return cL(()=>{var e=new c$((e,t)=>{this._lock();let o=n(e,t,this);o&&o.then&&o.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var o=new c$((e,t)=>{var o=n(e,t,this);o&&o.then&&o.then(e,t)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=c$.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var o=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=e)}()}var a=n._waitingFor;return new c$((e,o)=>{t.then(t=>n._waitingQueue.push(cT(e.bind(null,t))),e=>n._waitingQueue.push(cT(o.bind(null,e)))).finally(()=>{n._waitingFor===a&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new lX.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(lp(n,e))return n[e];let t=this.schema[e];if(!t)throw new lX.NotFound("Table "+e+" not part of transaction");let o=new this.db.Table(e,t,this);return o.core=this.db.core.table(e),n[e]=o,o}}function pT(e,n,t,o,a,r,i){return{name:e,keyPath:n,unique:t,multi:o,auto:a,compound:r,src:(t&&!i?"&":"")+(o?"*":"")+(a?"++":"")+pN(n)}}function pN(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function pI(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:lA(t,e=>[e.name,e])}}let pB=e=>{try{return e.only([[]]),pB=()=>[[]],[[]]}catch(e){return pB=()=>c2,c2}};function pj(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>lw(n,e):n=>lw(n,e)}function pR(e){return[].slice.call(e)}let pF=0;function pL(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function pW({_novip:e},n){let t=n.db,o=function(e,n,{IDBKeyRange:t,indexedDB:o},a){var r;return{dbcore:(r=function(e,n,t){let o;function a(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:o,lowerOpen:a,upperOpen:r}=e;return void 0===t?void 0===o?null:n.upperBound(o,!!r):void 0===o?n.lowerBound(t,!!a):n.bound(t,o,!!a,!!r)}let{schema:r,hasGetAll:i}=(o=pR(e.objectStoreNames),{schema:{name:e.name,tables:o.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,o=li(n),a=null==n,r={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:a,compound:o,keyPath:n,autoIncrement:t,unique:!0,extractKey:pj(n)},indexes:pR(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:o,keyPath:a}=e,i={name:n,compound:li(a),keyPath:a,unique:t,multiEntry:o,extractKey:pj(a)};return r[pL(a)]=i,i}),getIndexByKeyPath:e=>r[pL(e)]};return r[":id"]=i.primaryKey,null!=n&&(r[pL(n)]=i.primaryKey),i})},hasGetAll:o.length>0&&"getAll"in t.objectStore(o[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=r.tables.map(e=>{let n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:o,values:r,range:i}){return new Promise((s,l)=>{let c;s=cT(s);let p=e.objectStore(n),u=null==p.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=o||r||{length:1};if(o&&r&&o.length!==r.length)throw Error("Given keys array must have same length as given values array.");if(0===f)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],g=0,b=e=>{++g,pD(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===i.type?h.push(c=p.clear()):h.push(c=p.delete(a(i)))}else{let[e,n]=d?u?[r,o]:[r,null]:[o,null];if(d)for(let o=0;o<f;++o)h.push(c=n&&void 0!==n[o]?p[t](e[o],n[o]):p[t](e[o])),c.onerror=b;else for(let n=0;n<f;++n)h.push(c=p[t](e[n])),c.onerror=b}let y=e=>{let n=e.target.result;h.forEach((e,n)=>null!=e.error&&(m[n]=e.error)),s({numFailures:g,failures:m,results:"delete"===t?o:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{b(e),y(e)},c.onsuccess=y})},getMany:({trans:e,keys:t})=>new Promise((o,a)=>{o=cT(o);let r=e.objectStore(n),i=t.length,s=Array(i),l,c=0,p=0,u=e=>{let n=e.target;s[n._pos]=n.result,++p===c&&o(s)},d=pS(a);for(let e=0;e<i;++e)null!=t[e]&&((l=r.get(t[e]))._pos=e,l.onsuccess=u,l.onerror=d,++c);0===c&&o(s)}),get:({trans:e,key:t})=>new Promise((o,a)=>{o=cT(o);let r=e.objectStore(n).get(t);r.onsuccess=e=>o(e.target.result),r.onerror=pS(a)}),query:e=>new Promise((t,o)=>{t=cT(t);let{trans:r,values:s,limit:l,query:c}=e,p=l===1/0?void 0:l,{index:u,range:d}=c,f=r.objectStore(n),h=u.isPrimaryKey?f:f.index(u.name),m=a(d);if(0===l)return t({result:[]});if(i){let e=s?h.getAll(m,p):h.getAllKeys(m,p);e.onsuccess=e=>t({result:e.target.result}),e.onerror=pS(o)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),a=[];n.onsuccess=o=>{let r=n.result;return r?(a.push(s?r.value:r.primaryKey),++e===l?t({result:a}):void r.continue()):t({result:a})},n.onerror=pS(o)}}),openCursor:function({trans:e,values:t,query:o,reverse:r,unique:i}){return new Promise((s,l)=>{s=cT(s);let{index:c,range:p}=o,u=e.objectStore(n),d=c.isPrimaryKey?u:u.index(c.name),f=r?i?"prevunique":"prev":i?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(a(p),f):d.openCursor(a(p),f);h.onerror=pS(l),h.onsuccess=cT(n=>{let t=h.result;if(!t)return void s(null);t.___id=++pF,t.done=!1;let o=t.continue.bind(t),a=t.continuePrimaryKey;a&&(a=a.bind(t));let r=t.advance.bind(t),i=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=cT(l),t.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},t.start=e=>{let n=new Promise((e,n)=>{e=cT(e),h.onerror=pS(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=i,e(n)}}),s=()=>{if(h.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return h.onsuccess=cT(e=>{h.onsuccess=s,s()}),t.continue=o,t.continuePrimaryKey=a,t.advance=r,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:o,range:r}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=o.isPrimaryKey?s:s.index(o.name),c=a(r),p=c?l.count(c):l.count();p.onsuccess=cT(n=>e(n.target.result)),p.onerror=pS(i)})}}}),l={};return s.forEach(e=>l[e.name]=e),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!l[e])throw Error(`Table '${e}' not found`);return l[e]},MIN_KEY:-1/0,MAX_KEY:pB(n),schema:r}}(n,t,a),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),r))}}(e._middlewares,t,e._deps,n);e.core=o.dbcore,e.tables.forEach(n=>{let t=n.name;e.core.schema.tables.some(e=>e.name===t)&&(n.core=e.core.table(t),e[t]instanceof e.Table&&(e[t].core=n.core))})}function pV({_novip:e},n,t,o){t.forEach(t=>{let a=o[t];n.forEach(n=>{let o=lg(n,t);(!o||"value"in o&&void 0===o.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?lf(n,t,{get(){return this.table(t)},set(e){ld(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,a))})})}function pG({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function pU(e,n){return e._cfg.version-n._cfg.version}function pq(e,n){let t,o={del:[],add:[],change:[]};for(t in e)n[t]||o.del.push(t);for(t in n){let a=e[t],r=n[t];if(a){let e={name:t,def:r,recreate:!1,del:[],add:[],change:[]};if(""+(a.primKey.keyPath||"")==""+(r.primKey.keyPath||"")&&(a.primKey.auto===r.primKey.auto||c7)){let n,t=a.idxByName,i=r.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let o=t[n],a=i[n];o?o.src!==a.src&&e.change.push(a):e.add.push(a)}(e.del.length>0||e.add.length>0||e.change.length>0)&&o.change.push(e)}else e.recreate=!0,o.change.push(e)}else o.add.push([t,r])}return o}function pH(e,n,t,o){let a=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return o.forEach(e=>pK(a,e)),a}function pK(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function pY(e,n,t){let o={};return ly(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),a=n.keyPath,r=pT(pN(a),a||"",!1,!1,!!n.autoIncrement,a&&"string"!=typeof a,!0),i=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);a=t.keyPath;var s=pT(t.name,a,!!t.unique,!!t.multiEntry,!1,a&&"string"!=typeof a,!1);i.push(s)}o[e]=pI(e,r,i)}),o}function pZ({_novip:e},n,t){let o=t.db.objectStoreNames;for(let a=0;a<o.length;++a){let r=o[a],i=t.objectStore(r);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],o=i.index(t).keyPath,a="string"==typeof o?o:"["+ly(o).join("+")+"]";if(n[r]){let e=n[r].idxByName[a];e&&(e.name=t,delete n[r].idxByName[a],n[r].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&la.WorkerGlobalScope&&la instanceof la.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class pJ{_parseStoresSpec(e,n){lr(e).forEach(t=>{if(null!==e[t]){var o=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),o=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return pT(t,o||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),li(o),0===n)}),a=o.shift();if(a.multi)throw new lX.Schema("Primary key cannot be multi-valued");o.forEach(e=>{if(e.auto)throw new lX.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new lX.Schema("Index must have a name and cannot be an empty string")}),n[t]=pI(t,a,o)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?ls(this._cfg.storesSource,e):e;let t=n._versions,o={},a={};return t.forEach(e=>{ls(o,e._cfg.storesSource),a=e._cfg.dbschema={},e._parseStoresSpec(o,a)}),n._dbSchema=a,pG(n,[n._allTables,n,n.Transaction.prototype]),pV(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],lr(a),a),n._storeNames=lr(a),this}upgrade(e){return this._cfg.contentUpgrade=l9(this._cfg.contentUpgrade||l1,e),this}}function pX(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new us(c9,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function pQ(e){return e&&"function"==typeof e.databases}function p0(e){return cL(function(){return cb.letThrough=!0,e()})}function p1(e){var n=n=>e.next(n),t=a(n),o=a(n=>e.throw(n));function a(e){return n=>{var a=e(n),r=a.value;return a.done?r:r&&"function"==typeof r.then?r.then(t,o):li(r)?Promise.all(r).then(t,o):t(r)}}return a(n)()}function p2(e,n,t){var o=arguments.length;if(o<2)throw new lX.InvalidArgument("Too few arguments");for(var a=Array(o-1);--o;)a[o-1]=arguments[o];return t=a.pop(),[e,lE(a),t]}function p3(e,n,t){let o=li(e)?e.slice():[e];for(let e=0;e<t;++e)o.push(n);return o}let p5={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:o}=t,a={},r=[];function i(e,n,t){let o=pL(e),s=a[o]=a[o]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,p={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:pj(e),unique:!c&&t.unique};return s.push(p),p.isPrimaryKey||r.push(p),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),p}let s=i(o.primaryKey.keyPath,0,o.primaryKey);for(let e of(a[":id"]=[s],o.indexes))i(e.keyPath,0,e);function l(n){var t,o;let a=n.query.index;return a.isVirtual?{...n,query:{index:a,range:(t=n.query.range,o=a.keyTail,{type:1===t.type?2:t.type,lower:p3(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,o),lowerOpen:!0,upper:p3(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,o),upperOpen:!0})}}:n}return{...t,schema:{...o,primaryKey:s,indexes:r,getIndexByKeyPath:function(e){let n=a[pL(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:o,isVirtual:a,keyLength:r}=n.query.index;return a?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(a){null!=a?t.continue(p3(a,n.reverse?e.MAX_KEY:e.MIN_KEY,o)):n.unique?t.continue(t.key.slice(0,r).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,o)):t.continue()}},continuePrimaryKey:{value(n,a){t.continuePrimaryKey(p3(n,e.MAX_KEY,o),a)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===r?e[0]:e.slice(0,r)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function p4(e,n,t,o){return t=t||{},o=o||"",lr(e).forEach(a=>{if(lp(n,a)){var r=e[a],i=n[a];if("object"==typeof r&&"object"==typeof i&&r&&i){let e=lO(r);e!==lO(i)?t[o+a]=n[a]:"Object"===e?p4(r,i,t,o+a+"."):r!==i&&(t[o+a]=n[a])}else r!==i&&(t[o+a]=n[a])}else t[o+a]=void 0}),lr(n).forEach(a=>{lp(e,a)||(t[o+a]=n[a])}),t}let p6={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:o}=t.schema;return{...t,mutate(e){let a=cb.trans,{deleting:r,creating:i,updating:s}=a.table(n).hook;switch(e.type){case"add":if(i.fire===l1)break;return a._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===l1&&s.fire===l1)break;return a._promise("readwrite",()=>l(e),!0);case"delete":if(r.fire===l1)break;return a._promise("readwrite",()=>l(e),!0);case"deleteRange":if(r.fire===l1)break;return a._promise("readwrite",()=>(function e(n,a,r){return t.query({trans:n,values:!1,query:{index:o,range:a},limit:r}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(o=>o.numFailures>0?Promise.reject(o.failures[0]):t.length<r?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...a,lower:t[t.length-1],lowerOpen:!0},r)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,a;let l=cb.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(o.extractKey));if(!c)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:c}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(a=e).type?Promise.resolve([]):t.getMany({trans:a.trans,keys:c,cache:"immutable"})).then(n=>{let a=c.map((t,a)=>{let c=n[a],p={onerror:null,onsuccess:null};if("delete"===e.type)r.fire.call(p,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(p,t,e.values[a],l);null==t&&null!=n&&(t=n,e.keys[a]=t,o.outbound||lk(e.values[a],o.keyPath,t))}else{let n=p4(c,e.values[a]),o=s.fire.call(p,n,t,c,l);if(o){let n=e.values[a];Object.keys(o).forEach(e=>{lp(n,e)?n[e]=o[e]:lk(n,e,o[e])})}}return p});return t.mutate(e).then(({failures:t,results:o,numFailures:r,lastResult:i})=>{for(let r=0;r<c.length;++r){let i=o?o[r]:c[r],s=a[r];null==i?s.onerror&&s.onerror(t[r]):s.onsuccess&&s.onsuccess("put"===e.type&&n[r]?e.values[r]:i)}return{failures:t,results:o,numFailures:r,lastResult:i}}).catch(e=>(a.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function p7(e,n,t){try{if(!n||n.keys.length<e.length)return null;let o=[];for(let a=0,r=0;a<n.keys.length&&r<e.length;++a)0===pm(n.keys[a],e[r])&&(o.push(t?lM(n.values[a]):n.values[a]),++r);return o.length===e.length?o:null}catch(e){return null}}let p8={stack:"dbcore",level:-1,create:e=>({table:n=>{let t=e.table(n);return{...t,getMany:e=>{if(!e.cache)return t.getMany(e);let n=p7(e.keys,e.trans._cache,"clone"===e.cache);return n?c$.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?lM(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function p9(e){return!("from"in e)}let ue=function(e,n){if(!this){let n=new ue;return e&&"d"in e&&ls(n,e),n}ls(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function un(e,n,t){let o=pm(n,t);if(isNaN(o))return;if(o>0)throw RangeError();if(p9(e))return ls(e,{from:n,to:t,d:1});let a=e.l,r=e.r;if(0>pm(t,e.from))return a?un(a,n,t):e.l={from:n,to:t,d:1,l:null,r:null},ua(e);if(pm(n,e.to)>0)return r?un(r,n,t):e.r={from:n,to:t,d:1,l:null,r:null},ua(e);0>pm(n,e.from)&&(e.from=n,e.l=null,e.d=r?r.d+1:1),pm(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;a&&!e.l&&ut(e,a),r&&i&&ut(e,r)}function ut(e,n){p9(n)||function e(n,{from:t,to:o,l:a,r:r}){un(n,t,o),a&&e(n,a),r&&e(n,r)}(e,n)}function uo(e){let n=p9(e)?null:{s:0,n:e};return{next(e){let t=arguments.length>0;for(;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&0>pm(e,n.n.from);)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||0>=pm(e,n.n.to))return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function ua(e){var n,t;let o=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),a=o>1?"r":o<-1?"l":"";if(a){let n="r"===a?"l":"r",t={...e},o=e[a];e.from=o.from,e.to=o.to,e[a]=o[a],t[a]=o[n],e[n]=t,t.d=ur(t)}e.d=ur(e)}function ur({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}lu(ue.prototype,{add(e){return ut(this,e),this},addKey(e){return un(this,e,e),this},addKeys(e){return e.forEach(e=>un(this,e,e)),this},[lT](){return uo(this)}});let ui={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new ue(e.MIN_KEY,e.MAX_KEY);return{...e,table:o=>{let a=e.table(o),{schema:r}=a,{primaryKey:i}=r,{extractKey:s,outbound:l}=i,c={...a,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let t=`idb://${n}/${o}/${e}`;return s[t]||(s[t]=new ue)},c=l(""),p=l(":dels"),{type:u}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return a.mutate(e).then(e=>{if(li(d)){"delete"!==u&&(d=e.results),c.addKeys(d);let n=p7(d,h);n||"add"===u||p.addKeys(d),(n||f)&&r.indexes.forEach(function(e){let t=l(e.name||"");function o(n){return null!=n?e.extractKey(n):null}let a=n=>e.multiEntry&&li(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let r=n&&o(n[t]),i=f&&o(f[t]);0!==pm(r,i)&&(null!=r&&a(r),null!=i&&a(i))})})}else if(d){let e={from:d.lower,to:d.upper};p.add(e),c.add(e)}else c.add(t),p.add(t),r.indexes.forEach(e=>l(e.name).add(t));return e})}},p=({query:{index:n,range:t}})=>{var o,a;return[n,new ue(null!=(o=t.lower)?o:e.MIN_KEY,null!=(a=t.upper)?a:e.MAX_KEY)]},u={get:e=>[i,new ue(e.key)],getMany:e=>[i,(new ue).addKeys(e.keys)],count:p,query:p,openCursor:p};return lr(u).forEach(e=>{c[e]=function(r){let{subscr:i}=cb;if(i){let c=e=>{let t=`idb://${n}/${o}/${e}`;return i[t]||(i[t]=new ue)},p=c(""),d=c(":dels"),[f,h]=u[e](r);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&r.values&&a.query({...r,values:!1});return a[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&r.values)return n.then(({result:e})=>(p.addKeys(e),t));let e=r.values?t.result.map(s):t.result;r.values?p.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=r.values;return t&&Object.create(t,{key:{get:()=>(d.addKey(t.primaryKey),t.key)},primaryKey:{get(){let e=t.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&p.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return a[e].apply(this,arguments)}}),c}}}};class us{constructor(e,n){var t;this._middlewares={},this.verno=0;const o=us.dependencies;this._options=n={addons:us.addons,autoOpen:!0,indexedDB:o.indexedDB,IDBKeyRange:o.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:a}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const r={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:l1,dbReadyPromise:null,cancelOpen:l1,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};r.dbReadyPromise=new c$(e=>{r.dbReadyResolve=e}),r.openCanceller=new c$((e,n)=>{r.cancelOpen=n}),this._state=r,this.name=e,this.on=pi(this,"populate","blocked","versionchange","close",{ready:[l9,l1]}),this.on.ready.subscribe=l_(this.on.ready.subscribe,e=>(n,t)=>{us.vip(()=>{let o=this._state;if(o.openComplete)o.dbOpenError||c$.resolve().then(n),t&&e(n);else if(o.onReadyBeingFired)o.onReadyBeingFired.push(n),t&&e(n);else{e(n);let o=this;t||e(function e(){o.on.ready.unsubscribe(n),o.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,ps(py.prototype,function(e,n){this.db=t;let o=po,a=null;if(n)try{o=n()}catch(e){a=e}let r=e._ctx,i=r.table,s=i.hook.reading.fire;this._ctx={table:i,index:r.index,isPrimKey:!r.index||i.schema.primKey.keyPath&&r.index===i.schema.primKey.name,range:o,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:a,or:r.or,valueMapper:s!==l2?s:null}})),this.Table=function(e){return ps(pr.prototype,function(n,t,o){this.db=e,this._tx=o,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:pi(null,{creating:[l4,l1],reading:[l3,l2],updating:[l7,l1],deleting:[l6,l1]})})}(this),this.Transaction=function(e){return ps(pO.prototype,function(n,t,o,a,r){this.db=e,this.mode=n,this.storeNames=t,this.schema=o,this.chromeTransactionDurability=a,this.idbtrans=null,this.on=pi(this,"complete","error","abort"),this.parent=r||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 c$((e,n)=>{this._resolve=e,this._reject=n}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var n=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):n&&this.idbtrans&&this.idbtrans.abort(),c0(e)})})}(this),this.Version=function(e){return ps(pJ.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return ps(pE.prototype,function(n,t,o){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:o};let a=e._deps.indexedDB;if(!a)throw new lX.MissingAPI;this._cmp=this._ascending=a.cmp.bind(a),this._descending=(e,n)=>a.cmp(n,e),this._max=(e,n)=>a.cmp(e,n)>0?e:n,this._min=(e,n)=>0>a.cmp(e,n)?e:n,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=pB(n.IDBKeyRange),this._createTransaction=(e,n,t,o)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,o),this._fireOnBlocked=e=>{this.on("blocked").fire(e),c6.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(p5),this.use(p6),this.use(ui),this.use(p8),this.vip=Object.create(this,{_vip:{value:!0}}),a.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new lX.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new lX.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var t=n.filter(n=>n._cfg.version===e)[0];return t||(t=new this.Version(e),n.push(t),n.sort(pU),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||cb.letThrough||this._vip)?e():new c$((e,n)=>{if(this._state.openComplete)return n(new lX.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new lX.DatabaseClosed);this.open().catch(l1)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:o}){o&&this.unuse({stack:e,name:o});let a=this._middlewares[e]||(this._middlewares[e]=[]);return a.push({stack:e,create:n,level:null==t?10:t,name:o}),a.sort((e,n)=>e.level-n.level),this}unuse({stack:e,name:n,create:t}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>t?e.create!==t:!!n&&e.name!==n)),this}open(){return function(e){var n;let t=e._state,{indexedDB:o}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?c0(t.dbOpenError):e);lR&&(t.openCanceller._stackHolder=lW()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let a=t.openCanceller;function r(){if(t.openCanceller!==a)throw new lX.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1;return c$.race([a,("u"<typeof navigator?c$.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var t=function(){return indexedDB.databases().finally(e)};n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(()=>new c$((n,a)=>{if(r(),!o)throw new lX.MissingAPI;let i=e.name,c=t.autoSchema?o.open(i):o.open(i,Math.round(10*e.verno));if(!c)throw new lX.MissingAPI;c.onerror=pS(a),c.onblocked=cT(e._fireOnBlocked),c.onupgradeneeded=cT(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=pD,s.abort(),c.result.close();let e=o.deleteDatabase(i);e.onsuccess=e.onerror=cT(()=>{a(new lX.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,o,i,d;s.onerror=pS(a);var r,p,u=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=u<1,e._novip.idbdb=c.result,r=u/10,p=s,t=e._dbSchema,(o=e._createTransaction("readwrite",e._storeNames,t)).create(p),o._completion.catch(a),i=o._reject.bind(o),d=cb.transless||cb,cL(()=>{cb.trans=o,cb.transless=d,0===r?(lr(t).forEach(e=>{pH(p,e,t[e].primKey,t[e].indexes)}),pW(e,p),c$.follow(()=>e.on.populate.fire(o)).catch(i)):(function({_novip:e},n,t,o){let a=[],r=e._versions,i=e._dbSchema=pY(e,e.idbdb,o),s=!1;return r.filter(e=>e._cfg.version>=n).forEach(r=>{a.push(()=>{let a=i,l=r._cfg.dbschema;pZ(e,a,o),pZ(e,l,o),i=e._dbSchema=l;let c=pq(a,l);c.add.forEach(e=>{pH(o,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new lX.Upgrade("Not yet support for changing primary key");{let n=o.objectStore(e.name);e.add.forEach(e=>pK(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),pK(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let p=r._cfg.contentUpgrade;if(p&&r._cfg.version>n){let n;pW(e,o),t._memoizedTables={},s=!0;let r=lx(l);c.del.forEach(e=>{r[e]=a[e]}),pG(e,[e.Transaction.prototype]),pV(e,[e.Transaction.prototype],lr(r),r),t.schema=r;let i=lj(p);i&&cW();let u=c$.follow(()=>{if((n=p(t))&&i){var e=cV.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?c$.resolve(n):u.then(()=>n)}}),a.push(n=>{var o;s&&c7||(o=r._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==o[e]&&n.db.deleteObjectStore(e))),pG(e,[e.Transaction.prototype]),pV(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return a.length?c$.resolve(a.shift()(t.idbtrans)).then(e):c$.resolve()})().then(()=>{var e;lr(e=i).forEach(n=>{o.db.objectStoreNames.contains(n)||pH(o,n,e[n].primKey,e[n].indexes)})})})(e,r,o,p).catch(i)})}},a),c.onsuccess=cT(()=>{s=null;let o=e._novip.idbdb=c.result,a=ly(o.objectStoreNames);if(a.length>0)try{let n,r=o.transaction(1===a.length?a[0]:a,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let o=e._dbSchema=pY(0,n,t);e._storeNames=ly(n.objectStoreNames,0),pV(e,[e._allTables],lr(o),o)}(e,o,r):(pZ(e,e._dbSchema,r),((n=pq(pY(0,e.idbdb,r),e._dbSchema)).add.length||n.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.")),pW(e,r)}catch(e){}c6.push(e),o.onversionchange=cT(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),o.onclose=cT(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){pQ(e)||t===c9||pX(e,n).put({name:t}).catch(l1)}(e._deps,i),n()},a)}))]).then(()=>(r(),t.onReadyBeingFired=[],c$.resolve(p0(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let o=t.onReadyBeingFired.reduce(l9,l1);return t.onReadyBeingFired=[],c$.resolve(p0(()=>o(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return a===t.openCanceller&&e._close(),c0(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=c6.indexOf(this);if(n>=0&&c6.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new c$(n=>{e.dbReadyResolve=n}),e.openCanceller=new c$((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new lX.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new c$((t,o)=>{let a=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=cT(()=>{!function({indexedDB:e,IDBKeyRange:n},t){pQ(e)||t===c9||pX(e,n).delete(t).catch(l1)}(this._deps,this.name),t()}),e.onerror=pS(o),e.onblocked=this._fireOnBlocked};if(e)throw new lX.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(a):a()})}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 lr(this._allTables).map(e=>this._allTables[e])}transaction(){let e=p2.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let o,a,r=cb.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(a=n.map(e=>{var n=e instanceof this.Table?e.name:e;if("string"!=typeof n)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}),"r"==e||e===pe)o=pe;else{if("rw"!=e&&e!=pn)throw new lX.InvalidArgument("Invalid transaction mode: "+e);o=pn}if(r){if(r.mode===pe&&o===pn){if(!i)throw new lX.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&a.forEach(e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!i)throw new lX.SubTransaction("Table "+e+" not included in parent transaction.");r=null}}),i&&r&&!r.active&&(r=null)}}catch(e){return r?r._promise(null,(n,t)=>{t(e)}):c0(e)}let s=(function e(n,t,o,a,r){return c$.resolve().then(()=>{let i,s=cb.transless||cb,l=n._createTransaction(t,o,n._dbSchema,a);if(a)l.idbtrans=a.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(a){return a.name===lJ.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,o,null,r))):c0(a)}let c=lj(r);c&&cW();let p=c$.follow(()=>{if(i=r.call(l,l))if(c){var e=cV.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=p1(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?c$.resolve(i).then(e=>l.active?e:c0(new lX.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):p.then(()=>i)).then(e=>(a&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),c0(e)))})}).bind(null,this,o,a,r,t);return r?r._promise(o,s,"lock"):cb.trans?cY(cb.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!lp(this._allTables,e))throw new lX.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let ul="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class uc{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[ul](){return this}}function up(e,n){return lr(n).forEach(t=>{ut(e[t]||(e[t]=new ue),n[t])}),e}try{a={indexedDB:la.indexedDB||la.mozIndexedDB||la.webkitIndexedDB||la.msIndexedDB,IDBKeyRange:la.IDBKeyRange||la.webkitIDBKeyRange}}catch(e){a={indexedDB:null,IDBKeyRange:null}}function uu(e){let n=ud;try{ud=!0,pP.storagemutated.fire(e)}finally{ud=n}}lu(us,{...l0,delete:e=>new us(e,{addons:[]}).delete(),exists:e=>new us(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return pQ(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==c9)):pX(e,n).toCollection().primaryKeys()})(us.dependencies).then(e)}catch(e){return c0(new lX.MissingAPI)}},defineClass:()=>function(e){ls(this,e)},ignoreTransaction:e=>cb.trans?cY(cb.transless,e):e(),vip:p0,async:function(e){return function(){try{var n=p1(e.apply(this,arguments));return n&&"function"==typeof n.then?n:c$.resolve(n)}catch(e){return c0(e)}}},spawn:function(e,n,t){try{var o=p1(e.apply(t,n||[]));return o&&"function"==typeof o.then?o:c$.resolve(o)}catch(e){return c0(e)}},currentTransaction:{get:()=>cb.trans||null},waitFor:function(e,n){let t=c$.resolve("function"==typeof e?us.ignoreTransaction(e):e).timeout(n||6e4);return cb.trans?cb.trans.waitFor(t):t},Promise:c$,debug:{get:()=>lR,set:e=>{lR=e,lF="dexie"===e?()=>!0:c8}},derive:lh,extend:ls,props:lu,override:l_,Events:pi,on:pP,liveQuery:function(e){let n,t=!1,o=new uc(o=>{let a=lj(e),r=!1,i={},s={},l={get closed(){return r},unsubscribe:()=>{r=!0,pP.storagemutated.unsubscribe(d)}};o.start&&o.start(l);let c=!1,p=!1;function u(){return lr(s).some(e=>i[e]&&function(e,n){let t=uo(n),o=t.next();if(o.done)return!1;let a=o.value,r=uo(e),i=r.next(a.from),s=i.value;for(;!o.done&&!i.done;){if(0>=pm(s.from,a.to)&&pm(s.to,a.from)>=0)return!0;0>pm(a.from,s.from)?a=(o=t.next(s.from)).value:s=(i=r.next(a.from)).value}return!1}(i[e],s[e]))}let d=e=>{up(i,e),u()&&f()},f=()=>{let h,m;if(c||r)return;i={};let g={},b=(a&&cW(),h=()=>cL(e,{subscr:g,trans:null}),m=cb.trans?cY(cb.transless,h):h(),a&&m.then(cV,cV),m);p||(pP(pz,d),p=!0),c=!0,Promise.resolve(b).then(e=>{t=!0,n=e,c=!1,r||(u()?f():(i={},s=g,o.next&&o.next(e)))},e=>{c=!1,t=!1,o.error&&o.error(e),l.unsubscribe()})};return f(),l});return o.hasValue=()=>t,o.getValue=()=>n,o},extendObservabilitySet:up,getByKeyPath:lw,setByKeyPath:lk,delByKeyPath:function(e,n){"string"==typeof n?lk(e,n,void 0):"length"in n&&[].map.call(n,function(n){lk(e,n,void 0)})},shallowClone:lx,deepClone:lM,getObjectDiff:p4,cmp:pm,asap:l$,minKey:c3,addons:[],connections:c6,errnames:lJ,dependencies:a,semVer:c1,version:c1.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),us.maxKey=pB(us.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(pP(pz,e=>{if(!ud){let n;c7?(n=document.createEvent("CustomEvent")).initCustomEvent(pM,!0,!0,e):n=new CustomEvent(pM,{detail:e}),ud=!0,dispatchEvent(n),ud=!1}}),addEventListener(pM,({detail:e})=>{ud||uu(e)}));let ud=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(pM);"function"==typeof e.unref&&e.unref(),pP(pz,n=>{ud||e.postMessage(n)}),e.onmessage=e=>{e.data&&uu(e.data)}}else if("u">typeof self&&"u">typeof navigator){pP(pz,e=>{try{ud||("u">typeof localStorage&&localStorage.setItem(pM,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:pM,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===pM){let n=JSON.parse(e.newValue);n&&uu(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===pM&&uu(e.changedParts)})}function uf(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}c$.rejectionMapper=function(e,n){if(!e||e instanceof lH||e instanceof TypeError||e instanceof SyntaxError||!e.name||!lQ[e.name])return e;var t=new lQ[e.name](n||e.message,e);return"stack"in e&&lf(t,"stack",{get:function(){return this.inner.stack}}),t},lF=c8;class uh extends us{constructor(){super("EsmOffline"),uf(this,"syncQueue",void 0),uf(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 um(){return new uh}let ug=new uh,ub={},uy=G("offline-synchronization",{});function u_(){return uy}async function uv(){if(uy.getState().synchronization)return;let e=await ug.syncQueue.count(),n={},t=Object.entries(ub),o=t.length,a={},r=new AbortController,i=()=>{let e=uy.getState().synchronization;uy.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{uy.setState({synchronization:{totalCount:e,pendingCount:e,abortController:r}});for(let e=0;e<o&&t.length>0;e++)for(let e=t.length;e--;){let[o,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(a[o]={},await Promise.all(l),n[o]=u$(s,a,r,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{uy.setState({synchronization:void 0})}}async function u$({type:e,dependsOn:n,process:t},o,a,r){let i=[],s=[],l=await uA();await ug.syncQueue.where({type:e,userId:l}).each((e,n)=>{i.push([n.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<i.length;c++){let[p,u,{id:d,dependencies:f=[]}]=i[c];try{let r=await t(u,{abort:a,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?o[t][e]:void 0)});void 0!==d&&(o[e][d]=r),await ug.syncQueue.delete(p)}catch(e){await ug.syncQueue.update(p,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{r()}}}async function uA(){let e=await io();return e?.uuid||"*"}async function uw(e,n,t,o){let a=o&&o.id;return void 0!==a&&await ug.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===a).delete().catch(us.errnames.DatabaseClosed),await ug.syncQueue.add({type:n,content:t,userId:e,descriptor:o||{},createdOn:new Date}).catch(us.errnames.DatabaseClosed,()=>-1)}async function uk(e,n,t){let o=await uA();return await uw(o,e,n,t)}async function ux(e,n){return(await uC(e,n)).map(e=>e.content)}async function uC(e,n){return await ug.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(us.errnames.DatabaseClosed,()=>[])}async function uE(e){let n=await uA();return await ux(n,e)}async function uS(e){let n=await uA();return await uC(n,e)}async function uD(e){return await ug.syncQueue.get(e).catch(us.errnames.DatabaseClosed,()=>void 0)}function uz(e){return!!ub[e]?.options.onBeginEditSyncItem}async function uM(e){let n=await uD(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=ub[n.type]?.options.onBeginEditSyncItem;if(!t)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 "${n.type}" supports editing items.`);t(n)}async function uP(e){await ug.syncQueue.delete(e).catch(us.errnames.DatabaseClosed)}function uO(e,n,t,o={}){ub[e]={type:e,dependsOn:n,process:t,options:o}}let uT="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),uN=new Uint8Array(16),uI=[];for(let e=0;e<256;++e)uI.push((e+256).toString(16).slice(1));let uB=function(e,n,t){if(uT&&!n&&!e)return uT();let o=(e=e||{}).random||(e.rng||function(){if(!r&&!(r="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 r(uN)})();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=o[e];return n}return function(e,n=0){return uI[e[n+0]]+uI[e[n+1]]+uI[e[n+2]]+uI[e[n+3]]+"-"+uI[e[n+4]]+uI[e[n+5]]+"-"+uI[e[n+6]]+uI[e[n+7]]+"-"+uI[e[n+8]]+uI[e[n+9]]+"-"+uI[e[n+10]]+uI[e[n+11]]+uI[e[n+12]]+uI[e[n+13]]+uI[e[n+14]]+uI[e[n+15]]}(o)},uj="OFFLINE+";function uR(){return uj+uB()}function uF(e){return e.startsWith(uj)}let uL={};function uW(){return Object.values(uL)}function uV(e){uL[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.`),uL[e.id]=e}async function uG(e){let n=await uX();return await uU(n,e)}async function uU(e,n){let t=new uh;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(us.errnames.DatabaseClosed,()=>[])}async function uq(e,n){let t=await uX();return await uH(t,e,n)}async function uH(e,n,t){let o=new uh,a=await o.dynamicOfflineData.get({type:n,identifier:t}).catch(us.errnames.DatabaseClosed,()=>void 0);a?a.users.includes(e)||await o.dynamicOfflineData.update(a.id,{users:[...a.users,e]}).catch(us.errnames.DatabaseClosed):await o.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(us.errnames.DatabaseClosed)}async function uK(e,n){let t=await uX();return await uY(t,e,n)}async function uY(e,n,t){let o=new uh,a=await o.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(us.errnames.DatabaseClosed,()=>void 0);a&&(a.users.length>1?await o.dynamicOfflineData.update(a.id,{users:a.users.filter(n=>n!==e)}).catch(us.errnames.DatabaseClosed):await o.dynamicOfflineData.delete(a.id).catch(us.errnames.DatabaseClosed))}async function uZ(e,n){let t=await uG(e);await Promise.all(t.map(async e=>uJ(e.type,e.identifier,n)))}async function uJ(e,n,t){await uq(e,n);let o=new uh,a=await uX(),r=await o.dynamicOfflineData.get({type:e,identifier:n}).catch(us.errnames.DatabaseClosed,()=>void 0),i=uW().filter(n=>n.type===e);if(!r)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(n,t),{id:e.id,error:void 0}}catch(t){let n=t.message?.toString()??t.toString();return{id:e.id,error:n}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),p=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),u={syncedOn:new Date,syncedBy:a,succeededHandlers:l,erroredHandlers:c,errors:p};r.id&&await o.dynamicOfflineData.update(r.id,{syncState:u}).catch(us.errnames.DatabaseClosed)}async function uX(){let e=(await io()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let uQ=G("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function u0(){return u3(),uQ}function u1(e,n){u3(),uV({type:"patient",displayName:n.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,t)=>n.onOfflinePatientAdded({patientUuid:e,signal:t??new AbortController().signal})})}async function u2(e){u3(),await uJ("patient",e)}function u3(){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 u5(e,n,t=!0){if(e){let o=null,[a,r]=await Promise.all([r1(`${rX}/Patient/${e}`,n).catch(e=>o=e),t?u4(e):Promise.resolve(null)]);if(a.ok)return a.data;if(r)return r;if(o)throw o}return null}async function u4(e){let n=(await uE("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function u6(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function u7(e,n){let t=e=>{n("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,t),()=>{window.removeEventListener(`openmrs:${e}`,t)}}var u8=t(9549);function u9(e){return{uuid:e.uuid,display:e.display}}function de(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let o=t.toString();return r2(`${rJ}/location${o?"?"+o:""}`).pipe((0,u8.map)(e=>e.data.results.map(u9))).pipe((0,u8.take)(1))}function dn(e){return{uuid:e.uuid,display:e.display,name:e.name}}function dt(){return r2(`${rJ}/visittype`).pipe((0,u8.map)(e=>e.data.results.map(dn))).pipe((0,u8.take)(1))}var da=((ea={}).NEWVISIT="startVisit",ea.EDITVISIT="editVisit",ea.LOADING="loadingVisit",ea),dr=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let di="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))",ds=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function dl(){return q("visit",ds)}function dc(e,n){dl().setState({patientUuid:e,manuallySetVisitUuid:n})}function dp(e,n){return r1(`${rJ}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function du(e,n,t){return r1(`${rJ}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function dd(e,n,t){return r1(`${rJ}/visit?patient=${e}&v=${t??di}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}dl().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let df=new el.BehaviorSubject(null);class dh{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+dh.version}static addUnaryOp(e){return dh.max_unop_len=Math.max(e.length,dh.max_unop_len),dh.unary_ops[e]=1,dh}static addBinaryOp(e,n,t){return dh.max_binop_len=Math.max(e.length,dh.max_binop_len),dh.binary_ops[e]=n,t?dh.right_associative.add(e):dh.right_associative.delete(e),dh}static addIdentifierChar(e){return dh.additional_identifier_chars.add(e),dh}static addLiteral(e,n){return dh.literals[e]=n,dh}static removeUnaryOp(e){return delete dh.unary_ops[e],e.length===dh.max_unop_len&&(dh.max_unop_len=dh.getMaxKeyLen(dh.unary_ops)),dh}static removeAllUnaryOps(){return dh.unary_ops={},dh.max_unop_len=0,dh}static removeIdentifierChar(e){return dh.additional_identifier_chars.delete(e),dh}static removeBinaryOp(e){return delete dh.binary_ops[e],e.length===dh.max_binop_len&&(dh.max_binop_len=dh.getMaxKeyLen(dh.binary_ops)),dh.right_associative.delete(e),dh}static removeAllBinaryOps(){return dh.binary_ops={},dh.max_binop_len=0,dh}static removeLiteral(e){return delete dh.literals[e],dh}static removeAllLiterals(){return dh.literals={},dh}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 dh(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 dh.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!dh.binary_ops[String.fromCharCode(e)]||dh.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return dh.isIdentifierStart(e)||dh.isDecimalDigit(e)}throwError(e){let n=Error(e+" at character "+this.index);throw n.index=this.index,n.description=e,n}runHook(e,n){if(dh.hooks[e]){let t={context:this,node:n};return dh.hooks.run(e,t),t.node}return n}searchHook(e){if(dh.hooks[e]){let n={context:this};return dh.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===dh.SPACE_CODE||e===dh.TAB_CODE||e===dh.LF_CODE||e===dh.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),n=1===e.length?e[0]:{type:dh.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,o;for(;this.index<this.expr.length;)if((t=this.code)===dh.SEMCOL_CODE||t===dh.COMMA_CODE)this.index++;else if(o=this.gobbleExpression())n.push(o);else if(this.index<this.expr.length){if(t===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}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,dh.max_binop_len),n=e.length;for(;n>0;){if(dh.binary_ops.hasOwnProperty(e)&&(!dh.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!dh.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=n,e;e=e.substr(0,--n)}return!1}gobbleBinaryExpression(){let e,n,t,o,a,r,i,s,l;if(!(r=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return r;for(a={value:n,prec:dh.binaryPrecedence(n),right_a:dh.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),o=[r,a,i];n=this.gobbleBinaryOp();){if(0===(t=dh.binaryPrecedence(n))){this.index-=n.length;break}a={value:n,prec:t,right_a:dh.right_associative.has(n)},l=n;let s=e=>a.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;o.length>2&&s(o[o.length-2]);)i=o.pop(),n=o.pop().value,r=o.pop(),e={type:dh.BINARY_EXP,operator:n,left:r,right:i},o.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),o.push(a,e)}for(s=o.length-1,e=o[s];s>1;)e={type:dh.BINARY_EXP,operator:o[s-1].value,left:o[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,o;if(this.gobbleSpaces(),o=this.searchHook("gobble-token"))return this.runHook("after-token",o);if(e=this.code,dh.isDecimalDigit(e)||e===dh.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===dh.SQUOTE_CODE||e===dh.DQUOTE_CODE)o=this.gobbleStringLiteral();else if(e===dh.OBRACK_CODE)o=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,dh.max_unop_len)).length;t>0;){if(dh.unary_ops.hasOwnProperty(n)&&(!dh.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!dh.isIdentifierPart(this.expr.charCodeAt(this.index+n.length)))){this.index+=t;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:dh.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}dh.isIdentifierStart(e)?(o=this.gobbleIdentifier(),dh.literals.hasOwnProperty(o.name)?o={type:dh.LITERAL,value:dh.literals[o.name],raw:o.name}:o.name===dh.this_str&&(o={type:dh.THIS_EXP})):e===dh.OPAREN_CODE&&(o=this.gobbleGroup())}return o?(o=this.gobbleTokenProperty(o),this.runHook("after-token",o)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===dh.PERIOD_CODE||n===dh.OBRACK_CODE||n===dh.OPAREN_CODE||n===dh.QUMARK_CODE;){let t;if(n===dh.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==dh.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===dh.OBRACK_CODE?((e={type:dh.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==dh.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===dh.OPAREN_CODE?e={type:dh.CALL_EXP,arguments:this.gobbleArguments(dh.CPAREN_CODE),callee:e}:(n===dh.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:dh.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),t&&(e.optional=!0),this.gobbleSpaces(),n=this.code}return e}gobbleNumericLiteral(){let e="",n,t;for(;dh.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===dh.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);dh.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(n=this.char)||"E"===n){for(e+=this.expr.charAt(this.index++),("+"===(n=this.char)||"-"===n)&&(e+=this.expr.charAt(this.index++));dh.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);dh.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,dh.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===dh.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===dh.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:dh.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),o=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){o=!0;break}if("\\"===n)switch(n=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+=n}else e+=n}return o||this.throwError('Unclosed quote after "'+e+'"'),{type:dh.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(dh.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,dh.isIdentifierPart(e))this.index++;else break;return{type:dh.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,o=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){t=!0,this.index++,e===dh.CPAREN_CODE&&o&&o>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===dh.COMMA_CODE){if(this.index++,++o!==n.length){if(e===dh.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===dh.CBRACK_CODE)for(let e=n.length;e<o;e++)n.push(null)}}else if(n.length!==o&&0!==o)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==dh.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(dh.CPAREN_CODE);if(this.code===dh.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:dh.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:dh.ARRAY_EXP,elements:this.gobbleArguments(dh.CBRACK_CODE)}}}Object.assign(dh,{hooks:new class{add(e,n,t){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]||[],n&&this[e][t?"unshift":"push"](n)},this)}run(e,n){this[e]=this[e]||[],this[e].forEach(function(e){e.call(n&&n.context?n.context:n,n)})}},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)})}}(dh),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"}),dh.max_unop_len=dh.getMaxKeyLen(dh.unary_ops),dh.max_binop_len=dh.getMaxKeyLen(dh.binary_ops);let dm=e=>new dh(e).parse(),dg=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(dh).filter(e=>!dg.includes(e)&&void 0===dm[e]).forEach(e=>{dm[e]=dh[e]}),dm.Jsep=dh,dm.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:o,alternate:a},t.operator&&e.binary_ops[t.operator]<=.9){let o=t;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let db="ArrowFunctionExpression",dy={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)}},d_={...dy,Promise};function dv(e,n={}){return dC(e,n,dD)}async function d$(e,n={}){return dE(e,n,dD)}function dA(e,n={}){return dC(e,n,dz)}function dw(e,n={}){return dE(e,n,dz)}function dk(e,n={}){return dC(e,n,dM)}function dx(e,n={}){return dE(e,n,dM)}function dC(e,n={},t){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==n&&(n={});let o=dT(n,dy),a=dP("string"==typeof e?dm(e):e,o);if(t(a))return a;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 dE(e,n={},t){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==n&&(n={});let o=dT(n,d_);return Promise.resolve(dP("string"==typeof e?dm(e):e,o)).then(n=>{if(t(n))return n;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 dS(e){return dm(e)}function dD(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function dz(e){return"boolean"==typeof e}function dM(e){return"number"==typeof e}function dP(e,n){switch(e.type){case"UnaryExpression":var t,o,a,r,i,s,l,c,p,u,d,f,h=e,m=n;let g=dP(h.argument,m);switch(h.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var b=e,y=n;let v=dP(b.left,y),$=dP(b.right,y);switch(b.operator){case"+":return v+$;case"-":return v-$;case"*":return v*$;case"/":return v/$;case"%":return v%$;case"**":return v**$;case"==":return v==$;case"===":return v===$;case"!=":return v!=$;case"!==":return v!==$;case">":return v>$;case">=":return v>=$;case"<":return v<$;case"<=":return v<=$;case"in":return v in $;case"&&":return v&&$;case"||":return v||$;case"??":return v??$;default:throw`Expression evaluator does not support operator '${b.operator}' operator`}case"ConditionalExpression":return t=e,o=n,dP(t.test,o)?dP(t.consequent,o):dP(t.alternate,o);case"CallExpression":var A=e,w=n;let k=A.arguments?.map(dN(w)),x=dP(A.callee,w);if(x){if("function"!=typeof x)throw`${dB(A.callee)} is not a function`}else throw`No function named ${dB(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return a=e,r=n,C=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<C.length)throw`Required argument(s) ${C.slice(e.length,-1).join(", ")} were not provided`;let n=Object.fromEntries(C.reduce((n,t,o)=>{let a=e[o];return function e(n){if("string"==typeof n||"number"==typeof n||"boolean"==typeof n||"function"==typeof n||null===n||n instanceof RegExp)return!0;if("object"==typeof n){for(let t of Object.keys(n))if(!e(n[t]))return!1;return!0}if(Array.isArray(n)){for(let t of n)if(!e(t))break}return!1}(a)&&n.push([t,a]),n},[]));return dP(a.body,r.addVariables(n))}).bind(r.thisObj??null);case"MemberExpression":return function(e,n){let t,o=dP(e.object,n);if(void 0===o)switch(e.object.type){case"Identifier":{let t=dO(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=dO(e.property,n);throw TypeError(`TypeError: cannot read properties of undefined (reading '${t}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let a=o;if("string"==typeof o)a=String.prototype;else if("number"==typeof o)a=Number.prototype;else if("function"==typeof o);else if("object"!=typeof o)throw`VisitMemberExpression does not support member access on type ${typeof o}`;switch(n.thisObj=a,e.property.type){case"Identifier":case"MemberExpression":t=dP(e.property,n);break;default:{let a=dP(e.property,n);if(void 0===a)throw{type:"Illegal property access",message:"No property was supplied to the property access"};dI(a),t=o[a]}}return"function"==typeof t?t.bind(o):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(dN(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(dN(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(dN(D));switch(S.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${S.callee.name}`}}if(S.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return dI((p=e).value),p.value;case"Identifier":var z=e,M=n;dI(z.name);let P=M.thisObj;if(P&&("object"==typeof P||"function"==typeof P)&&z.name in P){let e=P[z.name];return dI(e),e}if(M.variables&&z.name in M.variables){let e=M.variables[z.name];return dI(e),e}return z.name in M.globals?M.globals[z.name]:void 0;case"TemplateLiteral":let O,T;return u=e,d=n,O=u.expressions?.map(dN(d))??[],(T=u.quasis?.map(dN(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+O.join("")+T.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dO(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return dO(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function dT(e,n){let t={thisObj:void 0,variables:{...e},globals:{...n},addVariables(e){return this.variables={...this.variables,...e},this}};return t.addVariables.bind(t),t}function dN(e){return function(n){return null===n?null:dP(n,e)}}function dI(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function dB(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function dj(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 n={globals:{...d_},isLocalExpression:!1,variables:new Set};return dR("string"==typeof e?dm(e):e,n),[...n.variables]}function dR(e,n){switch(e.type){case"UnaryExpression":return o=e,a=n,dR(o.argument,a);case"BinaryExpression":return r=e,i=n,[dR(r.left,i),dR(r.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[dR(s.consequent,l),dR(s.test,l),dR(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,p=n,t=dR(c.callee,p),c.arguments?.map(dF(p)),t;case"ArrowFunctionExpression":var o,a,r,i,s,l,c,p,u,d,f,h,m,g,b,y,v,$,A=e,w=n;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(dF(k))??[],C=dR(A.body,k)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||w.variables.add(e);return;case"MemberExpression":let E;return u=e,d=n,dR(u.object,d),void((E={...d}).isLocalExpression=!0,dR(u.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(dF(h));case"SequenceExpression":return m=e,g=n,void m.expressions?.map(dF(g));case"NewExpression":return b=e,y=n,void b.arguments?.map(dF(y));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=n;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=n,void(v.expressions?.map(dF($)),v.quasis?.map(dF($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dF(e){return function(n){return null===n?null:dR(n,e)}}dm.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(n){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let t=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let t=this.gobbleBinaryExpression();t||this.throwError("Expected expression after "+e),n.node={type:db,params:null,body:t};return}}this.index=t}}),e.hooks.add("after-expression",function(n){!function n(t){t&&(Object.values(t).forEach(e=>{e&&"object"==typeof e&&n(e)}),"=>"===t.operator&&(t.type=db,t.params=t.left?[t.left]:null,t.body=t.right,t.params&&t.params[0].type===e.SEQUENCE_EXP&&(t.params=t.params[0].expressions),delete t.left,delete t.right,delete t.operator))}(n.node)})}}),dm.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(n){let t=n.node;if(t&&"new"===t.operator){t.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(t.argument.type)||this.throwError("Expected new function()"),n.node=t.argument;let o=n.node;for(;o.type===e.MEMBER_EXP||o.type===e.CALL_EXP&&o.callee.type===e.MEMBER_EXP;)o=o.type===e.MEMBER_EXP?o.object:o.callee.object;o.type="NewExpression"}})}}),dm.plugins.register({name:"numbers",init(e){function n(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 t(n){let t=this.index,o="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:o+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(o+=this.expr.charAt(this.index++),a());let r=this.char;("e"===r||"E"===r)&&(o+=this.expr.charAt(this.index++),("+"===(r=this.char)||"-"===r)&&(o+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+o+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+o+this.char+")");else if(i===e.PERIOD_CODE){o.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:o},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(o),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(o){if(48===this.code){var a,r,i;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let p="";for(;a=this.code,r=c,95===a||r.some(([e,n])=>a>=e&&a<=n);)95===this.code?this.index++:p+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,t.call(this,o);return}this.throwError("unexpected char within number")}o.node={type:e.LITERAL,value:parseInt(p,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&t.call(this,o)})}}),dm.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,o=!1;for(;this.index<this.expr.length;){if(47===this.code&&!o){let o,a=this.expr.slice(t,this.index),r="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)r+=this.char;else break}try{o=new RegExp(a,r)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:o,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?o=!0:o&&this.code===e.CBRACK_CODE&&(o=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),dm.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:o,alternate:a},t.operator&&e.binary_ops[t.operator]<=.9){let o=t;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),dm.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},o="",a="",r=!1,i=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:a,cooked:o},tail:r});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,r=!0,s(),e.node=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",o="",n.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(a+=i,i=this.expr.charAt(++this.index),a+=i,i){case"n":o+="\n";break;case"r":o+="\r";break;case"t":o+=" ";break;case"b":o+="\b";break;case"f":o+="\f";break;case"v":o+="\v";break;default:o+=i}else o+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",n),e.hooks.add("after-token",function(t){if((t.node.type===e.IDENTIFIER||t.node.type===e.MEMBER_EXP)&&96===this.code)return t.node={type:"TaggedTemplateExpression",tag:t.node,quasi:n.bind(this)(t,!1)},t.node=this.gobbleTokenProperty(t.node),t.node})}}),dm.addBinaryOp("in",7),dm.addBinaryOp("??",1);let dL=q("feature-flags",{flags:function(){let e={};for(let n of Object.keys(localStorage))if(n.startsWith("openmrs:feature-flag:")){let t=n.replace("openmrs:feature-flag:",""),o=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...o}}return e}()});function dW(e,n,t){dL.setState(o=>({flags:{...o.flags,[e]:{enabled:o.flags[e]?.enabled??!1,label:n,description:t}}}))}function dV(){let e=dL.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(n=>{let t=n.replace("openmrs:feature-flag:","");e[t]||(localStorage.removeItem(n),localStorage.removeItem(`openmrs:feature-flag-meta:${t}`))})}function dG(e){return dL.getState().flags[e].enabled}function dU(e,n){dL.subscribe(t=>{n(t.flags[e].enabled)})}function dq(e,n){dL.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function dH(e){return!window.offlineEnabled||(e??navigator.onLine)}dL.subscribe(e=>{for(let[n,t]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${n}`,t.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${n}`,JSON.stringify({label:t.label,description:t.description}))});var dK=nJ(function(e,n,t){nV(e,n,t)});function dY(e=!0,n=!1){return dZ(dH(),e,n)}function dZ(e,n=!0,t=!1){return!!(e?n:t)}let dJ=G("extensionsInternal",{slots:{},extensions:{}}),dX=()=>q("extensionsInternal",{slots:{},extensions:{}});function dQ(e){let n=dJ.getState(),t=e(n);t!==n&&dJ.setState(t)}let d0=()=>q("extensions",{slots:{}});function d1(e){let n=[];for(let t of Object.values(e.extensions))for(let e of t.instances)n.push({slotModuleName:e.slotModuleName,extensionModuleName:t.moduleName,slotName:e.slotName,extensionId:e.id});tP(ox.getState().mountedExtensions,n)||ox.setState({mountedExtensions:n})}d1(dJ.getState()),dJ.subscribe(d1);let d2=dX(),d3=d0(),d5=oE(),d4=oz();function d6(e,n,t,o,a){let r={},i=dH(),s=Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[o,l]of Object.entries(e.slots)){let{config:c}=oD(n,l.name),p=fs(o,e,c,t,s,i,a.session);r[o]={moduleName:l.moduleName,assignedExtensions:p}}tP(d3.getState().slots,r)||d3.setState({slots:r})}function d7(){d6(d2.getState(),d5.getState(),d4.getState(),dL.getState(),r5.getState())}function d8(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function d9(e){let[n]=e.split("#");return n}function fe(e,n){let t=d9(n);return e.extensions[t]}function fn(e){return fe(d2.getState(),e)}d2.subscribe(e=>{d6(e,d5.getState(),d4.getState(),dL.getState(),r5.getState())}),d5.subscribe(e=>{d6(d2.getState(),e,d4.getState(),dL.getState(),r5.getState())}),d4.subscribe(e=>{d6(d2.getState(),d5.getState(),e,dL.getState(),r5.getState())}),dL.subscribe(e=>{d6(d2.getState(),d5.getState(),d4.getState(),e,r5.getState())}),r5.subscribe(e=>{d6(d2.getState(),d5.getState(),d4.getState(),dL.getState(),e)}),d7(),g(d7);let ft=e=>d2.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function fo(e,n){dQ(t=>{let o=t.slots[e];return o?{...t,slots:{...t.slots,[e]:{...o,attachedIds:[...o.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...d8(e),attachedIds:[n]}}}})}function fa(e,n){dQ(t=>{let o=t.slots[e];return o&&o.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...o,attachedIds:o.attachedIds.filter(e=>e!==n)}}}:t})}function fr(e){dQ(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function fi(e,n,t,o){let a=n.indexOf(e);if(-1!==a)return a;{if(void 0!==t)return 1e3+t;let n=o.indexOf(e);return -1!==n?2e3+n:-1}}function fs(e,n,t,o,a,r,i){let s=function(e,n){let t=e.add||[],o=e.remove||[],a=e.order||[],{extensions:r}=d2.getState();return[...n,...t].filter(e=>!o.includes(e)).sort((e,t)=>{let o=fi(e,a,r[d9(e)]?.order,n),i=fi(t,a,r[d9(t)]?.order,n);return -1===i?-1:-1===o?1:o-i})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,p=c&&"object"==typeof c?{session:i,...c}:{session:i};for(let c of s){let{config:s}=oP(o,e,c),u=dK(s,oO(t,e,c)),d=d9(c),f=n.extensions[d];if(f){let n=u?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!i?.user||!it(n,i.user)))continue;let t=u?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!dA(t,p))continue}catch(n){console.error(`Error while evaluating expression '${t}' for extension ${d} in slot ${e}`,n);continue}if(f.featureFlag&&!a.includes(f.featureFlag)||window.offlineEnabled&&!dZ(r,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:u,featureFlag:f.featureFlag,meta:f.meta,online:u?.["Display conditions"]?.online??f.online??!0,offline:u?.["Display conditions"]?.offline??f.offline??!1})}}return l}function fl(e){let n=d2.getState(),{config:t}=oS(e),o=d4.getState(),a=dL.getState(),r=r5.getState(),i=dH();return fs(e,n,t,o,Object.entries(a.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),i,r.session)}let fc=(e,n,t)=>d2.setState(o=>{let a=o.slots[n]?.moduleName;if(a&&a!=e)return console.warn(`An extension slot with the name '${n}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${a}.`),o;if(a&&a==e)return o;if(o.slots[n])return{...o,slots:{...o.slots,[n]:{...o.slots[n],moduleName:e,state:t}}};let r=d8(n,e,t);return{...o,slots:{...o.slots,[n]:{...r}}}});function fp(e,n,t=!1){d2.setState(o=>{let a=t?dK(o.slots[e].state,n):n;return{...o,slots:{...o.slots,[e]:{...o.slots[e],state:a}}}})}let fu=()=>d3.setState(()=>({slots:{},extensions:{}})),fd=G("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function ff({name:e,basePath:n,mode:t,componentContext:o,state:a}){fd.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:o,state:a})}function fh(e){fd.getState().slotName===e&&fd.setState(fd.getInitialState(),!0)}let fm=G("modalRegistry",{modals:{}});function fg(e){fm.setState(n=>(n.modals[e.name]=e,n))}function fb(e){let n=fm.getState().modals[e];if(!n){let t=fn(e);t&&(n={name:e,load:t.load,moduleName:t.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.`),fg(n))}return n}let fy=G("workspaceRegistrations",{workspaces:{}}),f_=G("workspaceGroups",{workspaceGroups:{}});function fv(e){fy.setState(n=>({workspaces:{...n.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 f$(e){f_.setState(n=>{let t=n.workspaceGroups[e.name];return t?{workspaceGroups:{...n.workspaceGroups,[e.name]:{...t,members:Array.from(new Set([...t.members,...e.members]))}}}:{workspaceGroups:{...n.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let fA=new Set;function fw(e){let n=fy.getState().workspaces;if(n[e])return n[e];{let n=fn(e);if(n){var t;let o;return fA.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.`),fA.add(e)),{name:n.name,title:(t=n,"string"==typeof(o=t?.meta?.title)?o:o&&"object"==typeof o?i2(t.moduleName,o.key,o.default):t.name),moduleName:n.moduleName,preferredWindowSize:n.meta?.screenSize??"normal",load:n.load,type:n.meta?.type??"form",canHide:n.meta?.canHide??!1,canMaximize:n.meta?.canMaximize??!1,width:n.meta?.width??"narrow",groups:n.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function fk(e){let n=f_.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let fx=G("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function fC(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=fx.getState(),o=n[e];if(o){let n=t[o.window];if(n)return n;throw Error(`No workspace window found with name: ${o.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function fE(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=fx.getState(),o=t[e];if(o){let t=n[o.group];if(t)return t;throw Error(`No workspace group found with name: ${o.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function fS(e){let{openedWindows:n}=fx.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function fD(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=fx.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);o[t.name]={...t,moduleName:e}}fx.setState({registeredGroupsByName:o})}function fz(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=fx.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};o[t.name]=n}fx.setState({registeredWindowsByName:o})}function fM(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=fx.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};o[t.name]=n}fx.setState({registeredWorkspacesByName:o})}let fP=0;async function fO(e,n,t,o,a=e=>e,r={}){let i=d9(o),s=fn(o),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:p,online:u,offline:d,load:f}=s;if(dY(u,d)){dQ(a=>({...a,extensions:{...a.extensions,[i]:{...a.extensions[i],instances:[...a.extensions[i].instances,{domElement:e,id:o,slotName:n,slotModuleName:t}]}}}));let s=await f(),u=fP++;l=aQ(a({...s,name:`${n}/${i}-${u}`}),{...r,_meta:c,_extensionContext:{extensionId:o,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:p},domElement:e})}}else console.warn(`Tried to render ${o} into ${n} but no DOM element was available.`);return l}var fT=t(2491),fN=t.n(fT);let fI=(0,fT.createContext)({moduleName:"",featureName:""});function fB({to:e,templateParams:n,onBeforeNavigate:t,children:o,...a}){return(0,fT.useEffect)(()=>{a.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${a.href}'`),a.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),fN().createElement("a",{onClick:o=>{0===o.button&&!o.ctrlKey&&!o.shiftKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),t?.(o),rL({to:e,templateParams:n})),0===o.button&&(o.ctrlKey||o.metaKey)&&t?.(o),0===o.button&&o.shiftKey&&t?.(o),1===o.button&&t?.(o)},href:rR(e,n),...a},o)}let fj=({state:e,children:n,...t})=>{let{extension:o}=(0,fT.useContext)(fI),a=(0,fT.useRef)(null),r=(0,fT.useRef)(Promise.resolve()),i=(0,fT.useCallback)(n=>{o?.extensionSlotName&&o.extensionSlotModuleName&&o.extensionSlotModuleName&&!a.current&&fO(n,o.extensionSlotName,o.extensionSlotModuleName,o.extensionId,void 0,e).then(e=>{a.current=e})},[]);return(0,fT.useEffect)(()=>()=>{if(a&&a.current)switch(a.current.getStatus()){case"MOUNTING":a.current.mountPromise.then(()=>{a.current?.getStatus()==="MOUNTED"&&a.current.unmount()});break;case"MOUNTED":a.current.unmount();break;case"UPDATING":r.current&&r.current.then(()=>{a.current?.getStatus()==="MOUNTED"&&a.current.unmount()})}},[]),(0,fT.useEffect)(()=>{a.current&&a.current.update&&"UNMOUNTING"!==a.current.getStatus()&&Promise.all([a.current.mountPromise,r.current]).then(()=>{a?.current?.getStatus()==="MOUNTED"&&a.current.update&&(r.current=a.current.update({...e}).catch(e=>{if(!(e instanceof Error)||!e.message.includes("minified message #32")||a.current?.getStatus()==="MOUNTED")throw e}))})},[e]),o?fN().createElement("div",{ref:i,"data-extension-id":o?.extensionId,style:{position:"relative"},...t}):null};function fR(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[o,a]of Object.entries(n)){let n=function(...n){e.setState(e=>a(e,...n))};t[o]=n}return t}let fF=()=>e=>e;function fL(e,n=fF(),t){let o=(0,fT.useCallback)(n=>e.subscribe(n),[e]),a=(0,fT.useCallback)(()=>n(e.getState()),[e,n]),r=(0,fT.useSyncExternalStore)(o,a,a),i=(0,fT.useMemo)(()=>t?fR(e,t):{},[e,t]);return{...r,...i}}function fW(e,n){return fL(e,fF(),n)}function fV(e){return function(n){let t=(0,fT.useCallback)(n=>e.subscribe(n),[]),o=(0,fT.useCallback)(()=>e.getState(),[]),a=(0,fT.useSyncExternalStore)(t,o,o),r=(0,fT.useMemo)(()=>n?fR(e,n):{},[n]);return{...a,...r}}}let fG=e=>fL(d0(),n=>n.slots?.[e]);function fU(e){let n=fG(e);return n?.assignedExtensions??[]}function fq(e,n){let{moduleName:t}=(0,fT.useContext)(fI),o=(0,fT.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,fT.useEffect)(()=>{fc(t,e,n),o.current=!1},[]),(0,fT.useEffect)(()=>{o.current||fp(e,n)},[e,n]),{extensions:fU(e),extensionSlotName:e,extensionSlotModuleName:t}}function fH(e){return e}function fK({name:e,extensionSlotName:n,select:t=fH,children:o,state:a,style:r,...i}){if(o&&a)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??n,l=(0,fT.useRef)(null),{extensions:c,extensionSlotModuleName:p}=fq(s,a),u=(0,fT.useMemo)(()=>t(c),[t,c]),d=(0,fT.useMemo)(()=>{if("function"==typeof o&&!fN().isValidElement(o))return u.map(e=>o(e,a))},[o,u]);return fN().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":p,style:{...r,position:"relative"},...i},s&&u?.map((e,n)=>fN().createElement(fI.Provider,{key:e.id,value:{moduleName:p,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:p}}},d?.[n]??("function"!=typeof o?o:null)??fN().createElement(fj,{state:a}))))}var fY=t(5873);function fZ(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,o)}return t}function fJ(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?fZ(Object(t),!0).forEach(function(n){var o,a,r;o=e,a=n,r=t[n],a in o?Object.defineProperty(o,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):o[a]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):fZ(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function fX(e){return(fX="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 fQ(e){return(fQ="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 f0(e,n){var t;if("function"!=typeof(t=n.domElement?function(){return n.domElement}:n.domElementGetter?n.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var n=e.appName||e.name;if(!n)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 t="single-spa-application:".concat(n);return function(){var e=document.getElementById(t);return e||((e=document.createElement("div")).id=t,document.body.appendChild(e)),e}}(n)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(n.name,"'. Expected a function, received ").concat(fQ(t)));return function(){var e=t(n);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(n.name,"'. Expected HTMLElement, received ").concat(fQ(e)));return e}}var f1=null;try{f1=require("react").createContext()}catch(e){}var f2={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 f3(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function f5(e,n){return new Promise(function(t,o){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var n=e.version.slice(0,e.version.indexOf("."));try{return Number(n)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,r=f8(e,n,function(){t(this)}),i=f0(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,o=e.elementToRender,a=e.domElement,r=n[t];if("function"!=typeof r)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=r(a);return i.render(o),i;case"hydrateRoot":return r(a,o);default:return r(o,a),null}}({elementToRender:r,domElement:i,reactDom:f7(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function f4(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var o=e.renderResults[n.name];o&&o.unmount?o.unmount():f7(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function f6(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var o=f8(e,n,null),a=e.renderResults[n.name];if(a&&a.render)a.render(o);else{var r=f0(e,n)();f7(e).render(o,r)}})}function f7(e){return e.ReactDOMClient||e.ReactDOM}function f8(e,n,t){var o=e.React.createElement(e.rootComponent,n),a=f1?e.React.createElement(f1.Provider,{value:n},o):o;return(e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,n){function t(n){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},t.displayName="SingleSpaReactErrorBoundary(".concat(n.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||n.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},t.prototype.componentDidCatch=function(e,n){this.setState({caughtError:e,caughtErrorInfo:n})},t}(e,n),a=e.React.createElement(e.errorBoundaryClass,n,a)),a=e.React.createElement(e.SingleSpaRoot,fJ(fJ({},n),{},{mountFinished:t,updateFinished:function(){e.updateResolves[n.name]&&(e.updateResolves[n.name].forEach(function(e){return e()}),delete e.updateResolves[n.name])},unmountFinished:function(){e.unmountResolves[n.name]&&(e.unmountResolves[n.name](),delete e.unmountResolves[n.name])}}),a)}var f9=t(4011),he=t(1123),hn=t(3780);let ht={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ho=new Map;(0,hn.initCache)(ho);let ha={errorRetryCount:3,fetcher:r1,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof r3){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>ho};function hr(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},ht,e),t={...ha,...n.swrConfig};return function(e){var o,a,r,i,s;return r=a=class extends(o=fN().Component){componentDidCatch(e,t){t&&t.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:t.componentStack})),n.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:t})}render(){if(this.state.caughtError)return fN().createElement("div",null,"An error has occurred. Please try reloading the page.");{let o=fN().createElement(fT.Suspense,{fallback:null},fN().createElement(he.BE,{value:t},fN().createElement(fI.Provider,{value:this.state.config},n.disableTranslations?fN().createElement(e,this.props):fN().createElement(f9.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},fN().createElement(e,this.props)))));return n.strictMode&&fN().StrictMode?fN().createElement(fN().StrictMode,null,o):o}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${n.featureName})`,i in r?Object.defineProperty(r,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[i]=s,a}}function hi(e,n){return function(e){if("object"!==fX(e))throw Error("single-spa-react requires a configuration object");var n,t=fJ(fJ({},f2),e);if(!t.React)throw Error("single-spa-react must be passed opts.React");if(!t.ReactDOM&&!t.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(t.renderType||(null!=(n=t.ReactDOMClient)&&n.createRoot?t.renderType="createRoot":t.renderType="render"),!t.rootComponent&&!t.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(t.errorBoundary&&"function"!=typeof t.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!f1&&t.React.createContext&&(f1=t.React.createContext()),t.SingleSpaRoot=function(e){function n(e){n.displayName="SingleSpaRoot(".concat(e.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},n.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},n.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},n}(t);var o={bootstrap:f3.bind(null,t),mount:f5.bind(null,t),unmount:f4.bind(null,t)};return t.parcelCanUpdate&&(o.update=f6.bind(null,t)),o}({React:fN(),ReactDOMClient:fY,rootComponent:hr(n)(e)})}function hs(e,n){return()=>e().then(({default:e})=>hi(e,n))}function hl(e,n){return()=>Promise.resolve(hi(e,n))}let hc=hs,hp=L()(()=>({}));U("openmrs-app-context",hp);let hu={};function hd(e,n=e=>e){let t=hp.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function hf(e,n){hp.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function hh(e){return null===e?null:Object.freeze(Object.assign({},e))}let hm=new Map;function hg(e,n){let t=(0,fT.useRef)(n??{}),o=(0,fT.useRef)(n=>hf(e,n)),a=(0,fT.useRef)(Symbol());return(0,fT.useEffect)(()=>{let t=n??{},o=a.current;return null===hd(e)?!function(e,n=hu){hp.setState(t=>{if(e in t)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({},t,{[e]:n===hu?{}:n})})}(e,t):(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.`),hf(e,()=>t)),hm.set(e,o),()=>{hm.get(e)===o&&(hp.setState(n=>(e in n&&delete n[e],n)),hm.delete(e))}},[e]),(0,fT.useEffect)(()=>{let o=n??{};B(t.current,o)||(hf(e,()=>o),t.current=o)},[n]),o.current}function hb({namespace:e,value:n}){return hg(e,n),null}let hy=({children:e,value:n,fallback:t})=>n?fN().createElement(fN().Fragment,null,e):t?fN().createElement(fN().Fragment,null,t):null;function h_(){let e=(0,fT.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,fT.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function hv(e,n=e=>e??{}){let[t,o]=(0,fT.useState)(()=>{if(h$(e))return;let t=hd(e);if(null!==t)return n?n(t):t});return(0,fT.useEffect)(()=>{if(h$(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,fT.useEffect)(()=>{var t;let a;return(t=e=>{if(null==e)return void o(void 0);let t=n?n(e):e;o(e=>B(e,t)?e:t)})(hh(a=hd(e))),hp.subscribe(n=>{let o=e in n?n[e]:null;o!==a&&(a=o,t(hh(o)))})},[e,n]),t}function h$(e){return"string"!=typeof e||0===e.trim().length}function hA(e){let[n,t]=(0,fT.useState)([]);return(0,fT.useEffect)(()=>d0().subscribe(o=>{let a=o.slots[e]?.assignedExtensions.map(e=>e.id)??[];tP(a,n)||t(a)}),[]),n}function hw(e,n){let{data:t,error:o,mutate:a,isLoading:r,isValidating:i}=(0,he.Ay)(`${sB}?patient=${e}&includeEncounterless=${n}`,r1);return(0,fT.useMemo)(()=>({isLoading:r,data:t?.data.results??[],error:o,mutate:a,isValidating:i}),[t,o,r,i,a])}function hk(e){(0,fT.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let hx={},hC=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function hE(e){let{moduleName:n,extension:t}=(0,fT.useContext)(fI),o=e?.externalModuleName??n;if(!o&&!t)throw Error(hC);let a=function(e){let n=(0,fT.useMemo)(()=>oC(e),[e]),t=function(e){let[n,t]=(0,fT.useState)(()=>{let n=e.getState();return n.loaded&&n.config?n.config:null});return(0,fT.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&t(e.config)}),[e]),n}(n);if(!t)throw hx[e]||(hx[e]=new Promise(e=>{let t=n.subscribe(n=>{n.loaded&&n.config&&(e(n.config),t())})})),hx[e];return t}(o),r=function(e){let n=(0,fT.useMemo)(oz,[]),t=function(e,n){let[t,o]=(0,fT.useState)(n?()=>{let t=oP(e.getState(),n.extensionSlotName,n.extensionId);if(t.loaded&&t.config)return t.config}:null);return(0,fT.useEffect)(()=>{if(n)return e.subscribe(e=>{let a=oP(e,n.extensionSlotName,n.extensionId);a.loaded&&a.config&&!tP(a.config,t)&&o(a.config)})},[e,n,t]),t}(n,e);if(!t&&e){let t=`${e.extensionSlotName}-${e.extensionId}`;throw!hx[t]&&n&&(hx[t]=new Promise(t=>{let o=n.subscribe(n=>{let a=oP(n,e.extensionSlotName,e.extensionId);a.loaded&&a.config&&(t(a.config),o())})})),hx[t]}return t||{}}(t);return(0,fT.useMemo)(()=>e?.externalModuleName&&o===e.externalModuleName?{...a}:{...a,...r},[o,e?.externalModuleName,a,r])}let hS=fU;function hD(){let[e,n]=(0,fT.useState)(dH());return(0,fT.useEffect)(()=>g(({online:e})=>n(e)),[]),e}function hz(e,n=300){let[t,o]=(0,fT.useState)(e);return(0,fT.useEffect)(()=>{let t=setTimeout(()=>{o(e)},n);return()=>{clearTimeout(t)}},[e,n]),t}var hM=t(9256),hP=t.n(hM);let hO=`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,n])=>`${e}:${n}`).join(",")}`;function hT(){let e=`${rJ}/emrapi/configuration?v=${hO}`,n=hP()(e,r1);return(0,fT.useMemo)(()=>({emrConfiguration:n.data?.data,isLoadingEmrConfiguration:n.isLoading,mutateEmrConfiguration:n.mutate,errorFetchingEmrConfiguration:n.error}),[n])}let hN=fV(dX());function hI(e){let n=fU(e);return(0,fT.useMemo)(()=>Object.fromEntries(n.map(e=>[e.name,e.meta])),[n])}let hB=fV(d0());function hj(e){let{flags:n}=fL(dL);return n[e]?.enabled??!1}function hR(){let[,e]=(0,fT.useState)(0);return(0,fT.useCallback)(()=>{e(e=>e+1)},[])}function hF(e,n,t={}){return hW(e,n,hL,t)}let hL={getPaginatedUrl:(e,n,t)=>{if(!e)return null;{let o=new URL(r0(e.toString()),window.location.toString());return o.searchParams.set("limit",""+n),o.searchParams.set("startIndex",""+t),o.searchParams.set("totalCount","true"),o.toString()}},getNextUrl:e=>{let n=e?.links?.find(e=>"next"==e.rel)?.uri;if(!n)return null;{let e=new URL(n);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 hW(e,n,t,o={}){let{getPaginatedUrl:a,getTotalCount:r,getCurrentPageSize:i,getData:s}=t,{immutable:l,swrConfig:c}=o,p=o.fetcher??r1,[u,d]=(0,fT.useState)(1),f=(0,fT.useRef)(NaN),h=(0,fT.useRef)(NaN),m=(u-1)*n,g=(0,fT.useMemo)(()=>a(e,n,m),[e,n,m]),{data:b,...y}=(l?hP():he.Ay)(g,p,c);b?.data&&(f.current=r(b?.data),h.current=i(b?.data));let v=Math.ceil(f.current/n),$=(0,fT.useCallback)(e=>{0<e&&e<=v?d(e):console.warn("Invalid attempt to go to out of bounds page: "+e)},[e,u,v]),A=(0,fT.useCallback)(()=>{$(u+1)},[e,u,v]),w=(0,fT.useCallback)(()=>{$(u-1)},[e,u,v]);return{data:s(b?.data),totalPages:v,totalCount:f.current,currentPage:u,currentPageSize:h,paginated:v>1,showNextButton:u<v,showPreviousButton:u>1,goTo:$,goToNext:A,goToPrevious:w,...y}}function hV(e,n,t={}){return hW(e,n,hG(),t)}function hG(){return{getPaginatedUrl:(e,n,t)=>{if(!e)return null;{let o=new URL(r0(e.toString()),window.location.toString());return o.searchParams.set("_count",""+n),o.searchParams.set("_getpagesoffset",""+t),o.toString()}},getNextUrl:e=>{let n=e?.link?.find(e=>"next"==e.relation)?.url;if(!n)return null;{let e=new URL(n);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 hU=t(6038),hq=t.n(hU);function hH(e,n={}){return hK(e,hL,n)}function hK(e,n,t={}){let{swrInfiniteConfig:o,immutable:a}=t,{getNextUrl:r,getTotalCount:i,getData:s}=n,l=t.fetcher??r1,c=(0,fT.useCallback)((t,o)=>0==t?e?.toString()??null:n.getNextUrl(o.data),[e]),{data:p,size:u,setSize:d,...f}=hq()(c,l,{...o,...a?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),h=r(p?.[p.length-1].data),m=i(p?.[0]?.data);return{data:p?.flatMap(e=>s(e.data)),totalCount:m,hasMore:null!=h,loadMore:()=>{d((p?.length??0)+1)},nextUri:h,...f}}function hY(e,n={}){return hZ(e,hL,n)}function hZ(e,n,t={}){let o=hK(e,n,t),{hasMore:a,error:r,data:i,loadMore:s,isLoading:l,nextUri:c}=o;return((0,fT.useEffect)(()=>{a&&!r&&s()},[a,c]),t.partialData)?o:{...o,data:a||r?void 0:i,isLoading:l||a}}function hJ(e,n={}){return hZ(e,hG(),n)}function hX(e,n={}){return hK(e,hG(),n)}function hQ(){let e="tablet";return document.body.classList.forEach(n=>{switch(n){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 h0(){let[e,n]=(0,fT.useState)(hQ);return(0,fT.useEffect)(()=>{let e=()=>{n(hQ())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let h1=e=>"small-desktop"===e||"large-desktop"===e;function h2(e){let n=(0,fT.useContext)(fI);(0,fT.useEffect)(()=>(n&&n.moduleName&&(e.componentContext=n),ff(e),()=>{fh(e.name)}),[n,e])}function h3(){return fL(fd)}function h5(e=null,n=null){let[t,o]=(0,fT.useState)([]);return(0,fT.useEffect)(()=>{let t=de(e,n).subscribe(e=>{o(e)},e=>{console.error(e)});return()=>t.unsubscribe()},[e,n]),t}function h4(e,n=!0){let t=(0,fT.useRef)(null);return(0,fT.useEffect)(()=>{let o=o=>{n&&t.current&&o.target&&o.target instanceof Node&&(t.current.contains(o.target)||e(o))};return window.addEventListener("mousedown",o),window.addEventListener("touchstart",o),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("touchstart",o)}},[e,n]),t}function h6(e){let n=(0,fT.useRef)();return(0,fT.useEffect)(()=>{let t=new IntersectionObserver(n=>{for(let t of n)if(t.isIntersecting)return void e()},{threshold:1});return n.current&&t.observe(n.current),()=>{n.current&&t.unobserve(n.current)}},[n.current,e]),n}function h7(e,n={}){let{abortController:t,fetchInit:o,url:a,swrConfig:r}=n,i=h_(),s=(0,fT.useMemo)(()=>o?.signal??t?.signal??i.signal,[t?.signal,o?.signal,i.signal]),l=(0,fT.useCallback)(e=>r1(function(e,n){if(n)return"function"==typeof n?n(e):n;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,a),{...o,signal:s}),[s,o,a]);return(0,he.Ay)(e,l,r)}function h8(e=[],n=10){let[t,o]=(0,fT.useState)(1),a=(0,fT.useMemo)(()=>"number"==typeof n&&n>0?Math.max(1,Math.ceil(e.length/n)):1,[e.length,n]),r=(0,fT.useMemo)(()=>{let o=(t-1)*n,a=(t+0)*n;return e.slice(o,a)},[e,t,n]),i=(0,fT.useCallback)(e=>{o(Math.max(1,Math.min(a,e)))},[o,a]),s=(0,fT.useCallback)(()=>{t<a&&o(t+1)},[t,a,o]),l=(0,fT.useCallback)(()=>{t>1&&o(t-1)},[t,o]);return(0,fT.useMemo)(()=>({results:r,totalPages:a,currentPage:t,paginated:e.length>n,showNextButton:t<a,showPreviousButton:t>1,goTo:i,goToNext:s,goToPrevious:l}),[r,a,e.length,n,t,i,s,l])}function h9(e,n,t,o){return{pageSizes:(0,fT.useMemo)(()=>{let t=Math.ceil(n/e);return isNaN(t)&&(t=0),[...Array(t).keys()].map(n=>(n+1)*e)},[e,n]),pageItemsCount:(0,fT.useMemo)(()=>e>n?n:e*t>n?e*(t-1)+o:e*t,[e,n,t,o])}}function me(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function mn(e){let[n,t]=(0,fT.useState)(e??me()),{data:o,error:a,isValidating:r}=(0,he.Ay)(n?["patient",n]:null,()=>u5(n,{}));return(0,fT.useEffect)(()=>{let e=()=>{let e=me();e!==n&&t(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[n]),(0,fT.useMemo)(()=>({isLoading:r&&!a&&!o,patient:o,patientUuid:n,error:a}),[r,a,o,n])}function mt(){let e=`${rJ}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:n,error:t,isLoading:o}=(0,he.Ay)(e,r1);return(0,fT.useMemo)(()=>({primaryIdentifierCode:n?.data?.results[0]?.metadataUuid,isLoading:o,error:t}),[n,t,o])}function mo(e){let{extensions:n,extensionSlotModuleName:t}=fq(e);return e?n.map(n=>({state:o})=>fN().createElement(fI.Provider,{value:{moduleName:t,featureName:"",extension:{extensionId:n.id,extensionSlotName:e,extensionSlotModuleName:t}}},fN().createElement(fj,{state:o}))):[]}function ma(){let e=(0,fT.useRef)(),[n,t]=(0,fT.useState)(null),o=null;if(!n){if(i){let e=r7().getState();e.loaded&&(o=e.session)}else i=new Promise(n=>{let t=({loaded:t,session:a})=>{t&&(n(a),o=a,e.current&&(e.current(),e.current=void 0))};t(r7().getState()),o||(e.current=r7().subscribe(t))});if(o)t(o);else throw i}(0,fT.useEffect)(()=>(e.current||(e.current=r7().subscribe(({loaded:e,session:n})=>{e&&(o=n,t(n))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let a=n||o;if(!a)if(i)throw console.warn("useSession is in an unexpected state. Attempting to recover."),i;else throw Error("useSession is in an invalid state.");return a}let mr=({privilege:e,fallback:n,children:t})=>{let[o,a]=(0,fT.useState)(null);return((0,fT.useEffect)(()=>{let e=r6({includeAuthStatus:!1}).subscribe(a);return()=>e.unsubscribe()},[]),o&&it(e,o))?fN().createElement(fN().Fragment,null,t):n?fN().createElement(fN().Fragment,null,n):null};var mi=t(4274),ms=t.n(mi),ml=t(5602);let mc={setVisitContext:(e,n)=>null==n?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:n.uuid,patientUuid:n.patient?.uuid},mutateVisit(e){for(let n of Object.values(e.mutateVisitCallbacks??{}))n();return{}}};function mp(e){let n=(0,fT.useId)();return(0,fT.useEffect)(()=>{let t=dl();return e&&t.setState({mutateVisitCallbacks:{...t.getState().mutateVisitCallbacks,[n]:e}}),()=>{if(e){let e={...t.getState().mutateVisitCallbacks};delete e[n],t.setState({mutateVisitCallbacks:e})}}},[n,e]),fW(dl(),mc)}function mu(e,n=di){let{patientUuid:t,manuallySetVisitUuid:o,setVisitContext:a}=mp(),r=e&&t==e?o:null,i=`?patient=${e}&v=${n}&includeInactive=false`,s=`/${r}?v=${n}`,{data:l,error:c,mutate:p,isValidating:u}=(0,he.Ay)(e?`${rJ}/visit${i}`:null,r1),{data:d,error:f,mutate:h,isValidating:m}=(0,he.Ay)(e&&r?`${rJ}/visit${s}`:null,r1),g=(0,fT.useMemo)(()=>l?.data.results.find(e=>null===e.stopDatetime)??null,[l]),b=(0,fT.useMemo)(()=>r&&d?d.data:null,[d,r]),y=(0,fT.useRef)(null);(0,fT.useEffect)(()=>{!u&&g&&t===e&&null===o&&a(g),m||(y.current&&b&&y.current.uuid===b.uuid&&!y.current.stopDatetime&&b.stopDatetime&&a(null),y.current=b)},[b,o,g,u,m,t]);let v=(0,fT.useCallback)(()=>{p(),h()},[p,h]);mp(v);let $=!!(!l||r&&!d),A=!!(r?f:c);return{error:c||f,mutate:v,isValidating:u||m,activeVisit:g,currentVisit:b,currentVisitIsRetrospective:!!r,isLoading:$&&!A}}function md(){let[e,n]=(0,fT.useState)([]);return(0,fT.useEffect)(()=>{let e=dt().subscribe(e=>{n(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}ms().extend(ml);let mf=new Map;async function mh(e,n){let t=n.indexOf("#"),o=t>=0,a=o?n.substring(0,t):e,r=o?n.substring(t+1):n,i=await sm(a);return i&&Object.hasOwn(i,r)&&"function"==typeof i[r]?mg(a,i).then(()=>i[r]()):(i?i&&Object.hasOwn(i,r)?console.warn(`The export ${n}, defined in ${e}'s routes.json, is not a function`):console.warn(`${a} does not define a component called "${r}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${a} for ${n} defined in ${e}'s routes.json`),mm)}let mm={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function mg(e,n){if(e in mf)await mf[e];else{let t=n??await sm(e);await (mf[e]=new Promise((n,o)=>{if(Object.hasOwn(t,"startupApp")){let a=t.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{oL(e),n(null)}).catch(o)}oL(e),n(null)}))}}function mb(e,n){let t=n.name;if(!t)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.`,n);n.slots&&n.slot&&console.warn(`The extension ${t} from ${e} declares both a 'slots' property and