@openmrs/esm-fast-data-entry-app 1.5.1-pre.871 → 1.5.1-pre.873

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/2657.js CHANGED
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
12
12
  ${t}`)}return a}let tp=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let a=n[t],r=e[t];if(r&&(r.hasOwnProperty("_type")||r.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=r._default);let e=r._elements;if(a&&td(e)){if(r._type===e_.Array&&Array.isArray(a)){let r=a.map(t=>tp(e,t));n[t]=r}else if(r._type===e_.Object)for(let t of Object.keys(a))a[t]=tp(e,a[t])}}else if(tf(r)){let e=a??{};tf(e)&&(n[t]=tp(r,e))}}return n};function td(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function tf(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let th=new Set;function tm(e,t){let n=`${e}:::${t}`;th||(th=new Set),th.has(n)||(console.error(t),th.add(n))}function tg(e){e?th.forEach(t=>{t.startsWith(e)&&th.delete(t)}):th.clear()}function ty(){eY.forEach(e=>e()),eY.length=0,eQ.clear(),te.clear(),tn.clear(),tt.clear(),eZ()}let tb={"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:e_.Object,_default:{},_validators:[ev(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let t=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${t.join(", ")}.`})]}},t_={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:e_.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:e_.String,_default:void 0}},...tb},tv=(e,t)=>ev(n=>e<=n&&n<=t,`must be between ${e} and ${t}`),t$=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return ev(e=>{if(!e||"string"!=typeof e)return!1;let n=/\${(.*?)}/g,a=n.exec(e);for(;a;){if(!t.includes(a[1]))return!1;a=n.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},tA=t$([]),tw=e=>ev(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),tk={inRange:tv,isUrl:tA,isUrlWithTemplateParameters:t$,oneOf:tw};var tx=n(8067);let tC=U("breadcrumbs",[]);function tE(e){return tS([e])}function tS(e){let t=[...tD(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,tx.pathToRegexp)(e.matcher).regexp:(0,tx.pathToRegexp)(e.path).regexp,settings:e}))];tC.setState(t,!0)}function tD(){return tC.getState()}function tM(e,t){if(t)return function(e,t){let[n]=e.filter(e=>e.matcher.test(t));return n}(e,t)||function(e,t){let n=t.split("/");for(;n.length>1;){n.pop();let t=tM(e,n.join("/"));if(t)return t}}(e,t)}function tz(e,t){if(e.length>0){let n=tM(e,t);if(n){let t=[n],a=tM(e,n.settings.parent);for(;void 0!==a;)t.push(a),a=tM(e,a.settings.parent);return t.reverse()}}return[]}function tO(e){return tz(tD(),e)}var tP=Object.freeze({__proto__:null,get start(){return n3},get ensureJQuerySupport(){return nO},get setBootstrapMaxTime(){return nf},get setMountMaxTime(){return nh},get setUnmountMaxTime(){return nm},get setUnloadMaxTime(){return ng},get registerApplication(){return nG},get unregisterApplication(){return nU},get getMountedApps(){return nR},get getAppStatus(){return nL},get unloadApplication(){return nq},get checkActivityFunctions(){return nV},get getAppNames(){return nF},get pathToActiveWhen(){return nY},get navigateToUrl(){return nw},get patchHistoryApi(){return nD},get triggerAppChange(){return nQ},get addErrorHandler(){return tj},get removeErrorHandler(){return tR},get mountRootParcel(){return nl},get NOT_LOADED(){return tW},get LOADING_SOURCE_CODE(){return tG},get NOT_BOOTSTRAPPED(){return tV},get BOOTSTRAPPING(){return tU},get NOT_MOUNTED(){return tq},get MOUNTING(){return tH},get UPDATING(){return tY},get LOAD_ERROR(){return tX},get MOUNTED(){return tK},get UNLOADING(){return tZ},get UNMOUNTING(){return tJ},get SKIP_BECAUSE_BROKEN(){return tQ}}),tT=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,tB=!function(){try{var e=new tT("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var n=document.createEvent("CustomEvent");return t?n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):n.initCustomEvent(e,!1,!1,void 0),n}:function(e,t){var n=document.createEventObject();return n.type=e,t?(n.bubbles=!!t.bubbles,n.cancelable=!!t.cancelable,n.detail=t.detail):(n.bubbles=!1,n.cancelable=!1,n.detail=void 0),n}:tT;let tI=[];function tN(e,t,n){let a=tL(e,t,n);tI.length?tI.forEach(e=>e(a)):setTimeout(()=>{throw a})}function tj(e){if("function"!=typeof e)throw Error(tF(28,!1));tI.push(e)}function tR(e){if("function"!=typeof e)throw Error(tF(29,!1));let t=!1;return tI=tI.filter(n=>{let a=n===e;return t=t||a,!a}),t}function tF(e,t,...n){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${n.length?`&arg=${n.join("&arg=")}`:""}`}function tL(e,t,n){let a,r=`${t4(t)} '${t2(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=r+e.message}catch(e){}a=e}else{console.warn(tF(30,!1,t.status,t2(t)));try{a=Error(r+JSON.stringify(e))}catch(t){a=e}}return a.appOrParcelName=t2(t),t.status=n,a}let tW="NOT_LOADED",tG="LOADING_SOURCE_CODE",tV="NOT_BOOTSTRAPPED",tU="BOOTSTRAPPING",tq="NOT_MOUNTED",tH="MOUNTING",tK="MOUNTED",tY="UPDATING",tJ="UNMOUNTING",tZ="UNLOADING",tX="LOAD_ERROR",tQ="SKIP_BECAUSE_BROKEN";function t0(e){return e.status===tK}function t1(e){try{return e.activeWhen(window.location)}catch(t){return tN(t,e,tQ),!1}}function t2(e){return e.name}function t3(e){return!!e.unmountThisParcel}function t4(e){return t3(e)?"parcel":"application"}function t5(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function t6(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}function t8(e){return e&&("function"==typeof e||Array.isArray(e)&&!t6(e,e=>"function"!=typeof e))}function t7(e,t){let n=e[t]||[];0===(n=Array.isArray(n)?n:[n]).length&&(n=[()=>Promise.resolve()]);let a=t4(e),r=t2(e);return function(e){return n.reduce((n,o,i)=>n.then(()=>{let n=o(e);return t9(n)?n:Promise.reject(tF(15,!1,a,r,t,i))}),Promise.resolve())}}function t9(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let ne=[];function nt(e,t){return Promise.resolve().then(()=>e.status!==tV?e:(e.status=tU,e.bootstrap?ny(e,"bootstrap").then(n).catch(n=>{if(t)throw tL(n,e,tQ);return tN(n,e,tQ),e}):Promise.resolve().then(n)));function n(){return e.status=tq,e}}function nn(e,t){return Promise.resolve().then(()=>{if(e.status!==tK)return e;return e.status=tJ,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(n,a=>n().then(()=>{let n=Error(a.message);if(t)throw tL(n,e,tQ);tN(n,e,tQ)})).then(()=>e);function n(){return ny(e,"unmount").then(()=>{e.status=tq},n=>{if(t)throw tL(n,e,tQ);tN(n,e,tQ)})}})}let na=!1,nr=!1;function no(e,t){return Promise.resolve().then(()=>e.status!==tq?e:(na||(window.dispatchEvent(new tB("single-spa:before-first-mount")),na=!0),e.status=tH,ny(e,"mount").then(()=>(e.status=tK,nr||(window.dispatchEvent(new tB("single-spa:first-mount")),nr=!0),e)).catch(n=>{return e.status=tK,nn(e,!0).then(a,a);function a(){if(t)throw tL(n,e,tQ);return tN(n,e,tQ),e}})))}let ni=0,ns={parcels:{}};function nl(){return nc.apply(ns,arguments)}function nc(e,t){let n,a,r,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(tF(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(tF(3,!1,typeof e.name));let i=ni++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(tF(4,!1,s,typeof t));if(!t.domElement)throw Error(tF(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:i,parcels:{},status:l?tG:tV,customProps:t,parentName:t2(o),unmountThisParcel:()=>f.then(()=>{if(u.status!==tK)throw Error(tF(6,!1,s,u.status));return nn(u,!0)}).then(e=>(u.parentName&&delete o.parcels[u.id],e)).then(e=>(a(e),e)).catch(e=>{throw u.status=tQ,r(e),e})};o.parcels[i]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(tF(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(tF(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!t8(e.bootstrap))throw Error(tF(9,!1,s));if(!t8(e.mount))throw Error(tF(10,!1,s));if(!t8(e.unmount))throw Error(tF(11,!1,s));if(e.update&&!t8(e.update))throw Error(tF(12,!1,s));let t=t7(e,"bootstrap"),a=t7(e,"mount"),r=t7(e,"unmount");u.status=tV,u.name=s,u.bootstrap=t,u.mount=a,u.unmount=r,u.timeouts=nb(e.timeouts),e.update&&(u.update=t7(e,"update"),n.update=function(e){return u.customProps=e,nu(Promise.resolve().then(()=>{if(u.status!==tK)throw Error(tF(32,!1,t2(u)));return u.status=tY,ny(u,"update").then(()=>(u.status=tK,u)).catch(e=>{throw tL(e,u,tQ)})}))})})).then(()=>nt(u,!0)),f=d.then(()=>no(u,!0)),h=new Promise((e,t)=>{a=e,r=t});return n={mount:()=>nu(Promise.resolve().then(()=>{if(u.status!==tq)throw Error(tF(13,!1,s,u.status));return o.parcels[i]=u,no(u)})),unmount:()=>nu(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:nu(p),bootstrapPromise:nu(d),mountPromise:nu(f),unmountPromise:nu(h)}}function nu(e){return e.then(()=>null)}function np(e){let t=t2(e),n="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof n||null===n||Array.isArray(n))&&(n={},console.warn(tF(40,!1),t,n));let a=t5({},n,{name:t,mountParcel:nc.bind(e),singleSpa:tP});return t3(e)&&(a.unmountSelf=e.unmountThisParcel),a}let nd={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 nf(e,t,n){if("number"!=typeof e||e<=0)throw Error(tF(16,!1));nd.bootstrap={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function nh(e,t,n){if("number"!=typeof e||e<=0)throw Error(tF(17,!1));nd.mount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function nm(e,t,n){if("number"!=typeof e||e<=0)throw Error(tF(18,!1));nd.unmount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ng(e,t,n){if("number"!=typeof e||e<=0)throw Error(tF(19,!1));nd.unload={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ny(e,t){let n=e.timeouts[t],a=n.warningMillis,r=t4(e);return new Promise((o,i)=>{let s=!1,l=!1;e[t](np(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>u(1),a),setTimeout(()=>u(!0),n.millis);let c=tF(31,!1,t,r,t2(e),n.millis);function u(e){s||(!0===e?(l=!0,n.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*a+a<n.millis&&setTimeout(()=>u(e+1),a)))}})}function nb(e){let t={};for(let n in nd)t[n]=t5({},nd[n],e&&e[n]||{});return t}function n_(e){return Promise.resolve().then(()=>{let t,n;return e.loadPromise?e.loadPromise:e.status!==tW&&e.status!==tX?e:(e.status=tG,e.loadPromise=Promise.resolve().then(()=>{let a=e.loadApp(np(e));if(!t9(a))throw n=!0,Error(tF(33,!1,t2(e)));return a.then(n=>{let a;e.loadErrorTime=null,"object"!=typeof(t=n)&&(a=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!t8(t.bootstrap)&&(a=35),t8(t.mount)||(a=36),t8(t.unmount)||(a=37);let r=t4(t);if(a){let n;try{n=JSON.stringify(t)}catch(e){}return console.error(tF(a,!1,r,t2(e),n),t),tN(void 0,e,tQ),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=t5({},e.devtools.overlays,t.devtools.overlays)),e.status=tV,e.bootstrap=t7(t,"bootstrap"),e.mount=t7(t,"mount"),e.unmount=t7(t,"unmount"),e.unload=t7(t,"unload"),e.timeouts=nb(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let a;return delete e.loadPromise,n?a=tQ:(a=tX,e.loadErrorTime=(new Date).getTime()),tN(t,e,a),e}))})}let nv="u">typeof window,n$={hashchange:[],popstate:[]},nA=["hashchange","popstate"];function nw(e){let t;if("string"==typeof e)t=e;else if(this&&this.href)t=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(tF(14,!1));t=e.currentTarget.href,e.preventDefault()}let n=nM(window.location.href),a=nM(t);0===t.indexOf("#")?window.location.hash=a.hash:n.host!==a.host&&a.host?window.location.href=t:a.pathname===n.pathname&&a.search===n.search?window.location.hash=a.hash:window.history.pushState(null,null,t)}function nk(e){if(e){let t=e[0].type;nA.indexOf(t)>=0&&n$[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function nx(){n0([],arguments)}function nC(e,t){return function(){let n=window.location.href,a=e.apply(this,arguments),o=window.location.href;return r&&n===o||window.dispatchEvent(function(e,t){let n;try{n=new PopStateEvent("popstate",{state:e})}catch(t){(n=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return n.singleSpa=!0,n.singleSpaTrigger=t,n}(window.history.state,t)),a}}let nE=null,nS=!1;function nD(e){if(nS)throw Error(tF(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,nS=!0,nE=window.history.replaceState,window.addEventListener("hashchange",nx),window.addEventListener("popstate",nx);let t=window.addEventListener,n=window.removeEventListener;window.addEventListener=function(e,n){if(!("function"==typeof n&&nA.indexOf(e)>=0)||t6(n$[e],e=>e===n))return t.apply(this,arguments);n$[e].push(n)},window.removeEventListener=function(e,t){return"function"==typeof t&&nA.indexOf(e)>=0&&(n$[e]=n$[e].filter(e=>e!==t)),n.apply(this,arguments)},window.history.pushState=nC(window.history.pushState,"pushState"),window.history.replaceState=nC(nE,"replaceState")}function nM(e){let t=document.createElement("a");return t.href=e,t}nv&&(window.singleSpaNavigate?console.warn(tF(41,!1)):window.singleSpaNavigate=nw);let nz=!1;function nO(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!nz){let t=e.fn.on,n=e.fn.off;e.fn.on=function(e,n){return nP.call(this,t,window.addEventListener,e,n,arguments)},e.fn.off=function(e,t){return nP.call(this,n,window.removeEventListener,e,t,arguments)},nz=!0}}function nP(e,t,n,a,r){return"string"!=typeof n?e.apply(this,r):(n.split(/\s+/).forEach(e=>{nA.indexOf(e)>=0&&(t(e,a),n=n.replace(e,""))}),""===n.trim()?this:e.apply(this,r))}let nT={};function nB(e){return Promise.resolve().then(()=>{let t=nT[t2(e)];if(!t)return e;if(e.status===tW)return nI(e,t),e;if(e.status===tZ)return t.promise.then(()=>e);if(e.status!==tq&&e.status!==tX)return e;let n=e.status===tX?Promise.resolve():ny(e,"unload");return e.status=tZ,n.then(()=>(nI(e,t),e)).catch(n=>(delete nT[t2(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,tN(n,e,tQ),t.reject(n),e))})}function nI(e,t){delete nT[t2(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=tW,t.resolve()}function nN(e,t,n,a){nT[t2(e)]={app:e,resolve:n,reject:a},Object.defineProperty(nT[t2(e)],"promise",{get:t})}let nj=[];function nR(){return nj.filter(t0).map(t2)}function nF(){return nj.map(t2)}function nL(e){let t=t6(nj,t=>t2(t)===e);return t?t.status:null}let nW=!1;function nG(e,t,n,a){var r,o;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(tF(39,!1));let t=["name","app","activeWhen","customProps"],n=Object.keys(e).reduce((e,n)=>t.indexOf(n)>=0?e:e.concat(n),[]);if(0!==n.length)throw Error(tF(38,!1,t.join(", "),n.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(tF(20,!1));let a=e=>"string"==typeof e||"function"==typeof e;if(!(a(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(a)))throw Error(tF(24,!1));if(!nK(e.customProps))throw Error(tF(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,t,n,a){if("string"!=typeof e||0===e.length)throw Error(tF(20,!1));if(!t)throw Error(tF(23,!1));if("function"!=typeof n)throw Error(tF(24,!1));if(!nK(a))throw Error(tF(22,!1))}(e,t,n,a),i.name=e,i.loadApp=t,i.activeWhen=n,i.customProps=a),i.loadApp="function"!=typeof(r=i.loadApp)?()=>Promise.resolve(r):r,i.customProps=i.customProps||{},s=(s=Array.isArray(o=i.activeWhen)?o:[o]).map(e=>"function"==typeof e?e:nY(e)),i.activeWhen=e=>s.some(t=>t(e)),i);if(n2||nW||(nW=!0,setTimeout(()=>{n2||console.warn(tF(1,!1))},5e3)),-1!==nF().indexOf(l.name))throw Error(tF(21,!1,l.name));nj.push(t5({loadErrorTime:null,status:tW,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),nv&&(nO(),n0())}function nV(e=window.location){return nj.filter(t=>t.activeWhen(e)).map(t2)}function nU(e){if(0===nj.filter(t=>t2(t)===e).length)throw Error(tF(25,!1,e));return(nv?nq(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=nj.map(t2).indexOf(e);nj.splice(t,1)})}function nq(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(tF(26,!1));let n=t6(nj,t=>t2(t)===e);if(!n)throw Error(tF(27,!1,e));let a=nT[t2(n)];if(t&&t.waitForUnmount){if(a)return a.promise;{let e=new Promise((t,a)=>{nN(n,()=>e,t,a)});return e}}{let e;return a?(e=a.promise,nH(n,a.resolve,a.reject)):e=new Promise((t,a)=>{nN(n,()=>e,t,a),nH(n,t,a)}),e}}function nH(e,t,n){Promise.resolve().then(()=>{if(t6(nV(),t=>t===t2(e)))return nQ()}).then(()=>nn(e).then(nB).then(()=>{t(),setTimeout(()=>{n0()})})).catch(n)}function nK(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function nY(e,t){let n=function(e,t){let n=0,a=!1,r="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let n=e[t],r=a&&"/"===n;(!a&&":"===n||r)&&o(t)}return o(e.length),RegExp(r,"i");function o(o){let i=e.slice(n,o).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(r+=a?"[^/]+/?":i,o===e.length)if(a)t&&(r+="$");else{let e=t?"":".*";r="/"===r.charAt(r.length-1)?`${r}${e}$`:`${r}(/${e})?(#.*)?$`}a=!a,n=o}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let a=e.href.replace(t,"").replace(e.search,"").split("?")[0];return n.test(a)}}let nJ=!1,nZ=[],nX=nv&&window.location.href;function nQ(){return n0()}function n0(e=[],t,n=!1){let a,r,o,i,s;if(nJ)return new Promise((e,n)=>{nZ.push({resolve:e,reject:n,eventArguments:t})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(a=[],r=[],o=[],i=[],s=(new Date).getTime(),nj.forEach(e=>{let t=e.status!==tQ&&t1(e);switch(e.status){case tX:t&&s-e.loadErrorTime>=200&&o.push(e);break;case tW:case tG:t&&o.push(e);break;case tV:case tq:!t&&nT[t2(e)]?a.push(e):t&&i.push(e);break;case tK:t||r.push(e)}}),{appsToUnload:a,appsToUnmount:r,appsToLoad:o,appsToMount:i}),d,f=[],h=nX,m=nX=window.location.href;return n2?(nJ=!0,d=l.concat(u,c,p),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(n=>{if(n.some(e=>e))return nE.call(window.history,history.state,"",h.substring(location.origin.length)),nX=location.href,nJ=!1,n0(e,t,!0);let a=l.map(nB),r=Promise.all(c.map(nn).map(e=>e.then(nB)).concat(a));r.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let o=u.map(e=>n_(e).then(e=>n1(e,r))),i=p.filter(e=>0>u.indexOf(e)).map(e=>n1(e,r));return r.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(o.concat(i)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(y).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(n_)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function g(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(t.catch(e=>(console.warn(Error(tF(42,!1))),console.warn(e),!1)))}function y(){let t=nR();e.forEach(e=>e.resolve(t));try{$(0===d.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(nJ=!1,nZ.length>0){let e=nZ;nZ=[],n0(e)}return t}function b(){n||(e.forEach(e=>{nk(e.eventArguments)}),nk(t))}function v(e=!1,n){let a={},r={[tK]:[],[tq]:[],[tW]:[],[tQ]:[]};e?(u.concat(p).forEach((e,t)=>{i(e,tK)}),l.forEach(e=>{i(e,tW)}),c.forEach(e=>{i(e,tq)})):d.forEach(e=>{i(e)});let o={detail:{newAppStatuses:a,appsByNewStatus:r,totalAppChanges:d.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return n&&t5(o.detail,n),o;function i(e,t){let n=t2(e);t=t||nL(n),a[n]=t,(r[t]=r[t]||[]).push(n)}}function $(e,t){n||window.dispatchEvent(new tB(`single-spa:${e}`,t))}}function n1(e,t){return t1(e)?nt(e).then(e=>t.then(()=>t1(e)?no(e):e)):t.then(()=>e)}let n2=!1;function n3(e){n2=!0,nv&&(nD(e),n0())}function n4(e,t){let n=window.getOpenmrsSpaBase().replace(/\/$/,"");return n5(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t}).replace(/^\/\//,"/")}function n5(e,t){return Object.keys(t).reduce((e,n)=>e.split("${"+n+"}").join(t[n]),e)}function n6({to:e,templateParams:t}){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),a=n4(e,t).replace(window.location.origin,"");a.startsWith(n)?nw(a):window.location.assign(a)}nv&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...nj]},reroute:n0,NOT_LOADED:tW,toLoadPromise:n_,toBootstrapPromise:nt,unregisterApplication:nU,getProfilerData:function(){return ne}});let n8="openmrs:history";function n7(e){let t=JSON.parse(sessionStorage.getItem(n8)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(n8,JSON.stringify(t))}function n9(){0===JSON.parse(sessionStorage.getItem(n8)??"[]").length&&document.referrer&&n7(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=ae();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(n8,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?at({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&n7(window.location.href)})}function ae(){return JSON.parse(sessionStorage.getItem(n8)??"[]")}function at({toUrl:e}){let t=ae(),n=t.lastIndexOf(e);if(-1!=n){let e=t.slice(0,n+1);n6({to:t[n]}),sessionStorage.setItem(n8,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function an(){sessionStorage.removeItem(n8)}let aa="${openmrsSpaBase}/login",ar={redirectAuthFailure:{enabled:{_type:e_.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:e_.String,_default:aa,_validators:[tk.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:e_.Array,_default:[401],_elements:{_type:e_.Number,_validators:[tk.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:e_.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:e_.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function ao(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let ai="/ws/rest/v1",as="/ws/fhir2/R4",al=`${ai}/session`;function ac(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function au(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let n=ac(e);if(t.headers||(t.headers={}),(0,et.isPlainObject)(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept,e.startsWith(ai)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(as)){let e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}let a=Error();return window.fetch(n,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:r}=await e8("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(r&&t&&(n===ac(al)||204===e.status)&&n6({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return n===ac(al)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(an(),n6({to:t.url||e.headers.get("location")||aa}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let r=t;try{r=JSON.parse(t)}catch(e){}throw new ad(n,e,r,a)},t=>{throw new ad(n,e,null,a)})})}function ap(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let n=new AbortController;return t.signal=n.signal,new ey(a=>{let r=!1;return au(e,t).then(e=>{r=!0,a.next(e),a.complete()},e=>{r=!0,a.error(e)}),()=>{r||n.abort()}})}class ad extends Error{constructor(e,t,n,a){super(),ao(this,"response",void 0),ao(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,a.message=this.message,this.responseBody=n,this.response=t,this.stack=`Stacktrace for outgoing request:
13
13
  ${a.stack}
14
14
  Stacktrace for incoming response:
15
- ${this.stack}`}}let af=U("session",{loaded:!1,session:null}),ah=0;function am(e={includeAuthStatus:!0}){return(ah<Date.now()-6e4||!af.getState().loaded)&&ab(),new ey(t=>{let n=n=>{n.loaded&&(e.includeAuthStatus?t.next(n.session):t.next(n.session?.user))};return n(af.getState()),af.subscribe(n)})}function ag(){return(ah<Date.now()-6e4||!af.getState().loaded)&&ab(),af}function ay(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function ab(e,t){ah=Date.now();let n={};return e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),ax(au(al,{headers:n}))}function a_(){af.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function av(e,t){var n,a;if(void 0===t)return!e;if(!e)return!0;return n=e,a=t,("string"==typeof n?!(0,et.isUndefined)(a.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!(0,et.isUndefined)(a.privileges.find(t=>e===t.display))):((0,et.isUndefined)(n)||console.error(`Could not understand privileges "${n}"`),!0))||!(0,et.isUndefined)(t.roles.find(e=>"System Developer"===e.display))}function a$(){let e,t;return new Promise(n=>{let a=a=>{a.loaded&&a.session.user&&(e=a.session.user,n(a.session.user),t&&t())};a(af.getState()),e||(t=af.subscribe(a))})}function aA(){return new Promise((e,t)=>{am().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function aw(e,t){return ax(au(al,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function ak(e,t,n){return n||(n=new AbortController),await au(`${ai}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),ab()}function ax(e){return new Promise((t,n)=>{e.then(e=>{let a;"object"==typeof e?.data?(a={loaded:!0,session:e.data},af.setState(a),t(a)):(a={loaded:!1,session:null},af.setState(a),n(a))}).catch(e=>{B(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};af.setState(t),n(t)})})}function aC(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}af.subscribe(e=>{e.loaded&&e.session&&ay(e.session)});let aE={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function aS(){e0("@openmrs/esm-api",ar),ab()}let aD={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var aM=n(2284),az=n(3029),aO=n(2901);function aP(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var aT=n(3662);function aB(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&(0,aT.A)(e,t)}function aI(e,t){if(t&&("object"==(0,aM.A)(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return aP(e)}function aN(e){return(aN=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var aj=n(4467),aR=n(6369),aF=n(3612),aL=n(6562);function aW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function aG(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?aW(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var aV={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},aU=new(function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,az.A)(this,e),this.init(t,n)}return(0,aO.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||aV,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,a){return a&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,aG(aG({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),aq=function(){function e(){(0,az.A)(this,e),this.observers={}}return(0,aO.A)(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach(function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)}),this}},{key:"off",value:function(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e]=this.observers[e].filter(function(e){return e!==t})}}},{key:"emit",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];this.observers[e]&&[].concat(this.observers[e]).forEach(function(e){e.apply(void 0,n)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(t){t.apply(t,[e].concat(n))})}}]),e}();function aH(){var e,t,n=new Promise(function(n,a){e=n,t=a});return n.resolve=e,n.reject=t,n}function aK(e){return null==e?"":""+e}function aY(e,t,n){function a(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function r(){return!e||"string"==typeof e}for(var o="string"!=typeof t?[].concat(t):t.split(".");o.length>1;){if(r())return{};var i=a(o.shift());!e[i]&&n&&(e[i]=new n),e=Object.prototype.hasOwnProperty.call(e,i)?e[i]:{}}return r()?{}:{obj:e,k:a(o.shift())}}function aJ(e,t,n){var a=aY(e,t,Object);a.obj[a.k]=n}function aZ(e,t){var n=aY(e,t),a=n.obj,r=n.k;if(a)return a[r]}function aX(e,t,n){var a=aZ(e,n);return void 0!==a?a:aZ(t,n)}function aQ(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var a0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function a1(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return a0[e]}):e}var a2="u">typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,a3=[" ",",","?","!",";"];function a4(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function a5(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a4(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a4(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var a6=function(e){aB(a,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aN(a);return e=t?Reflect.construct(n,arguments,aN(this).constructor):n.apply(this,arguments),aI(this,e)});function a(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return(0,az.A)(this,a),t=n.call(this),a2&&aq.call(aP(t)),t.data=e||{},t.options=r,void 0===t.options.keySeparator&&(t.options.keySeparator="."),void 0===t.options.ignoreJSONStructure&&(t.options.ignoreJSONStructure=!0),t}return(0,aO.A)(a,[{key:"addNamespaces",value:function(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,o=void 0!==a.ignoreJSONStructure?a.ignoreJSONStructure:this.options.ignoreJSONStructure,i=[e,t];n&&"string"!=typeof n&&(i=i.concat(n)),n&&"string"==typeof n&&(i=i.concat(r?n.split(r):n)),e.indexOf(".")>-1&&(i=e.split("."));var s=aZ(this.data,i);return s||!o||"string"!=typeof n?s:function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(t){if(t[n])return t[n];for(var r=n.split(a),o=t,i=0;i<r.length;++i){if(!o||"string"==typeof o[r[i]]&&i+1<r.length)return;if(void 0===o[r[i]]){for(var s=2,l=r.slice(i,i+s).join(a),c=o[l];void 0===c&&r.length>i+s;)s++,c=o[l=r.slice(i,i+s).join(a)];if(void 0===c)return;if(null===c)return null;if(n.endsWith(l)){if("string"==typeof c)return c;if(l&&"string"==typeof c[l])return c[l]}var u=r.slice(i+s).join(a);if(u)return e(c,u,a);return}o=o[r[i]]}return o}}(this.data&&this.data[e]&&this.data[e][t],n,r)}},{key:"addResource",value:function(e,t,n,a){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},o=this.options.keySeparator;void 0===o&&(o=".");var i=[e,t];n&&(i=i.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(i=e.split("."),a=t,t=i[1]),this.addNamespaces(t),aJ(this.data,i,a),r.silent||this.emit("added",e,t,n,a)}},{key:"addResources",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var r in n)("string"==typeof n[r]||"[object Array]"===Object.prototype.toString.apply(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});a.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,a,r){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},i=[e,t];e.indexOf(".")>-1&&(i=e.split("."),a=n,n=t,t=i[1]),this.addNamespaces(t);var s=aZ(this.data,i)||{};a?function e(t,n,a){for(var r in n)"__proto__"!==r&&"constructor"!==r&&(r in t?"string"==typeof t[r]||t[r]instanceof String||"string"==typeof n[r]||n[r]instanceof String?a&&(t[r]=n[r]):e(t[r],n[r],a):t[r]=n[r]);return t}(s,n,r):s=a5(a5({},s),n),aJ(this.data,i,s),o.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return(t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI)?a5(a5({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(function(e){return t[e]&&Object.keys(t[e]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),a}(aq),a8={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,a,r){var o=this;return e.forEach(function(e){o.processors[e]&&(t=o.processors[e].process(t,n,a,r))}),t}};function a7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function a9(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a7(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var re={},rt=function(e){aB(a,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aN(a);return e=t?Reflect.construct(n,arguments,aN(this).constructor):n.apply(this,arguments),aI(this,e)});function a(e){var t,r,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,az.A)(this,a),o=n.call(this),a2&&aq.call(aP(o)),t=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r=aP(o),t.forEach(function(t){e[t]&&(r[t]=e[t])}),o.options=i,void 0===o.options.keySeparator&&(o.options.keySeparator="."),o.logger=aU.create("translator"),o}return(0,aO.A)(a,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,r=t.ns||this.options.defaultNS||[],o=n&&e.indexOf(n)>-1,i=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!function(e,t,n){t=t||"",n=n||"";var a=a3.filter(function(e){return 0>t.indexOf(e)&&0>n.indexOf(e)});if(0===a.length)return!0;var r=new RegExp("(".concat(a.map(function(e){return"?"===e?"\\?":e}).join("|"),")")),o=!r.test(e);if(!o){var i=e.indexOf(n);i>0&&!r.test(e.substring(0,i))&&(o=!0)}return o}(e,n,a);if(o&&!i){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:r};var l=e.split(n);(n!==a||n===a&&this.options.ns.indexOf(l[0])>-1)&&(r=l.shift()),e=l.join(a)}return"string"==typeof r&&(r=[r]),{key:e,namespaces:r}}},{key:"translate",value:function(e,t,n){var r=this;if("object"!==(0,aM.A)(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var o=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(e[e.length-1],t),l=s.key,c=s.namespaces,u=c[c.length-1],p=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p&&"cimode"===p.toLowerCase()){if(d){var f=t.nsSeparator||this.options.nsSeparator;return o?(h.res="".concat(u).concat(f).concat(l),h):"".concat(u).concat(f).concat(l)}return o?(h.res=l,h):l}var h=this.resolve(e,t),m=h&&h.res,g=h&&h.usedKey||l,y=h&&h.exactUsedKey||l,b=Object.prototype.toString.apply(m),v=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,$=!this.i18nFormat||this.i18nFormat.handleAsObject,A="string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m;if($&&m&&A&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(b)&&("string"!=typeof v||"[object Array]"!==b)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var w=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,m,a9(a9({},t),{},{ns:c})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return o?(h.res=w,h):w}if(i){var k="[object Array]"===b,x=k?[]:{},C=k?y:g;for(var E in m)if(Object.prototype.hasOwnProperty.call(m,E)){var S="".concat(C).concat(i).concat(E);x[E]=this.translate(S,a9(a9({},t),{joinArrays:!1,ns:c})),x[E]===S&&(x[E]=m[E])}m=x}}else if($&&"string"==typeof v&&"[object Array]"===b)(m=m.join(v))&&(m=this.extendTranslation(m,e,t,n));else{var D=!1,M=!1,z=void 0!==t.count&&"string"!=typeof t.count,O=a.hasDefaultValue(t),P=z?this.pluralResolver.getSuffix(p,t.count,t):"",T=t["defaultValue".concat(P)]||t.defaultValue;!this.isValidLookup(m)&&O&&(D=!0,m=T),this.isValidLookup(m)||(M=!0,m=l);var B=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&M?void 0:m,I=O&&T!==m&&this.options.updateMissing;if(M||D||I){if(this.logger.log(I?"updateKey":"missingKey",p,u,l,I?T:m),i){var N=this.resolve(l,a9(a9({},t),{},{keySeparator:!1}));N&&N.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var j=[],R=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&R&&R[0])for(var F=0;F<R.length;F++)j.push(R[F]);else"all"===this.options.saveMissingTo?j=this.languageUtils.toResolveHierarchy(t.lng||this.language):j.push(t.lng||this.language);var L=function(e,n,a){var o=O&&a!==m?a:B;r.options.missingKeyHandler?r.options.missingKeyHandler(e,u,n,o,I,t):r.backendConnector&&r.backendConnector.saveMissing&&r.backendConnector.saveMissing(e,u,n,o,I,t),r.emit("missingKey",e,u,n,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&z?j.forEach(function(e){r.pluralResolver.getSuffixes(e,t).forEach(function(n){L([e],l+n,t["defaultValue".concat(n)]||T)})}):L(j,l,T))}m=this.extendTranslation(m,e,t,h,n),M&&m===l&&this.options.appendNamespaceToMissingKey&&(m="".concat(u,":").concat(l)),(M||D)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(u,":").concat(l):l,D?m:void 0):this.options.parseMissingKeyHandler(m))}return o?(h.res=m,h):m}},{key:"extendTranslation",value:function(e,t,n,a,r){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,a9(a9({},this.options.interpolation.defaultVariables),n),a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(a9(a9({},n),{interpolation:a9(a9({},this.options.interpolation),n.interpolation)}));var i,s="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(s){var l=e.match(this.interpolator.nestingRegexp);i=l&&l.length}var c=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(c=a9(a9({},this.options.interpolation.defaultVariables),c)),e=this.interpolator.interpolate(e,c,n.lng||this.language,n),s){var u=e.match(this.interpolator.nestingRegexp);i<(u&&u.length)&&(n.nest=!1)}!1!==n.nest&&(e=this.interpolator.nest(e,function(){for(var e=arguments.length,a=Array(e),i=0;i<e;i++)a[i]=arguments[i];return r&&r[0]===a[0]&&!n.context?(o.logger.warn("It seems you are nesting recursively key: ".concat(a[0]," in key: ").concat(t[0])),null):o.translate.apply(o,a.concat([t]))},n)),n.interpolation&&this.interpolator.reset()}var p=n.postProcess||this.options.postProcess,d="string"==typeof p?[p]:p;return null!=e&&d&&d.length&&!1!==n.applyPostProcessor&&(e=a8.handle(d,e,t,this.options&&this.options.postProcessPassResolved?a9({i18nResolved:a},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,a,r,o,i=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!i.isValidLookup(t)){var l=i.extractFromKey(e,s),c=l.key;n=c;var u=l.namespaces;i.options.fallbackNS&&(u=u.concat(i.options.fallbackNS));var p=void 0!==s.count&&"string"!=typeof s.count,d=p&&!s.ordinal&&0===s.count&&i.pluralResolver.shouldUseIntlApi(),f=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,h=s.lngs?s.lngs:i.languageUtils.toResolveHierarchy(s.lng||i.language,s.fallbackLng);u.forEach(function(e){i.isValidLookup(t)||(o=e,!re["".concat(h[0],"-").concat(e)]&&i.utils&&i.utils.hasLoadedNamespace&&!i.utils.hasLoadedNamespace(o)&&(re["".concat(h[0],"-").concat(e)]=!0,i.logger.warn('key "'.concat(n,'" for languages "').concat(h.join(", "),'" won\'t get resolved as namespace "').concat(o,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),h.forEach(function(n){if(!i.isValidLookup(t)){r=n;var o,l=[c];if(i.i18nFormat&&i.i18nFormat.addLookupKeys)i.i18nFormat.addLookupKeys(l,c,n,e,s);else{p&&(u=i.pluralResolver.getSuffix(n,s.count,s));var u,h="".concat(i.options.pluralSeparator,"zero");if(p&&(l.push(c+u),d&&l.push(c+h)),f){var m="".concat(c).concat(i.options.contextSeparator).concat(s.context);l.push(m),p&&(l.push(m+u),d&&l.push(m+h))}}for(;o=l.pop();)i.isValidLookup(t)||(a=o,t=i.getResource(n,e,o,s))}}))})}}),{res:t,usedKey:n,exactUsedKey:a,usedLng:r,usedNS:o}}},{key:"isValidLookup",value:function(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,a):this.resourceStore.getResource(e,t,n,a)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&void 0!==e[n])return!0;return!1}}]),a}(aq);function rn(e){return e.charAt(0).toUpperCase()+e.slice(1)}var ra=function(){function e(t){(0,az.A)(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=aU.create("languageUtils")}return(0,aO.A)(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return null;var t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map(function(e){return e.toLowerCase()}):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=rn(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=rn(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=rn(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach(function(e){if(!t){var a=n.formatLanguageCode(e);(!n.options.supportedLngs||n.isSupportedCode(a))&&(t=a)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var a=n.getLanguagePartFromCode(e);if(n.isSupportedCode(a))return t=a;t=n.options.supportedLngs.find(function(e){if(0===e.indexOf(a))return e})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,a=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],o=function(e){e&&(n.isSupportedCode(e)?r.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):"string"==typeof e&&o(this.formatLanguageCode(e)),a.forEach(function(e){0>r.indexOf(e)&&o(n.formatLanguageCode(e))}),r}}]),e}(),rr=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],ro={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(+(1!=e&&(e%10!=1||e%100==11)))},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:3*(e%100==3||e%100==4))},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},ri=["v1","v2","v3"],rs={zero:0,one:1,two:2,few:3,many:4,other:5},rl=function(){function e(t){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,az.A)(this,e),this.languageUtils=t,this.options=a,this.logger=aU.create("pluralResolver"),(!this.options.compatibilityJSON||"v4"===this.options.compatibilityJSON)&&("u"<typeof Intl||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(n={},rr.forEach(function(e){e.lngs.forEach(function(t){n[t]={numbers:e.nr,plurals:ro[e.fc]}})}),n)}return(0,aO.A)(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map(function(e){return"".concat(t).concat(e)})}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=this.getRule(e,n);return a?this.shouldUseIntlApi()?a.resolvedOptions().pluralCategories.sort(function(e,t){return rs[e]-rs[t]}).map(function(e){return"".concat(t.options.prepend).concat(e)}):a.numbers.map(function(a){return t.getSuffix(e,a,n)}):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this.getRule(e,n);return a?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(a.select(t)):this.getSuffixRetroCompatible(a,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,a=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),r=e.numbers[a];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===r?r="plural":1===r&&(r=""));var o=function(){return n.options.prepend&&r.toString()?n.options.prepend+r.toString():r.toString()};return"v1"===this.options.compatibilityJSON?1===r?"":"number"==typeof r?"_plural_".concat(r.toString()):o():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?o():this.options.prepend&&a.toString()?this.options.prepend+a.toString():a.toString()}},{key:"shouldUseIntlApi",value:function(){return!ri.includes(this.options.compatibilityJSON)}}]),e}();function rc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function ru(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rc(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var rp=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,az.A)(this,e),this.logger=aU.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return(0,aO.A)(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:a1,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?aQ(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?aQ(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?aQ(t.nestingPrefix):t.nestingPrefixEscaped||aQ("$t("),this.nestingSuffix=t.nestingSuffix?aQ(t.nestingSuffix):t.nestingSuffixEscaped||aQ(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,a){var r,o,i,s=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var u=function(e){if(0>e.indexOf(s.formatSeparator)){var r=aX(t,l,e);return s.alwaysFormat?s.format(r,void 0,n,ru(ru(ru({},a),t),{},{interpolationkey:e})):r}var o=e.split(s.formatSeparator),i=o.shift().trim(),c=o.join(s.formatSeparator).trim();return s.format(aX(t,l,i),c,n,ru(ru(ru({},a),t),{},{interpolationkey:i}))};this.resetRegExp();var p=a&&a.missingInterpolationHandler||this.options.missingInterpolationHandler,d=a&&a.interpolation&&void 0!==a.interpolation.skipOnVariables?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return c(e)}},{regex:this.regexp,safeValue:function(e){return s.escapeValue?c(s.escape(e)):c(e)}}].forEach(function(t){for(i=0;r=t.regex.exec(e);){var n=r[1].trim();if(void 0===(o=u(n)))if("function"==typeof p){var l=p(e,r,a);o="string"==typeof l?l:""}else if(a&&a.hasOwnProperty(n))o="";else if(d){o=r[0];continue}else s.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),o="";else"string"==typeof o||s.useRawValueToEscape||(o=aK(o));var c=t.safeValue(o);if(e=e.replace(r[0],c),d?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=r[0].length):t.regex.lastIndex=0,++i>=s.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var n,a,r=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=ru({},o);function s(e,t){var n=this.nestingOptionsSeparator;if(0>e.indexOf(n))return e;var a=e.split(new RegExp("".concat(n,"[ ]*{"))),r="{".concat(a[1]);e=a[0];var o=(r=this.interpolate(r,i)).match(/'/g),s=r.match(/"/g);(o&&o.length%2==0&&!s||s.length%2!=0)&&(r=r.replace(/'/g,'"'));try{i=JSON.parse(r),t&&(i=ru(ru({},t),i))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(r)}return delete i.defaultValue,e}for(i.applyPostProcessor=!1,delete i.defaultValue;n=this.nestingRegexp.exec(e);){var l=[],c=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var u=n[1].split(this.formatSeparator).map(function(e){return e.trim()});n[1]=u.shift(),l=u,c=!0}if((a=t(s.call(this,n[1].trim(),i),i))&&n[0]===e&&"string"!=typeof a)return a;"string"!=typeof a&&(a=aK(a)),a||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),a=""),c&&(a=l.reduce(function(e,t){return r.format(e,t,o.lng,ru(ru({},o),{},{interpolationkey:n[1].trim()}))},a.trim())),e=e.replace(n[0],a),this.regexp.lastIndex=0}return e}}]),e}();function rd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function rf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rd(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rd(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rh(e){var t={};return function(n,a,r){var o=a+JSON.stringify(r),i=t[o];return i||(i=e(a,r),t[o]=i),i(n)}}var rm=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,az.A)(this,e),this.logger=aU.create("formatter"),this.options=t,this.formats={number:rh(function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}}),currency:rh(function(e,t){var n=new Intl.NumberFormat(e,rf(rf({},t),{},{style:"currency"}));return function(e){return n.format(e)}}),datetime:rh(function(e,t){var n=new Intl.DateTimeFormat(e,rf({},t));return function(e){return n.format(e)}}),relativetime:rh(function(e,t){var n=new Intl.RelativeTimeFormat(e,rf({},t));return function(e){return n.format(e,t.range||"day")}}),list:rh(function(e,t){var n=new Intl.ListFormat(e,rf({},t));return function(e){return n.format(e)}})},this.init(t)}return(0,aO.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},n=t.interpolation;this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=rh(t)}},{key:"format",value:function(e,t,n,a){var r=this;return t.split(this.formatSeparator).reduce(function(e,t){var o=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var a=e.split("(");t=a[0].toLowerCase().trim();var r=a[1].substring(0,a[1].length-1);"currency"===t&&0>r.indexOf(":")?n.currency||(n.currency=r.trim()):"relativetime"===t&&0>r.indexOf(":")?n.range||(n.range=r.trim()):r.split(";").forEach(function(e){if(e){var t,a=(t=e.split(":"),(0,aR.A)(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||(0,aF.A)(t)||(0,aL.A)()),r=a[0],o=a.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[r.trim()]||(n[r.trim()]=o),"false"===o&&(n[r.trim()]=!1),"true"===o&&(n[r.trim()]=!0),isNaN(o)||(n[r.trim()]=parseInt(o,10))}})}return{formatName:t,formatOptions:n}}(t),i=o.formatName,s=o.formatOptions;if(r.formats[i]){var l=e;try{var c=a&&a.formatParams&&a.formatParams[a.interpolationkey]||{},u=c.locale||c.lng||a.locale||a.lng||n;l=r.formats[i](e,u,rf(rf(rf({},s),a),c))}catch(e){r.logger.warn(e)}return l}return r.logger.warn("there was no format function for ".concat(i)),e},e)}}]),e}();function rg(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function ry(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rg(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rg(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var rb=function(e){aB(a,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aN(a);return e=t?Reflect.construct(n,arguments,aN(this).constructor):n.apply(this,arguments),aI(this,e)});function a(e,t,r){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,az.A)(this,a),o=n.call(this),a2&&aq.call(aP(o)),o.backend=e,o.store=t,o.services=r,o.languageUtils=r.languageUtils,o.options=i,o.logger=aU.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=i.maxParallelReads||10,o.readingCalls=0,o.maxRetries=i.maxRetries>=0?i.maxRetries:5,o.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(r,i.backend,i),o}return(0,aO.A)(a,[{key:"queueLoad",value:function(e,t,n,a){var r=this,o={},i={},s={},l={};return e.forEach(function(e){var a=!0;t.forEach(function(t){var s="".concat(e,"|").concat(t);!n.reload&&r.store.hasResourceBundle(e,t)?r.state[s]=2:r.state[s]<0||(1===r.state[s]?void 0===i[s]&&(i[s]=!0):(r.state[s]=1,a=!1,void 0===i[s]&&(i[s]=!0),void 0===o[s]&&(o[s]=!0),void 0===l[t]&&(l[t]=!0)))}),a||(s[e]=!0)}),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,n){var a=e.split("|"),r=a[0],o=a[1];t&&this.emit("failedLoading",r,o,t),n&&this.store.addResourceBundle(r,o,n),this.state[e]=t?-1:2;var i={};this.queue.forEach(function(n){var a,s,l,c;a=n.loaded,(l=(s=aY(a,[r],Object)).obj)[c=s.k]=l[c]||[],l[c].push(o),void 0!==n.pending[e]&&(delete n.pending[e],n.pendingCount--),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach(function(e){i[e]||(i[e]={});var t=n.loaded[e];t.length&&t.forEach(function(t){void 0===i[e][t]&&(i[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,n){var a=this,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,i=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:o,callback:i}):(this.readingCalls++,this.backend[n](e,t,function(s,l){if(a.readingCalls--,a.waitingReads.length>0){var c=a.waitingReads.shift();a.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}s&&l&&r<a.maxRetries?setTimeout(function(){a.read.call(a,e,t,n,r+1,2*o,i)},o):i(s,l)})):i(null,{})}},{key:"prepareLoading",value:function(e,t){var n=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var o=this.queueLoad(e,t,a,r);if(!o.toLoad.length)return o.pending.length||r(),null;o.toLoad.forEach(function(e){n.loadOne(e)})}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",a=e.split("|"),r=a[0],o=a[1];this.read(r,o,"read",void 0,void 0,function(a,i){a&&t.logger.warn("".concat(n,"loading namespace ").concat(o," for language ").concat(r," failed"),a),!a&&i&&t.logger.log("".concat(n,"loaded namespace ").concat(o," for language ").concat(r),i),t.loaded(e,a,i)})}},{key:"saveMissing",value:function(e,t,n,a,r){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null==n||""===n||(this.backend&&this.backend.create&&this.backend.create(e,t,n,a,null,ry(ry({},o),{},{isUpdate:r})),e&&e[0]&&this.store.addResource(e[0],t,n,a))}}]),a}(aq);function r_(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&0>e.supportedLngs.indexOf("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function rv(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function r$(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rv(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rv(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rA(){}var rw=function(e){aB(a,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aN(a);return e=t?Reflect.construct(n,arguments,aN(this).constructor):n.apply(this,arguments),aI(this,e)});function a(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;if((0,az.A)(this,a),t=n.call(this),a2&&aq.call(aP(t)),t.options=r_(r),t.services={},t.logger=aU,t.modules={external:[]},Object.getOwnPropertyNames(Object.getPrototypeOf(e=aP(t))).forEach(function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}),o&&!t.isInitialized&&!r.isClone){if(!t.options.initImmediate)return t.init(r,o),aI(t,aP(t));setTimeout(function(){t.init(r,o)},0)}return t}return(0,aO.A)(a,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:0>t.ns.indexOf("translation")&&(t.defaultNS=t.ns[0]));var a={debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===(0,aM.A)(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===(0,aM.A)(e[2])||"object"===(0,aM.A)(e[3])){var n=e[3]||e[2];Object.keys(n).forEach(function(e){t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:function(e,t,n,a){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}};function r(e){return e?"function"==typeof e?new e:e:null}if(this.options=r$(r$(r$({},a),this.options),r_(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=r$(r$({},a.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){this.modules.logger?aU.init(r(this.modules.logger),this.options):aU.init(null,this.options),this.modules.formatter?o=this.modules.formatter:"u">typeof Intl&&(o=rm);var o,i=new ra(this.options);this.store=new a6(this.options.resources,this.options);var s=this.services;s.logger=aU,s.resourceStore=this.store,s.languageUtils=i,s.pluralResolver=new rl(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),o&&(!this.options.interpolation.format||this.options.interpolation.format===a.interpolation.format)&&(s.formatter=r(o),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new rp(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new rb(r(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",function(t){for(var n=arguments.length,a=Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];e.emit.apply(e,[t].concat(a))}),this.modules.languageDetector&&(s.languageDetector=r(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=r(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new rt(this.services,this.options),this.translator.on("*",function(t){for(var n=arguments.length,a=Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];e.emit.apply(e,[t].concat(a))}),this.modules.external.forEach(function(t){t.init&&t.init(e)})}if(this.format=this.options.interpolation.format,n||(n=rA),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&"dev"!==l[0]&&(this.options.lng=l[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}});var c=aH(),u=function(){var t=function(t,a){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),c.resolve(a),n(t,a)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:rA,a=n,r="string"==typeof e?e:this.language;if("function"==typeof e&&(a=e),!this.options.resources||this.options.partialBundledLanguages){if(r&&"cimode"===r.toLowerCase())return a();var o=[],i=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){0>o.indexOf(e)&&o.push(e)})};r?i(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(e){return i(e)}),this.options.preload&&this.options.preload.forEach(function(e){return i(e)}),this.services.backendConnector.load(o,this.options.ns,function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),a(e)})}else a(null)}},{key:"reloadResources",value:function(e,t,n){var a=aH();return e||(e=this.languages),t||(t=this.options.ns),n||(n=rA),this.services.backendConnector.reload(e,t,function(e){a.resolve(),n(e)}),a}},{key:"use",value:function(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&a8.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var a=aH();this.emit("languageChanging",e);var r=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},o=function(e,o){o?(r(o),n.translator.changeLanguage(o),n.isLanguageChangingTo=void 0,n.emit("languageChanged",o),n.logger.log("languageChanged",o)):n.isLanguageChangingTo=void 0,a.resolve(function(){return n.t.apply(n,arguments)}),t&&t(e,function(){return n.t.apply(n,arguments)})},i=function(t){e||t||!n.services.languageDetector||(t=[]);var a="string"==typeof t?t:n.services.languageUtils.getBestMatchFromCodes(t);a&&(n.language||r(a),n.translator.language||n.translator.changeLanguage(a),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(a)),n.loadResources(a,function(e){o(e,a)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),a}},{key:"getFixedT",value:function(e,t,n){var a=this,r=function e(t,r){if("object"!==(0,aM.A)(r)){for(var o,i=arguments.length,s=Array(i>2?i-2:0),l=2;l<i;l++)s[l-2]=arguments[l];o=a.options.overloadTranslationOptionHandler([t,r].concat(s))}else o=r$({},r);o.lng=o.lng||e.lng,o.lngs=o.lngs||e.lngs,o.ns=o.ns||e.ns,o.keyPrefix=o.keyPrefix||n||e.keyPrefix;var c=a.options.keySeparator||".",u=o.keyPrefix?"".concat(o.keyPrefix).concat(c).concat(t):t;return a.t(u,o)};return"string"==typeof e?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=n,r}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var a=this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===a.toLowerCase())return!0;var i=function(e,n){var a=t.services.backendConnector.state["".concat(e,"|").concat(n)];return -1===a||2===a};if(n.precheck){var s=n.precheck(this,i);if(void 0!==s)return s}return!!(this.hasResourceBundle(a,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(a,e)&&(!r||i(o,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,a=aH();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){0>n.options.ns.indexOf(e)&&n.options.ns.push(e)}),this.loadResources(function(e){a.resolve(),t&&t(e)}),a):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=aH();"string"==typeof e&&(e=[e]);var a=this.options.preload||[],r=e.filter(function(e){return 0>a.indexOf(e)});return r.length?(this.options.preload=a.concat(r),this.loadResources(function(e){n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),e)?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr":"rtl"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:rA,r=r$(r$(r$({},this.options),t),{isClone:!0}),o=new a(r);return(void 0!==t.debug||void 0!==t.prefix)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(function(t){o[t]=e[t]}),o.services=r$({},this.services),o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o.translator=new rt(o.services,o.options),o.translator.on("*",function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];o.emit.apply(o,[e].concat(n))}),o.init(r,n),o.translator.options=o.options,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),a}(aq);(0,aj.A)(rw,"createInstance",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new rw(e,t)});var rk=rw.createInstance();rk.createInstance=rw.createInstance,rk.createInstance,rk.init,rk.loadResources,rk.reloadResources,rk.use,rk.changeLanguage,rk.getFixedT,rk.t,rk.exists,rk.setDefaultNamespace,rk.hasLoadedNamespace,rk.loadNamespaces,rk.loadLanguages;let rx=rk.default||rk;function rC(e,t,n,a){return rx.t(t,{ns:e,defaultValue:n,...a})}function rE(e,t,n){return aD[e]?rC("core",e,t??aD[e],n):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}rx.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let rS="import-map-override:",rD="import-map-overrides-disabled",rM="import-map-overrides:change",rz=!1,rO=null,rP=null;async function rT(){return rP??(rP=rB().then(({map:e,complete:t})=>(t||(rP=null),e))),rP}async function rB(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let a=0;a<e.length;a++){let r=e[a];try{if(r.src){let e=await fetch(r.src);if(!e.ok)throw Error(`Request for ${r.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else r.textContent&&t.push(JSON.parse(r.textContent))}catch(e){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${a}`,e)}}return{map:rI(t),complete:n}}function rI(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function rN(){let e={};try{let t=rW();for(let n=0;n<localStorage.length;n++){let a=localStorage.key(n);if(a?.startsWith(rS)){let n=a.slice(rS.length);if(!t.includes(n)){let t=localStorage.getItem(a);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function rj(){let e=await rT();return rz?rI([e,rO??rN()]):e}async function rR(){return rT()}async function rF(){return rz?rI([await rT(),rN()]):rT()}function rL(e){if(!rz)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(rS)){let t=localStorage.getItem(n);t&&(e[n.slice(rS.length)]=t)}}return{imports:e}}return rN()}function rW(){if(!rz)return[];try{let e=localStorage.getItem(rD);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function rG(e){return!!rz&&rW().includes(e)}function rV(e,t){if(!rz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(rS+e,t),window.dispatchEvent(new CustomEvent(rM))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function rU(e){if(!rz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(rS+e);let t=rW().filter(t=>t!==e);t.length>0?localStorage.setItem(rD,JSON.stringify(t)):localStorage.removeItem(rD),window.dispatchEvent(new CustomEvent(rM))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function rq(){if(!rz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(rS)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(rD),window.dispatchEvent(new CustomEvent(rM))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function rH(e){if(!rz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=rW().filter(t=>t!==e);t.length>0?localStorage.setItem(rD,JSON.stringify(t)):localStorage.removeItem(rD),window.dispatchEvent(new CustomEvent(rM))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let rK=!1;function rY(){!rK&&(rK=!0,(rz="development"===window.spaEnv)&&(rO=rN()))}function rJ(e){return e.replace(/[\/\-@]/g,"_")}async function rZ(e,t="./start",a){var r;let o,i=!a?.maxLoadingTime||a.maxLoadingTime<=0?6e5:a.maxLoadingTime;await Promise.race([rX(e,a?.importMap),new Promise((t,n)=>{o=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=rJ(e),l=window[s];if(!("object"==typeof(r=l)&&null!==r&&"init"in r&&"function"==typeof r.init&&"get"in r&&"function"==typeof r.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(n.S.default);let c=(await l.get(t))();if("object"!=typeof c||null===c){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return c}async function rX(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let n=rJ(e);if(!window[n]){let n=t??await rQ();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let a=n.imports[e];a.startsWith("./")&&(a=window.spaBase+a.substring(1));let r=e in rL().imports;try{return await new Promise((e,t)=>{!function(e,t,n){let a=document.head.querySelector(`script[src="${e}"]`),r=window[r0];if(r||(r=window[r0]=new Set([])),a)if(r.has(e)){let e,r,o;o=()=>{e&&a.removeEventListener("load",e),r&&a.removeEventListener("error",r)},e=()=>{o(),t(null)},r=e=>{o(),n(e.message)},a.addEventListener("load",e),a.addEventListener("error",r)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),t(null);else{let a,o,i;r.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),r.delete(e),a&&s.removeEventListener("load",a),o&&s.removeEventListener("error",o)},a=()=>{i(),t(null)},o=t=>{i();let a=`Failed to load script from ${e}`;console.error(a,t),n(t.message??a)},s.addEventListener("load",a),s.addEventListener("error",o),document.head.appendChild(s)}}(a,e,t)})}catch(e){return r&&M({kind:"error",title:rE("scriptLoadingFailed","Error: Script failed to load"),description:rE("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:a}),actionButtonLabel:rE("resetOverrides","Reset overrides"),onActionButtonClick(){rq(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function rQ(){return rj()}let r0=Symbol("__openmrs_script_loading");function r1(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 r2(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&r1(t))}let r3="openmrs-routes:",r4="openmrs-routes:change",r5=!1,r6=null,r8=null;async function r7(){return r8??(r8=r9().then(({map:e,complete:t})=>(t||(r8=null),e))),r8}async function r9(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let a=0;a<e.length;a++){let r=e[a];try{let e;if(r.src){let t=await fetch(r.src);if(!t.ok)throw Error(`Request for ${r.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&r2(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${a}`,e)}}return{map:oe(t),complete:n}}function oe(e){let t={routes:{}};for(let n of e)n&&"object"==typeof n&&!Array.isArray(n)&&(Object.assign(t.routes,n.routes),void 0===t.version&&void 0!==n.version&&(t.version=n.version));return t}async function ot(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(r3)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(r3.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(r1(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),a=await t.json();if(r1(a))return{moduleName:e,routes:a};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function on(){let e=await r7();return r5?oe([e,r6??await ot()]):e}async function oa(){return r7()}async function or(){return r5?oe([await r7(),await ot()]):r7()}function oo(){if(!r5)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(r3)){let t=localStorage.getItem(n);t&&(e[n.slice(r3.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function oi(e,t){if(!r5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(r3+e,JSON.stringify(t));else{let n=JSON.parse(t);if(!r1(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(r3+e,JSON.stringify(n))}else if(t instanceof URL)localStorage.setItem(r3+e,JSON.stringify(t.toString()));else{if(!r1(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(r3+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(r4))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function os(e){if(!r5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(r3+e),window.dispatchEvent(new CustomEvent(r4))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ol(){if(!r5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(r3)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(r4))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let oc=null;function ou(){return oc||(oc=(r5="development"===window.spaEnv)?ot().then(e=>{r6=e}):Promise.resolve())}let op=`${ai}/attachment`;function od(e,t){return au(`${op}/${e}`,{signal:t.signal})}function of(e,t,n){return au(`${op}?patient=${e}&includeEncounterless=${t}`,{signal:n.signal})}async function oh(e,t){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),au(`${op}`,{method:"POST",body:n})}function om(e,t){return au(`${op}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function og(e,t){return new Promise(function(n){var a=new MessageChannel;a.port1.onmessage=function(e){n(e.data)},e.postMessage(t,[a.port2])})}function oy(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function ob(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var o_=function(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})};function ov(e,t){var n=location.href;return new URL(e,n).href===new URL(t,n).href}var o$=function(e,t){this.type=e,Object.assign(this,t)};function oA(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function ow(){}var ok={type:"SKIP_WAITING"};function ox(e,t){if(!t)return e&&e.then?e.then(ow):Promise.resolve()}var oC=function(e){function t(t,n){var a,r;return void 0===n&&(n={}),(a=e.call(this)||this).nn={},a.tn=0,a.rn=new o_,a.en=new o_,a.on=new o_,a.un=0,a.an=new Set,a.cn=function(){var e=a.fn,t=e.installing;a.tn>0||!ov(t.scriptURL,a.sn.toString())||performance.now()>a.un+6e4?(a.vn=t,e.removeEventListener("updatefound",a.cn)):(a.hn=t,a.an.add(t),a.rn.resolve(t)),++a.tn,t.addEventListener("statechange",a.ln)},a.ln=function(e){var t=a.fn,n=e.target,r=n.state,o=n===a.vn,i={sw:n,isExternal:o,originalEvent:e};!o&&a.mn&&(i.isUpdate=!0),a.dispatchEvent(new o$(r,i)),"installed"===r?a.wn=self.setTimeout(function(){"installed"===r&&t.waiting===n&&a.dispatchEvent(new o$("waiting",i))},200):"activating"===r&&(clearTimeout(a.wn),o||a.en.resolve(n))},a.dn=function(e){var t=a.hn,n=t!==navigator.serviceWorker.controller;a.dispatchEvent(new o$("controlling",{isExternal:n,originalEvent:e,sw:t,isUpdate:a.mn})),n||a.on.resolve(t)},r=function(e){var t=e.data,n=e.ports,r=e.source;return oA(a.getSW(),function(){a.an.has(r)&&a.dispatchEvent(new o$("message",{data:t,originalEvent:e,ports:n,sw:r}))})},a.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(e){return Promise.reject(e)}},a.sn=t,a.nn=n,navigator.serviceWorker.addEventListener("message",a.gn),a}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var n,a,r=t.prototype;return r.register=function(e){var t=(void 0===e?{}:e).immediate,n=void 0!==t&&t;try{var a,r,o,i=this;return a=function(){if(!n&&"complete"!==document.readyState)return ox(new Promise(function(e){return window.addEventListener("load",e)}))},r=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),oA(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 t=i.fn.waiting;return t&&ov(t.scriptURL,i.sn.toString())&&(i.hn=t,Promise.resolve().then(function(){i.dispatchEvent(new o$("waiting",{sw:t,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})},(o=a())&&o.then?o.then(r):r(o)}catch(e){return Promise.reject(e)}},r.update=function(){try{return this.fn?ox(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},r.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},r.messageSW=function(e){try{return oA(this.getSW(),function(t){return og(t,e)})}catch(e){return Promise.reject(e)}},r.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&og(this.fn.waiting,ok)},r.pn=function(){var e=navigator.serviceWorker.controller;return e&&ov(e.scriptURL,this.sn.toString())?e:void 0},r.bn=function(){try{var e=this;return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(function(){return oA(navigator.serviceWorker.register(e.sn,e.nn),function(t){return e.un=performance.now(),t})},function(e){throw e})}catch(e){return Promise.reject(e)}},n=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],oy(t.prototype,n),a&&oy(t,a),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,n=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return ob(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ob(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=n()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function oE(e,t){if(void 0!==p)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),p;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let n=new oC(e,t);return p=n.register().then(()=>n.controlling.then(()=>n))}function oS(){return p??Promise.resolve(void 0)}let oD="x-omrs-offline-response-body",oM="x-omrs-offline-response-status",oz="x-omrs-offline-caching-strategy";async function oO(e){let t=await oS();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function oP(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function oT(){return!window.indexedDB}async function oB(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function oI(){return await oB()||await oT()||await oP()}let oN="openmrs3:offline-mode",oj="unavailable";function oR(){return{current:oj,notAvailable:"unavailable"===oj,active:"on"===oj}}function oF(e){"unavailable"!==oj&&"unavailable"!==e&&(localStorage.setItem(oN,"on"===e?"active":"disabled"),oj=e)}async function oL(){await oI()||(oj="active"===localStorage.getItem(oN)?"on":"off"),navigator.onLine}let oW="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,oG=Object.keys,oV=Array.isArray;function oU(e,t){return"object"!=typeof t||oG(t).forEach(function(n){e[n]=t[n]}),e}"u"<typeof Promise||oW.Promise||(oW.Promise=Promise);let oq=Object.getPrototypeOf,oH={}.hasOwnProperty;function oK(e,t){return oH.call(e,t)}function oY(e,t){"function"==typeof t&&(t=t(oq(e))),("u"<typeof Reflect?oG:Reflect.ownKeys)(t).forEach(n=>{oZ(e,n,t[n])})}let oJ=Object.defineProperty;function oZ(e,t,n,a){oJ(e,t,oU(n&&oK(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},a))}function oX(e){return{from:function(t){return e.prototype=Object.create(t.prototype),oZ(e.prototype,"constructor",e),{extend:oY.bind(null,e.prototype)}}}}let oQ=Object.getOwnPropertyDescriptor;function o0(e,t){let n;return oQ(e,t)||(n=oq(e))&&o0(n,t)}let o1=[].slice;function o2(e,t,n){return o1.call(e,t,n)}function o3(e,t){return t(e)}function o4(e){if(!e)throw Error("Assertion Failed")}function o5(e){oW.setImmediate?setImmediate(e):setTimeout(e,0)}function o6(e,t){return e.reduce((e,n,a)=>{var r=t(n,a);return r&&(e[r[0]]=r[1]),e},{})}function o8(e,t){if(oK(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],a=0,r=t.length;a<r;++a){var o=o8(e,t[a]);n.push(o)}return n}var i=t.indexOf(".");if(-1!==i){var s=e[t.substr(0,i)];return void 0===s?void 0:o8(s,t.substr(i+1))}}function o7(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){o4("string"!=typeof n&&"length"in n);for(var a=0,r=t.length;a<r;++a)o7(e,t[a],n[a])}else{var o=t.indexOf(".");if(-1!==o){var i=t.substr(0,o),s=t.substr(o+1);if(""===s)void 0===n?oV(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=n;else{var l=e[i];l&&oK(e,i)||(l=e[i]={}),o7(l,s,n)}}else void 0===n?oV(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function o9(e){var t={};for(var n in e)oK(e,n)&&(t[n]=e[n]);return t}let ie=[].concat;function it(e){return ie.apply([],e)}let ia="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(it([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>oW[e]),ir=ia.map(e=>oW[e]);o6(ia,e=>[e,!0]);let io=null;function ii(e){io="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let n=io&&io.get(t);if(n)return n;if(oV(t)){n=[],io&&io.set(t,n);for(var a=0,r=t.length;a<r;++a)n.push(e(t[a]))}else if(ir.indexOf(t.constructor)>=0)n=t;else{let a=oq(t);for(var o in n=a===Object.prototype?{}:Object.create(a),io&&io.set(t,n),t)oK(t,o)&&(n[o]=e(t[o]))}return n}(e);return io=null,t}let{toString:is}={};function il(e){return is.call(e).slice(8,-1)}let ic="u">typeof Symbol?Symbol.iterator:"@@iterator",iu="symbol"==typeof ic?function(e){var t;return null!=e&&(t=e[ic])&&t.apply(e)}:function(){return null},ip={};function id(e){var t,n,a,r;if(1==arguments.length){if(oV(e))return e.slice();if(this===ip&&"string"==typeof e)return[e];if(r=iu(e)){for(n=[];!(a=r.next()).done;)n.push(a.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=Array(t);t--;)n[t]=arguments[t];return n}let ih="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var im="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),ig=()=>!0;let iy=!Error("").stack;function ib(){if(iy)try{throw ib.arguments,Error()}catch(e){return e}return Error()}function i_(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(ig).map(e=>"\n"+e).join("")):""}var iv=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],i$=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(iv),iA={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 iw(e,t){this._e=ib(),this.name=e,this.message=t}function ik(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,n)=>n.indexOf(e)===t).join("\n")}function ix(e,t,n,a){this._e=ib(),this.failures=t,this.failedKeys=a,this.successCount=n,this.message=ik(e,t)}function iC(e,t){this._e=ib(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=ik(e,t)}oX(iw).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+i_(this._e,2))}},toString:function(){return this.name+": "+this.message}}),oX(ix).from(iw),oX(iC).from(iw);var iE=i$.reduce((e,t)=>(e[t]=t+"Error",e),{}),iS=i$.reduce((e,t)=>{var n=t+"Error";function a(e,a){this._e=ib(),this.name=n,e?"string"==typeof e?(this.message=`${e}${a?"\n "+a:""}`,this.inner=a||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=iA[t]||n,this.inner=null)}return oX(a).from(iw),e[t]=a,e},{});iS.Syntax=SyntaxError,iS.Type=TypeError,iS.Range=RangeError;var iD=iv.reduce((e,t)=>(e[t+"Error"]=iS[t],e),{}),iM=i$.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=iS[t]),e),{});function iz(){}function iO(e){return e}function iP(e,t){return null==e||e===iO?t:function(n){return t(e(n))}}function iT(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function iB(e,t){return e===iz?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var a=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?iT(a,this.onsuccess):a),r&&(this.onerror=this.onerror?iT(r,this.onerror):r),void 0!==o?o:n}}function iI(e,t){return e===iz?t:function(){e.apply(this,arguments);var n=this.onsuccess,a=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?iT(n,this.onsuccess):n),a&&(this.onerror=this.onerror?iT(a,this.onerror):a)}}function iN(e,t){return e===iz?t:function(n){var a=e.apply(this,arguments);oU(n,a);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?iT(r,this.onsuccess):r),o&&(this.onerror=this.onerror?iT(o,this.onerror):o),void 0===a?void 0===i?void 0:i:oU(a,i)}}function ij(e,t){return e===iz?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function iR(e,t){return e===iz?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var a=this,r=arguments.length,o=Array(r);r--;)o[r]=arguments[r];return n.then(function(){return t.apply(a,o)})}return t.apply(this,arguments)}}iM.ModifyError=ix,iM.DexieError=iw,iM.BulkError=iC;var iF={};let[iL,iW,iG]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,oq(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,oq(t),e]})(),iV=iW&&iW.then,iU=iL&&iL.constructor,iq=!!iG;var iH=!1,iK=iG?()=>{iG.then(so)}:oW.setImmediate?setImmediate.bind(null,so):oW.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{so(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(so,0)},iY=function(e,t){i4.push([e,t]),iZ&&(iK(),iZ=!1)},iJ=!0,iZ=!0,iX=[],iQ=[],i0=null,i1=iO,i2={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:sS,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{sS(e[0],e[1])}catch(e){}})}},i3=i2,i4=[],i5=0,i6=[];function i8(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=iz,this._lib=!1;var t=this._PSD=i3;if(im&&(this._stackHolder=ib(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==iF)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&se(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,n){try{n(n=>{if(null===t._state){if(n===t)throw TypeError("A promise cannot be resolved with itself.");var a=t._lib&&si();n&&"function"==typeof n.then?e(t,(e,t)=>{n instanceof i8?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,st(t)),a&&ss()}},se.bind(null,t))}catch(e){se(t,e)}}(this,e)}let i7={get:function(){var e=i3,t=sm;function n(n,a){var r=!e.global&&(e!==i3||t!==sm);let o=r&&!s_();var i=new i8((t,i)=>{sn(this,new i9(sC(n,e,r,o),sC(a,e,r,o),t,i,e))});return im&&sr(i,this),i}return n.prototype=iF,n},set:function(e){oZ(this,"then",e&&e.prototype===iF?i7:{get:function(){return e},set:i7.set})}};function i9(e,t,n,a,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=a,this.psd=r}function se(e,t){if(iQ.push(t),null===e._state){var n=e._lib&&si();t=i1(t),e._state=!1,e._value=t,im&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var n=o0(t,"stack");t._promise=e,oZ(t,"stack",{get:()=>iH?n&&(n.get?n.get.apply(t):n.value):e.stack})}),iX.some(t=>t._value===e._value)||iX.push(e),st(e),n&&ss()}}function st(e){var t=e._listeners;e._listeners=[];for(var n=0,a=t.length;n<a;++n)sn(e,t[n]);var r=e._PSD;--r.ref||r.finalize(),0===i5&&(++i5,iY(()=>{0==--i5&&sl()},[]))}function sn(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++i5,iY(sa,[n,e,t])}else e._listeners.push(t)}function sa(e,t,n){try{i0=t;var a,r=t._value;t._state?a=e(r):(iQ.length&&(iQ=[]),a=e(r),-1===iQ.indexOf(r)&&function(e){for(var t=iX.length;t;)if(iX[--t]._value===e._value)return void iX.splice(t,1)}(t)),n.resolve(a)}catch(e){n.reject(e)}finally{i0=null,0==--i5&&sl(),--n.psd.ref||n.psd.finalize()}}function sr(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function so(){si()&&ss()}function si(){var e=iJ;return iJ=!1,iZ=!1,e}function ss(){var e,t,n;do for(;i4.length>0;)for(e=i4,i4=[],n=e.length,t=0;t<n;++t){var a=e[t];a[0].apply(null,a[1])}while(i4.length>0);iJ=!0,iZ=!0}function sl(){var e=iX;iX=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=i6.slice(0),n=t.length;n;)t[--n]()}function sc(e){return new i8(iF,!1,e)}function su(e,t){var n=i3;return function(){var a=si(),r=i3;try{return sw(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{sw(r,!1),a&&ss()}}}oY(i8.prototype,{then:i7,_then:function(e,t){sn(this,new i9(null,null,e,t,i3))},catch:function(e){if(1==arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?n(e):sc(e)):this.then(null,e=>e&&e.name===t?n(e):sc(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),sc(t)))},stack:{get:function(){if(this._stack)return this._stack;try{iH=!0;var e=(function e(t,n,a){if(n.length===a)return n;var r="";if(!1===t._state){var o,i,s=t._value;null!=s?(o=s.name||"Error",i=s.message||s,r=i_(s,0)):(o=s,i=""),n.push(o+(i?": "+i:"")+r)}return im&&((r=i_(t._stackHolder,2))&&-1===n.indexOf(r)&&n.push(r),t._prev&&e(t._prev,n,a)),n})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{iH=!1}}},timeout:function(e,t){return e<1/0?new i8((n,a)=>{var r=setTimeout(()=>a(new iS.Timeout(t)),e);this.then(n,a).finally(clearTimeout.bind(null,r))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&oZ(i8.prototype,Symbol.toStringTag,"Dexie.Promise"),i2.env=sk(),oY(i8,{all:function(){var e=id.apply(null,arguments).map(sv);return new i8(function(t,n){0===e.length&&t([]);var a=e.length;e.forEach((r,o)=>i8.resolve(r).then(n=>{e[o]=n,--a||t(e)},n))})},resolve:e=>{if(e instanceof i8)return e;if(e&&"function"==typeof e.then)return new i8((t,n)=>{e.then(t,n)});var t=new i8(iF,!0,e);return sr(t,i0),t},reject:sc,race:function(){var e=id.apply(null,arguments).map(sv);return new i8((t,n)=>{e.map(e=>i8.resolve(e).then(t,n))})},PSD:{get:()=>i3,set:e=>i3=e},totalEchoes:{get:()=>sm},newPSD:sy,usePSD:sx,scheduler:{get:()=>iY,set:e=>{iY=e}},rejectionMapper:{get:()=>i1,set:e=>{i1=e}},follow:(e,t)=>new i8((n,a)=>sy((t,n)=>{var a=i3;a.unhandleds=[],a.onunhandled=n,a.finalize=iT(function(){var e;e=()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])},i6.push(function t(){e(),i6.splice(i6.indexOf(t),1)}),++i5,iY(()=>{0==--i5&&sl()},[])},a.finalize),e()},t,n,a))}),iU&&(iU.allSettled&&oZ(i8,"allSettled",function(){let e=id.apply(null,arguments).map(sv);return new i8(t=>{0===e.length&&t([]);let n=e.length,a=Array(n);e.forEach((e,r)=>i8.resolve(e).then(e=>a[r]={status:"fulfilled",value:e},e=>a[r]={status:"rejected",reason:e}).then(()=>--n||t(a)))})}),iU.any&&"u">typeof AggregateError&&oZ(i8,"any",function(){let e=id.apply(null,arguments).map(sv);return new i8((t,n)=>{0===e.length&&n(AggregateError([]));let a=e.length,r=Array(a);e.forEach((e,o)=>i8.resolve(e).then(e=>t(e),e=>{r[o]=e,--a||n(AggregateError(r))}))})}));let sp={awaits:0,echoes:0,id:0};var sd=0,sf=[],sh=0,sm=0,sg=0;function sy(e,t,n,a){var r=i3,o=Object.create(r);o.parent=r,o.ref=0,o.global=!1,o.id=++sg;var i=i2.env;o.env=iq?{Promise:i8,PromiseProp:{value:i8,configurable:!0,writable:!0},all:i8.all,race:i8.race,allSettled:i8.allSettled,any:i8.any,resolve:i8.resolve,reject:i8.reject,nthen:sE(i.nthen,o),gthen:sE(i.gthen,o)}:{},t&&oU(o,t),++r.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=sx(o,e,n,a);return 0===o.ref&&o.finalize(),s}function sb(){return sp.id||(sp.id=++sd),++sp.awaits,sp.echoes+=100,sp.id}function s_(){return!!sp.awaits&&(0==--sp.awaits&&(sp.id=0),sp.echoes=100*sp.awaits,!0)}function sv(e){return sp.echoes&&e&&e.constructor===iU?(sb(),e.then(e=>(s_(),e),e=>(s_(),sD(e)))):e}function s$(e){++sm,sp.echoes&&0!=--sp.echoes||(sp.echoes=sp.id=0),sf.push(i3),sw(e,!0)}function sA(){var e=sf[sf.length-1];sf.pop(),sw(e,!1)}function sw(e,t){var n,a=i3;if((t?!sp.echoes||sh++&&e===i3:!sh||--sh&&e===i3)||(n=t?s$.bind(null,e):sA,iV.call(iL,n)),e!==i3&&(i3=e,a===i2&&(i2.env=sk()),iq)){var r=i2.env.Promise,o=e.env;iW.then=o.nthen,r.prototype.then=o.gthen,(a.global||e.global)&&(Object.defineProperty(oW,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function sk(){var e=oW.Promise;return iq?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(oW,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:iW.then,gthen:e.prototype.then}:{}}function sx(e,t,n,a,r){var o=i3;try{return sw(e,!0),t(n,a,r)}finally{sw(o,!1)}}function sC(e,t,n,a){return"function"!=typeof e?e:function(){var r,o=i3;n&&sb(),sw(t,!0);try{return e.apply(this,arguments)}finally{sw(o,!1),a&&(r=s_,iV.call(iL,r))}}}function sE(e,t){return function(n,a){return e.call(this,sC(n,t),sC(a,t))}}function sS(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var a,r={promise:t,reason:e};if(oW.document&&document.createEvent?((a=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),oU(a,r)):oW.CustomEvent&&oU(a=new CustomEvent("unhandledrejection",{detail:r}),r),a&&oW.dispatchEvent&&(dispatchEvent(a),!oW.PromiseRejectionEvent&&oW.onunhandledrejection))try{oW.onunhandledrejection(a)}catch(e){}im&&a&&!a.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+iV).indexOf("[native code]")&&(sb=s_=iz);var sD=i8.reject;let sM=String.fromCharCode(65535),sz="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",sO=[],sP="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),sT=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function sB(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let sI={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function sN(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=ii(t))[e],t)}class sj{_trans(e,t,n){let a=this._tx||i3.trans,r=this.name;function o(e,n,a){if(!a.schema[r])throw new iS.NotFound("Table "+r+" not part of transaction");return t(a.idbtrans,a)}let i=si();try{return a&&a.db===this.db?a===i3.trans?a._promise(e,o,n):sy(()=>a._promise(e,o,n),{trans:a,transless:i3.transless||i3}):function e(t,n,a,r){if(t.idbdb&&(t._state.openComplete||i3.letThrough||t._vip)){var o=t._createTransaction(n,a,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===iE.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,a,r))):sD(o)}return o._promise(n,(e,t)=>sy(()=>(i3.trans=o,r(e,t,o)))).then(e=>o._completion.then(()=>e))}if(t._state.openComplete)return sD(new iS.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return sD(new iS.DatabaseClosed);t.open().catch(iz)}return t._state.dbReadyPromise.then(()=>e(t,n,a,r))}(this.db,e,[this.name],o)}finally{i&&ss()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(oV(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=oG(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)&&e.keyPath.every(e=>t.indexOf(e)>=0))[0];if(n&&this.db._maxKey!==sM)return this.where(n.name).equals(n.keyPath.map(t=>e[t]));!n&&im&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:a}=this.schema,r=this.db._deps.indexedDB;function o(e,t){try{return 0===r.cmp(e,t)}catch(e){return!1}}let[i,s]=t.reduce(([t,n],r)=>{let i=a[r],s=e[r];return[t||i,t||!i?sB(n,i&&i.multi?e=>{let t=o8(e,r);return oV(t)&&t.some(e=>o(s,e))}:e=>o(s,o8(e,r))):n]},[null,null]);return i?this.where(i.name).equals(e[i.keyPath]).filter(s):n?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,oV(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let n=Object.create(e.prototype);for(var a in t)if(oK(t,a))try{n[a]=t[a]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){oU(this,e)})}add(e,t){let{auto:n,keyPath:a}=this.schema.primKey,r=e;return a&&n&&(r=sN(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[r]})).then(e=>e.numFailures?i8.reject(e.failures[0]):e.lastResult).then(t=>{if(a)try{o7(e,a,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||oV(e))return this.where(":id").equals(e).modify(t);{let n=o8(e,this.schema.primKey.keyPath);if(void 0===n)return sD(new iS.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?oG(t).forEach(n=>{o7(e,n,t[n])}):t(e,{value:e,primKey:n})}catch(e){}return this.where(":id").equals(n).modify(t)}}put(e,t){let{auto:n,keyPath:a}=this.schema.primKey,r=e;return a&&n&&(r=sN(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[r],keys:null!=t?[t]:null})).then(e=>e.numFailures?i8.reject(e.failures[0]):e.lastResult).then(t=>{if(a)try{o7(e,a,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?i8.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:sI})).then(e=>e.numFailures?i8.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,n){let a=Array.isArray(t)?t:void 0,r=(n=n||(a?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:o}=this.schema.primKey;if(o&&a)throw new iS.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new iS.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=o&&n?e.map(sN(o)):e;return this.core.mutate({trans:t,type:"add",keys:a,values:s,wantResults:r}).then(({numFailures:e,results:t,lastResult:n,failures:a})=>{if(0===e)return r?t:n;throw new iC(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,a)})})}bulkPut(e,t,n){let a=Array.isArray(t)?t:void 0,r=(n=n||(a?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:o}=this.schema.primKey;if(o&&a)throw new iS.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new iS.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=o&&n?e.map(sN(o)):e;return this.core.mutate({trans:t,type:"put",keys:a,values:s,wantResults:r}).then(({numFailures:e,results:t,lastResult:n,failures:a})=>{if(0===e)return r?t:n;throw new iC(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,a)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:n,failures:a})=>{if(0===e)return n;throw new iC(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,a)})}}function sR(e){var t={},n=function(n,a){if(a){for(var r=arguments.length,o=Array(r-1);--r;)o[r-1]=arguments[r];return t[n].subscribe.apply(null,o),e}if("string"==typeof n)return t[n]};n.addEventType=o;for(var a=1,r=arguments.length;a<r;++a)o(arguments[a]);return n;function o(e,a,r){if("object"==typeof e){var i;return void oG(i=e).forEach(function(e){var t=i[e];if(oV(t))o(e,i[e][0],i[e][1]);else{if("asap"!==t)throw new iS.InvalidArgument("Invalid event config");var n=o(e,iO,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){o5(function(){e.apply(null,t)})})})}})}a||(a=ij),r||(r=iz);var s={subscribers:[],fire:r,subscribe:function(e){-1===s.subscribers.indexOf(e)&&(s.subscribers.push(e),s.fire=a(s.fire,e))},unsubscribe:function(e){s.subscribers=s.subscribers.filter(function(t){return t!==e}),s.fire=s.subscribers.reduce(a,r)}};return t[e]=n[e]=s,s}}function sF(e,t){return oX(t).from({prototype:e}),t}function sL(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function sW(e,t){e.filter=sB(e.filter,t)}function sG(e,t,n){var a=e.replayFilter;e.replayFilter=a?()=>sB(a(),t()):t,e.justLimit=n&&!a}function sV(e,t){if(e.isPrimKey)return t.primaryKey;let n=t.getIndexByKeyPath(e.index);if(!n)throw new iS.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function sU(e,t,n){let a=sV(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:a,range:e.range}})}function sq(e,t,n,a){let r=e.replayFilter?sB(e.filter,e.replayFilter()):e.filter;if(e.or){let o={},i=(e,n,a)=>{if(!r||r(n,a,e=>n.stop(e),e=>n.fail(e))){var i=n.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),oK(o,s)||(o[s]=!0,t(e,n,a))}};return Promise.all([e.or._iterate(i,n),sH(sU(e,a,n),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return sH(sU(e,a,n),sB(e.algorithm,r),t,!e.keysOnly&&e.valueMapper)}function sH(e,t,n,a){var r=su(a?(e,t,r)=>n(a(e),t,r):n);return e.then(e=>{if(e)return e.start(()=>{var n=()=>e.continue();t&&!t(e,e=>n=e,t=>{e.stop(t),n=iz},t=>{e.fail(t),n=iz})||r(e.value,e,e=>n=e),n()})})}function sK(e,t){try{let n=sY(e),a=sY(t);if(n!==a)return"Array"===n?1:"Array"===a?-1:"binary"===n?1:"binary"===a?-1:"string"===n?1:"string"===a?-1:"Date"===n?1:"Date"!==a?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let n=e.length,a=t.length,r=n<a?n:a;for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===a?0:n<a?-1:1}(sJ(e),sJ(t));case"Array":return function(e,t){let n=e.length,a=t.length,r=n<a?n:a;for(let n=0;n<r;++n){let a=sK(e[n],t[n]);if(0!==a)return a}return n===a?0:n<a?-1:1}(e,t)}}catch(e){}return NaN}function sY(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let n=il(e);return"ArrayBuffer"===n?"binary":n}function sJ(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class sZ{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,sD.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,sD.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=sB(t.algorithm,e)}_iterate(e,t){return sq(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&oU(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(n=>sq(t,e,n,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,n=t.table.core;if(sL(t,!0))return n.count({trans:e,query:{index:sV(t,n.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var a=0;return sq(t,()=>(++a,!1),e,n).then(()=>a)}).then(e)}sortBy(e,t){let n=e.split(".").reverse(),a=n[0],r=n.length-1;function o(e,t){return t?o(e[n[t]],t-1):e[a]}var i="next"===this._ctx.dir?1:-1;function s(e,t){var n=o(e,r),a=o(t,r);return n<a?-i:n>a?i:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&sL(t,!0)&&t.limit>0){let{valueMapper:n}=t,a=sV(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:a,range:t.range}}).then(({result:e})=>n?e.map(n):e)}{let n=[];return sq(t,e=>n.push(e),e,t.table.core).then(()=>n)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,sL(t)?sG(t,()=>{var t=e;return(e,n)=>0===t||(1===t?--t:n(()=>{e.advance(t),t=0}),!1)}):sG(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),sG(this._ctx,()=>{var t=e;return function(e,n,a){return--t<=0&&n(a),t>=0}},!0),this}until(e,t){return sW(this._ctx,function(n,a,r){return!e(n.value)||(a(r),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return sW(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=sB(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&sL(t,!0)&&t.limit>0)return this._read(e=>{var n=sV(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return sW(this._ctx,function(e){var t=e.primaryKey.toString(),a=oK(n,t);return n[t]=!0,!a}),this}modify(e){var t=this._ctx;return this._write(n=>{var a;if("function"==typeof e)a=e;else{var r=oG(e),o=r.length;a=function(t){for(var n=!1,a=0;a<o;++a){var i=r[a],s=e[i];o8(t,i)!==s&&(o7(t,i,s),n=!0)}return n}}let i=t.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,u=[],p=0,d=[],f=(e,t)=>{let{failures:n,numFailures:a}=t;for(let t of(p+=e-a,oG(n)))u.push(n[t])};return this.clone().primaryKeys().then(r=>{let o=u=>{let p=Math.min(c,r.length-u);return i.getMany({trans:n,keys:r.slice(u,u+p),cache:"immutable"}).then(d=>{let h=[],m=[],g=s?[]:null,y=[];for(let e=0;e<p;++e){let t=d[e],n={value:ii(t),primKey:r[u+e]};!1!==a.call(n,n.value,n)&&(null==n.value?y.push(r[u+e]):s||0===sK(l(t),l(n.value))?(m.push(n.value),s&&g.push(r[u+e])):(y.push(r[u+e]),h.push(n.value)))}let b=sL(t)&&t.limit===1/0&&("function"!=typeof e||e===sX)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&i.mutate({trans:n,type:"add",values:h}).then(e=>{for(let t in e.failures)y.splice(parseInt(t),1);f(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&i.mutate({trans:n,type:"put",keys:g,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(y.length>0||b&&e===sX)&&i.mutate({trans:n,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>r.length>u+p&&o(u+c))})};return o(0).then(()=>{if(u.length>0)throw new ix("Error modifying one or more objects",u,p,d);return r.length})})})}delete(){var e=this._ctx,t=e.range;return sL(e)&&(e.isPrimKey&&!sP||3===t.type)?this._write(n=>{let{primaryKey:a}=e.table.core.schema;return e.table.core.count({trans:n,query:{index:a,range:t}}).then(a=>e.table.core.mutate({trans:n,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:n,numFailures:r})=>{if(r)throw new ix("Could not delete some values",Object.keys(e).map(t=>e[t]),a-r);return a-r}))}):this.modify(sX)}}let sX=(e,t)=>t.value=null;function sQ(e,t){return e<t?-1:+(e!==t)}function s0(e,t){return e>t?-1:+(e!==t)}function s1(e,t,n){var a=e instanceof s6?new e.Collection(e):e;return a._ctx.error=n?new n(t):TypeError(t),a}function s2(e){return new e.Collection(e,()=>s5("")).limit(0)}function s3(e,t,n,a){var r,o,i,s,l,c,u,p=n.length;if(!n.every(e=>"string"==typeof e))return s1(e,"String expected.");function d(e){r="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),o="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?sQ:s0;var t=n.map(function(e){return{lower:o(e),upper:r(e)}}).sort(function(e,t){return i(e.lower,t.lower)});s=t.map(function(e){return e.upper}),l=t.map(function(e){return e.lower}),c=e,u="next"===e?"":a}d("next");var f=new e.Collection(e,()=>s4(s[0],l[p-1]+a));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,n,a){var r=e.key;if("string"!=typeof r)return!1;var d=o(r);if(t(d,l,h))return!0;for(var f=null,m=h;m<p;++m){var g=function(e,t,n,a,r,o){for(var i=Math.min(e.length,a.length),s=-1,l=0;l<i;++l){var c=t[l];if(c!==a[l])return 0>r(e[l],n[l])?e.substr(0,l)+n[l]+n.substr(l+1):0>r(e[l],a[l])?e.substr(0,l)+a[l]+n.substr(l+1):s>=0?e.substr(0,s)+t[s]+n.substr(s+1):null;0>r(e[l],c)&&(s=l)}return i<a.length&&"next"===o?e+n.substr(e.length):i<e.length&&"prev"===o?e.substr(0,n.length):s<0?null:e.substr(0,s)+a[s]+n.substr(s+1)}(r,d,s[m],l[m],i,c);null===g&&null===f?h=m+1:(null===f||i(f,g)>0)&&(f=g)}return n(null!==f?function(){e.continue(f+u)}:a),!1}),f}function s4(e,t,n,a){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:a}}function s5(e){return{type:1,lower:e,upper:e}}class s6{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,a){n=!1!==n,a=!0===a;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||a)&&(!n||!a)?s2(this):new this.Collection(this,()=>s4(e,t,!n,!a))}catch(e){return s1(this,sz)}}equals(e){return null==e?s1(this,sz):new this.Collection(this,()=>s5(e))}above(e){return null==e?s1(this,sz):new this.Collection(this,()=>s4(e,void 0,!0))}aboveOrEqual(e){return null==e?s1(this,sz):new this.Collection(this,()=>s4(e,void 0,!1))}below(e){return null==e?s1(this,sz):new this.Collection(this,()=>s4(void 0,e,!1,!0))}belowOrEqual(e){return null==e?s1(this,sz):new this.Collection(this,()=>s4(void 0,e))}startsWith(e){return"string"!=typeof e?s1(this,"String expected."):this.between(e,e+sM,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):s3(this,(e,t)=>0===e.indexOf(t[0]),[e],sM)}equalsIgnoreCase(e){return s3(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=id.apply(ip,arguments);return 0===e.length?s2(this):s3(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=id.apply(ip,arguments);return 0===e.length?s2(this):s3(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,sM)}anyOf(){let e=id.apply(ip,arguments),t=this._cmp;try{e.sort(t)}catch(e){return s1(this,sz)}if(0===e.length)return s2(this);let n=new this.Collection(this,()=>s4(e[0],e[e.length-1]));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let a=0;return n._addAlgorithm((n,r,o)=>{let i=n.key;for(;t(i,e[a])>0;)if(++a===e.length)return r(o),!1;return 0===t(i,e[a])||(r(()=>{n.continue(e[a])}),!1)}),n}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=id.apply(ip,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return s1(this,sz)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let n=this._cmp,a=this._ascending,r=this._descending,o=this._min,i=this._max;if(0===e.length)return s2(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=a(e[0],e[1])))return s1(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",iS.InvalidArgument);let s=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,c,u=a;function p(e,t){return u(e[0],t[0])}try{(c=e.reduce(function(e,t){let a=0,r=e.length;for(;a<r;++a){let r=e[a];if(0>n(t[0],r[1])&&n(t[1],r[0])>0){r[0]=o(r[0],t[0]),r[1]=i(r[1],t[1]);break}}return a===r&&e.push(t),e},[])).sort(p)}catch(e){return s1(this,sz)}let d=0,f=l?e=>a(e,c[d][1])>0:e=>a(e,c[d][1])>=0,h=s?e=>r(e,c[d][0])>0:e=>r(e,c[d][0])>=0,m=f,g=new this.Collection(this,()=>s4(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,u=a):(m=h,u=r),c.sort(p)},g._addAlgorithm((e,t,n)=>{for(var r=e.key;m(r);)if(++d===c.length)return t(n),!1;return!!(!f(r)&&!h(r))||(0===this._cmp(r,c[d][1])||0===this._cmp(r,c[d][0])||t(()=>{u===a?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=id.apply(ip,arguments);return e.every(e=>"string"==typeof e)?0===e.length?s2(this):this.inAnyRange(e.map(e=>[e,e+sM])):s1(this,"startsWithAnyOf() only works with strings")}}function s8(e){return su(function(t){return s7(t),e(t.target.error),!1})}function s7(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let s9=sR(null,"storagemutated");class le{_lock(){return o4(!i3.global),++this._reculock,1!==this._reculock||i3.global||(i3.lockOwnerFor=this),this}_unlock(){if(o4(!i3.global),0==--this._reculock)for(i3.global||(i3.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{sx(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&i3.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,n=this.db._state.dbOpenError;if(o4(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new iS.DatabaseClosed(n);case"MissingAPIError":throw new iS.MissingAPI(n.message,n);default:throw new iS.OpenFailed(n)}if(!this.active)throw new iS.TransactionInactive;return o4(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=su(t=>{s7(t),this._reject(e.error)}),e.onabort=su(t=>{s7(t),this.active&&this._reject(new iS.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=su(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&s9.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return sD(new iS.ReadOnly("Transaction is readonly"));if(!this.active)return sD(new iS.TransactionInactive);if(this._locked())return new i8((a,r)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(a,r)},i3])});if(n)return sy(()=>{var e=new i8((e,n)=>{this._lock();let a=t(e,n,this);a&&a.then&&a.then(e,n)});return e.finally(()=>this._unlock()),e._lib=!0,e});var a=new i8((e,n)=>{var a=t(e,n,this);a&&a.then&&a.then(e,n)});return a._lib=!0,a}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let n=i8.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>n);else{t._waitingFor=n,t._waitingQueue=[];var a=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(a.get(-1/0).onsuccess=e)}()}var r=t._waitingFor;return new i8((e,a)=>{n.then(n=>t._waitingQueue.push(su(e.bind(null,n))),e=>t._waitingQueue.push(su(a.bind(null,e)))).finally(()=>{t._waitingFor===r&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new iS.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(oK(t,e))return t[e];let n=this.schema[e];if(!n)throw new iS.NotFound("Table "+e+" not part of transaction");let a=new this.db.Table(e,n,this);return a.core=this.db.core.table(e),t[e]=a,a}}function lt(e,t,n,a,r,o,i){return{name:e,keyPath:t,unique:n,multi:a,auto:r,compound:o,src:(n&&!i?"&":"")+(a?"*":"")+(r?"++":"")+ln(t)}}function ln(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function la(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:o6(n,e=>[e.name,e])}}let lr=e=>{try{return e.only([[]]),lr=()=>[[]],[[]]}catch(e){return lr=()=>sM,sM}};function lo(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>o8(t,e):t=>o8(t,e)}function li(e){return[].slice.call(e)}let ls=0;function ll(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function lc({_novip:e},t){let n=t.db,a=function(e,t,{IDBKeyRange:n,indexedDB:a},r){var o;return{dbcore:(o=function(e,t,n){let a;function r(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:n,upper:a,lowerOpen:r,upperOpen:o}=e;return void 0===n?void 0===a?null:t.upperBound(a,!!o):void 0===a?t.lowerBound(n,!!r):t.bound(n,a,!!r,!!o)}let{schema:o,hasGetAll:i}=(a=li(e.objectStoreNames),{schema:{name:e.name,tables:a.map(e=>n.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:n}=e,a=oV(t),r=null==t,o={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:r,compound:a,keyPath:t,autoIncrement:n,unique:!0,extractKey:lo(t)},indexes:li(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:n,multiEntry:a,keyPath:r}=e,i={name:t,compound:oV(r),keyPath:r,unique:n,multiEntry:a,extractKey:lo(r)};return o[ll(r)]=i,i}),getIndexByKeyPath:e=>o[ll(e)]};return o[":id"]=i.primaryKey,null!=t&&(o[ll(t)]=i.primaryKey),i})},hasGetAll:a.length>0&&"getAll"in n.objectStore(a[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=o.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:n,keys:a,values:o,range:i}){return new Promise((s,l)=>{let c;s=su(s);let u=e.objectStore(t),p=null==u.keyPath,d="put"===n||"add"===n;if(!d&&"delete"!==n&&"deleteRange"!==n)throw Error("Invalid operation type: "+n);let{length:f}=a||o||{length:1};if(a&&o&&a.length!==o.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,y=e=>{++g,s7(e)};if("deleteRange"===n){if(4===i.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===i.type?h.push(c=u.clear()):h.push(c=u.delete(r(i)))}else{let[e,t]=d?p?[o,a]:[o,null]:[a,null];if(d)for(let a=0;a<f;++a)h.push(c=t&&void 0!==t[a]?u[n](e[a],t[a]):u[n](e[a])),c.onerror=y;else for(let t=0;t<f;++t)h.push(c=u[n](e[t])),c.onerror=y}let b=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:g,failures:m,results:"delete"===n?a:h.map(e=>e.result),lastResult:t})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:n})=>new Promise((a,r)=>{a=su(a);let o=e.objectStore(t),i=n.length,s=Array(i),l,c=0,u=0,p=e=>{let t=e.target;s[t._pos]=t.result,++u===c&&a(s)},d=s8(r);for(let e=0;e<i;++e)null!=n[e]&&((l=o.get(n[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&a(s)}),get:({trans:e,key:n})=>new Promise((a,r)=>{a=su(a);let o=e.objectStore(t).get(n);o.onsuccess=e=>a(e.target.result),o.onerror=s8(r)}),query:e=>new Promise((n,a)=>{n=su(n);let{trans:o,values:s,limit:l,query:c}=e,u=l===1/0?void 0:l,{index:p,range:d}=c,f=o.objectStore(t),h=p.isPrimaryKey?f:f.index(p.name),m=r(d);if(0===l)return n({result:[]});if(i){let e=s?h.getAll(m,u):h.getAllKeys(m,u);e.onsuccess=e=>n({result:e.target.result}),e.onerror=s8(a)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),r=[];t.onsuccess=a=>{let o=t.result;return o?(r.push(s?o.value:o.primaryKey),++e===l?n({result:r}):void o.continue()):n({result:r})},t.onerror=s8(a)}}),openCursor:function({trans:e,values:n,query:a,reverse:o,unique:i}){return new Promise((s,l)=>{s=su(s);let{index:c,range:u}=a,p=e.objectStore(t),d=c.isPrimaryKey?p:p.index(c.name),f=o?i?"prevunique":"prev":i?"nextunique":"next",h=!n&&"openKeyCursor"in d?d.openKeyCursor(r(u),f):d.openCursor(r(u),f);h.onerror=s8(l),h.onsuccess=su(t=>{let n=h.result;if(!n)return void s(null);n.___id=++ls,n.done=!1;let a=n.continue.bind(n),r=n.continuePrimaryKey;r&&(r=r.bind(n));let o=n.advance.bind(n),i=()=>{throw Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw Error("Cursor not started")},n.fail=su(l),n.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},n.start=e=>{let t=new Promise((e,t)=>{e=su(e),h.onerror=s8(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=i,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw Error("Cursor behind last entry")},n.stop()};return h.onsuccess=su(e=>{h.onsuccess=s,s()}),n.continue=a,n.continuePrimaryKey=r,n.advance=o,s(),t},s(n)},l)})},count({query:e,trans:n}){let{index:a,range:o}=e;return new Promise((e,i)=>{let s=n.objectStore(t),l=a.isPrimaryKey?s:s.index(a.name),c=r(o),u=c?l.count(c):l.count();u.onsuccess=su(t=>e(t.target.result)),u.onerror=s8(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:lr(t),schema:o}}(t,n,r),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),o))}}(e._middlewares,n,e._deps,t);e.core=a.dbcore,e.tables.forEach(t=>{let n=t.name;e.core.schema.tables.some(e=>e.name===n)&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))})}function lu({_novip:e},t,n,a){n.forEach(n=>{let r=a[n];t.forEach(t=>{let a=o0(t,n);(!a||"value"in a&&void 0===a.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?oZ(t,n,{get(){return this.table(n)},set(e){oJ(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,r))})})}function lp({_novip:e},t){t.forEach(t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]})}function ld(e,t){return e._cfg.version-t._cfg.version}function lf(e,t){let n,a={del:[],add:[],change:[]};for(n in e)t[n]||a.del.push(n);for(n in t){let r=e[n],o=t[n];if(r){let e={name:n,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(r.primKey.keyPath||"")==""+(o.primKey.keyPath||"")&&(r.primKey.auto===o.primKey.auto||sP)){let t,n=r.idxByName,i=o.idxByName;for(t in n)i[t]||e.del.push(t);for(t in i){let a=n[t],r=i[t];a?a.src!==r.src&&e.change.push(r):e.add.push(r)}(e.del.length>0||e.add.length>0||e.change.length>0)&&a.change.push(e)}else e.recreate=!0,a.change.push(e)}else a.add.push([n,o])}return a}function lh(e,t,n,a){let r=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return a.forEach(e=>lm(r,e)),r}function lm(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function lg(e,t,n){let a={};return o2(t.objectStoreNames,0).forEach(e=>{let t=n.objectStore(e),r=t.keyPath,o=lt(ln(r),r||"",!1,!1,!!t.autoIncrement,r&&"string"!=typeof r,!0),i=[];for(let e=0;e<t.indexNames.length;++e){let n=t.index(t.indexNames[e]);r=n.keyPath;var s=lt(n.name,r,!!n.unique,!!n.multiEntry,!1,r&&"string"!=typeof r,!1);i.push(s)}a[e]=la(e,o,i)}),a}function ly({_novip:e},t,n){let a=n.db.objectStoreNames;for(let r=0;r<a.length;++r){let o=a[r],i=n.objectStore(o);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let n=i.indexNames[e],a=i.index(n).keyPath,r="string"==typeof a?a:"["+o2(a).join("+")+"]";if(t[o]){let e=t[o].idxByName[r];e&&(e.name=n,delete t[o].idxByName[r],t[o].idxByName[n]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&oW.WorkerGlobalScope&&oW instanceof oW.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class lb{_parseStoresSpec(e,t){oG(e).forEach(n=>{if(null!==e[n]){var a=e[n].split(",").map((e,t)=>{let n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),a=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return lt(n,a||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),oV(a),0===t)}),r=a.shift();if(r.multi)throw new iS.Schema("Primary key cannot be multi-valued");a.forEach(e=>{if(e.auto)throw new iS.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new iS.Schema("Index must have a name and cannot be an empty string")}),t[n]=la(n,r,a)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?oU(this._cfg.storesSource,e):e;let n=t._versions,a={},r={};return n.forEach(e=>{oU(a,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(a,r)}),t._dbSchema=r,lp(t,[t._allTables,t,t.Transaction.prototype]),lu(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],oG(r),r),t._storeNames=oG(r),this}upgrade(e){return this._cfg.contentUpgrade=iR(this._cfg.contentUpgrade||iz,e),this}}function l_(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new lj("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function lv(e){return e&&"function"==typeof e.databases}function l$(e){return sy(function(){return i3.letThrough=!0,e()})}function lA(e){var t=t=>e.next(t),n=r(t),a=r(t=>e.throw(t));function r(e){return t=>{var r=e(t),o=r.value;return r.done?o:o&&"function"==typeof o.then?o.then(n,a):oV(o)?Promise.all(o).then(n,a):n(o)}}return r(t)()}function lw(e,t,n){var a=arguments.length;if(a<2)throw new iS.InvalidArgument("Too few arguments");for(var r=Array(a-1);--a;)r[a-1]=arguments[a];return n=r.pop(),[e,it(r),n]}function lk(e,t,n){let a=oV(e)?e.slice():[e];for(let e=0;e<n;++e)a.push(t);return a}let lx={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let n=e.table(t),{schema:a}=n,r={},o=[];function i(e,t,n){let a=ll(e),s=r[a]=r[a]||[],l=null==e?0:"string"==typeof e?1:e.length,c=t>0,u={...n,isVirtual:c,keyTail:t,keyLength:l,extractKey:lo(e),unique:!c&&n.unique};return s.push(u),u.isPrimaryKey||o.push(u),l>1&&i(2===l?e[0]:e.slice(0,l-1),t+1,n),s.sort((e,t)=>e.keyTail-t.keyTail),u}let s=i(a.primaryKey.keyPath,0,a.primaryKey);for(let e of(r[":id"]=[s],a.indexes))i(e.keyPath,0,e);function l(t){var n,a;let r=t.query.index;return r.isVirtual?{...t,query:{index:r,range:(n=t.query.range,a=r.keyTail,{type:1===n.type?2:n.type,lower:lk(n.lower,n.lowerOpen?e.MAX_KEY:e.MIN_KEY,a),lowerOpen:!0,upper:lk(n.upper,n.upperOpen?e.MIN_KEY:e.MAX_KEY,a),upperOpen:!0})}}:t}return{...n,schema:{...a,primaryKey:s,indexes:o,getIndexByKeyPath:function(e){let t=r[ll(e)];return t&&t[0]}},count:e=>n.count(l(e)),query:e=>n.query(l(e)),openCursor(t){let{keyTail:a,isVirtual:r,keyLength:o}=t.query.index;return r?n.openCursor(l(t)).then(n=>n&&Object.create(n,{continue:{value:function(r){null!=r?n.continue(lk(r,t.reverse?e.MAX_KEY:e.MIN_KEY,a)):t.unique?n.continue(n.key.slice(0,o).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,a)):n.continue()}},continuePrimaryKey:{value(t,r){n.continuePrimaryKey(lk(t,e.MAX_KEY,a),r)}},primaryKey:{get:()=>n.primaryKey},key:{get(){let e=n.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:()=>n.value}})):n.openCursor(t)}}}}}};function lC(e,t,n,a){return n=n||{},a=a||"",oG(e).forEach(r=>{if(oK(t,r)){var o=e[r],i=t[r];if("object"==typeof o&&"object"==typeof i&&o&&i){let e=il(o);e!==il(i)?n[a+r]=t[r]:"Object"===e?lC(o,i,n,a+r+"."):o!==i&&(n[a+r]=t[r])}else o!==i&&(n[a+r]=t[r])}else n[a+r]=void 0}),oG(t).forEach(r=>{oK(e,r)||(n[a+r]=t[r])}),n}let lE={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let n=e.table(t),{primaryKey:a}=n.schema;return{...n,mutate(e){let r=i3.trans,{deleting:o,creating:i,updating:s}=r.table(t).hook;switch(e.type){case"add":if(i.fire===iz)break;return r._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===iz&&s.fire===iz)break;return r._promise("readwrite",()=>l(e),!0);case"delete":if(o.fire===iz)break;return r._promise("readwrite",()=>l(e),!0);case"deleteRange":if(o.fire===iz)break;return r._promise("readwrite",()=>(function e(t,r,o){return n.query({trans:t,values:!1,query:{index:a,range:r},limit:o}).then(({result:n})=>l({type:"delete",keys:n,trans:t}).then(a=>a.numFailures>0?Promise.reject(a.failures[0]):n.length<o?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...r,lower:n[n.length-1],lowerOpen:!0},o)))})(e.trans,e.range,1e4),!0)}return n.mutate(e);function l(e){var t,r;let l=i3.trans,c=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(a.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"===(r=e).type?Promise.resolve([]):n.getMany({trans:r.trans,keys:c,cache:"immutable"})).then(t=>{let r=c.map((n,r)=>{let c=t[r],u={onerror:null,onsuccess:null};if("delete"===e.type)o.fire.call(u,n,c,l);else if("add"===e.type||void 0===c){let t=i.fire.call(u,n,e.values[r],l);null==n&&null!=t&&(n=t,e.keys[r]=n,a.outbound||o7(e.values[r],a.keyPath,n))}else{let t=lC(c,e.values[r]),a=s.fire.call(u,t,n,c,l);if(a){let t=e.values[r];Object.keys(a).forEach(e=>{oK(t,e)?t[e]=a[e]:o7(t,e,a[e])})}}return u});return n.mutate(e).then(({failures:n,results:a,numFailures:o,lastResult:i})=>{for(let o=0;o<c.length;++o){let i=a?a[o]:c[o],s=r[o];null==i?s.onerror&&s.onerror(n[o]):s.onsuccess&&s.onsuccess("put"===e.type&&t[o]?e.values[o]:i)}return{failures:n,results:a,numFailures:o,lastResult:i}}).catch(e=>(r.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function lS(e,t,n){try{if(!t||t.keys.length<e.length)return null;let a=[];for(let r=0,o=0;r<t.keys.length&&o<e.length;++r)0===sK(t.keys[r],e[o])&&(a.push(n?ii(t.values[r]):t.values[r]),++o);return a.length===e.length?a:null}catch(e){return null}}let lD={stack:"dbcore",level:-1,create:e=>({table:t=>{let n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);let t=lS(e.keys,e.trans._cache,"clone"===e.cache);return t?i8.resolve(t):n.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?ii(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function lM(e){return!("from"in e)}let lz=function(e,t){if(!this){let t=new lz;return e&&"d"in e&&oU(t,e),t}oU(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function lO(e,t,n){let a=sK(t,n);if(isNaN(a))return;if(a>0)throw RangeError();if(lM(e))return oU(e,{from:t,to:n,d:1});let r=e.l,o=e.r;if(0>sK(n,e.from))return r?lO(r,t,n):e.l={from:t,to:n,d:1,l:null,r:null},lB(e);if(sK(t,e.to)>0)return o?lO(o,t,n):e.r={from:t,to:n,d:1,l:null,r:null},lB(e);0>sK(t,e.from)&&(e.from=t,e.l=null,e.d=o?o.d+1:1),sK(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;r&&!e.l&&lP(e,r),o&&i&&lP(e,o)}function lP(e,t){lM(t)||function e(t,{from:n,to:a,l:r,r:o}){lO(t,n,a),r&&e(t,r),o&&e(t,o)}(e,t)}function lT(e){let t=lM(e)?null:{s:0,n:e};return{next(e){let n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&0>sK(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||0>=sK(e,t.n.to))return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function lB(e){var t,n;let a=((null==(t=e.r)?void 0:t.d)||0)-((null==(n=e.l)?void 0:n.d)||0),r=a>1?"r":a<-1?"l":"";if(r){let t="r"===r?"l":"r",n={...e},a=e[r];e.from=a.from,e.to=a.to,e[r]=a[r],n[r]=a[t],e[t]=n,n.d=lI(n)}e.d=lI(e)}function lI({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}oY(lz.prototype,{add(e){return lP(this,e),this},addKey(e){return lO(this,e,e),this},addKeys(e){return e.forEach(e=>lO(this,e,e)),this},[ic](){return lT(this)}});let lN={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,n=new lz(e.MIN_KEY,e.MAX_KEY);return{...e,table:a=>{let r=e.table(a),{schema:o}=r,{primaryKey:i}=o,{extractKey:s,outbound:l}=i,c={...r,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let n=`idb://${t}/${a}/${e}`;return s[n]||(s[n]=new lz)},c=l(""),u=l(":dels"),{type:p}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return r.mutate(e).then(e=>{if(oV(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let t=lS(d,h);t||"add"===p||u.addKeys(d),(t||f)&&o.indexes.forEach(function(e){let n=l(e.name||"");function a(t){return null!=t?e.extractKey(t):null}let r=t=>e.multiEntry&&oV(t)?t.forEach(e=>n.addKey(e)):n.addKey(t);(t||f).forEach((e,n)=>{let o=t&&a(t[n]),i=f&&a(f[n]);0!==sK(o,i)&&(null!=o&&r(o),null!=i&&r(i))})})}else if(d){let e={from:d.lower,to:d.upper};u.add(e),c.add(e)}else c.add(n),u.add(n),o.indexes.forEach(e=>l(e.name).add(n));return e})}},u=({query:{index:t,range:n}})=>{var a,r;return[t,new lz(null!=(a=n.lower)?a:e.MIN_KEY,null!=(r=n.upper)?r:e.MAX_KEY)]},p={get:e=>[i,new lz(e.key)],getMany:e=>[i,(new lz).addKeys(e.keys)],count:u,query:u,openCursor:u};return oG(p).forEach(e=>{c[e]=function(o){let{subscr:i}=i3;if(i){let c=e=>{let n=`idb://${t}/${a}/${e}`;return i[n]||(i[n]=new lz)},u=c(""),d=c(":dels"),[f,h]=p[e](o);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&o.values&&r.query({...o,values:!1});return r[e].apply(this,arguments).then(n=>{if("query"===e){if(l&&o.values)return t.then(({result:e})=>(u.addKeys(e),n));let e=o.values?n.result.map(s):n.result;o.values?u.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=o.values;return n&&Object.create(n,{key:{get:()=>(d.addKey(n.primaryKey),n.key)},primaryKey:{get(){let e=n.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&u.addKey(n.primaryKey),n.value)}})}return n})}d.add(n)}}return r[e].apply(this,arguments)}}),c}}}};class lj{constructor(e,t){var n;this._middlewares={},this.verno=0;const a=lj.dependencies;this._options=t={addons:lj.addons,autoOpen:!0,indexedDB:a.indexedDB,IDBKeyRange:a.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:r}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:iz,dbReadyPromise:null,cancelOpen:iz,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new i8(e=>{o.dbReadyResolve=e}),o.openCanceller=new i8((e,t)=>{o.cancelOpen=t}),this._state=o,this.name=e,this.on=sR(this,"populate","blocked","versionchange","close",{ready:[iR,iz]}),this.on.ready.subscribe=o3(this.on.ready.subscribe,e=>(t,n)=>{lj.vip(()=>{let a=this._state;if(a.openComplete)a.dbOpenError||i8.resolve().then(t),n&&e(t);else if(a.onReadyBeingFired)a.onReadyBeingFired.push(t),n&&e(t);else{e(t);let a=this;n||e(function e(){a.on.ready.unsubscribe(t),a.on.ready.unsubscribe(e)})}})}),this.Collection=(n=this,sF(sZ.prototype,function(e,t){this.db=n;let a=sI,r=null;if(t)try{a=t()}catch(e){r=e}let o=e._ctx,i=o.table,s=i.hook.reading.fire;this._ctx={table:i,index:o.index,isPrimKey:!o.index||i.schema.primKey.keyPath&&o.index===i.schema.primKey.name,range:a,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:s!==iO?s:null}})),this.Table=function(e){return sF(sj.prototype,function(t,n,a){this.db=e,this._tx=a,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:sR(null,{creating:[iB,iz],reading:[iP,iO],updating:[iN,iz],deleting:[iI,iz]})})}(this),this.Transaction=function(e){return sF(le.prototype,function(t,n,a,r,o){this.db=e,this.mode=t,this.storeNames=n,this.schema=a,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=sR(this,"complete","error","abort"),this.parent=o||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 i8((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),sD(e)})})}(this),this.Version=function(e){return sF(lb.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return sF(s6.prototype,function(t,n,a){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:a};let r=e._deps.indexedDB;if(!r)throw new iS.MissingAPI;this._cmp=this._ascending=r.cmp.bind(r),this._descending=(e,t)=>r.cmp(t,e),this._max=(e,t)=>r.cmp(e,t)>0?e:t,this._min=(e,t)=>0>r.cmp(e,t)?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=lr(t.IDBKeyRange),this._createTransaction=(e,t,n,a)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,a),this._fireOnBlocked=e=>{this.on("blocked").fire(e),sO.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(lx),this.use(lE),this.use(lN),this.use(lD),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new iS.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new iS.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let t=this._versions;var n=t.filter(t=>t._cfg.version===e)[0];return n||(n=new this.Version(e),t.push(n),t.sort(ld),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||i3.letThrough||this._vip)?e():new i8((e,t)=>{if(this._state.openComplete)return t(new iS.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new iS.DatabaseClosed);this.open().catch(iz)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:n,name:a}){a&&this.unuse({stack:e,name:a});let r=this._middlewares[e]||(this._middlewares[e]=[]);return r.push({stack:e,create:t,level:null==n?10:n,name:a}),r.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>n?e.create!==n:!!t&&e.name!==t)),this}open(){return function(e){var t;let n=e._state,{indexedDB:a}=e._deps;if(n.isBeingOpened||e.idbdb)return n.dbReadyPromise.then(()=>n.dbOpenError?sD(n.dbOpenError):e);im&&(n.openCanceller._stackHolder=ib()),n.isBeingOpened=!0,n.dbOpenError=null,n.openComplete=!1;let r=n.openCanceller;function o(){if(n.openCanceller!==r)throw new iS.DatabaseClosed("db.open() was cancelled")}let i=n.dbReadyResolve,s=null,l=!1;return i8.race([r,("u"<typeof navigator?i8.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(()=>new i8((t,r)=>{if(o(),!a)throw new iS.MissingAPI;let i=e.name,c=n.autoSchema?a.open(i):a.open(i,Math.round(10*e.verno));if(!c)throw new iS.MissingAPI;c.onerror=s8(r),c.onblocked=su(e._fireOnBlocked),c.onupgradeneeded=su(t=>{if(s=c.transaction,n.autoSchema&&!e._options.allowEmptyDB){c.onerror=s7,s.abort(),c.result.close();let e=a.deleteDatabase(i);e.onsuccess=e.onerror=su(()=>{r(new iS.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let n,a,i,d;s.onerror=s8(r);var o,u,p=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=p<1,e._novip.idbdb=c.result,o=p/10,u=s,n=e._dbSchema,(a=e._createTransaction("readwrite",e._storeNames,n)).create(u),a._completion.catch(r),i=a._reject.bind(a),d=i3.transless||i3,sy(()=>{i3.trans=a,i3.transless=d,0===o?(oG(n).forEach(e=>{lh(u,e,n[e].primKey,n[e].indexes)}),lc(e,u),i8.follow(()=>e.on.populate.fire(a)).catch(i)):(function({_novip:e},t,n,a){let r=[],o=e._versions,i=e._dbSchema=lg(e,e.idbdb,a),s=!1;return o.filter(e=>e._cfg.version>=t).forEach(o=>{r.push(()=>{let r=i,l=o._cfg.dbschema;ly(e,r,a),ly(e,l,a),i=e._dbSchema=l;let c=lf(r,l);c.add.forEach(e=>{lh(a,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new iS.Upgrade("Not yet support for changing primary key");{let t=a.objectStore(e.name);e.add.forEach(e=>lm(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),lm(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let u=o._cfg.contentUpgrade;if(u&&o._cfg.version>t){let t;lc(e,a),n._memoizedTables={},s=!0;let o=o9(l);c.del.forEach(e=>{o[e]=r[e]}),lp(e,[e.Transaction.prototype]),lu(e,[e.Transaction.prototype],oG(o),o),n.schema=o;let i=ih(u);i&&sb();let p=i8.follow(()=>{if((t=u(n))&&i){var e=s_.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?i8.resolve(t):p.then(()=>t)}}),r.push(t=>{var a;s&&sP||(a=o._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==a[e]&&t.db.deleteObjectStore(e))),lp(e,[e.Transaction.prototype]),lu(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),n.schema=e._dbSchema})}),(function e(){return r.length?i8.resolve(r.shift()(n.idbtrans)).then(e):i8.resolve()})().then(()=>{var e;oG(e=i).forEach(t=>{a.db.objectStoreNames.contains(t)||lh(a,t,e[t].primKey,e[t].indexes)})})})(e,o,a,u).catch(i)})}},r),c.onsuccess=su(()=>{s=null;let a=e._novip.idbdb=c.result,r=o2(a.objectStoreNames);if(r.length>0)try{let t,o=a.transaction(1===r.length?r[0]:r,"readonly");n.autoSchema?function({_novip:e},t,n){e.verno=t.version/10;let a=e._dbSchema=lg(0,t,n);e._storeNames=o2(t.objectStoreNames,0),lu(e,[e._allTables],oG(a),a)}(e,a,o):(ly(e,e._dbSchema,o),((t=lf(lg(0,e.idbdb,o),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),lc(e,o)}catch(e){}sO.push(e),a.onversionchange=su(t=>{n.vcFired=!0,e.on("versionchange").fire(t)}),a.onclose=su(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},n){lv(e)||"__dbnames"===n||l_(e,t).put({name:n}).catch(iz)}(e._deps,i),t()},r)}))]).then(()=>(o(),n.onReadyBeingFired=[],i8.resolve(l$(()=>e.on.ready.fire(e.vip))).then(function t(){if(n.onReadyBeingFired.length>0){let a=n.onReadyBeingFired.reduce(iR,iz);return n.onReadyBeingFired=[],i8.resolve(l$(()=>a(e.vip))).then(t)}}))).finally(()=>{n.onReadyBeingFired=null,n.isBeingOpened=!1}).then(()=>e).catch(t=>{n.dbOpenError=t;try{s&&s.abort()}catch(e){}return r===n.openCanceller&&e._close(),sD(t)}).finally(()=>{n.openComplete=!0,i()})}(this)}_close(){let e=this._state,t=sO.indexOf(this);if(t>=0&&sO.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new i8(t=>{e.dbReadyResolve=t}),e.openCanceller=new i8((t,n)=>{e.cancelOpen=n})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new iS.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new i8((n,a)=>{let r=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=su(()=>{!function({indexedDB:e,IDBKeyRange:t},n){lv(e)||"__dbnames"===n||l_(e,t).delete(n).catch(iz)}(this._deps,this.name),n()}),e.onerror=s8(a),e.onblocked=this._fireOnBlocked};if(e)throw new iS.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(r):r()})}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 oG(this._allTables).map(e=>this._allTables[e])}transaction(){let e=lw.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let a,r,o=i3.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(r=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||"readonly"===e)a="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new iS.InvalidArgument("Invalid transaction mode: "+e);a="readwrite"}if(o){if("readonly"===o.mode&&"readwrite"===a){if(!i)throw new iS.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&r.forEach(e=>{if(o&&-1===o.storeNames.indexOf(e)){if(!i)throw new iS.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),i&&o&&!o.active&&(o=null)}}catch(e){return o?o._promise(null,(t,n)=>{n(e)}):sD(e)}let s=(function e(t,n,a,r,o){return i8.resolve().then(()=>{let i,s=i3.transless||i3,l=t._createTransaction(n,a,t._dbSchema,r);if(r)l.idbtrans=r.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(r){return r.name===iE.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,a,null,o))):sD(r)}let c=ih(o);c&&sb();let u=i8.follow(()=>{if(i=o.call(l,l))if(c){var e=s_.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=lA(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?i8.resolve(i).then(e=>l.active?e:sD(new iS.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>i)).then(e=>(r&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),sD(e)))})}).bind(null,this,a,r,o,n);return o?o._promise(a,s,"lock"):i3.trans?sx(i3.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!oK(this._allTables,e))throw new iS.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let lR="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class lF{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[lR](){return this}}function lL(e,t){return oG(t).forEach(n=>{lP(e[n]||(e[n]=new lz),t[n])}),e}try{o={indexedDB:oW.indexedDB||oW.mozIndexedDB||oW.webkitIndexedDB||oW.msIndexedDB,IDBKeyRange:oW.IDBKeyRange||oW.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function lW(e){let t=lG;try{lG=!0,s9.storagemutated.fire(e)}finally{lG=t}}oY(lj,{...iM,delete:e=>new lj(e,{addons:[]}).delete(),exists:e=>new lj(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return lv(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>"__dbnames"!==e)):l_(e,t).toCollection().primaryKeys()})(lj.dependencies).then(e)}catch(e){return sD(new iS.MissingAPI)}},defineClass:()=>function(e){oU(this,e)},ignoreTransaction:e=>i3.trans?sx(i3.transless,e):e(),vip:l$,async:function(e){return function(){try{var t=lA(e.apply(this,arguments));return t&&"function"==typeof t.then?t:i8.resolve(t)}catch(e){return sD(e)}}},spawn:function(e,t,n){try{var a=lA(e.apply(n,t||[]));return a&&"function"==typeof a.then?a:i8.resolve(a)}catch(e){return sD(e)}},currentTransaction:{get:()=>i3.trans||null},waitFor:function(e,t){let n=i8.resolve("function"==typeof e?lj.ignoreTransaction(e):e).timeout(t||6e4);return i3.trans?i3.trans.waitFor(n):n},Promise:i8,debug:{get:()=>im,set:e=>{im=e,ig="dexie"===e?()=>!0:sT}},derive:oX,extend:oU,props:oY,override:o3,Events:sR,on:s9,liveQuery:function(e){return new lF(t=>{let n=ih(e),a=!1,r={},o={},i={get closed(){return a},unsubscribe:()=>{a=!0,s9.storagemutated.unsubscribe(u)}};t.start&&t.start(i);let s=!1,l=!1;function c(){return oG(o).some(e=>r[e]&&function(e,t){let n=lT(t),a=n.next();if(a.done)return!1;let r=a.value,o=lT(e),i=o.next(r.from),s=i.value;for(;!a.done&&!i.done;){if(0>=sK(s.from,r.to)&&sK(s.to,r.from)>=0)return!0;0>sK(r.from,s.from)?r=(a=n.next(s.from)).value:s=(i=o.next(r.from)).value}return!1}(r[e],o[e]))}let u=e=>{lL(r,e),c()&&p()},p=()=>{let d,f;if(s||a)return;r={};let h={},m=(n&&sb(),d=()=>sy(e,{subscr:h,trans:null}),f=i3.trans?sx(i3.transless,d):d(),n&&f.then(s_,s_),f);l||(s9("storagemutated",u),l=!0),s=!0,Promise.resolve(m).then(e=>{s=!1,a||(c()?p():(r={},o=h,t.next&&t.next(e)))},e=>{s=!1,t.error&&t.error(e),i.unsubscribe()})};return p(),i})},extendObservabilitySet:lL,getByKeyPath:o8,setByKeyPath:o7,delByKeyPath:function(e,t){"string"==typeof t?o7(e,t,void 0):"length"in t&&[].map.call(t,function(t){o7(e,t,void 0)})},shallowClone:o9,deepClone:ii,getObjectDiff:lC,cmp:sK,asap:o5,minKey:-1/0,addons:[],connections:sO,errnames:iE,dependencies:o,semVer:"3.2.2",version:"3.2.2".split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),lj.maxKey=lr(lj.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(s9("storagemutated",e=>{if(!lG){let t;sP?(t=document.createEvent("CustomEvent")).initCustomEvent("x-storagemutated-1",!0,!0,e):t=new CustomEvent("x-storagemutated-1",{detail:e}),lG=!0,dispatchEvent(t),lG=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{lG||lW(e)}));let lG=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel("x-storagemutated-1");s9("storagemutated",t=>{lG||e.postMessage(t)}),e.onmessage=e=>{e.data&&lW(e.data)}}else if("u">typeof self&&"u">typeof navigator){s9("storagemutated",e=>{try{lG||("u">typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:"x-storagemutated-1",changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if("x-storagemutated-1"===e.key){let t=JSON.parse(e.newValue);t&&lW(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&"x-storagemutated-1"===e.type&&lW(e.changedParts)})}function lV(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}i8.rejectionMapper=function(e,t){if(!e||e instanceof iw||e instanceof TypeError||e instanceof SyntaxError||!e.name||!iD[e.name])return e;var n=new iD[e.name](t||e.message,e);return"stack"in e&&oZ(n,"stack",{get:function(){return this.inner.stack}}),n},ig=sT;class lU extends lj{constructor(){super("EsmOffline"),lV(this,"syncQueue",void 0),lV(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 lq(){return new lU}let lH=new lU,lK={},lY=U("offline-synchronization",{});function lJ(){return lY}async function lZ(){if(lY.getState().synchronization)return;let e=await lH.syncQueue.count(),t={},n=Object.entries(lK),a=n.length,r={},o=new AbortController,i=()=>{let e=lY.getState().synchronization;lY.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{lY.setState({synchronization:{totalCount:e,pendingCount:e,abortController:o}});for(let e=0;e<a&&n.length>0;e++)for(let e=n.length;e--;){let[a,s]=n[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(r[a]={},await Promise.all(l),t[a]=lX(s,r,o,i),n.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{lY.setState({synchronization:void 0})}}async function lX({type:e,dependsOn:t,process:n},a,r,o){let i=[],s=[],l=await lQ();await lH.syncQueue.where({type:e,userId:l}).each((e,t)=>{i.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<i.length;c++){let[u,p,{id:d,dependencies:f=[]}]=i[c];try{let o=await n(p,{abort:r,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:n})=>t.includes(n)?a[n][e]:void 0)});void 0!==d&&(a[e][d]=o),await lH.syncQueue.delete(u)}catch(e){await lH.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{o()}}}async function lQ(){let e=await a$();return e?.uuid||"*"}async function l0(e,t,n,a){let r=a&&a.id;return void 0!==r&&await lH.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===r).delete().catch(lj.errnames.DatabaseClosed),await lH.syncQueue.add({type:t,content:n,userId:e,descriptor:a||{},createdOn:new Date}).catch(lj.errnames.DatabaseClosed,()=>-1)}async function l1(e,t,n){let a=await lQ();return await l0(a,e,t,n)}async function l2(e,t){return(await l3(e,t)).map(e=>e.content)}async function l3(e,t){return await lH.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(lj.errnames.DatabaseClosed,()=>[])}async function l4(e){let t=await lQ();return await l2(t,e)}async function l5(e){let t=await lQ();return await l3(t,e)}async function l6(e){return await lH.syncQueue.get(e).catch(lj.errnames.DatabaseClosed,()=>void 0)}function l8(e){return!!lK[e]?.options.onBeginEditSyncItem}async function l7(e){let t=await l6(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let n=lK[t.type]?.options.onBeginEditSyncItem;if(!n)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);n(t)}async function l9(e){await lH.syncQueue.delete(e).catch(lj.errnames.DatabaseClosed)}function ce(e,t,n,a={}){lK[e]={type:e,dependsOn:t,process:n,options:a}}var ct=n(8414);let cn="OFFLINE+";function ca(){return cn+(0,ct.A)()}function cr(e){return e.startsWith(cn)}let co={};function ci(){return Object.values(co)}function cs(e){co[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.`),co[e.id]=e}async function cl(e){let t=await cg();return await cc(t,e)}async function cc(e,t){let n=new lU;return await n.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(lj.errnames.DatabaseClosed,()=>[])}async function cu(e,t){let n=await cg();return await cp(n,e,t)}async function cp(e,t,n){let a=new lU,r=await a.dynamicOfflineData.get({type:t,identifier:n}).catch(lj.errnames.DatabaseClosed,()=>void 0);r?r.users.includes(e)||await a.dynamicOfflineData.update(r.id,{users:[...r.users,e]}).catch(lj.errnames.DatabaseClosed):await a.dynamicOfflineData.add({users:[e],type:t,identifier:n}).catch(lj.errnames.DatabaseClosed)}async function cd(e,t){let n=await cg();return await cf(n,e,t)}async function cf(e,t,n){let a=new lU,r=await a.dynamicOfflineData.get({type:t,identifier:n,users:e}).catch(lj.errnames.DatabaseClosed,()=>void 0);r&&(r.users.length>1?await a.dynamicOfflineData.update(r.id,{users:r.users.filter(t=>t!==e)}).catch(lj.errnames.DatabaseClosed):await a.dynamicOfflineData.delete(r.id).catch(lj.errnames.DatabaseClosed))}async function ch(e,t){let n=await cl(e);await Promise.all(n.map(async e=>cm(e.type,e.identifier,t)))}async function cm(e,t,n){await cu(e,t);let a=new lU,r=await cg(),o=await a.dynamicOfflineData.get({type:e,identifier:t}).catch(lj.errnames.DatabaseClosed,()=>void 0),i=ci().filter(t=>t.type===e);if(!o)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(t,n),{id:e.id,error:void 0}}catch(n){let t=n.message?.toString()??n.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),p={syncedOn:new Date,syncedBy:r,succeededHandlers:l,erroredHandlers:c,errors:u};o.id&&await a.dynamicOfflineData.update(o.id,{syncState:p}).catch(lj.errnames.DatabaseClosed)}async function cg(){let e=(await a$()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let cy=U("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function cb(){return c$(),cy}function c_(e,t){c$(),cs({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,n)=>t.onOfflinePatientAdded({patientUuid:e,signal:n??new AbortController().signal})})}async function cv(e){c$(),await cm("patient",e)}function c$(){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 cA(e,t,n=!0){if(e){let a=null,[r,o]=await Promise.all([au(`${as}/Patient/${e}`,t).catch(e=>a=e),n?cw(e):Promise.resolve(null)]);if(r.ok)return r.data;if(o)return o;if(a)throw a}return null}async function cw(e){let t=(await l4("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function ck(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function cx(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}var cC=n(6170);function cE(e){return{uuid:e.uuid,display:e.display}}function cS(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let a=n.toString();return ap(`${ai}/location${a?"?"+a:""}`).pipe((0,cC.map)(e=>e.data.results.map(cE))).pipe((0,cC.take)(1))}function cD(e){return{uuid:e.uuid,display:e.display,name:e.name}}function cM(){return ap(`${ai}/visittype`).pipe((0,cC.map)(e=>e.data.results.map(cD))).pipe((0,cC.take)(1))}var cz=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),cO=function(e){function t(t,n){var a=e.call(this)||this;return a.subject=t,a.subscriber=n,a.closed=!1,a}return ea(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(ep),cP=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return ea(t,e),t}(eh),cT=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return ea(t,e),t.prototype[ef]=function(){return new cP(this)},t.prototype.lift=function(e){var t=new cB(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new cz;if(!this.isStopped)for(var t=this.observers,n=t.length,a=t.slice(),r=0;r<n;r++)a[r].next(e)},t.prototype.error=function(e){if(this.closed)throw new cz;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,a=t.slice(),r=0;r<n;r++)a[r].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new cz;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),a=0;a<t;a++)n[a].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new cz},t.prototype._subscribe=function(e){if(this.closed)throw new cz;return this.hasError?(e.error(this.thrownError),ep.EMPTY):this.isStopped?(e.complete(),ep.EMPTY):(this.observers.push(e),new cO(this,e))},t.prototype.asObservable=function(){var e=new ey;return e.source=this,e},t.create=function(e,t){return new cB(e,t)},t}(ey),cB=function(e){function t(t,n){var a=e.call(this)||this;return a.destination=t,a.source=n,a}return ea(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):ep.EMPTY},t}(cT),cI=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return ea(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new cz},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(cT),cN=((Z={}).NEWVISIT="startVisit",Z.EDITVISIT="editVisit",Z.LOADING="loadingVisit",Z),cj=((X={}).NOTSTARTED="notStarted",X.ONGOING="ongoing",X);let cR="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))",cF=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function cL(){return H("visit",cF)}function cW(e,t){cL().setState({patientUuid:e,manuallySetVisitUuid:t})}function cG(e,t){return au(`${ai}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function cV(e,t,n){return au(`${ai}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function cU(e,t,n){return au(`${ai}/visit?patient=${e}&v=${n??cR}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}cL().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let cq=new cI(null);class cH{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+cH.version}static addUnaryOp(e){return cH.max_unop_len=Math.max(e.length,cH.max_unop_len),cH.unary_ops[e]=1,cH}static addBinaryOp(e,t,n){return cH.max_binop_len=Math.max(e.length,cH.max_binop_len),cH.binary_ops[e]=t,n?cH.right_associative.add(e):cH.right_associative.delete(e),cH}static addIdentifierChar(e){return cH.additional_identifier_chars.add(e),cH}static addLiteral(e,t){return cH.literals[e]=t,cH}static removeUnaryOp(e){return delete cH.unary_ops[e],e.length===cH.max_unop_len&&(cH.max_unop_len=cH.getMaxKeyLen(cH.unary_ops)),cH}static removeAllUnaryOps(){return cH.unary_ops={},cH.max_unop_len=0,cH}static removeIdentifierChar(e){return cH.additional_identifier_chars.delete(e),cH}static removeBinaryOp(e){return delete cH.binary_ops[e],e.length===cH.max_binop_len&&(cH.max_binop_len=cH.getMaxKeyLen(cH.binary_ops)),cH.right_associative.delete(e),cH}static removeAllBinaryOps(){return cH.binary_ops={},cH.max_binop_len=0,cH}static removeLiteral(e){return delete cH.literals[e],cH}static removeAllLiterals(){return cH.literals={},cH}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 cH(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 cH.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!cH.binary_ops[String.fromCharCode(e)]||cH.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return cH.isIdentifierStart(e)||cH.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(cH.hooks[e]){let n={context:this,node:t};return cH.hooks.run(e,n),n.node}return t}searchHook(e){if(cH.hooks[e]){let t={context:this};return cH.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===cH.SPACE_CODE||e===cH.TAB_CODE||e===cH.LF_CODE||e===cH.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:cH.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],n,a;for(;this.index<this.expr.length;)if((n=this.code)===cH.SEMCOL_CODE||n===cH.COMMA_CODE)this.index++;else if(a=this.gobbleExpression())t.push(a);else if(this.index<this.expr.length){if(n===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,cH.max_binop_len),t=e.length;for(;t>0;){if(cH.binary_ops.hasOwnProperty(e)&&(!cH.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!cH.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,n,a,r,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(r={value:t,prec:cH.binaryPrecedence(t),right_a:cH.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),a=[o,r,i];t=this.gobbleBinaryOp();){if(0===(n=cH.binaryPrecedence(t))){this.index-=t.length;break}r={value:t,prec:n,right_a:cH.right_associative.has(t)},l=t;let s=e=>r.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;a.length>2&&s(a[a.length-2]);)i=a.pop(),t=a.pop().value,o=a.pop(),e={type:cH.BINARY_EXP,operator:t,left:o,right:i},a.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),a.push(r,e)}for(s=a.length-1,e=a[s];s>1;)e={type:cH.BINARY_EXP,operator:a[s-1].value,left:a[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,n,a;if(this.gobbleSpaces(),a=this.searchHook("gobble-token"))return this.runHook("after-token",a);if(e=this.code,cH.isDecimalDigit(e)||e===cH.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===cH.SQUOTE_CODE||e===cH.DQUOTE_CODE)a=this.gobbleStringLiteral();else if(e===cH.OBRACK_CODE)a=this.gobbleArray();else{for(n=(t=this.expr.substr(this.index,cH.max_unop_len)).length;n>0;){if(cH.unary_ops.hasOwnProperty(t)&&(!cH.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!cH.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=n;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:cH.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--n)}cH.isIdentifierStart(e)?(a=this.gobbleIdentifier(),cH.literals.hasOwnProperty(a.name)?a={type:cH.LITERAL,value:cH.literals[a.name],raw:a.name}:a.name===cH.this_str&&(a={type:cH.THIS_EXP})):e===cH.OPAREN_CODE&&(a=this.gobbleGroup())}return a?(a=this.gobbleTokenProperty(a),this.runHook("after-token",a)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===cH.PERIOD_CODE||t===cH.OBRACK_CODE||t===cH.OPAREN_CODE||t===cH.QUMARK_CODE;){let n;if(t===cH.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==cH.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===cH.OBRACK_CODE?((e={type:cH.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==cH.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===cH.OPAREN_CODE?e={type:cH.CALL_EXP,arguments:this.gobbleArguments(cH.CPAREN_CODE),callee:e}:(t===cH.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:cH.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,n;for(;cH.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===cH.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);cH.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));cH.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);cH.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return n=this.code,cH.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(n===cH.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===cH.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:cH.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,n=this.expr.charAt(this.index++),a=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){a=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return a||this.throwError('Unclosed quote after "'+e+'"'),{type:cH.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(cH.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,cH.isIdentifierPart(e))this.index++;else break;return{type:cH.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],n=!1,a=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let r=this.code;if(r===e){n=!0,this.index++,e===cH.CPAREN_CODE&&a&&a>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(r===cH.COMMA_CODE){if(this.index++,++a!==t.length){if(e===cH.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===cH.CBRACK_CODE)for(let e=t.length;e<a;e++)t.push(null)}}else if(t.length!==a&&0!==a)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==cH.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(cH.CPAREN_CODE);if(this.code===cH.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:cH.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:cH.ARRAY_EXP,elements:this.gobbleArguments(cH.CBRACK_CODE)}}}Object.assign(cH,{hooks:new class{add(e,t,n){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(cH),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"}),cH.max_unop_len=cH.getMaxKeyLen(cH.unary_ops),cH.max_binop_len=cH.getMaxKeyLen(cH.binary_ops);let cK=e=>new cH(e).parse(),cY=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(cH).filter(e=>!cY.includes(e)&&void 0===cK[e]).forEach(e=>{cK[e]=cH[e]}),cK.Jsep=cH,cK.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:a,alternate:r},n.operator&&e.binary_ops[n.operator]<=.9){let a=n;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=n}}else this.throwError("Expected :")}})}});let cJ="ArrowFunctionExpression",cZ={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)}},cX={...cZ,Promise};function cQ(e,t={}){return c5(e,t,c7)}async function c0(e,t={}){return c6(e,t,c7)}function c1(e,t={}){return c5(e,t,c9)}function c2(e,t={}){return c6(e,t,c9)}function c3(e,t={}){return c5(e,t,ue)}function c4(e,t={}){return c6(e,t,ue)}function c5(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let a=ua(t,cZ),r=ut("string"==typeof e?cK(e):e,a);if(n(r))return r;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 c6(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let a=ua(t,cX);return Promise.resolve(ut("string"==typeof e?cK(e):e,a)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function c8(e){return cK(e)}function c7(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function c9(e){return"boolean"==typeof e}function ue(e){return"number"==typeof e}function ut(e,t){switch(e.type){case"UnaryExpression":var n,a,r,o,i,s,l,c,u,p,d,f,h=e,m=t;let g=ut(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 y=e,b=t;let v=ut(y.left,b),$=ut(y.right,b);switch(y.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 '${y.operator}' operator`}case"ConditionalExpression":return n=e,a=t,ut(n.test,a)?ut(n.consequent,a):ut(n.alternate,a);case"CallExpression":var A=e,w=t;let k=A.arguments?.map(ur(w)),x=ut(A.callee,w);if(x){if("function"!=typeof x)throw`${ui(A.callee)} is not a function`}else throw`No function named ${ui(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return r=e,o=t,C=r.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 t=Object.fromEntries(C.reduce((t,n,a)=>{let r=e[a];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(r)&&t.push([n,r]),t},[]));return ut(r.body,o.addVariables(t))}).bind(o.thisObj??null);case"MemberExpression":return function(e,t){let n,a=ut(e.object,t);if(void 0===a)switch(e.object.type){case"Identifier":{let n=un(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":{let n=un(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${n}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let r=a;if("string"==typeof a)r=String.prototype;else if("number"==typeof a)r=Number.prototype;else if("function"==typeof a);else if("object"!=typeof a)throw`VisitMemberExpression does not support member access on type ${typeof a}`;switch(t.thisObj=r,e.property.type){case"Identifier":case"MemberExpression":n=ut(e.property,t);break;default:{let r=ut(e.property,t);if(void 0===r)throw{type:"Illegal property access",message:"No property was supplied to the property access"};uo(r),n=a[r]}}return"function"==typeof n?n.bind(a):n}(e,t);case"ArrayExpression":return i=e,s=t,i.elements?.map(ur(s));case"SequenceExpression":let E;return l=e,c=t,(E=l.expressions.map(ur(c)))[E.length-1];case"NewExpression":var S=e,D=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(ur(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 uo((u=e).value),u.value;case"Identifier":var M=e,z=t;uo(M.name);let O=z.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&M.name in O){let e=O[M.name];return uo(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return uo(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let P,T;return p=e,d=t,P=p.expressions?.map(ur(d))??[],(T=p.quasis?.map(ur(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.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 un(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return un(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function ua(e,t){let n={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}function ur(e){return function(t){return null===t?null:ut(t,e)}}function uo(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function ui(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function us(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...cX},isLocalExpression:!1,variables:new Set};return ul("string"==typeof e?cK(e):e,t),[...t.variables]}function ul(e,t){switch(e.type){case"UnaryExpression":return a=e,r=t,ul(a.argument,r);case"BinaryExpression":return o=e,i=t,[ul(o.left,i),ul(o.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[ul(s.consequent,l),ul(s.test,l),ul(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return c=e,u=t,n=ul(c.callee,u),c.arguments?.map(uc(u)),n;case"ArrowFunctionExpression":var a,r,o,i,s,l,c,u,p,d,f,h,m,g,y,b,v,$,A=e,w=t;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(uc(k))??[],C=ul(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 p=e,d=t,ul(p.object,d),void((E={...d}).isLocalExpression=!0,ul(p.property,E));case"ArrayExpression":return f=e,h=t,void f.elements?.map(uc(h));case"SequenceExpression":return m=e,g=t,void m.expressions?.map(uc(g));case"NewExpression":return y=e,b=t,void y.arguments?.map(uc(b));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=t;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=t,void(v.expressions?.map(uc($)),v.quasis?.map(uc($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function uc(e){return function(t){return null===t?null:ul(t,e)}}cK.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let n=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let n=this.gobbleBinaryExpression();n||this.throwError("Expected expression after "+e),t.node={type:cJ,params:null,body:n};return}}this.index=n}}),e.hooks.add("after-expression",function(t){!function t(n){n&&(Object.values(n).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===n.operator&&(n.type=cJ,n.params=n.left?[n.left]:null,n.body=n.right,n.params&&n.params[0].type===e.SEQUENCE_EXP&&(n.params=n.params[0].expressions),delete n.left,delete n.right,delete n.operator))}(t.node)})}}),cK.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let n=t.node;if(n&&"new"===n.operator){n.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(n.argument.type)||this.throwError("Expected new function()"),t.node=n.argument;let a=t.node;for(;a.type===e.MEMBER_EXP||a.type===e.CALL_EXP&&a.callee.type===e.MEMBER_EXP;)a=a.type===e.MEMBER_EXP?a.object:a.callee.object;a.type="NewExpression"}})}}),cK.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function n(t){let n=this.index,a="",r=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:a+=this.expr.charAt(this.index++)};r(),this.code===e.PERIOD_CODE&&(a+=this.expr.charAt(this.index++),r());let o=this.char;("e"===o||"E"===o)&&(a+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(a+=this.expr.charAt(this.index++)),r(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+a+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+a+this.char+")");else if(i===e.PERIOD_CODE){a.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:a},null,2)}`),this.index=n;return}t.node={type:e.LITERAL,value:parseFloat(a),raw:this.expr.substring(n,this.index)}}e.hooks.add("gobble-token",function(a){if(48===this.code){var r,o,i;let s=this.index,l=this.expr.charAt(this.index+1),c=t.call(this,l);if(!c)return;let u="";for(;r=this.code,o=c,95===r||o.some(([e,t])=>r>=e&&r<=t);)95===this.code?this.index++:u+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,n.call(this,a);return}this.throwError("unexpected char within number")}a.node={type:e.LITERAL,value:parseInt(u,"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)&&n.call(this,a)})}}),cK.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let n=++this.index,a=!1;for(;this.index<this.expr.length;){if(47===this.code&&!a){let a,r=this.expr.slice(n,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{a=new RegExp(r,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:a,raw:this.expr.slice(n-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?a=!0:a&&this.code===e.CBRACK_CODE&&(a=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),cK.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:a,alternate:r},n.operator&&e.binary_ops[n.operator]<=.9){let a=n;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=n}}else this.throwError("Expected :")}})}}),cK.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,n=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},a="",r="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:r,cooked:a},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=t,n&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),r="",a="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(r+=i,i=this.expr.charAt(++this.index),r+=i,i){case"n":a+="\n";break;case"r":a+="\r";break;case"t":a+=" ";break;case"b":a+="\b";break;case"f":a+="\f";break;case"v":a+="\v";break;default:a+=i}else a+=i,r+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(n){if((n.node.type===e.IDENTIFIER||n.node.type===e.MEMBER_EXP)&&96===this.code)return n.node={type:"TaggedTemplateExpression",tag:n.node,quasi:t.bind(this)(n,!1)},n.node=this.gobbleTokenProperty(n.node),n.node})}}),cK.addBinaryOp("in",7),cK.addBinaryOp("??",1);let uu=H("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),a=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...a}}return e}()});function up(e,t,n){uu.setState(a=>({flags:{...a.flags,[e]:{enabled:a.flags[e]?.enabled??!1,label:t,description:n}}}))}function ud(){let e=uu.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function uf(e){return uu.getState().flags[e].enabled}function uh(e,t){uu.subscribe(n=>{t(n.flags[e].enabled)})}function um(e,t){uu.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}function ug(e){return!window.offlineEnabled||(e??navigator.onLine)}function uy(e=!0,t=!1){return ub(ug(),e,t)}function ub(e,t=!0,n=!1){return!!(e?t:n)}uu.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});let u_=U("extensionsInternal",{slots:{},extensions:{}}),uv=U("extensionRenderings",{renderings:new Map}),u$=()=>H("extensionsInternal",{slots:{},extensions:{}}),uA=()=>H("extensionRenderings",{renderings:new Map});function uw(e){let t=u_.getState(),n=e(t);n!==t&&u_.setState(n)}let uk=null,ux=null;function uC(){let e=uv.getState();return uk&&e===ux||(uk=new Map(e.renderings),ux=e,function(e){for(let t of(uI.clear(),e.values()))uj(t,1);uN=!0}(uk)),uk}function uE(e){ux={renderings:e},uv.setState(ux,!0)}function uS(e){let t=uC();t.has(e.renderingId)||(t.set(e.renderingId,e),uj(e,1),uE(t))}function uD(e){let t=uC(),n=t.get(e);n&&(t.delete(e),uj(n,-1),uE(t))}let uM=()=>H("extensions",{slots:{}}),uz=0,uO=new Set;function uP(e){uz++;try{return e()}finally{if(0==--uz&&uO.size>0){let e=Array.from(uO);for(let t of(uO.clear(),e))uT(t)}}}function uT(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function uB(e){uz>0?uO.add(e):uT(e)}let uI=new Map,uN=!1;function uj(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),a=uI.get(n);if(!a){if(t<0)return;uI.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),uN=!0;return}a.count+=t,a.count<1&&(uI.delete(n),uN=!0)}function uR(){var e,t;if(uC(),!uN)return;uN=!1;let n=Array.from(uI.values(),({record:e})=>e);n.sort(uF),e=eD.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===uF(e,t[n]))||eD.setState({mountedExtensions:n})}function uF(e,t){return uL(e.slotName,t.slotName)||uL(e.extensionId,t.extensionId)||uL(e.slotModuleName,t.slotModuleName)||uL(e.extensionModuleName,t.extensionModuleName)}function uL(e,t){return e===t?0:e<t?-1:1}uR(),uv.subscribe(()=>uB(uR));let uW=u$(),uG=uM(),uV=ez(),uU=eT(),uq=new Set,uH=!1;function uK(e){if(null===e)uq=null;else if(null!==uq)for(let t of e)uq.add(t);uB(uY)}function uY(){if(!uH){uH=!0;try{for(let e=1;;e++){let t=uq;if(null!==t&&0===t.size)return;uq=new Set;try{!function(e,t,n,a,r,o=null){let i=uG.getState().slots,s={},l=!1,c=ug(),u=Object.entries(a.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[a,p]of Object.entries(e.slots)){let d=i[a];if(d&&o&&!o.has(a)){s[a]=d;continue}let{config:f}=eP(t,p.name),h=function(e,t,n,a,r,o,i){let s=function(e,t){let n=e.add||[],a=e.remove||[],r=e.order||[],{extensions:o}=uW.getState();return[...t,...n].filter(e=>!a.includes(e)).sort((e,n)=>u6(e,r,o[uQ(e)]?.order,t)-u6(n,r,o[uQ(n)]?.order,t))}(n,t.slots[e].attachedIds),l=[];for(let c of s){let{config:s}=eI(a,e,c),u=eN(n,e,c),p=u?(0,et.merge)({},s,u):s,d=uQ(c),f=t.extensions[d];if(f){let e=p?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!i?.user||!av(e,i.user))||f.featureFlag&&!r.includes(f.featureFlag)||window.offlineEnabled&&!ub(o,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:p,featureFlag:f.featureFlag,meta:f.meta,online:p?.["Display conditions"]?.online??f.online??!0,offline:p?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:p?.["Display conditions"]?.expression||f.displayExpression})}}return l}(a,e,f,n,u,c,r.session);d&&d.moduleName===p.moduleName&&(0,et.isEqual)(d.candidateExtensions,h)?s[a]=d:(s[a]={moduleName:p.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&uG.setState({slots:s})}(uW.getState(),uV.getState(),uU.getState(),uu.getState(),af.getState(),t)}catch(e){throw uq=null===t||null===uq?null:new Set([...t,...uq]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{uH=!1}}}function uJ(e,t){let n=new Set;for(let a of Object.keys(e))e[a]!==t[a]&&n.add(a);for(let a of Object.keys(t))a in e||n.add(a);return n}function uZ(){uK(null)}function uX(e,t){return{moduleName:t,name:e,attachedIds:[]}}function uQ(e){let[t]=e.split("#");return t}function u0(e,t){let n=uQ(t);return e.extensions[n]}function u1(e){return u0(uW.getState(),e)}uW.subscribe((e,t)=>{uK(e.extensions!==t.extensions?null:uJ(e.slots,t.slots))}),uV.subscribe((e,t)=>{uK(uJ(e.slots,t.slots))}),uU.subscribe((e,t)=>{uK(uJ(e.configs,t.configs))}),uu.subscribe(()=>uK(null)),af.subscribe(()=>uK(null)),uZ(),y(uZ);let u2=e=>uw(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function u3(e,t){uw(n=>{let a=n.slots[e];return a?{...n,slots:{...n.slots,[e]:{...a,attachedIds:[...a.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...uX(e),attachedIds:[t]}}}})}function u4(e,t){uw(n=>{let a=n.slots[e];return a&&a.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...a,attachedIds:a.attachedIds.filter(e=>e!==t)}}}:n})}function u5(e){uw(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function u6(e,t,n,a){let r=t.indexOf(e);if(-1!==r)return r;{if(void 0!==n)return 1e3+n;let t=a.indexOf(e);return -1!==t?2e3+t:3e3}}function u8(e,t){return function(e,t,n=null,a){let r;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;r??(r=t&&"object"==typeof t?{session:n,...t}:{session:n});try{return!!c1(o,r)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(a?` in ${a}`:""),t),!1}})}(u7(e),t,af.getState().session,e)}function u7(e){return uG.getState().slots[e]?.candidateExtensions??[]}let u9=(e,t)=>uW.setState(n=>{let a=n.slots[t]?.moduleName;if(a&&a!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${a}.`),n;if(a&&a==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let r=uX(t,e);return{...n,slots:{...n.slots,[t]:{...r}}}}),pe=()=>{uq=null,uw(()=>({slots:{},extensions:{}})),uA().setState({renderings:new Map}),uG.setState({slots:{}})},pt=U("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function pn({name:e,basePath:t,mode:n,componentContext:a,state:r}){pt.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:a,state:r})}function pa(e){pt.getState().slotName===e&&pt.setState(pt.getInitialState(),!0)}let pr=U("modalRegistry",{modals:{}});function po(e){pr.setState(t=>(t.modals[e.name]=e,t))}function pi(e){let t=pr.getState().modals[e];if(!t){let n=u1(e);n&&(t={name:e,load:n.load,moduleName:n.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.`),po(t))}return t}let ps=U("workspaceRegistrations",{workspaces:{}}),pl=U("workspaceGroups",{workspaceGroups:{}});function pc(e){ps.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function pu(e){pl.setState(t=>{let n=t.workspaceGroups[e.name];return n?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...n,members:Array.from(new Set([...n.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let pp=new Set;function pd(e){let t=ps.getState().workspaces;if(t[e])return t[e];{let t=u1(e);if(t){var n;let a;return pp.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.`),pp.add(e)),{name:t.name,title:(n=t,"string"==typeof(a=n?.meta?.title)?a:a&&"object"==typeof a?rC(n.moduleName,a.key,a.default):n.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function pf(e){let t=pl.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let ph=U("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function pm(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=ph.getState(),a=t[e];if(a){let t=n[a.window];if(t)return t;throw Error(`No workspace window found with name: ${a.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function pg(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=ph.getState(),a=n[e];if(a){let n=t[a.group];if(n)return n;throw Error(`No workspace group found with name: ${a.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function py(e){let{openedWindows:t}=ph.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function pb(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=ph.getState(),a={...n};for(let n of t){if(a[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);a[n.name]={...n,moduleName:e}}ph.setState({registeredGroupsByName:a})}function p_(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=ph.getState(),a={...n};for(let n of t){if(a[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};a[n.name]=t}ph.setState({registeredWindowsByName:a})}function pv(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=ph.getState(),a={...n};for(let n of t){if(a[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};a[n.name]=t}ph.setState({registeredWorkspacesByName:a})}let p$=0,pA=null,pw={bootstrap:{millis:15e3,dieOnTimeout:!0},mount:{millis:15e3,dieOnTimeout:!0},unmount:{millis:15e3,dieOnTimeout:!0}};async function pk(e,t){return(await (pA??(pA=new Promise((e,t)=>{nl({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),nl))),pA))("function"==typeof e?()=>e().then(e=>({timeouts:pw,...e})):{timeouts:pw,...e},t)}function px(){return pC}function pC(e,t){let n,a=pk(e,t).then(e=>n=e);return{mount:()=>a.then(e=>e.mount()),unmount:()=>a.then(e=>e.unmount()),update:e=>a.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return a.then(e=>e.loadPromise)},get bootstrapPromise(){return a.then(e=>e.bootstrapPromise)},get mountPromise(){return a.then(e=>e.mountPromise)},get unmountPromise(){return a.then(e=>e.unmountPromise)}}}async function pE(e,t,n,a,r=e=>e,o={}){let i=uQ(a),s=u1(a),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(uy(p,d)){let s,p=p$++,d=`${t}/${a}-${p}`;e.dataset.extensionRenderingId=d;let h=e=>{try{uD(d)}catch(t){console.error(e,t)}};try{uS({renderingId:d,extensionName:i,extensionModuleName:u,extensionId:a,slotName:t,slotModuleName:n})}catch(e){throw h(`Recomputing configuration after registering '${a}' failed also failed`),e}try{s=await f()}catch(e){throw h(`Recomputing configuration after '${a}' failed to load also failed`),e}try{l=await pk(r({...s,name:`${t}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:a,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:u},domElement:e})}catch(e){throw h(`Recomputing configuration after '${a}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${a}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${a}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${a}' failed`),e=>{console.error(`Extension '${a}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${a}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${a} into ${t} but no DOM element was available.`);return l}var pS=n(7979),pD=n.n(pS);let pM=(0,pS.createContext)({moduleName:"",featureName:""});function pz({to:e,templateParams:t,onBeforeNavigate:n,children:a,...r}){return(0,pS.useEffect)(()=>{r.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${r.href}'`),r.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),pD().createElement("a",{onClick:a=>{0===a.button&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&!a.metaKey&&(a.preventDefault(),n?.(a),n6({to:e,templateParams:t})),0===a.button&&(a.ctrlKey||a.metaKey)&&n?.(a),0===a.button&&a.shiftKey&&n?.(a),1===a.button&&n?.(a)},href:n4(e,t),...r},a)}let pO=({state:e,children:t,...n})=>{let{extension:a}=(0,pS.useContext)(pM),r=(0,pS.useRef)(null),o=(0,pS.useRef)(Promise.resolve()),i=(0,pS.useRef)(!1),s=(0,pS.useRef)(!1),l=(0,pS.useRef)(e),c=(0,pS.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),u=(0,pS.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(r.current?.getStatus()==="MOUNTED"&&r.current.update)return r.current.update({...t})}).catch(e=>{let t=r.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${a?.extensionId}' failed to update`,e)}))},[]),p=(0,pS.useCallback)(t=>{t&&!r.current&&!s.current&&a?.extensionSlotName&&a.extensionSlotModuleName&&(s.current=!0,pE(t,a.extensionSlotName,a.extensionSlotModuleName,a.extensionId,void 0,e).then(t=>{(s.current=!1,r.current=t,i.current)?c(t):t&&l.current!==e&&u(t,l.current)},()=>{s.current=!1}))},[]);return(0,pS.useEffect)(()=>(i.current=!1,()=>{i.current=!0,c(r.current)}),[]),(0,pS.useEffect)(()=>{l.current=e,r.current&&u(r.current,e)},[e]),a?pD().createElement("div",{ref:p,"data-extension-id":a?.extensionId,style:{position:"relative"},...n}):null};function pP(e){let t=(0,pS.useRef)(e);return j(t.current,e)||(t.current=e),t.current}function pT(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[a,r]of Object.entries(t)){let t=function(...t){e.setState(e=>r(e,...t))};n[a]=t}return n}let pB=e=>e;function pI(e,t=pB,n){let a=(0,pS.useCallback)(t=>e.subscribe(t),[e]),r=(0,pS.useCallback)(()=>t(e.getState()),[e,t]),o=(0,pS.useSyncExternalStore)(a,r,r),i=(0,pS.useMemo)(()=>n?pT(e,n):null,[e,n]);return(0,pS.useMemo)(()=>i?{...o,...i}:o,[o,i])}function pN(e,t){return pI(e,pB,t)}function pj(e){return function(t){let n=(0,pS.useCallback)(t=>e.subscribe(t),[]),a=(0,pS.useCallback)(()=>e.getState(),[]),r=(0,pS.useSyncExternalStore)(n,a,a),o=(0,pS.useMemo)(()=>t?pT(e,t):null,[t]);return(0,pS.useMemo)(()=>o?{...r,...o}:r,[r,o])}}let pR=[];Object.freeze(pR);let pF={candidateExtensions:pR};Object.freeze(pF);let pL=e=>{let t=(0,pS.useCallback)(t=>t.slots?.[e]??pF,[e]);return pI(uM(),t)},pW=e=>e.session;function pG(e,t){let{candidateExtensions:n}=pL(e),a=pI(af,pW),r=pP(t);return(0,pS.useMemo)(()=>u8(e,r),[e,r,a,n])}function pV(e,t){let{moduleName:n}=(0,pS.useContext)(pM);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,pS.useEffect)(()=>{u9(n,e)},[n,e]),{extensions:pG(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function pU(e){return e}function pq({name:e,extensionSlotName:t,select:n=pU,children:a,state:r,style:o,...i}){if(a&&r)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,pS.useRef)(null),{extensions:c,extensionSlotModuleName:u}=pV(s,r),p=(0,pS.useMemo)(()=>n(c),[n,c]),d=(0,pS.useMemo)(()=>{if("function"==typeof a&&!pD().isValidElement(a))return p.map(e=>a(e,r))},[a,p]);return pD().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...o,position:"relative"},...i},s&&p?.map((e,t)=>pD().createElement(pM.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[t]??("function"!=typeof a?a:null)??pD().createElement(pO,{state:r}))))}var pH=n(5338);function pK(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function pY(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pK(Object(n),!0).forEach(function(t){var a,r,o;a=e,r=t,o=n[t],r in a?Object.defineProperty(a,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[r]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pK(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pJ(e){return(pJ="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 pZ(e){return(pZ="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 pX(e,t){var n;if("function"!=typeof(n=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var n="single-spa-application:".concat(t);return function(){var e=document.getElementById(n);return e||((e=document.createElement("div")).id=n,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(pZ(n)));return function(){var e=n(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(pZ(e)));return e}}var pQ=null;try{pQ=require("react").createContext()}catch(e){}var p0={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 p1(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function p2(e,t){return new Promise(function(n,a){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var r,o=p6(e,t,function(){n(this)}),i=pX(e,t)(),s=function(e){var t=e.reactDom,n=e.renderType,a=e.elementToRender,r=e.domElement,o=t[n];if("function"!=typeof o)throw Error('renderType "'.concat(n,'" did not return a function.'));switch(n){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(r);return i.render(a),i;case"hydrateRoot":return o(r,a);default:return o(a,r),null}}({elementToRender:o,domElement:i,reactDom:p5(e),renderType:"function"==typeof(r=e).renderType?r.renderType():r.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function p3(e,t){return new Promise(function(n){e.unmountResolves[t.name]=n;var a=e.renderResults[t.name];a&&a.unmount?a.unmount():p5(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function p4(e,t){return new Promise(function(n){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(n);var a=p6(e,t,null),r=e.renderResults[t.name];if(r&&r.render)r.render(a);else{var o=pX(e,t)();p5(e).render(a,o)}})}function p5(e){return e.ReactDOMClient||e.ReactDOM}function p6(e,t,n){var a=e.React.createElement(e.rootComponent,t),r=pQ?e.React.createElement(pQ.Provider,{value:t},a):a;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function n(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},n.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},n.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},n}(e,t),r=e.React.createElement(e.errorBoundaryClass,t,r)),r=e.React.createElement(e.SingleSpaRoot,pY(pY({},t),{},{mountFinished:n,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),r)}var p8=n(3826),p7=n(9324),p9=n(7956);let de={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},dt=new Map;(0,p9.initCache)(dt);let dn={errorRetryCount:3,fetcher:au,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof ad){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>dt};function da(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},de,e),n={...dn,...t.swrConfig};return function(e){var a,r,o,i,s;return o=r=class extends(a=pD().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return pD().createElement("div",null,"An error has occurred. Please try reloading the page.");{let a=pD().createElement(pS.Suspense,{fallback:null},pD().createElement(p7.BE,{value:n},pD().createElement(pM.Provider,{value:this.state.config},t.disableTranslations?pD().createElement(e,this.props):pD().createElement(p8.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},pD().createElement(e,this.props)))));return t.strictMode&&pD().StrictMode?pD().createElement(pD().StrictMode,null,a):a}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,r}}function dr(e,t){return function(e){if("object"!==pJ(e))throw Error("single-spa-react requires a configuration object");var t,n=pY(pY({},p0),e);if(!n.React)throw Error("single-spa-react must be passed opts.React");if(!n.ReactDOM&&!n.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(n.renderType||(null!=(t=n.ReactDOMClient)&&t.createRoot?n.renderType="createRoot":n.renderType="render"),!n.rootComponent&&!n.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(n.errorBoundary&&"function"!=typeof n.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!pQ&&n.React.createContext&&(pQ=n.React.createContext()),n.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(n);var a={bootstrap:p1.bind(null,n),mount:p2.bind(null,n),unmount:p3.bind(null,n)};return n.parcelCanUpdate&&(a.update=p4.bind(null,n)),a}({React:pD(),ReactDOMClient:pH,rootComponent:da(t)(e)})}function di(e,t){return()=>e().then(({default:e})=>dr(e,t))}function ds(e,t){return()=>Promise.resolve(dr(e,t))}let dl=di,dc=W()(()=>({}));q("openmrs-app-context",dc);let du={};function dp(e,t=e=>e){let n=dc.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function dd(e,t){dc.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function df(e){return null===e?null:Object.freeze(Object.assign({},e))}let dh=new Map;function dm(e,t){let n=(0,pS.useRef)(t??{}),a=(0,pS.useRef)(t=>dd(e,t)),r=(0,pS.useRef)(Symbol());return(0,pS.useEffect)(()=>{let n=t??{},a=r.current;return null===dp(e)?!function(e,t=du){dc.setState(n=>{if(e in n)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({},n,{[e]:t===du?{}:t})})}(e,n):(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.`),dd(e,()=>n)),dh.set(e,a),()=>{dh.get(e)===a&&(dc.setState(t=>(e in t&&delete t[e],t)),dh.delete(e))}},[e]),(0,pS.useEffect)(()=>{let a=t??{};j(n.current,a)||(dd(e,()=>a),n.current=a)},[t]),a.current}function dg({namespace:e,value:t}){return dm(e,t),null}let dy=({children:e,value:t,fallback:n})=>t?pD().createElement(pD().Fragment,null,e):n?pD().createElement(pD().Fragment,null,n):null;function db(){let e=(0,pS.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,pS.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function d_(e,t=e=>e??{}){let[n,a]=(0,pS.useState)(()=>{if(dv(e))return;let n=dp(e);if(null!==n)return t?t(n):n});return(0,pS.useEffect)(()=>{if(dv(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,pS.useEffect)(()=>{var n;let r;return(n=e=>{if(null==e)return void a(void 0);let n=t?t(e):e;a(e=>j(e,n)?e:n)})(df(r=dp(e))),dc.subscribe(t=>{let a=e in t?t[e]:null;a!==r&&(r=a,n(df(a)))})},[e,t]),n}function dv(e){return"string"!=typeof e||0===e.trim().length}function d$(e){let t=pG(e);return(0,pS.useMemo)(()=>t.map(e=>e.id),[t])}function dA(e){return pL(e).candidateExtensions}function dw(e,t){let{data:n,error:a,mutate:r,isLoading:o,isValidating:i}=(0,p7.Ay)(`${op}?patient=${e}&includeEncounterless=${t}`,au);return(0,pS.useMemo)(()=>({isLoading:o,data:n?.data.results??[],error:a,mutate:r,isValidating:i}),[n,a,o,i,r])}function dk(e){(0,pS.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let dx={},dC=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let af=U("session",{loaded:!1,session:null}),ah=0;function am(e={includeAuthStatus:!0}){return(ah<Date.now()-6e4||!af.getState().loaded)&&ab(),new ey(t=>{let n=n=>{n.loaded&&(e.includeAuthStatus?t.next(n.session):t.next(n.session?.user))};return n(af.getState()),af.subscribe(n)})}function ag(){return(ah<Date.now()-6e4||!af.getState().loaded)&&ab(),af}function ay(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function ab(e,t){ah=Date.now();let n={};return e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),ax(au(al,{headers:n}))}function a_(){af.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function av(e,t){var n,a;if(void 0===t)return!e;if(!e)return!0;return n=e,a=t,("string"==typeof n?!(0,et.isUndefined)(a.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!(0,et.isUndefined)(a.privileges.find(t=>e===t.display))):((0,et.isUndefined)(n)||console.error(`Could not understand privileges "${n}"`),!0))||!(0,et.isUndefined)(t.roles.find(e=>"System Developer"===e.display))}function a$(){let e,t;return new Promise(n=>{let a=a=>{a.loaded&&a.session.user&&(e=a.session.user,n(a.session.user),t&&t())};a(af.getState()),e||(t=af.subscribe(a))})}function aA(){return new Promise((e,t)=>{am().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function aw(e,t){return ax(au(al,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function ak(e,t,n){return n||(n=new AbortController),await au(`${ai}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),ab()}function ax(e){return new Promise((t,n)=>{e.then(e=>{let a;"object"==typeof e?.data?(a={loaded:!0,session:e.data},af.setState(a),t(a)):(a={loaded:!1,session:null},af.setState(a),n(a))}).catch(e=>{B(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};af.setState(t),n(t)})})}function aC(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}af.subscribe(e=>{e.loaded&&e.session&&ay(e.session)});let aE={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function aS(){e0("@openmrs/esm-api",ar),ab()}let aD={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var aM=n(2284),az=n(3029),aO=n(2901);function aP(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var aT=n(3662);function aB(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&(0,aT.A)(e,t)}function aI(e,t){if(t&&("object"==(0,aM.A)(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return aP(e)}function aN(e){return(aN=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var aj=n(4467),aR=n(6369),aF=n(3612),aL=n(6562);function aW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function aG(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?aW(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var aV={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},aU=new(function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,az.A)(this,e),this.init(t,n)}return(0,aO.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||aV,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,a){return a&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,aG(aG({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),aq=function(){function e(){(0,az.A)(this,e),this.observers={}}return(0,aO.A)(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach(function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)}),this}},{key:"off",value:function(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e]=this.observers[e].filter(function(e){return e!==t})}}},{key:"emit",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];this.observers[e]&&[].concat(this.observers[e]).forEach(function(e){e.apply(void 0,n)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(t){t.apply(t,[e].concat(n))})}}]),e}();function aH(){var e,t,n=new Promise(function(n,a){e=n,t=a});return n.resolve=e,n.reject=t,n}function aK(e){return null==e?"":""+e}function aY(e,t,n){function a(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function r(){return!e||"string"==typeof e}for(var o="string"!=typeof t?[].concat(t):t.split(".");o.length>1;){if(r())return{};var i=a(o.shift());!e[i]&&n&&(e[i]=new n),e=Object.prototype.hasOwnProperty.call(e,i)?e[i]:{}}return r()?{}:{obj:e,k:a(o.shift())}}function aJ(e,t,n){var a=aY(e,t,Object);a.obj[a.k]=n}function aZ(e,t){var n=aY(e,t),a=n.obj,r=n.k;if(a)return a[r]}function aX(e,t,n){var a=aZ(e,n);return void 0!==a?a:aZ(t,n)}function aQ(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var a0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function a1(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return a0[e]}):e}var a2="u">typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,a3=[" ",",","?","!",";"];function a4(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function a5(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a4(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a4(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var a6=function(e){aB(a,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aN(a);return e=t?Reflect.construct(n,arguments,aN(this).constructor):n.apply(this,arguments),aI(this,e)});function a(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return(0,az.A)(this,a),t=n.call(this),a2&&aq.call(aP(t)),t.data=e||{},t.options=r,void 0===t.options.keySeparator&&(t.options.keySeparator="."),void 0===t.options.ignoreJSONStructure&&(t.options.ignoreJSONStructure=!0),t}return(0,aO.A)(a,[{key:"addNamespaces",value:function(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,o=void 0!==a.ignoreJSONStructure?a.ignoreJSONStructure:this.options.ignoreJSONStructure,i=[e,t];n&&"string"!=typeof n&&(i=i.concat(n)),n&&"string"==typeof n&&(i=i.concat(r?n.split(r):n)),e.indexOf(".")>-1&&(i=e.split("."));var s=aZ(this.data,i);return s||!o||"string"!=typeof n?s:function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(t){if(t[n])return t[n];for(var r=n.split(a),o=t,i=0;i<r.length;++i){if(!o||"string"==typeof o[r[i]]&&i+1<r.length)return;if(void 0===o[r[i]]){for(var s=2,l=r.slice(i,i+s).join(a),c=o[l];void 0===c&&r.length>i+s;)s++,c=o[l=r.slice(i,i+s).join(a)];if(void 0===c)return;if(null===c)return null;if(n.endsWith(l)){if("string"==typeof c)return c;if(l&&"string"==typeof c[l])return c[l]}var u=r.slice(i+s).join(a);if(u)return e(c,u,a);return}o=o[r[i]]}return o}}(this.data&&this.data[e]&&this.data[e][t],n,r)}},{key:"addResource",value:function(e,t,n,a){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},o=this.options.keySeparator;void 0===o&&(o=".");var i=[e,t];n&&(i=i.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(i=e.split("."),a=t,t=i[1]),this.addNamespaces(t),aJ(this.data,i,a),r.silent||this.emit("added",e,t,n,a)}},{key:"addResources",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var r in n)("string"==typeof n[r]||"[object Array]"===Object.prototype.toString.apply(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});a.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,a,r){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},i=[e,t];e.indexOf(".")>-1&&(i=e.split("."),a=n,n=t,t=i[1]),this.addNamespaces(t);var s=aZ(this.data,i)||{};a?function e(t,n,a){for(var r in n)"__proto__"!==r&&"constructor"!==r&&(r in t?"string"==typeof t[r]||t[r]instanceof String||"string"==typeof n[r]||n[r]instanceof String?a&&(t[r]=n[r]):e(t[r],n[r],a):t[r]=n[r]);return t}(s,n,r):s=a5(a5({},s),n),aJ(this.data,i,s),o.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return(t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI)?a5(a5({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(function(e){return t[e]&&Object.keys(t[e]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),a}(aq),a8={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,a,r){var o=this;return e.forEach(function(e){o.processors[e]&&(t=o.processors[e].process(t,n,a,r))}),t}};function a7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function a9(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a7(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var re={},rt=function(e){aB(a,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aN(a);return e=t?Reflect.construct(n,arguments,aN(this).constructor):n.apply(this,arguments),aI(this,e)});function a(e){var t,r,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,az.A)(this,a),o=n.call(this),a2&&aq.call(aP(o)),t=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r=aP(o),t.forEach(function(t){e[t]&&(r[t]=e[t])}),o.options=i,void 0===o.options.keySeparator&&(o.options.keySeparator="."),o.logger=aU.create("translator"),o}return(0,aO.A)(a,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,r=t.ns||this.options.defaultNS||[],o=n&&e.indexOf(n)>-1,i=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!function(e,t,n){t=t||"",n=n||"";var a=a3.filter(function(e){return 0>t.indexOf(e)&&0>n.indexOf(e)});if(0===a.length)return!0;var r=new RegExp("(".concat(a.map(function(e){return"?"===e?"\\?":e}).join("|"),")")),o=!r.test(e);if(!o){var i=e.indexOf(n);i>0&&!r.test(e.substring(0,i))&&(o=!0)}return o}(e,n,a);if(o&&!i){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:r};var l=e.split(n);(n!==a||n===a&&this.options.ns.indexOf(l[0])>-1)&&(r=l.shift()),e=l.join(a)}return"string"==typeof r&&(r=[r]),{key:e,namespaces:r}}},{key:"translate",value:function(e,t,n){var r=this;if("object"!==(0,aM.A)(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var o=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(e[e.length-1],t),l=s.key,c=s.namespaces,u=c[c.length-1],p=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p&&"cimode"===p.toLowerCase()){if(d){var f=t.nsSeparator||this.options.nsSeparator;return o?(h.res="".concat(u).concat(f).concat(l),h):"".concat(u).concat(f).concat(l)}return o?(h.res=l,h):l}var h=this.resolve(e,t),m=h&&h.res,g=h&&h.usedKey||l,y=h&&h.exactUsedKey||l,b=Object.prototype.toString.apply(m),v=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,$=!this.i18nFormat||this.i18nFormat.handleAsObject,A="string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m;if($&&m&&A&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(b)&&("string"!=typeof v||"[object Array]"!==b)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var w=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,m,a9(a9({},t),{},{ns:c})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return o?(h.res=w,h):w}if(i){var k="[object Array]"===b,x=k?[]:{},C=k?y:g;for(var E in m)if(Object.prototype.hasOwnProperty.call(m,E)){var S="".concat(C).concat(i).concat(E);x[E]=this.translate(S,a9(a9({},t),{joinArrays:!1,ns:c})),x[E]===S&&(x[E]=m[E])}m=x}}else if($&&"string"==typeof v&&"[object Array]"===b)(m=m.join(v))&&(m=this.extendTranslation(m,e,t,n));else{var D=!1,M=!1,z=void 0!==t.count&&"string"!=typeof t.count,O=a.hasDefaultValue(t),P=z?this.pluralResolver.getSuffix(p,t.count,t):"",T=t["defaultValue".concat(P)]||t.defaultValue;!this.isValidLookup(m)&&O&&(D=!0,m=T),this.isValidLookup(m)||(M=!0,m=l);var B=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&M?void 0:m,I=O&&T!==m&&this.options.updateMissing;if(M||D||I){if(this.logger.log(I?"updateKey":"missingKey",p,u,l,I?T:m),i){var N=this.resolve(l,a9(a9({},t),{},{keySeparator:!1}));N&&N.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var j=[],R=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&R&&R[0])for(var F=0;F<R.length;F++)j.push(R[F]);else"all"===this.options.saveMissingTo?j=this.languageUtils.toResolveHierarchy(t.lng||this.language):j.push(t.lng||this.language);var L=function(e,n,a){var o=O&&a!==m?a:B;r.options.missingKeyHandler?r.options.missingKeyHandler(e,u,n,o,I,t):r.backendConnector&&r.backendConnector.saveMissing&&r.backendConnector.saveMissing(e,u,n,o,I,t),r.emit("missingKey",e,u,n,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&z?j.forEach(function(e){r.pluralResolver.getSuffixes(e,t).forEach(function(n){L([e],l+n,t["defaultValue".concat(n)]||T)})}):L(j,l,T))}m=this.extendTranslation(m,e,t,h,n),M&&m===l&&this.options.appendNamespaceToMissingKey&&(m="".concat(u,":").concat(l)),(M||D)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(u,":").concat(l):l,D?m:void 0):this.options.parseMissingKeyHandler(m))}return o?(h.res=m,h):m}},{key:"extendTranslation",value:function(e,t,n,a,r){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,a9(a9({},this.options.interpolation.defaultVariables),n),a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(a9(a9({},n),{interpolation:a9(a9({},this.options.interpolation),n.interpolation)}));var i,s="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(s){var l=e.match(this.interpolator.nestingRegexp);i=l&&l.length}var c=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(c=a9(a9({},this.options.interpolation.defaultVariables),c)),e=this.interpolator.interpolate(e,c,n.lng||this.language,n),s){var u=e.match(this.interpolator.nestingRegexp);i<(u&&u.length)&&(n.nest=!1)}!1!==n.nest&&(e=this.interpolator.nest(e,function(){for(var e=arguments.length,a=Array(e),i=0;i<e;i++)a[i]=arguments[i];return r&&r[0]===a[0]&&!n.context?(o.logger.warn("It seems you are nesting recursively key: ".concat(a[0]," in key: ").concat(t[0])),null):o.translate.apply(o,a.concat([t]))},n)),n.interpolation&&this.interpolator.reset()}var p=n.postProcess||this.options.postProcess,d="string"==typeof p?[p]:p;return null!=e&&d&&d.length&&!1!==n.applyPostProcessor&&(e=a8.handle(d,e,t,this.options&&this.options.postProcessPassResolved?a9({i18nResolved:a},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,a,r,o,i=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!i.isValidLookup(t)){var l=i.extractFromKey(e,s),c=l.key;n=c;var u=l.namespaces;i.options.fallbackNS&&(u=u.concat(i.options.fallbackNS));var p=void 0!==s.count&&"string"!=typeof s.count,d=p&&!s.ordinal&&0===s.count&&i.pluralResolver.shouldUseIntlApi(),f=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,h=s.lngs?s.lngs:i.languageUtils.toResolveHierarchy(s.lng||i.language,s.fallbackLng);u.forEach(function(e){i.isValidLookup(t)||(o=e,!re["".concat(h[0],"-").concat(e)]&&i.utils&&i.utils.hasLoadedNamespace&&!i.utils.hasLoadedNamespace(o)&&(re["".concat(h[0],"-").concat(e)]=!0,i.logger.warn('key "'.concat(n,'" for languages "').concat(h.join(", "),'" won\'t get resolved as namespace "').concat(o,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),h.forEach(function(n){if(!i.isValidLookup(t)){r=n;var o,l=[c];if(i.i18nFormat&&i.i18nFormat.addLookupKeys)i.i18nFormat.addLookupKeys(l,c,n,e,s);else{p&&(u=i.pluralResolver.getSuffix(n,s.count,s));var u,h="".concat(i.options.pluralSeparator,"zero");if(p&&(l.push(c+u),d&&l.push(c+h)),f){var m="".concat(c).concat(i.options.contextSeparator).concat(s.context);l.push(m),p&&(l.push(m+u),d&&l.push(m+h))}}for(;o=l.pop();)i.isValidLookup(t)||(a=o,t=i.getResource(n,e,o,s))}}))})}}),{res:t,usedKey:n,exactUsedKey:a,usedLng:r,usedNS:o}}},{key:"isValidLookup",value:function(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,a):this.resourceStore.getResource(e,t,n,a)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&void 0!==e[n])return!0;return!1}}]),a}(aq);function rn(e){return e.charAt(0).toUpperCase()+e.slice(1)}var ra=function(){function e(t){(0,az.A)(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=aU.create("languageUtils")}return(0,aO.A)(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return null;var t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map(function(e){return e.toLowerCase()}):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=rn(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=rn(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=rn(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach(function(e){if(!t){var a=n.formatLanguageCode(e);(!n.options.supportedLngs||n.isSupportedCode(a))&&(t=a)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var a=n.getLanguagePartFromCode(e);if(n.isSupportedCode(a))return t=a;t=n.options.supportedLngs.find(function(e){if(0===e.indexOf(a))return e})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,a=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],o=function(e){e&&(n.isSupportedCode(e)?r.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):"string"==typeof e&&o(this.formatLanguageCode(e)),a.forEach(function(e){0>r.indexOf(e)&&o(n.formatLanguageCode(e))}),r}}]),e}(),rr=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],ro={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(+(1!=e&&(e%10!=1||e%100==11)))},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:3*(e%100==3||e%100==4))},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},ri=["v1","v2","v3"],rs={zero:0,one:1,two:2,few:3,many:4,other:5},rl=function(){function e(t){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,az.A)(this,e),this.languageUtils=t,this.options=a,this.logger=aU.create("pluralResolver"),(!this.options.compatibilityJSON||"v4"===this.options.compatibilityJSON)&&("u"<typeof Intl||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(n={},rr.forEach(function(e){e.lngs.forEach(function(t){n[t]={numbers:e.nr,plurals:ro[e.fc]}})}),n)}return(0,aO.A)(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map(function(e){return"".concat(t).concat(e)})}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=this.getRule(e,n);return a?this.shouldUseIntlApi()?a.resolvedOptions().pluralCategories.sort(function(e,t){return rs[e]-rs[t]}).map(function(e){return"".concat(t.options.prepend).concat(e)}):a.numbers.map(function(a){return t.getSuffix(e,a,n)}):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this.getRule(e,n);return a?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(a.select(t)):this.getSuffixRetroCompatible(a,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,a=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),r=e.numbers[a];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===r?r="plural":1===r&&(r=""));var o=function(){return n.options.prepend&&r.toString()?n.options.prepend+r.toString():r.toString()};return"v1"===this.options.compatibilityJSON?1===r?"":"number"==typeof r?"_plural_".concat(r.toString()):o():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?o():this.options.prepend&&a.toString()?this.options.prepend+a.toString():a.toString()}},{key:"shouldUseIntlApi",value:function(){return!ri.includes(this.options.compatibilityJSON)}}]),e}();function rc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function ru(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rc(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var rp=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,az.A)(this,e),this.logger=aU.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return(0,aO.A)(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:a1,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?aQ(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?aQ(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?aQ(t.nestingPrefix):t.nestingPrefixEscaped||aQ("$t("),this.nestingSuffix=t.nestingSuffix?aQ(t.nestingSuffix):t.nestingSuffixEscaped||aQ(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,a){var r,o,i,s=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var u=function(e){if(0>e.indexOf(s.formatSeparator)){var r=aX(t,l,e);return s.alwaysFormat?s.format(r,void 0,n,ru(ru(ru({},a),t),{},{interpolationkey:e})):r}var o=e.split(s.formatSeparator),i=o.shift().trim(),c=o.join(s.formatSeparator).trim();return s.format(aX(t,l,i),c,n,ru(ru(ru({},a),t),{},{interpolationkey:i}))};this.resetRegExp();var p=a&&a.missingInterpolationHandler||this.options.missingInterpolationHandler,d=a&&a.interpolation&&void 0!==a.interpolation.skipOnVariables?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return c(e)}},{regex:this.regexp,safeValue:function(e){return s.escapeValue?c(s.escape(e)):c(e)}}].forEach(function(t){for(i=0;r=t.regex.exec(e);){var n=r[1].trim();if(void 0===(o=u(n)))if("function"==typeof p){var l=p(e,r,a);o="string"==typeof l?l:""}else if(a&&a.hasOwnProperty(n))o="";else if(d){o=r[0];continue}else s.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),o="";else"string"==typeof o||s.useRawValueToEscape||(o=aK(o));var c=t.safeValue(o);if(e=e.replace(r[0],c),d?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=r[0].length):t.regex.lastIndex=0,++i>=s.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var n,a,r=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=ru({},o);function s(e,t){var n=this.nestingOptionsSeparator;if(0>e.indexOf(n))return e;var a=e.split(new RegExp("".concat(n,"[ ]*{"))),r="{".concat(a[1]);e=a[0];var o=(r=this.interpolate(r,i)).match(/'/g),s=r.match(/"/g);(o&&o.length%2==0&&!s||s.length%2!=0)&&(r=r.replace(/'/g,'"'));try{i=JSON.parse(r),t&&(i=ru(ru({},t),i))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(r)}return delete i.defaultValue,e}for(i.applyPostProcessor=!1,delete i.defaultValue;n=this.nestingRegexp.exec(e);){var l=[],c=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var u=n[1].split(this.formatSeparator).map(function(e){return e.trim()});n[1]=u.shift(),l=u,c=!0}if((a=t(s.call(this,n[1].trim(),i),i))&&n[0]===e&&"string"!=typeof a)return a;"string"!=typeof a&&(a=aK(a)),a||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),a=""),c&&(a=l.reduce(function(e,t){return r.format(e,t,o.lng,ru(ru({},o),{},{interpolationkey:n[1].trim()}))},a.trim())),e=e.replace(n[0],a),this.regexp.lastIndex=0}return e}}]),e}();function rd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function rf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rd(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rd(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rh(e){var t={};return function(n,a,r){var o=a+JSON.stringify(r),i=t[o];return i||(i=e(a,r),t[o]=i),i(n)}}var rm=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,az.A)(this,e),this.logger=aU.create("formatter"),this.options=t,this.formats={number:rh(function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}}),currency:rh(function(e,t){var n=new Intl.NumberFormat(e,rf(rf({},t),{},{style:"currency"}));return function(e){return n.format(e)}}),datetime:rh(function(e,t){var n=new Intl.DateTimeFormat(e,rf({},t));return function(e){return n.format(e)}}),relativetime:rh(function(e,t){var n=new Intl.RelativeTimeFormat(e,rf({},t));return function(e){return n.format(e,t.range||"day")}}),list:rh(function(e,t){var n=new Intl.ListFormat(e,rf({},t));return function(e){return n.format(e)}})},this.init(t)}return(0,aO.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},n=t.interpolation;this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=rh(t)}},{key:"format",value:function(e,t,n,a){var r=this;return t.split(this.formatSeparator).reduce(function(e,t){var o=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var a=e.split("(");t=a[0].toLowerCase().trim();var r=a[1].substring(0,a[1].length-1);"currency"===t&&0>r.indexOf(":")?n.currency||(n.currency=r.trim()):"relativetime"===t&&0>r.indexOf(":")?n.range||(n.range=r.trim()):r.split(";").forEach(function(e){if(e){var t,a=(t=e.split(":"),(0,aR.A)(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||(0,aF.A)(t)||(0,aL.A)()),r=a[0],o=a.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[r.trim()]||(n[r.trim()]=o),"false"===o&&(n[r.trim()]=!1),"true"===o&&(n[r.trim()]=!0),isNaN(o)||(n[r.trim()]=parseInt(o,10))}})}return{formatName:t,formatOptions:n}}(t),i=o.formatName,s=o.formatOptions;if(r.formats[i]){var l=e;try{var c=a&&a.formatParams&&a.formatParams[a.interpolationkey]||{},u=c.locale||c.lng||a.locale||a.lng||n;l=r.formats[i](e,u,rf(rf(rf({},s),a),c))}catch(e){r.logger.warn(e)}return l}return r.logger.warn("there was no format function for ".concat(i)),e},e)}}]),e}();function rg(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function ry(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rg(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rg(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var rb=function(e){aB(a,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aN(a);return e=t?Reflect.construct(n,arguments,aN(this).constructor):n.apply(this,arguments),aI(this,e)});function a(e,t,r){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,az.A)(this,a),o=n.call(this),a2&&aq.call(aP(o)),o.backend=e,o.store=t,o.services=r,o.languageUtils=r.languageUtils,o.options=i,o.logger=aU.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=i.maxParallelReads||10,o.readingCalls=0,o.maxRetries=i.maxRetries>=0?i.maxRetries:5,o.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(r,i.backend,i),o}return(0,aO.A)(a,[{key:"queueLoad",value:function(e,t,n,a){var r=this,o={},i={},s={},l={};return e.forEach(function(e){var a=!0;t.forEach(function(t){var s="".concat(e,"|").concat(t);!n.reload&&r.store.hasResourceBundle(e,t)?r.state[s]=2:r.state[s]<0||(1===r.state[s]?void 0===i[s]&&(i[s]=!0):(r.state[s]=1,a=!1,void 0===i[s]&&(i[s]=!0),void 0===o[s]&&(o[s]=!0),void 0===l[t]&&(l[t]=!0)))}),a||(s[e]=!0)}),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,n){var a=e.split("|"),r=a[0],o=a[1];t&&this.emit("failedLoading",r,o,t),n&&this.store.addResourceBundle(r,o,n),this.state[e]=t?-1:2;var i={};this.queue.forEach(function(n){var a,s,l,c;a=n.loaded,(l=(s=aY(a,[r],Object)).obj)[c=s.k]=l[c]||[],l[c].push(o),void 0!==n.pending[e]&&(delete n.pending[e],n.pendingCount--),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach(function(e){i[e]||(i[e]={});var t=n.loaded[e];t.length&&t.forEach(function(t){void 0===i[e][t]&&(i[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,n){var a=this,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,i=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:o,callback:i}):(this.readingCalls++,this.backend[n](e,t,function(s,l){if(a.readingCalls--,a.waitingReads.length>0){var c=a.waitingReads.shift();a.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}s&&l&&r<a.maxRetries?setTimeout(function(){a.read.call(a,e,t,n,r+1,2*o,i)},o):i(s,l)})):i(null,{})}},{key:"prepareLoading",value:function(e,t){var n=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var o=this.queueLoad(e,t,a,r);if(!o.toLoad.length)return o.pending.length||r(),null;o.toLoad.forEach(function(e){n.loadOne(e)})}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",a=e.split("|"),r=a[0],o=a[1];this.read(r,o,"read",void 0,void 0,function(a,i){a&&t.logger.warn("".concat(n,"loading namespace ").concat(o," for language ").concat(r," failed"),a),!a&&i&&t.logger.log("".concat(n,"loaded namespace ").concat(o," for language ").concat(r),i),t.loaded(e,a,i)})}},{key:"saveMissing",value:function(e,t,n,a,r){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null==n||""===n||(this.backend&&this.backend.create&&this.backend.create(e,t,n,a,null,ry(ry({},o),{},{isUpdate:r})),e&&e[0]&&this.store.addResource(e[0],t,n,a))}}]),a}(aq);function r_(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&0>e.supportedLngs.indexOf("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function rv(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function r$(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rv(Object(n),!0).forEach(function(t){(0,aj.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rv(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rA(){}var rw=function(e){aB(a,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aN(a);return e=t?Reflect.construct(n,arguments,aN(this).constructor):n.apply(this,arguments),aI(this,e)});function a(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;if((0,az.A)(this,a),t=n.call(this),a2&&aq.call(aP(t)),t.options=r_(r),t.services={},t.logger=aU,t.modules={external:[]},Object.getOwnPropertyNames(Object.getPrototypeOf(e=aP(t))).forEach(function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}),o&&!t.isInitialized&&!r.isClone){if(!t.options.initImmediate)return t.init(r,o),aI(t,aP(t));setTimeout(function(){t.init(r,o)},0)}return t}return(0,aO.A)(a,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:0>t.ns.indexOf("translation")&&(t.defaultNS=t.ns[0]));var a={debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===(0,aM.A)(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===(0,aM.A)(e[2])||"object"===(0,aM.A)(e[3])){var n=e[3]||e[2];Object.keys(n).forEach(function(e){t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:function(e,t,n,a){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}};function r(e){return e?"function"==typeof e?new e:e:null}if(this.options=r$(r$(r$({},a),this.options),r_(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=r$(r$({},a.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){this.modules.logger?aU.init(r(this.modules.logger),this.options):aU.init(null,this.options),this.modules.formatter?o=this.modules.formatter:"u">typeof Intl&&(o=rm);var o,i=new ra(this.options);this.store=new a6(this.options.resources,this.options);var s=this.services;s.logger=aU,s.resourceStore=this.store,s.languageUtils=i,s.pluralResolver=new rl(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),o&&(!this.options.interpolation.format||this.options.interpolation.format===a.interpolation.format)&&(s.formatter=r(o),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new rp(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new rb(r(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",function(t){for(var n=arguments.length,a=Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];e.emit.apply(e,[t].concat(a))}),this.modules.languageDetector&&(s.languageDetector=r(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=r(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new rt(this.services,this.options),this.translator.on("*",function(t){for(var n=arguments.length,a=Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];e.emit.apply(e,[t].concat(a))}),this.modules.external.forEach(function(t){t.init&&t.init(e)})}if(this.format=this.options.interpolation.format,n||(n=rA),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&"dev"!==l[0]&&(this.options.lng=l[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}});var c=aH(),u=function(){var t=function(t,a){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),c.resolve(a),n(t,a)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:rA,a=n,r="string"==typeof e?e:this.language;if("function"==typeof e&&(a=e),!this.options.resources||this.options.partialBundledLanguages){if(r&&"cimode"===r.toLowerCase())return a();var o=[],i=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){0>o.indexOf(e)&&o.push(e)})};r?i(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(e){return i(e)}),this.options.preload&&this.options.preload.forEach(function(e){return i(e)}),this.services.backendConnector.load(o,this.options.ns,function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),a(e)})}else a(null)}},{key:"reloadResources",value:function(e,t,n){var a=aH();return e||(e=this.languages),t||(t=this.options.ns),n||(n=rA),this.services.backendConnector.reload(e,t,function(e){a.resolve(),n(e)}),a}},{key:"use",value:function(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&a8.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var a=aH();this.emit("languageChanging",e);var r=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},o=function(e,o){o?(r(o),n.translator.changeLanguage(o),n.isLanguageChangingTo=void 0,n.emit("languageChanged",o),n.logger.log("languageChanged",o)):n.isLanguageChangingTo=void 0,a.resolve(function(){return n.t.apply(n,arguments)}),t&&t(e,function(){return n.t.apply(n,arguments)})},i=function(t){e||t||!n.services.languageDetector||(t=[]);var a="string"==typeof t?t:n.services.languageUtils.getBestMatchFromCodes(t);a&&(n.language||r(a),n.translator.language||n.translator.changeLanguage(a),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(a)),n.loadResources(a,function(e){o(e,a)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),a}},{key:"getFixedT",value:function(e,t,n){var a=this,r=function e(t,r){if("object"!==(0,aM.A)(r)){for(var o,i=arguments.length,s=Array(i>2?i-2:0),l=2;l<i;l++)s[l-2]=arguments[l];o=a.options.overloadTranslationOptionHandler([t,r].concat(s))}else o=r$({},r);o.lng=o.lng||e.lng,o.lngs=o.lngs||e.lngs,o.ns=o.ns||e.ns,o.keyPrefix=o.keyPrefix||n||e.keyPrefix;var c=a.options.keySeparator||".",u=o.keyPrefix?"".concat(o.keyPrefix).concat(c).concat(t):t;return a.t(u,o)};return"string"==typeof e?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=n,r}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var a=this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===a.toLowerCase())return!0;var i=function(e,n){var a=t.services.backendConnector.state["".concat(e,"|").concat(n)];return -1===a||2===a};if(n.precheck){var s=n.precheck(this,i);if(void 0!==s)return s}return!!(this.hasResourceBundle(a,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(a,e)&&(!r||i(o,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,a=aH();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){0>n.options.ns.indexOf(e)&&n.options.ns.push(e)}),this.loadResources(function(e){a.resolve(),t&&t(e)}),a):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=aH();"string"==typeof e&&(e=[e]);var a=this.options.preload||[],r=e.filter(function(e){return 0>a.indexOf(e)});return r.length?(this.options.preload=a.concat(r),this.loadResources(function(e){n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),e)?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr":"rtl"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:rA,r=r$(r$(r$({},this.options),t),{isClone:!0}),o=new a(r);return(void 0!==t.debug||void 0!==t.prefix)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(function(t){o[t]=e[t]}),o.services=r$({},this.services),o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o.translator=new rt(o.services,o.options),o.translator.on("*",function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];o.emit.apply(o,[e].concat(n))}),o.init(r,n),o.translator.options=o.options,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),a}(aq);(0,aj.A)(rw,"createInstance",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new rw(e,t)});var rk=rw.createInstance();rk.createInstance=rw.createInstance,rk.createInstance,rk.init,rk.loadResources,rk.reloadResources,rk.use,rk.changeLanguage,rk.getFixedT,rk.t,rk.exists,rk.setDefaultNamespace,rk.hasLoadedNamespace,rk.loadNamespaces,rk.loadLanguages;let rx=rk.default||rk;function rC(e,t,n,a){return rx.t(t,{ns:e,defaultValue:n,...a})}function rE(e,t,n){return aD[e]?rC("core",e,t??aD[e],n):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}rx.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let rS="import-map-override:",rD="import-map-overrides-disabled",rM="import-map-overrides:change",rz=!1,rO=null,rP=null;async function rT(){return rP??(rP=rB().then(({map:e,complete:t})=>(t||(rP=null),e))),rP}async function rB(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let a=0;a<e.length;a++){let r=e[a];try{if(r.src){let e=await fetch(r.src);if(!e.ok)throw Error(`Request for ${r.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else r.textContent&&t.push(JSON.parse(r.textContent))}catch(e){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${a}`,e)}}return{map:rI(t),complete:n}}function rI(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function rN(){let e={};try{let t=rW();for(let n=0;n<localStorage.length;n++){let a=localStorage.key(n);if(a?.startsWith(rS)){let n=a.slice(rS.length);if(!t.includes(n)){let t=localStorage.getItem(a);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function rj(){let e=await rT();return rz?rI([e,rO??rN()]):e}async function rR(){return rT()}async function rF(){return rz?rI([await rT(),rN()]):rT()}function rL(e){if(!rz)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(rS)){let t=localStorage.getItem(n);t&&(e[n.slice(rS.length)]=t)}}return{imports:e}}return rN()}function rW(){if(!rz)return[];try{let e=localStorage.getItem(rD);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function rG(e){return!!rz&&rW().includes(e)}function rV(e,t){if(!rz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(rS+e,t),window.dispatchEvent(new CustomEvent(rM))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function rU(e){if(!rz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(rS+e);let t=rW().filter(t=>t!==e);t.length>0?localStorage.setItem(rD,JSON.stringify(t)):localStorage.removeItem(rD),window.dispatchEvent(new CustomEvent(rM))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function rq(){if(!rz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(rS)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(rD),window.dispatchEvent(new CustomEvent(rM))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function rH(e){if(!rz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=rW().filter(t=>t!==e);t.length>0?localStorage.setItem(rD,JSON.stringify(t)):localStorage.removeItem(rD),window.dispatchEvent(new CustomEvent(rM))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let rK=!1;function rY(){!rK&&(rK=!0,(rz="development"===window.spaEnv)&&(rO=rN()))}function rJ(e){return e.replace(/[\/\-@]/g,"_")}async function rZ(e,t="./start",a){var r;let o,i=!a?.maxLoadingTime||a.maxLoadingTime<=0?6e5:a.maxLoadingTime;await Promise.race([rX(e,a?.importMap),new Promise((t,n)=>{o=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=rJ(e),l=window[s];if(!("object"==typeof(r=l)&&null!==r&&"init"in r&&"function"==typeof r.init&&"get"in r&&"function"==typeof r.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(n.S.default);let c=(await l.get(t))();if("object"!=typeof c||null===c){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return c}async function rX(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let n=rJ(e);if(!window[n]){let n=t??await rQ();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let a=n.imports[e];a.startsWith("./")&&(a=window.spaBase+a.substring(1));let r=e in rL().imports;try{return await function(e){var t;let n=(t=window)[r0]??(t[r0]=new Map),a=n.get(e);if(a)return a;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let r=document.createElement("script");r.src=e,r.type="text/javascript",r.async=!0;let o=new Promise((t,a)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),r.removeEventListener("load",s),r.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),n.delete(e),r.remove();let o=`Failed to load script from ${e}`;console.error(o,t),a(t.message??o)}r.addEventListener("load",s),r.addEventListener("error",l),document.head.appendChild(r)});return n.set(e,o),o}(a)}catch(e){return r&&M({kind:"error",title:rE("scriptLoadingFailed","Error: Script failed to load"),description:rE("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:a}),actionButtonLabel:rE("resetOverrides","Reset overrides"),onActionButtonClick(){rq(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function rQ(){return rj()}let r0=Symbol.for("__openmrs_script_loading");function r1(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 r2(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&r1(t))}let r3="openmrs-routes:",r4="openmrs-routes:change",r5=!1,r6=null,r8=null;async function r7(){return r8??(r8=r9().then(({map:e,complete:t})=>(t||(r8=null),e))),r8}async function r9(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let a=0;a<e.length;a++){let r=e[a];try{let e;if(r.src){let t=await fetch(r.src);if(!t.ok)throw Error(`Request for ${r.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&r2(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${a}`,e)}}return{map:oe(t),complete:n}}function oe(e){let t={routes:{}};for(let n of e)n&&"object"==typeof n&&!Array.isArray(n)&&(Object.assign(t.routes,n.routes),void 0===t.version&&void 0!==n.version&&(t.version=n.version));return t}async function ot(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(r3)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(r3.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(r1(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),a=await t.json();if(r1(a))return{moduleName:e,routes:a};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function on(){let e=await r7();return r5?oe([e,r6??await ot()]):e}async function oa(){return r7()}async function or(){return r5?oe([await r7(),await ot()]):r7()}function oo(){if(!r5)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(r3)){let t=localStorage.getItem(n);t&&(e[n.slice(r3.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function oi(e,t){if(!r5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(r3+e,JSON.stringify(t));else{let n=JSON.parse(t);if(!r1(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(r3+e,JSON.stringify(n))}else if(t instanceof URL)localStorage.setItem(r3+e,JSON.stringify(t.toString()));else{if(!r1(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(r3+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(r4))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function os(e){if(!r5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(r3+e),window.dispatchEvent(new CustomEvent(r4))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ol(){if(!r5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(r3)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(r4))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let oc=null;function ou(){return oc||(oc=(r5="development"===window.spaEnv)?ot().then(e=>{r6=e}):Promise.resolve())}let op=`${ai}/attachment`;function od(e,t){return au(`${op}/${e}`,{signal:t.signal})}function of(e,t,n){return au(`${op}?patient=${e}&includeEncounterless=${t}`,{signal:n.signal})}async function oh(e,t){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),au(`${op}`,{method:"POST",body:n})}function om(e,t){return au(`${op}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function og(e,t){return new Promise(function(n){var a=new MessageChannel;a.port1.onmessage=function(e){n(e.data)},e.postMessage(t,[a.port2])})}function oy(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function ob(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var o_=function(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})};function ov(e,t){var n=location.href;return new URL(e,n).href===new URL(t,n).href}var o$=function(e,t){this.type=e,Object.assign(this,t)};function oA(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function ow(){}var ok={type:"SKIP_WAITING"};function ox(e,t){if(!t)return e&&e.then?e.then(ow):Promise.resolve()}var oC=function(e){function t(t,n){var a,r;return void 0===n&&(n={}),(a=e.call(this)||this).nn={},a.tn=0,a.rn=new o_,a.en=new o_,a.on=new o_,a.un=0,a.an=new Set,a.cn=function(){var e=a.fn,t=e.installing;a.tn>0||!ov(t.scriptURL,a.sn.toString())||performance.now()>a.un+6e4?(a.vn=t,e.removeEventListener("updatefound",a.cn)):(a.hn=t,a.an.add(t),a.rn.resolve(t)),++a.tn,t.addEventListener("statechange",a.ln)},a.ln=function(e){var t=a.fn,n=e.target,r=n.state,o=n===a.vn,i={sw:n,isExternal:o,originalEvent:e};!o&&a.mn&&(i.isUpdate=!0),a.dispatchEvent(new o$(r,i)),"installed"===r?a.wn=self.setTimeout(function(){"installed"===r&&t.waiting===n&&a.dispatchEvent(new o$("waiting",i))},200):"activating"===r&&(clearTimeout(a.wn),o||a.en.resolve(n))},a.dn=function(e){var t=a.hn,n=t!==navigator.serviceWorker.controller;a.dispatchEvent(new o$("controlling",{isExternal:n,originalEvent:e,sw:t,isUpdate:a.mn})),n||a.on.resolve(t)},r=function(e){var t=e.data,n=e.ports,r=e.source;return oA(a.getSW(),function(){a.an.has(r)&&a.dispatchEvent(new o$("message",{data:t,originalEvent:e,ports:n,sw:r}))})},a.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(e){return Promise.reject(e)}},a.sn=t,a.nn=n,navigator.serviceWorker.addEventListener("message",a.gn),a}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var n,a,r=t.prototype;return r.register=function(e){var t=(void 0===e?{}:e).immediate,n=void 0!==t&&t;try{var a,r,o,i=this;return a=function(){if(!n&&"complete"!==document.readyState)return ox(new Promise(function(e){return window.addEventListener("load",e)}))},r=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),oA(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 t=i.fn.waiting;return t&&ov(t.scriptURL,i.sn.toString())&&(i.hn=t,Promise.resolve().then(function(){i.dispatchEvent(new o$("waiting",{sw:t,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})},(o=a())&&o.then?o.then(r):r(o)}catch(e){return Promise.reject(e)}},r.update=function(){try{return this.fn?ox(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},r.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},r.messageSW=function(e){try{return oA(this.getSW(),function(t){return og(t,e)})}catch(e){return Promise.reject(e)}},r.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&og(this.fn.waiting,ok)},r.pn=function(){var e=navigator.serviceWorker.controller;return e&&ov(e.scriptURL,this.sn.toString())?e:void 0},r.bn=function(){try{var e=this;return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(function(){return oA(navigator.serviceWorker.register(e.sn,e.nn),function(t){return e.un=performance.now(),t})},function(e){throw e})}catch(e){return Promise.reject(e)}},n=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],oy(t.prototype,n),a&&oy(t,a),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,n=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return ob(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ob(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=n()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function oE(e,t){if(void 0!==p)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),p;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let n=new oC(e,t);return p=n.register().then(()=>n.controlling.then(()=>n))}function oS(){return p??Promise.resolve(void 0)}let oD="x-omrs-offline-response-body",oM="x-omrs-offline-response-status",oz="x-omrs-offline-caching-strategy";async function oO(e){let t=await oS();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function oP(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function oT(){return!window.indexedDB}async function oB(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function oI(){return await oB()||await oT()||await oP()}let oN="openmrs3:offline-mode",oj="unavailable";function oR(){return{current:oj,notAvailable:"unavailable"===oj,active:"on"===oj}}function oF(e){"unavailable"!==oj&&"unavailable"!==e&&(localStorage.setItem(oN,"on"===e?"active":"disabled"),oj=e)}async function oL(){await oI()||(oj="active"===localStorage.getItem(oN)?"on":"off"),navigator.onLine}let oW="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,oG=Object.keys,oV=Array.isArray;function oU(e,t){return"object"!=typeof t||oG(t).forEach(function(n){e[n]=t[n]}),e}"u"<typeof Promise||oW.Promise||(oW.Promise=Promise);let oq=Object.getPrototypeOf,oH={}.hasOwnProperty;function oK(e,t){return oH.call(e,t)}function oY(e,t){"function"==typeof t&&(t=t(oq(e))),("u"<typeof Reflect?oG:Reflect.ownKeys)(t).forEach(n=>{oZ(e,n,t[n])})}let oJ=Object.defineProperty;function oZ(e,t,n,a){oJ(e,t,oU(n&&oK(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},a))}function oX(e){return{from:function(t){return e.prototype=Object.create(t.prototype),oZ(e.prototype,"constructor",e),{extend:oY.bind(null,e.prototype)}}}}let oQ=Object.getOwnPropertyDescriptor;function o0(e,t){let n;return oQ(e,t)||(n=oq(e))&&o0(n,t)}let o1=[].slice;function o2(e,t,n){return o1.call(e,t,n)}function o3(e,t){return t(e)}function o4(e){if(!e)throw Error("Assertion Failed")}function o5(e){oW.setImmediate?setImmediate(e):setTimeout(e,0)}function o6(e,t){return e.reduce((e,n,a)=>{var r=t(n,a);return r&&(e[r[0]]=r[1]),e},{})}function o8(e,t){if(oK(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],a=0,r=t.length;a<r;++a){var o=o8(e,t[a]);n.push(o)}return n}var i=t.indexOf(".");if(-1!==i){var s=e[t.substr(0,i)];return void 0===s?void 0:o8(s,t.substr(i+1))}}function o7(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){o4("string"!=typeof n&&"length"in n);for(var a=0,r=t.length;a<r;++a)o7(e,t[a],n[a])}else{var o=t.indexOf(".");if(-1!==o){var i=t.substr(0,o),s=t.substr(o+1);if(""===s)void 0===n?oV(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=n;else{var l=e[i];l&&oK(e,i)||(l=e[i]={}),o7(l,s,n)}}else void 0===n?oV(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function o9(e){var t={};for(var n in e)oK(e,n)&&(t[n]=e[n]);return t}let ie=[].concat;function it(e){return ie.apply([],e)}let ia="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(it([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>oW[e]),ir=ia.map(e=>oW[e]);o6(ia,e=>[e,!0]);let io=null;function ii(e){io="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let n=io&&io.get(t);if(n)return n;if(oV(t)){n=[],io&&io.set(t,n);for(var a=0,r=t.length;a<r;++a)n.push(e(t[a]))}else if(ir.indexOf(t.constructor)>=0)n=t;else{let a=oq(t);for(var o in n=a===Object.prototype?{}:Object.create(a),io&&io.set(t,n),t)oK(t,o)&&(n[o]=e(t[o]))}return n}(e);return io=null,t}let{toString:is}={};function il(e){return is.call(e).slice(8,-1)}let ic="u">typeof Symbol?Symbol.iterator:"@@iterator",iu="symbol"==typeof ic?function(e){var t;return null!=e&&(t=e[ic])&&t.apply(e)}:function(){return null},ip={};function id(e){var t,n,a,r;if(1==arguments.length){if(oV(e))return e.slice();if(this===ip&&"string"==typeof e)return[e];if(r=iu(e)){for(n=[];!(a=r.next()).done;)n.push(a.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=Array(t);t--;)n[t]=arguments[t];return n}let ih="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var im="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),ig=()=>!0;let iy=!Error("").stack;function ib(){if(iy)try{throw ib.arguments,Error()}catch(e){return e}return Error()}function i_(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(ig).map(e=>"\n"+e).join("")):""}var iv=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],i$=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(iv),iA={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 iw(e,t){this._e=ib(),this.name=e,this.message=t}function ik(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,n)=>n.indexOf(e)===t).join("\n")}function ix(e,t,n,a){this._e=ib(),this.failures=t,this.failedKeys=a,this.successCount=n,this.message=ik(e,t)}function iC(e,t){this._e=ib(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=ik(e,t)}oX(iw).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+i_(this._e,2))}},toString:function(){return this.name+": "+this.message}}),oX(ix).from(iw),oX(iC).from(iw);var iE=i$.reduce((e,t)=>(e[t]=t+"Error",e),{}),iS=i$.reduce((e,t)=>{var n=t+"Error";function a(e,a){this._e=ib(),this.name=n,e?"string"==typeof e?(this.message=`${e}${a?"\n "+a:""}`,this.inner=a||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=iA[t]||n,this.inner=null)}return oX(a).from(iw),e[t]=a,e},{});iS.Syntax=SyntaxError,iS.Type=TypeError,iS.Range=RangeError;var iD=iv.reduce((e,t)=>(e[t+"Error"]=iS[t],e),{}),iM=i$.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=iS[t]),e),{});function iz(){}function iO(e){return e}function iP(e,t){return null==e||e===iO?t:function(n){return t(e(n))}}function iT(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function iB(e,t){return e===iz?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var a=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?iT(a,this.onsuccess):a),r&&(this.onerror=this.onerror?iT(r,this.onerror):r),void 0!==o?o:n}}function iI(e,t){return e===iz?t:function(){e.apply(this,arguments);var n=this.onsuccess,a=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?iT(n,this.onsuccess):n),a&&(this.onerror=this.onerror?iT(a,this.onerror):a)}}function iN(e,t){return e===iz?t:function(n){var a=e.apply(this,arguments);oU(n,a);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?iT(r,this.onsuccess):r),o&&(this.onerror=this.onerror?iT(o,this.onerror):o),void 0===a?void 0===i?void 0:i:oU(a,i)}}function ij(e,t){return e===iz?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function iR(e,t){return e===iz?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var a=this,r=arguments.length,o=Array(r);r--;)o[r]=arguments[r];return n.then(function(){return t.apply(a,o)})}return t.apply(this,arguments)}}iM.ModifyError=ix,iM.DexieError=iw,iM.BulkError=iC;var iF={};let[iL,iW,iG]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,oq(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,oq(t),e]})(),iV=iW&&iW.then,iU=iL&&iL.constructor,iq=!!iG;var iH=!1,iK=iG?()=>{iG.then(so)}:oW.setImmediate?setImmediate.bind(null,so):oW.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{so(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(so,0)},iY=function(e,t){i4.push([e,t]),iZ&&(iK(),iZ=!1)},iJ=!0,iZ=!0,iX=[],iQ=[],i0=null,i1=iO,i2={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:sS,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{sS(e[0],e[1])}catch(e){}})}},i3=i2,i4=[],i5=0,i6=[];function i8(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=iz,this._lib=!1;var t=this._PSD=i3;if(im&&(this._stackHolder=ib(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==iF)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&se(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,n){try{n(n=>{if(null===t._state){if(n===t)throw TypeError("A promise cannot be resolved with itself.");var a=t._lib&&si();n&&"function"==typeof n.then?e(t,(e,t)=>{n instanceof i8?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,st(t)),a&&ss()}},se.bind(null,t))}catch(e){se(t,e)}}(this,e)}let i7={get:function(){var e=i3,t=sm;function n(n,a){var r=!e.global&&(e!==i3||t!==sm);let o=r&&!s_();var i=new i8((t,i)=>{sn(this,new i9(sC(n,e,r,o),sC(a,e,r,o),t,i,e))});return im&&sr(i,this),i}return n.prototype=iF,n},set:function(e){oZ(this,"then",e&&e.prototype===iF?i7:{get:function(){return e},set:i7.set})}};function i9(e,t,n,a,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=a,this.psd=r}function se(e,t){if(iQ.push(t),null===e._state){var n=e._lib&&si();t=i1(t),e._state=!1,e._value=t,im&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var n=o0(t,"stack");t._promise=e,oZ(t,"stack",{get:()=>iH?n&&(n.get?n.get.apply(t):n.value):e.stack})}),iX.some(t=>t._value===e._value)||iX.push(e),st(e),n&&ss()}}function st(e){var t=e._listeners;e._listeners=[];for(var n=0,a=t.length;n<a;++n)sn(e,t[n]);var r=e._PSD;--r.ref||r.finalize(),0===i5&&(++i5,iY(()=>{0==--i5&&sl()},[]))}function sn(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++i5,iY(sa,[n,e,t])}else e._listeners.push(t)}function sa(e,t,n){try{i0=t;var a,r=t._value;t._state?a=e(r):(iQ.length&&(iQ=[]),a=e(r),-1===iQ.indexOf(r)&&function(e){for(var t=iX.length;t;)if(iX[--t]._value===e._value)return void iX.splice(t,1)}(t)),n.resolve(a)}catch(e){n.reject(e)}finally{i0=null,0==--i5&&sl(),--n.psd.ref||n.psd.finalize()}}function sr(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function so(){si()&&ss()}function si(){var e=iJ;return iJ=!1,iZ=!1,e}function ss(){var e,t,n;do for(;i4.length>0;)for(e=i4,i4=[],n=e.length,t=0;t<n;++t){var a=e[t];a[0].apply(null,a[1])}while(i4.length>0);iJ=!0,iZ=!0}function sl(){var e=iX;iX=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=i6.slice(0),n=t.length;n;)t[--n]()}function sc(e){return new i8(iF,!1,e)}function su(e,t){var n=i3;return function(){var a=si(),r=i3;try{return sw(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{sw(r,!1),a&&ss()}}}oY(i8.prototype,{then:i7,_then:function(e,t){sn(this,new i9(null,null,e,t,i3))},catch:function(e){if(1==arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?n(e):sc(e)):this.then(null,e=>e&&e.name===t?n(e):sc(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),sc(t)))},stack:{get:function(){if(this._stack)return this._stack;try{iH=!0;var e=(function e(t,n,a){if(n.length===a)return n;var r="";if(!1===t._state){var o,i,s=t._value;null!=s?(o=s.name||"Error",i=s.message||s,r=i_(s,0)):(o=s,i=""),n.push(o+(i?": "+i:"")+r)}return im&&((r=i_(t._stackHolder,2))&&-1===n.indexOf(r)&&n.push(r),t._prev&&e(t._prev,n,a)),n})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{iH=!1}}},timeout:function(e,t){return e<1/0?new i8((n,a)=>{var r=setTimeout(()=>a(new iS.Timeout(t)),e);this.then(n,a).finally(clearTimeout.bind(null,r))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&oZ(i8.prototype,Symbol.toStringTag,"Dexie.Promise"),i2.env=sk(),oY(i8,{all:function(){var e=id.apply(null,arguments).map(sv);return new i8(function(t,n){0===e.length&&t([]);var a=e.length;e.forEach((r,o)=>i8.resolve(r).then(n=>{e[o]=n,--a||t(e)},n))})},resolve:e=>{if(e instanceof i8)return e;if(e&&"function"==typeof e.then)return new i8((t,n)=>{e.then(t,n)});var t=new i8(iF,!0,e);return sr(t,i0),t},reject:sc,race:function(){var e=id.apply(null,arguments).map(sv);return new i8((t,n)=>{e.map(e=>i8.resolve(e).then(t,n))})},PSD:{get:()=>i3,set:e=>i3=e},totalEchoes:{get:()=>sm},newPSD:sy,usePSD:sx,scheduler:{get:()=>iY,set:e=>{iY=e}},rejectionMapper:{get:()=>i1,set:e=>{i1=e}},follow:(e,t)=>new i8((n,a)=>sy((t,n)=>{var a=i3;a.unhandleds=[],a.onunhandled=n,a.finalize=iT(function(){var e;e=()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])},i6.push(function t(){e(),i6.splice(i6.indexOf(t),1)}),++i5,iY(()=>{0==--i5&&sl()},[])},a.finalize),e()},t,n,a))}),iU&&(iU.allSettled&&oZ(i8,"allSettled",function(){let e=id.apply(null,arguments).map(sv);return new i8(t=>{0===e.length&&t([]);let n=e.length,a=Array(n);e.forEach((e,r)=>i8.resolve(e).then(e=>a[r]={status:"fulfilled",value:e},e=>a[r]={status:"rejected",reason:e}).then(()=>--n||t(a)))})}),iU.any&&"u">typeof AggregateError&&oZ(i8,"any",function(){let e=id.apply(null,arguments).map(sv);return new i8((t,n)=>{0===e.length&&n(AggregateError([]));let a=e.length,r=Array(a);e.forEach((e,o)=>i8.resolve(e).then(e=>t(e),e=>{r[o]=e,--a||n(AggregateError(r))}))})}));let sp={awaits:0,echoes:0,id:0};var sd=0,sf=[],sh=0,sm=0,sg=0;function sy(e,t,n,a){var r=i3,o=Object.create(r);o.parent=r,o.ref=0,o.global=!1,o.id=++sg;var i=i2.env;o.env=iq?{Promise:i8,PromiseProp:{value:i8,configurable:!0,writable:!0},all:i8.all,race:i8.race,allSettled:i8.allSettled,any:i8.any,resolve:i8.resolve,reject:i8.reject,nthen:sE(i.nthen,o),gthen:sE(i.gthen,o)}:{},t&&oU(o,t),++r.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=sx(o,e,n,a);return 0===o.ref&&o.finalize(),s}function sb(){return sp.id||(sp.id=++sd),++sp.awaits,sp.echoes+=100,sp.id}function s_(){return!!sp.awaits&&(0==--sp.awaits&&(sp.id=0),sp.echoes=100*sp.awaits,!0)}function sv(e){return sp.echoes&&e&&e.constructor===iU?(sb(),e.then(e=>(s_(),e),e=>(s_(),sD(e)))):e}function s$(e){++sm,sp.echoes&&0!=--sp.echoes||(sp.echoes=sp.id=0),sf.push(i3),sw(e,!0)}function sA(){var e=sf[sf.length-1];sf.pop(),sw(e,!1)}function sw(e,t){var n,a=i3;if((t?!sp.echoes||sh++&&e===i3:!sh||--sh&&e===i3)||(n=t?s$.bind(null,e):sA,iV.call(iL,n)),e!==i3&&(i3=e,a===i2&&(i2.env=sk()),iq)){var r=i2.env.Promise,o=e.env;iW.then=o.nthen,r.prototype.then=o.gthen,(a.global||e.global)&&(Object.defineProperty(oW,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function sk(){var e=oW.Promise;return iq?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(oW,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:iW.then,gthen:e.prototype.then}:{}}function sx(e,t,n,a,r){var o=i3;try{return sw(e,!0),t(n,a,r)}finally{sw(o,!1)}}function sC(e,t,n,a){return"function"!=typeof e?e:function(){var r,o=i3;n&&sb(),sw(t,!0);try{return e.apply(this,arguments)}finally{sw(o,!1),a&&(r=s_,iV.call(iL,r))}}}function sE(e,t){return function(n,a){return e.call(this,sC(n,t),sC(a,t))}}function sS(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var a,r={promise:t,reason:e};if(oW.document&&document.createEvent?((a=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),oU(a,r)):oW.CustomEvent&&oU(a=new CustomEvent("unhandledrejection",{detail:r}),r),a&&oW.dispatchEvent&&(dispatchEvent(a),!oW.PromiseRejectionEvent&&oW.onunhandledrejection))try{oW.onunhandledrejection(a)}catch(e){}im&&a&&!a.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+iV).indexOf("[native code]")&&(sb=s_=iz);var sD=i8.reject;let sM=String.fromCharCode(65535),sz="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",sO=[],sP="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),sT=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function sB(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let sI={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function sN(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=ii(t))[e],t)}class sj{_trans(e,t,n){let a=this._tx||i3.trans,r=this.name;function o(e,n,a){if(!a.schema[r])throw new iS.NotFound("Table "+r+" not part of transaction");return t(a.idbtrans,a)}let i=si();try{return a&&a.db===this.db?a===i3.trans?a._promise(e,o,n):sy(()=>a._promise(e,o,n),{trans:a,transless:i3.transless||i3}):function e(t,n,a,r){if(t.idbdb&&(t._state.openComplete||i3.letThrough||t._vip)){var o=t._createTransaction(n,a,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===iE.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,a,r))):sD(o)}return o._promise(n,(e,t)=>sy(()=>(i3.trans=o,r(e,t,o)))).then(e=>o._completion.then(()=>e))}if(t._state.openComplete)return sD(new iS.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return sD(new iS.DatabaseClosed);t.open().catch(iz)}return t._state.dbReadyPromise.then(()=>e(t,n,a,r))}(this.db,e,[this.name],o)}finally{i&&ss()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(oV(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=oG(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)&&e.keyPath.every(e=>t.indexOf(e)>=0))[0];if(n&&this.db._maxKey!==sM)return this.where(n.name).equals(n.keyPath.map(t=>e[t]));!n&&im&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:a}=this.schema,r=this.db._deps.indexedDB;function o(e,t){try{return 0===r.cmp(e,t)}catch(e){return!1}}let[i,s]=t.reduce(([t,n],r)=>{let i=a[r],s=e[r];return[t||i,t||!i?sB(n,i&&i.multi?e=>{let t=o8(e,r);return oV(t)&&t.some(e=>o(s,e))}:e=>o(s,o8(e,r))):n]},[null,null]);return i?this.where(i.name).equals(e[i.keyPath]).filter(s):n?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,oV(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let n=Object.create(e.prototype);for(var a in t)if(oK(t,a))try{n[a]=t[a]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){oU(this,e)})}add(e,t){let{auto:n,keyPath:a}=this.schema.primKey,r=e;return a&&n&&(r=sN(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[r]})).then(e=>e.numFailures?i8.reject(e.failures[0]):e.lastResult).then(t=>{if(a)try{o7(e,a,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||oV(e))return this.where(":id").equals(e).modify(t);{let n=o8(e,this.schema.primKey.keyPath);if(void 0===n)return sD(new iS.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?oG(t).forEach(n=>{o7(e,n,t[n])}):t(e,{value:e,primKey:n})}catch(e){}return this.where(":id").equals(n).modify(t)}}put(e,t){let{auto:n,keyPath:a}=this.schema.primKey,r=e;return a&&n&&(r=sN(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[r],keys:null!=t?[t]:null})).then(e=>e.numFailures?i8.reject(e.failures[0]):e.lastResult).then(t=>{if(a)try{o7(e,a,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?i8.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:sI})).then(e=>e.numFailures?i8.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,n){let a=Array.isArray(t)?t:void 0,r=(n=n||(a?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:o}=this.schema.primKey;if(o&&a)throw new iS.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new iS.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=o&&n?e.map(sN(o)):e;return this.core.mutate({trans:t,type:"add",keys:a,values:s,wantResults:r}).then(({numFailures:e,results:t,lastResult:n,failures:a})=>{if(0===e)return r?t:n;throw new iC(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,a)})})}bulkPut(e,t,n){let a=Array.isArray(t)?t:void 0,r=(n=n||(a?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:o}=this.schema.primKey;if(o&&a)throw new iS.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new iS.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=o&&n?e.map(sN(o)):e;return this.core.mutate({trans:t,type:"put",keys:a,values:s,wantResults:r}).then(({numFailures:e,results:t,lastResult:n,failures:a})=>{if(0===e)return r?t:n;throw new iC(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,a)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:n,failures:a})=>{if(0===e)return n;throw new iC(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,a)})}}function sR(e){var t={},n=function(n,a){if(a){for(var r=arguments.length,o=Array(r-1);--r;)o[r-1]=arguments[r];return t[n].subscribe.apply(null,o),e}if("string"==typeof n)return t[n]};n.addEventType=o;for(var a=1,r=arguments.length;a<r;++a)o(arguments[a]);return n;function o(e,a,r){if("object"==typeof e){var i;return void oG(i=e).forEach(function(e){var t=i[e];if(oV(t))o(e,i[e][0],i[e][1]);else{if("asap"!==t)throw new iS.InvalidArgument("Invalid event config");var n=o(e,iO,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){o5(function(){e.apply(null,t)})})})}})}a||(a=ij),r||(r=iz);var s={subscribers:[],fire:r,subscribe:function(e){-1===s.subscribers.indexOf(e)&&(s.subscribers.push(e),s.fire=a(s.fire,e))},unsubscribe:function(e){s.subscribers=s.subscribers.filter(function(t){return t!==e}),s.fire=s.subscribers.reduce(a,r)}};return t[e]=n[e]=s,s}}function sF(e,t){return oX(t).from({prototype:e}),t}function sL(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function sW(e,t){e.filter=sB(e.filter,t)}function sG(e,t,n){var a=e.replayFilter;e.replayFilter=a?()=>sB(a(),t()):t,e.justLimit=n&&!a}function sV(e,t){if(e.isPrimKey)return t.primaryKey;let n=t.getIndexByKeyPath(e.index);if(!n)throw new iS.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function sU(e,t,n){let a=sV(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:a,range:e.range}})}function sq(e,t,n,a){let r=e.replayFilter?sB(e.filter,e.replayFilter()):e.filter;if(e.or){let o={},i=(e,n,a)=>{if(!r||r(n,a,e=>n.stop(e),e=>n.fail(e))){var i=n.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),oK(o,s)||(o[s]=!0,t(e,n,a))}};return Promise.all([e.or._iterate(i,n),sH(sU(e,a,n),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return sH(sU(e,a,n),sB(e.algorithm,r),t,!e.keysOnly&&e.valueMapper)}function sH(e,t,n,a){var r=su(a?(e,t,r)=>n(a(e),t,r):n);return e.then(e=>{if(e)return e.start(()=>{var n=()=>e.continue();t&&!t(e,e=>n=e,t=>{e.stop(t),n=iz},t=>{e.fail(t),n=iz})||r(e.value,e,e=>n=e),n()})})}function sK(e,t){try{let n=sY(e),a=sY(t);if(n!==a)return"Array"===n?1:"Array"===a?-1:"binary"===n?1:"binary"===a?-1:"string"===n?1:"string"===a?-1:"Date"===n?1:"Date"!==a?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let n=e.length,a=t.length,r=n<a?n:a;for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===a?0:n<a?-1:1}(sJ(e),sJ(t));case"Array":return function(e,t){let n=e.length,a=t.length,r=n<a?n:a;for(let n=0;n<r;++n){let a=sK(e[n],t[n]);if(0!==a)return a}return n===a?0:n<a?-1:1}(e,t)}}catch(e){}return NaN}function sY(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let n=il(e);return"ArrayBuffer"===n?"binary":n}function sJ(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class sZ{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,sD.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,sD.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=sB(t.algorithm,e)}_iterate(e,t){return sq(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&oU(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(n=>sq(t,e,n,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,n=t.table.core;if(sL(t,!0))return n.count({trans:e,query:{index:sV(t,n.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var a=0;return sq(t,()=>(++a,!1),e,n).then(()=>a)}).then(e)}sortBy(e,t){let n=e.split(".").reverse(),a=n[0],r=n.length-1;function o(e,t){return t?o(e[n[t]],t-1):e[a]}var i="next"===this._ctx.dir?1:-1;function s(e,t){var n=o(e,r),a=o(t,r);return n<a?-i:n>a?i:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&sL(t,!0)&&t.limit>0){let{valueMapper:n}=t,a=sV(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:a,range:t.range}}).then(({result:e})=>n?e.map(n):e)}{let n=[];return sq(t,e=>n.push(e),e,t.table.core).then(()=>n)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,sL(t)?sG(t,()=>{var t=e;return(e,n)=>0===t||(1===t?--t:n(()=>{e.advance(t),t=0}),!1)}):sG(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),sG(this._ctx,()=>{var t=e;return function(e,n,a){return--t<=0&&n(a),t>=0}},!0),this}until(e,t){return sW(this._ctx,function(n,a,r){return!e(n.value)||(a(r),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return sW(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=sB(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&sL(t,!0)&&t.limit>0)return this._read(e=>{var n=sV(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return sW(this._ctx,function(e){var t=e.primaryKey.toString(),a=oK(n,t);return n[t]=!0,!a}),this}modify(e){var t=this._ctx;return this._write(n=>{var a;if("function"==typeof e)a=e;else{var r=oG(e),o=r.length;a=function(t){for(var n=!1,a=0;a<o;++a){var i=r[a],s=e[i];o8(t,i)!==s&&(o7(t,i,s),n=!0)}return n}}let i=t.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,u=[],p=0,d=[],f=(e,t)=>{let{failures:n,numFailures:a}=t;for(let t of(p+=e-a,oG(n)))u.push(n[t])};return this.clone().primaryKeys().then(r=>{let o=u=>{let p=Math.min(c,r.length-u);return i.getMany({trans:n,keys:r.slice(u,u+p),cache:"immutable"}).then(d=>{let h=[],m=[],g=s?[]:null,y=[];for(let e=0;e<p;++e){let t=d[e],n={value:ii(t),primKey:r[u+e]};!1!==a.call(n,n.value,n)&&(null==n.value?y.push(r[u+e]):s||0===sK(l(t),l(n.value))?(m.push(n.value),s&&g.push(r[u+e])):(y.push(r[u+e]),h.push(n.value)))}let b=sL(t)&&t.limit===1/0&&("function"!=typeof e||e===sX)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&i.mutate({trans:n,type:"add",values:h}).then(e=>{for(let t in e.failures)y.splice(parseInt(t),1);f(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&i.mutate({trans:n,type:"put",keys:g,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(y.length>0||b&&e===sX)&&i.mutate({trans:n,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>r.length>u+p&&o(u+c))})};return o(0).then(()=>{if(u.length>0)throw new ix("Error modifying one or more objects",u,p,d);return r.length})})})}delete(){var e=this._ctx,t=e.range;return sL(e)&&(e.isPrimKey&&!sP||3===t.type)?this._write(n=>{let{primaryKey:a}=e.table.core.schema;return e.table.core.count({trans:n,query:{index:a,range:t}}).then(a=>e.table.core.mutate({trans:n,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:n,numFailures:r})=>{if(r)throw new ix("Could not delete some values",Object.keys(e).map(t=>e[t]),a-r);return a-r}))}):this.modify(sX)}}let sX=(e,t)=>t.value=null;function sQ(e,t){return e<t?-1:+(e!==t)}function s0(e,t){return e>t?-1:+(e!==t)}function s1(e,t,n){var a=e instanceof s6?new e.Collection(e):e;return a._ctx.error=n?new n(t):TypeError(t),a}function s2(e){return new e.Collection(e,()=>s5("")).limit(0)}function s3(e,t,n,a){var r,o,i,s,l,c,u,p=n.length;if(!n.every(e=>"string"==typeof e))return s1(e,"String expected.");function d(e){r="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),o="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?sQ:s0;var t=n.map(function(e){return{lower:o(e),upper:r(e)}}).sort(function(e,t){return i(e.lower,t.lower)});s=t.map(function(e){return e.upper}),l=t.map(function(e){return e.lower}),c=e,u="next"===e?"":a}d("next");var f=new e.Collection(e,()=>s4(s[0],l[p-1]+a));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,n,a){var r=e.key;if("string"!=typeof r)return!1;var d=o(r);if(t(d,l,h))return!0;for(var f=null,m=h;m<p;++m){var g=function(e,t,n,a,r,o){for(var i=Math.min(e.length,a.length),s=-1,l=0;l<i;++l){var c=t[l];if(c!==a[l])return 0>r(e[l],n[l])?e.substr(0,l)+n[l]+n.substr(l+1):0>r(e[l],a[l])?e.substr(0,l)+a[l]+n.substr(l+1):s>=0?e.substr(0,s)+t[s]+n.substr(s+1):null;0>r(e[l],c)&&(s=l)}return i<a.length&&"next"===o?e+n.substr(e.length):i<e.length&&"prev"===o?e.substr(0,n.length):s<0?null:e.substr(0,s)+a[s]+n.substr(s+1)}(r,d,s[m],l[m],i,c);null===g&&null===f?h=m+1:(null===f||i(f,g)>0)&&(f=g)}return n(null!==f?function(){e.continue(f+u)}:a),!1}),f}function s4(e,t,n,a){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:a}}function s5(e){return{type:1,lower:e,upper:e}}class s6{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,a){n=!1!==n,a=!0===a;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||a)&&(!n||!a)?s2(this):new this.Collection(this,()=>s4(e,t,!n,!a))}catch(e){return s1(this,sz)}}equals(e){return null==e?s1(this,sz):new this.Collection(this,()=>s5(e))}above(e){return null==e?s1(this,sz):new this.Collection(this,()=>s4(e,void 0,!0))}aboveOrEqual(e){return null==e?s1(this,sz):new this.Collection(this,()=>s4(e,void 0,!1))}below(e){return null==e?s1(this,sz):new this.Collection(this,()=>s4(void 0,e,!1,!0))}belowOrEqual(e){return null==e?s1(this,sz):new this.Collection(this,()=>s4(void 0,e))}startsWith(e){return"string"!=typeof e?s1(this,"String expected."):this.between(e,e+sM,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):s3(this,(e,t)=>0===e.indexOf(t[0]),[e],sM)}equalsIgnoreCase(e){return s3(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=id.apply(ip,arguments);return 0===e.length?s2(this):s3(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=id.apply(ip,arguments);return 0===e.length?s2(this):s3(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,sM)}anyOf(){let e=id.apply(ip,arguments),t=this._cmp;try{e.sort(t)}catch(e){return s1(this,sz)}if(0===e.length)return s2(this);let n=new this.Collection(this,()=>s4(e[0],e[e.length-1]));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let a=0;return n._addAlgorithm((n,r,o)=>{let i=n.key;for(;t(i,e[a])>0;)if(++a===e.length)return r(o),!1;return 0===t(i,e[a])||(r(()=>{n.continue(e[a])}),!1)}),n}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=id.apply(ip,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return s1(this,sz)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let n=this._cmp,a=this._ascending,r=this._descending,o=this._min,i=this._max;if(0===e.length)return s2(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=a(e[0],e[1])))return s1(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",iS.InvalidArgument);let s=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,c,u=a;function p(e,t){return u(e[0],t[0])}try{(c=e.reduce(function(e,t){let a=0,r=e.length;for(;a<r;++a){let r=e[a];if(0>n(t[0],r[1])&&n(t[1],r[0])>0){r[0]=o(r[0],t[0]),r[1]=i(r[1],t[1]);break}}return a===r&&e.push(t),e},[])).sort(p)}catch(e){return s1(this,sz)}let d=0,f=l?e=>a(e,c[d][1])>0:e=>a(e,c[d][1])>=0,h=s?e=>r(e,c[d][0])>0:e=>r(e,c[d][0])>=0,m=f,g=new this.Collection(this,()=>s4(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,u=a):(m=h,u=r),c.sort(p)},g._addAlgorithm((e,t,n)=>{for(var r=e.key;m(r);)if(++d===c.length)return t(n),!1;return!!(!f(r)&&!h(r))||(0===this._cmp(r,c[d][1])||0===this._cmp(r,c[d][0])||t(()=>{u===a?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=id.apply(ip,arguments);return e.every(e=>"string"==typeof e)?0===e.length?s2(this):this.inAnyRange(e.map(e=>[e,e+sM])):s1(this,"startsWithAnyOf() only works with strings")}}function s8(e){return su(function(t){return s7(t),e(t.target.error),!1})}function s7(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let s9=sR(null,"storagemutated");class le{_lock(){return o4(!i3.global),++this._reculock,1!==this._reculock||i3.global||(i3.lockOwnerFor=this),this}_unlock(){if(o4(!i3.global),0==--this._reculock)for(i3.global||(i3.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{sx(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&i3.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,n=this.db._state.dbOpenError;if(o4(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new iS.DatabaseClosed(n);case"MissingAPIError":throw new iS.MissingAPI(n.message,n);default:throw new iS.OpenFailed(n)}if(!this.active)throw new iS.TransactionInactive;return o4(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=su(t=>{s7(t),this._reject(e.error)}),e.onabort=su(t=>{s7(t),this.active&&this._reject(new iS.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=su(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&s9.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return sD(new iS.ReadOnly("Transaction is readonly"));if(!this.active)return sD(new iS.TransactionInactive);if(this._locked())return new i8((a,r)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(a,r)},i3])});if(n)return sy(()=>{var e=new i8((e,n)=>{this._lock();let a=t(e,n,this);a&&a.then&&a.then(e,n)});return e.finally(()=>this._unlock()),e._lib=!0,e});var a=new i8((e,n)=>{var a=t(e,n,this);a&&a.then&&a.then(e,n)});return a._lib=!0,a}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let n=i8.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>n);else{t._waitingFor=n,t._waitingQueue=[];var a=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(a.get(-1/0).onsuccess=e)}()}var r=t._waitingFor;return new i8((e,a)=>{n.then(n=>t._waitingQueue.push(su(e.bind(null,n))),e=>t._waitingQueue.push(su(a.bind(null,e)))).finally(()=>{t._waitingFor===r&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new iS.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(oK(t,e))return t[e];let n=this.schema[e];if(!n)throw new iS.NotFound("Table "+e+" not part of transaction");let a=new this.db.Table(e,n,this);return a.core=this.db.core.table(e),t[e]=a,a}}function lt(e,t,n,a,r,o,i){return{name:e,keyPath:t,unique:n,multi:a,auto:r,compound:o,src:(n&&!i?"&":"")+(a?"*":"")+(r?"++":"")+ln(t)}}function ln(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function la(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:o6(n,e=>[e.name,e])}}let lr=e=>{try{return e.only([[]]),lr=()=>[[]],[[]]}catch(e){return lr=()=>sM,sM}};function lo(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>o8(t,e):t=>o8(t,e)}function li(e){return[].slice.call(e)}let ls=0;function ll(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function lc({_novip:e},t){let n=t.db,a=function(e,t,{IDBKeyRange:n,indexedDB:a},r){var o;return{dbcore:(o=function(e,t,n){let a;function r(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:n,upper:a,lowerOpen:r,upperOpen:o}=e;return void 0===n?void 0===a?null:t.upperBound(a,!!o):void 0===a?t.lowerBound(n,!!r):t.bound(n,a,!!r,!!o)}let{schema:o,hasGetAll:i}=(a=li(e.objectStoreNames),{schema:{name:e.name,tables:a.map(e=>n.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:n}=e,a=oV(t),r=null==t,o={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:r,compound:a,keyPath:t,autoIncrement:n,unique:!0,extractKey:lo(t)},indexes:li(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:n,multiEntry:a,keyPath:r}=e,i={name:t,compound:oV(r),keyPath:r,unique:n,multiEntry:a,extractKey:lo(r)};return o[ll(r)]=i,i}),getIndexByKeyPath:e=>o[ll(e)]};return o[":id"]=i.primaryKey,null!=t&&(o[ll(t)]=i.primaryKey),i})},hasGetAll:a.length>0&&"getAll"in n.objectStore(a[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=o.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:n,keys:a,values:o,range:i}){return new Promise((s,l)=>{let c;s=su(s);let u=e.objectStore(t),p=null==u.keyPath,d="put"===n||"add"===n;if(!d&&"delete"!==n&&"deleteRange"!==n)throw Error("Invalid operation type: "+n);let{length:f}=a||o||{length:1};if(a&&o&&a.length!==o.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,y=e=>{++g,s7(e)};if("deleteRange"===n){if(4===i.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===i.type?h.push(c=u.clear()):h.push(c=u.delete(r(i)))}else{let[e,t]=d?p?[o,a]:[o,null]:[a,null];if(d)for(let a=0;a<f;++a)h.push(c=t&&void 0!==t[a]?u[n](e[a],t[a]):u[n](e[a])),c.onerror=y;else for(let t=0;t<f;++t)h.push(c=u[n](e[t])),c.onerror=y}let b=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:g,failures:m,results:"delete"===n?a:h.map(e=>e.result),lastResult:t})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:n})=>new Promise((a,r)=>{a=su(a);let o=e.objectStore(t),i=n.length,s=Array(i),l,c=0,u=0,p=e=>{let t=e.target;s[t._pos]=t.result,++u===c&&a(s)},d=s8(r);for(let e=0;e<i;++e)null!=n[e]&&((l=o.get(n[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&a(s)}),get:({trans:e,key:n})=>new Promise((a,r)=>{a=su(a);let o=e.objectStore(t).get(n);o.onsuccess=e=>a(e.target.result),o.onerror=s8(r)}),query:e=>new Promise((n,a)=>{n=su(n);let{trans:o,values:s,limit:l,query:c}=e,u=l===1/0?void 0:l,{index:p,range:d}=c,f=o.objectStore(t),h=p.isPrimaryKey?f:f.index(p.name),m=r(d);if(0===l)return n({result:[]});if(i){let e=s?h.getAll(m,u):h.getAllKeys(m,u);e.onsuccess=e=>n({result:e.target.result}),e.onerror=s8(a)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),r=[];t.onsuccess=a=>{let o=t.result;return o?(r.push(s?o.value:o.primaryKey),++e===l?n({result:r}):void o.continue()):n({result:r})},t.onerror=s8(a)}}),openCursor:function({trans:e,values:n,query:a,reverse:o,unique:i}){return new Promise((s,l)=>{s=su(s);let{index:c,range:u}=a,p=e.objectStore(t),d=c.isPrimaryKey?p:p.index(c.name),f=o?i?"prevunique":"prev":i?"nextunique":"next",h=!n&&"openKeyCursor"in d?d.openKeyCursor(r(u),f):d.openCursor(r(u),f);h.onerror=s8(l),h.onsuccess=su(t=>{let n=h.result;if(!n)return void s(null);n.___id=++ls,n.done=!1;let a=n.continue.bind(n),r=n.continuePrimaryKey;r&&(r=r.bind(n));let o=n.advance.bind(n),i=()=>{throw Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw Error("Cursor not started")},n.fail=su(l),n.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},n.start=e=>{let t=new Promise((e,t)=>{e=su(e),h.onerror=s8(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=i,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw Error("Cursor behind last entry")},n.stop()};return h.onsuccess=su(e=>{h.onsuccess=s,s()}),n.continue=a,n.continuePrimaryKey=r,n.advance=o,s(),t},s(n)},l)})},count({query:e,trans:n}){let{index:a,range:o}=e;return new Promise((e,i)=>{let s=n.objectStore(t),l=a.isPrimaryKey?s:s.index(a.name),c=r(o),u=c?l.count(c):l.count();u.onsuccess=su(t=>e(t.target.result)),u.onerror=s8(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:lr(t),schema:o}}(t,n,r),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),o))}}(e._middlewares,n,e._deps,t);e.core=a.dbcore,e.tables.forEach(t=>{let n=t.name;e.core.schema.tables.some(e=>e.name===n)&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))})}function lu({_novip:e},t,n,a){n.forEach(n=>{let r=a[n];t.forEach(t=>{let a=o0(t,n);(!a||"value"in a&&void 0===a.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?oZ(t,n,{get(){return this.table(n)},set(e){oJ(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,r))})})}function lp({_novip:e},t){t.forEach(t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]})}function ld(e,t){return e._cfg.version-t._cfg.version}function lf(e,t){let n,a={del:[],add:[],change:[]};for(n in e)t[n]||a.del.push(n);for(n in t){let r=e[n],o=t[n];if(r){let e={name:n,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(r.primKey.keyPath||"")==""+(o.primKey.keyPath||"")&&(r.primKey.auto===o.primKey.auto||sP)){let t,n=r.idxByName,i=o.idxByName;for(t in n)i[t]||e.del.push(t);for(t in i){let a=n[t],r=i[t];a?a.src!==r.src&&e.change.push(r):e.add.push(r)}(e.del.length>0||e.add.length>0||e.change.length>0)&&a.change.push(e)}else e.recreate=!0,a.change.push(e)}else a.add.push([n,o])}return a}function lh(e,t,n,a){let r=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return a.forEach(e=>lm(r,e)),r}function lm(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function lg(e,t,n){let a={};return o2(t.objectStoreNames,0).forEach(e=>{let t=n.objectStore(e),r=t.keyPath,o=lt(ln(r),r||"",!1,!1,!!t.autoIncrement,r&&"string"!=typeof r,!0),i=[];for(let e=0;e<t.indexNames.length;++e){let n=t.index(t.indexNames[e]);r=n.keyPath;var s=lt(n.name,r,!!n.unique,!!n.multiEntry,!1,r&&"string"!=typeof r,!1);i.push(s)}a[e]=la(e,o,i)}),a}function ly({_novip:e},t,n){let a=n.db.objectStoreNames;for(let r=0;r<a.length;++r){let o=a[r],i=n.objectStore(o);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let n=i.indexNames[e],a=i.index(n).keyPath,r="string"==typeof a?a:"["+o2(a).join("+")+"]";if(t[o]){let e=t[o].idxByName[r];e&&(e.name=n,delete t[o].idxByName[r],t[o].idxByName[n]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&oW.WorkerGlobalScope&&oW instanceof oW.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class lb{_parseStoresSpec(e,t){oG(e).forEach(n=>{if(null!==e[n]){var a=e[n].split(",").map((e,t)=>{let n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),a=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return lt(n,a||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),oV(a),0===t)}),r=a.shift();if(r.multi)throw new iS.Schema("Primary key cannot be multi-valued");a.forEach(e=>{if(e.auto)throw new iS.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new iS.Schema("Index must have a name and cannot be an empty string")}),t[n]=la(n,r,a)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?oU(this._cfg.storesSource,e):e;let n=t._versions,a={},r={};return n.forEach(e=>{oU(a,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(a,r)}),t._dbSchema=r,lp(t,[t._allTables,t,t.Transaction.prototype]),lu(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],oG(r),r),t._storeNames=oG(r),this}upgrade(e){return this._cfg.contentUpgrade=iR(this._cfg.contentUpgrade||iz,e),this}}function l_(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new lj("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function lv(e){return e&&"function"==typeof e.databases}function l$(e){return sy(function(){return i3.letThrough=!0,e()})}function lA(e){var t=t=>e.next(t),n=r(t),a=r(t=>e.throw(t));function r(e){return t=>{var r=e(t),o=r.value;return r.done?o:o&&"function"==typeof o.then?o.then(n,a):oV(o)?Promise.all(o).then(n,a):n(o)}}return r(t)()}function lw(e,t,n){var a=arguments.length;if(a<2)throw new iS.InvalidArgument("Too few arguments");for(var r=Array(a-1);--a;)r[a-1]=arguments[a];return n=r.pop(),[e,it(r),n]}function lk(e,t,n){let a=oV(e)?e.slice():[e];for(let e=0;e<n;++e)a.push(t);return a}let lx={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let n=e.table(t),{schema:a}=n,r={},o=[];function i(e,t,n){let a=ll(e),s=r[a]=r[a]||[],l=null==e?0:"string"==typeof e?1:e.length,c=t>0,u={...n,isVirtual:c,keyTail:t,keyLength:l,extractKey:lo(e),unique:!c&&n.unique};return s.push(u),u.isPrimaryKey||o.push(u),l>1&&i(2===l?e[0]:e.slice(0,l-1),t+1,n),s.sort((e,t)=>e.keyTail-t.keyTail),u}let s=i(a.primaryKey.keyPath,0,a.primaryKey);for(let e of(r[":id"]=[s],a.indexes))i(e.keyPath,0,e);function l(t){var n,a;let r=t.query.index;return r.isVirtual?{...t,query:{index:r,range:(n=t.query.range,a=r.keyTail,{type:1===n.type?2:n.type,lower:lk(n.lower,n.lowerOpen?e.MAX_KEY:e.MIN_KEY,a),lowerOpen:!0,upper:lk(n.upper,n.upperOpen?e.MIN_KEY:e.MAX_KEY,a),upperOpen:!0})}}:t}return{...n,schema:{...a,primaryKey:s,indexes:o,getIndexByKeyPath:function(e){let t=r[ll(e)];return t&&t[0]}},count:e=>n.count(l(e)),query:e=>n.query(l(e)),openCursor(t){let{keyTail:a,isVirtual:r,keyLength:o}=t.query.index;return r?n.openCursor(l(t)).then(n=>n&&Object.create(n,{continue:{value:function(r){null!=r?n.continue(lk(r,t.reverse?e.MAX_KEY:e.MIN_KEY,a)):t.unique?n.continue(n.key.slice(0,o).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,a)):n.continue()}},continuePrimaryKey:{value(t,r){n.continuePrimaryKey(lk(t,e.MAX_KEY,a),r)}},primaryKey:{get:()=>n.primaryKey},key:{get(){let e=n.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:()=>n.value}})):n.openCursor(t)}}}}}};function lC(e,t,n,a){return n=n||{},a=a||"",oG(e).forEach(r=>{if(oK(t,r)){var o=e[r],i=t[r];if("object"==typeof o&&"object"==typeof i&&o&&i){let e=il(o);e!==il(i)?n[a+r]=t[r]:"Object"===e?lC(o,i,n,a+r+"."):o!==i&&(n[a+r]=t[r])}else o!==i&&(n[a+r]=t[r])}else n[a+r]=void 0}),oG(t).forEach(r=>{oK(e,r)||(n[a+r]=t[r])}),n}let lE={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let n=e.table(t),{primaryKey:a}=n.schema;return{...n,mutate(e){let r=i3.trans,{deleting:o,creating:i,updating:s}=r.table(t).hook;switch(e.type){case"add":if(i.fire===iz)break;return r._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===iz&&s.fire===iz)break;return r._promise("readwrite",()=>l(e),!0);case"delete":if(o.fire===iz)break;return r._promise("readwrite",()=>l(e),!0);case"deleteRange":if(o.fire===iz)break;return r._promise("readwrite",()=>(function e(t,r,o){return n.query({trans:t,values:!1,query:{index:a,range:r},limit:o}).then(({result:n})=>l({type:"delete",keys:n,trans:t}).then(a=>a.numFailures>0?Promise.reject(a.failures[0]):n.length<o?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...r,lower:n[n.length-1],lowerOpen:!0},o)))})(e.trans,e.range,1e4),!0)}return n.mutate(e);function l(e){var t,r;let l=i3.trans,c=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(a.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"===(r=e).type?Promise.resolve([]):n.getMany({trans:r.trans,keys:c,cache:"immutable"})).then(t=>{let r=c.map((n,r)=>{let c=t[r],u={onerror:null,onsuccess:null};if("delete"===e.type)o.fire.call(u,n,c,l);else if("add"===e.type||void 0===c){let t=i.fire.call(u,n,e.values[r],l);null==n&&null!=t&&(n=t,e.keys[r]=n,a.outbound||o7(e.values[r],a.keyPath,n))}else{let t=lC(c,e.values[r]),a=s.fire.call(u,t,n,c,l);if(a){let t=e.values[r];Object.keys(a).forEach(e=>{oK(t,e)?t[e]=a[e]:o7(t,e,a[e])})}}return u});return n.mutate(e).then(({failures:n,results:a,numFailures:o,lastResult:i})=>{for(let o=0;o<c.length;++o){let i=a?a[o]:c[o],s=r[o];null==i?s.onerror&&s.onerror(n[o]):s.onsuccess&&s.onsuccess("put"===e.type&&t[o]?e.values[o]:i)}return{failures:n,results:a,numFailures:o,lastResult:i}}).catch(e=>(r.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function lS(e,t,n){try{if(!t||t.keys.length<e.length)return null;let a=[];for(let r=0,o=0;r<t.keys.length&&o<e.length;++r)0===sK(t.keys[r],e[o])&&(a.push(n?ii(t.values[r]):t.values[r]),++o);return a.length===e.length?a:null}catch(e){return null}}let lD={stack:"dbcore",level:-1,create:e=>({table:t=>{let n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);let t=lS(e.keys,e.trans._cache,"clone"===e.cache);return t?i8.resolve(t):n.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?ii(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function lM(e){return!("from"in e)}let lz=function(e,t){if(!this){let t=new lz;return e&&"d"in e&&oU(t,e),t}oU(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function lO(e,t,n){let a=sK(t,n);if(isNaN(a))return;if(a>0)throw RangeError();if(lM(e))return oU(e,{from:t,to:n,d:1});let r=e.l,o=e.r;if(0>sK(n,e.from))return r?lO(r,t,n):e.l={from:t,to:n,d:1,l:null,r:null},lB(e);if(sK(t,e.to)>0)return o?lO(o,t,n):e.r={from:t,to:n,d:1,l:null,r:null},lB(e);0>sK(t,e.from)&&(e.from=t,e.l=null,e.d=o?o.d+1:1),sK(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;r&&!e.l&&lP(e,r),o&&i&&lP(e,o)}function lP(e,t){lM(t)||function e(t,{from:n,to:a,l:r,r:o}){lO(t,n,a),r&&e(t,r),o&&e(t,o)}(e,t)}function lT(e){let t=lM(e)?null:{s:0,n:e};return{next(e){let n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&0>sK(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||0>=sK(e,t.n.to))return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function lB(e){var t,n;let a=((null==(t=e.r)?void 0:t.d)||0)-((null==(n=e.l)?void 0:n.d)||0),r=a>1?"r":a<-1?"l":"";if(r){let t="r"===r?"l":"r",n={...e},a=e[r];e.from=a.from,e.to=a.to,e[r]=a[r],n[r]=a[t],e[t]=n,n.d=lI(n)}e.d=lI(e)}function lI({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}oY(lz.prototype,{add(e){return lP(this,e),this},addKey(e){return lO(this,e,e),this},addKeys(e){return e.forEach(e=>lO(this,e,e)),this},[ic](){return lT(this)}});let lN={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,n=new lz(e.MIN_KEY,e.MAX_KEY);return{...e,table:a=>{let r=e.table(a),{schema:o}=r,{primaryKey:i}=o,{extractKey:s,outbound:l}=i,c={...r,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let n=`idb://${t}/${a}/${e}`;return s[n]||(s[n]=new lz)},c=l(""),u=l(":dels"),{type:p}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return r.mutate(e).then(e=>{if(oV(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let t=lS(d,h);t||"add"===p||u.addKeys(d),(t||f)&&o.indexes.forEach(function(e){let n=l(e.name||"");function a(t){return null!=t?e.extractKey(t):null}let r=t=>e.multiEntry&&oV(t)?t.forEach(e=>n.addKey(e)):n.addKey(t);(t||f).forEach((e,n)=>{let o=t&&a(t[n]),i=f&&a(f[n]);0!==sK(o,i)&&(null!=o&&r(o),null!=i&&r(i))})})}else if(d){let e={from:d.lower,to:d.upper};u.add(e),c.add(e)}else c.add(n),u.add(n),o.indexes.forEach(e=>l(e.name).add(n));return e})}},u=({query:{index:t,range:n}})=>{var a,r;return[t,new lz(null!=(a=n.lower)?a:e.MIN_KEY,null!=(r=n.upper)?r:e.MAX_KEY)]},p={get:e=>[i,new lz(e.key)],getMany:e=>[i,(new lz).addKeys(e.keys)],count:u,query:u,openCursor:u};return oG(p).forEach(e=>{c[e]=function(o){let{subscr:i}=i3;if(i){let c=e=>{let n=`idb://${t}/${a}/${e}`;return i[n]||(i[n]=new lz)},u=c(""),d=c(":dels"),[f,h]=p[e](o);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&o.values&&r.query({...o,values:!1});return r[e].apply(this,arguments).then(n=>{if("query"===e){if(l&&o.values)return t.then(({result:e})=>(u.addKeys(e),n));let e=o.values?n.result.map(s):n.result;o.values?u.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=o.values;return n&&Object.create(n,{key:{get:()=>(d.addKey(n.primaryKey),n.key)},primaryKey:{get(){let e=n.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&u.addKey(n.primaryKey),n.value)}})}return n})}d.add(n)}}return r[e].apply(this,arguments)}}),c}}}};class lj{constructor(e,t){var n;this._middlewares={},this.verno=0;const a=lj.dependencies;this._options=t={addons:lj.addons,autoOpen:!0,indexedDB:a.indexedDB,IDBKeyRange:a.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:r}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:iz,dbReadyPromise:null,cancelOpen:iz,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new i8(e=>{o.dbReadyResolve=e}),o.openCanceller=new i8((e,t)=>{o.cancelOpen=t}),this._state=o,this.name=e,this.on=sR(this,"populate","blocked","versionchange","close",{ready:[iR,iz]}),this.on.ready.subscribe=o3(this.on.ready.subscribe,e=>(t,n)=>{lj.vip(()=>{let a=this._state;if(a.openComplete)a.dbOpenError||i8.resolve().then(t),n&&e(t);else if(a.onReadyBeingFired)a.onReadyBeingFired.push(t),n&&e(t);else{e(t);let a=this;n||e(function e(){a.on.ready.unsubscribe(t),a.on.ready.unsubscribe(e)})}})}),this.Collection=(n=this,sF(sZ.prototype,function(e,t){this.db=n;let a=sI,r=null;if(t)try{a=t()}catch(e){r=e}let o=e._ctx,i=o.table,s=i.hook.reading.fire;this._ctx={table:i,index:o.index,isPrimKey:!o.index||i.schema.primKey.keyPath&&o.index===i.schema.primKey.name,range:a,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:s!==iO?s:null}})),this.Table=function(e){return sF(sj.prototype,function(t,n,a){this.db=e,this._tx=a,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:sR(null,{creating:[iB,iz],reading:[iP,iO],updating:[iN,iz],deleting:[iI,iz]})})}(this),this.Transaction=function(e){return sF(le.prototype,function(t,n,a,r,o){this.db=e,this.mode=t,this.storeNames=n,this.schema=a,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=sR(this,"complete","error","abort"),this.parent=o||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 i8((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),sD(e)})})}(this),this.Version=function(e){return sF(lb.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return sF(s6.prototype,function(t,n,a){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:a};let r=e._deps.indexedDB;if(!r)throw new iS.MissingAPI;this._cmp=this._ascending=r.cmp.bind(r),this._descending=(e,t)=>r.cmp(t,e),this._max=(e,t)=>r.cmp(e,t)>0?e:t,this._min=(e,t)=>0>r.cmp(e,t)?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=lr(t.IDBKeyRange),this._createTransaction=(e,t,n,a)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,a),this._fireOnBlocked=e=>{this.on("blocked").fire(e),sO.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(lx),this.use(lE),this.use(lN),this.use(lD),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new iS.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new iS.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let t=this._versions;var n=t.filter(t=>t._cfg.version===e)[0];return n||(n=new this.Version(e),t.push(n),t.sort(ld),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||i3.letThrough||this._vip)?e():new i8((e,t)=>{if(this._state.openComplete)return t(new iS.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new iS.DatabaseClosed);this.open().catch(iz)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:n,name:a}){a&&this.unuse({stack:e,name:a});let r=this._middlewares[e]||(this._middlewares[e]=[]);return r.push({stack:e,create:t,level:null==n?10:n,name:a}),r.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>n?e.create!==n:!!t&&e.name!==t)),this}open(){return function(e){var t;let n=e._state,{indexedDB:a}=e._deps;if(n.isBeingOpened||e.idbdb)return n.dbReadyPromise.then(()=>n.dbOpenError?sD(n.dbOpenError):e);im&&(n.openCanceller._stackHolder=ib()),n.isBeingOpened=!0,n.dbOpenError=null,n.openComplete=!1;let r=n.openCanceller;function o(){if(n.openCanceller!==r)throw new iS.DatabaseClosed("db.open() was cancelled")}let i=n.dbReadyResolve,s=null,l=!1;return i8.race([r,("u"<typeof navigator?i8.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(()=>new i8((t,r)=>{if(o(),!a)throw new iS.MissingAPI;let i=e.name,c=n.autoSchema?a.open(i):a.open(i,Math.round(10*e.verno));if(!c)throw new iS.MissingAPI;c.onerror=s8(r),c.onblocked=su(e._fireOnBlocked),c.onupgradeneeded=su(t=>{if(s=c.transaction,n.autoSchema&&!e._options.allowEmptyDB){c.onerror=s7,s.abort(),c.result.close();let e=a.deleteDatabase(i);e.onsuccess=e.onerror=su(()=>{r(new iS.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let n,a,i,d;s.onerror=s8(r);var o,u,p=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=p<1,e._novip.idbdb=c.result,o=p/10,u=s,n=e._dbSchema,(a=e._createTransaction("readwrite",e._storeNames,n)).create(u),a._completion.catch(r),i=a._reject.bind(a),d=i3.transless||i3,sy(()=>{i3.trans=a,i3.transless=d,0===o?(oG(n).forEach(e=>{lh(u,e,n[e].primKey,n[e].indexes)}),lc(e,u),i8.follow(()=>e.on.populate.fire(a)).catch(i)):(function({_novip:e},t,n,a){let r=[],o=e._versions,i=e._dbSchema=lg(e,e.idbdb,a),s=!1;return o.filter(e=>e._cfg.version>=t).forEach(o=>{r.push(()=>{let r=i,l=o._cfg.dbschema;ly(e,r,a),ly(e,l,a),i=e._dbSchema=l;let c=lf(r,l);c.add.forEach(e=>{lh(a,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new iS.Upgrade("Not yet support for changing primary key");{let t=a.objectStore(e.name);e.add.forEach(e=>lm(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),lm(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let u=o._cfg.contentUpgrade;if(u&&o._cfg.version>t){let t;lc(e,a),n._memoizedTables={},s=!0;let o=o9(l);c.del.forEach(e=>{o[e]=r[e]}),lp(e,[e.Transaction.prototype]),lu(e,[e.Transaction.prototype],oG(o),o),n.schema=o;let i=ih(u);i&&sb();let p=i8.follow(()=>{if((t=u(n))&&i){var e=s_.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?i8.resolve(t):p.then(()=>t)}}),r.push(t=>{var a;s&&sP||(a=o._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==a[e]&&t.db.deleteObjectStore(e))),lp(e,[e.Transaction.prototype]),lu(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),n.schema=e._dbSchema})}),(function e(){return r.length?i8.resolve(r.shift()(n.idbtrans)).then(e):i8.resolve()})().then(()=>{var e;oG(e=i).forEach(t=>{a.db.objectStoreNames.contains(t)||lh(a,t,e[t].primKey,e[t].indexes)})})})(e,o,a,u).catch(i)})}},r),c.onsuccess=su(()=>{s=null;let a=e._novip.idbdb=c.result,r=o2(a.objectStoreNames);if(r.length>0)try{let t,o=a.transaction(1===r.length?r[0]:r,"readonly");n.autoSchema?function({_novip:e},t,n){e.verno=t.version/10;let a=e._dbSchema=lg(0,t,n);e._storeNames=o2(t.objectStoreNames,0),lu(e,[e._allTables],oG(a),a)}(e,a,o):(ly(e,e._dbSchema,o),((t=lf(lg(0,e.idbdb,o),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),lc(e,o)}catch(e){}sO.push(e),a.onversionchange=su(t=>{n.vcFired=!0,e.on("versionchange").fire(t)}),a.onclose=su(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},n){lv(e)||"__dbnames"===n||l_(e,t).put({name:n}).catch(iz)}(e._deps,i),t()},r)}))]).then(()=>(o(),n.onReadyBeingFired=[],i8.resolve(l$(()=>e.on.ready.fire(e.vip))).then(function t(){if(n.onReadyBeingFired.length>0){let a=n.onReadyBeingFired.reduce(iR,iz);return n.onReadyBeingFired=[],i8.resolve(l$(()=>a(e.vip))).then(t)}}))).finally(()=>{n.onReadyBeingFired=null,n.isBeingOpened=!1}).then(()=>e).catch(t=>{n.dbOpenError=t;try{s&&s.abort()}catch(e){}return r===n.openCanceller&&e._close(),sD(t)}).finally(()=>{n.openComplete=!0,i()})}(this)}_close(){let e=this._state,t=sO.indexOf(this);if(t>=0&&sO.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new i8(t=>{e.dbReadyResolve=t}),e.openCanceller=new i8((t,n)=>{e.cancelOpen=n})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new iS.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new i8((n,a)=>{let r=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=su(()=>{!function({indexedDB:e,IDBKeyRange:t},n){lv(e)||"__dbnames"===n||l_(e,t).delete(n).catch(iz)}(this._deps,this.name),n()}),e.onerror=s8(a),e.onblocked=this._fireOnBlocked};if(e)throw new iS.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(r):r()})}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 oG(this._allTables).map(e=>this._allTables[e])}transaction(){let e=lw.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let a,r,o=i3.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(r=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||"readonly"===e)a="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new iS.InvalidArgument("Invalid transaction mode: "+e);a="readwrite"}if(o){if("readonly"===o.mode&&"readwrite"===a){if(!i)throw new iS.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&r.forEach(e=>{if(o&&-1===o.storeNames.indexOf(e)){if(!i)throw new iS.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),i&&o&&!o.active&&(o=null)}}catch(e){return o?o._promise(null,(t,n)=>{n(e)}):sD(e)}let s=(function e(t,n,a,r,o){return i8.resolve().then(()=>{let i,s=i3.transless||i3,l=t._createTransaction(n,a,t._dbSchema,r);if(r)l.idbtrans=r.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(r){return r.name===iE.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,a,null,o))):sD(r)}let c=ih(o);c&&sb();let u=i8.follow(()=>{if(i=o.call(l,l))if(c){var e=s_.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=lA(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?i8.resolve(i).then(e=>l.active?e:sD(new iS.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>i)).then(e=>(r&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),sD(e)))})}).bind(null,this,a,r,o,n);return o?o._promise(a,s,"lock"):i3.trans?sx(i3.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!oK(this._allTables,e))throw new iS.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let lR="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class lF{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[lR](){return this}}function lL(e,t){return oG(t).forEach(n=>{lP(e[n]||(e[n]=new lz),t[n])}),e}try{o={indexedDB:oW.indexedDB||oW.mozIndexedDB||oW.webkitIndexedDB||oW.msIndexedDB,IDBKeyRange:oW.IDBKeyRange||oW.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function lW(e){let t=lG;try{lG=!0,s9.storagemutated.fire(e)}finally{lG=t}}oY(lj,{...iM,delete:e=>new lj(e,{addons:[]}).delete(),exists:e=>new lj(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return lv(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>"__dbnames"!==e)):l_(e,t).toCollection().primaryKeys()})(lj.dependencies).then(e)}catch(e){return sD(new iS.MissingAPI)}},defineClass:()=>function(e){oU(this,e)},ignoreTransaction:e=>i3.trans?sx(i3.transless,e):e(),vip:l$,async:function(e){return function(){try{var t=lA(e.apply(this,arguments));return t&&"function"==typeof t.then?t:i8.resolve(t)}catch(e){return sD(e)}}},spawn:function(e,t,n){try{var a=lA(e.apply(n,t||[]));return a&&"function"==typeof a.then?a:i8.resolve(a)}catch(e){return sD(e)}},currentTransaction:{get:()=>i3.trans||null},waitFor:function(e,t){let n=i8.resolve("function"==typeof e?lj.ignoreTransaction(e):e).timeout(t||6e4);return i3.trans?i3.trans.waitFor(n):n},Promise:i8,debug:{get:()=>im,set:e=>{im=e,ig="dexie"===e?()=>!0:sT}},derive:oX,extend:oU,props:oY,override:o3,Events:sR,on:s9,liveQuery:function(e){return new lF(t=>{let n=ih(e),a=!1,r={},o={},i={get closed(){return a},unsubscribe:()=>{a=!0,s9.storagemutated.unsubscribe(u)}};t.start&&t.start(i);let s=!1,l=!1;function c(){return oG(o).some(e=>r[e]&&function(e,t){let n=lT(t),a=n.next();if(a.done)return!1;let r=a.value,o=lT(e),i=o.next(r.from),s=i.value;for(;!a.done&&!i.done;){if(0>=sK(s.from,r.to)&&sK(s.to,r.from)>=0)return!0;0>sK(r.from,s.from)?r=(a=n.next(s.from)).value:s=(i=o.next(r.from)).value}return!1}(r[e],o[e]))}let u=e=>{lL(r,e),c()&&p()},p=()=>{let d,f;if(s||a)return;r={};let h={},m=(n&&sb(),d=()=>sy(e,{subscr:h,trans:null}),f=i3.trans?sx(i3.transless,d):d(),n&&f.then(s_,s_),f);l||(s9("storagemutated",u),l=!0),s=!0,Promise.resolve(m).then(e=>{s=!1,a||(c()?p():(r={},o=h,t.next&&t.next(e)))},e=>{s=!1,t.error&&t.error(e),i.unsubscribe()})};return p(),i})},extendObservabilitySet:lL,getByKeyPath:o8,setByKeyPath:o7,delByKeyPath:function(e,t){"string"==typeof t?o7(e,t,void 0):"length"in t&&[].map.call(t,function(t){o7(e,t,void 0)})},shallowClone:o9,deepClone:ii,getObjectDiff:lC,cmp:sK,asap:o5,minKey:-1/0,addons:[],connections:sO,errnames:iE,dependencies:o,semVer:"3.2.2",version:"3.2.2".split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),lj.maxKey=lr(lj.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(s9("storagemutated",e=>{if(!lG){let t;sP?(t=document.createEvent("CustomEvent")).initCustomEvent("x-storagemutated-1",!0,!0,e):t=new CustomEvent("x-storagemutated-1",{detail:e}),lG=!0,dispatchEvent(t),lG=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{lG||lW(e)}));let lG=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel("x-storagemutated-1");s9("storagemutated",t=>{lG||e.postMessage(t)}),e.onmessage=e=>{e.data&&lW(e.data)}}else if("u">typeof self&&"u">typeof navigator){s9("storagemutated",e=>{try{lG||("u">typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:"x-storagemutated-1",changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if("x-storagemutated-1"===e.key){let t=JSON.parse(e.newValue);t&&lW(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&"x-storagemutated-1"===e.type&&lW(e.changedParts)})}function lV(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}i8.rejectionMapper=function(e,t){if(!e||e instanceof iw||e instanceof TypeError||e instanceof SyntaxError||!e.name||!iD[e.name])return e;var n=new iD[e.name](t||e.message,e);return"stack"in e&&oZ(n,"stack",{get:function(){return this.inner.stack}}),n},ig=sT;class lU extends lj{constructor(){super("EsmOffline"),lV(this,"syncQueue",void 0),lV(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 lq(){return new lU}let lH=new lU,lK={},lY=U("offline-synchronization",{});function lJ(){return lY}async function lZ(){if(lY.getState().synchronization)return;let e=await lH.syncQueue.count(),t={},n=Object.entries(lK),a=n.length,r={},o=new AbortController,i=()=>{let e=lY.getState().synchronization;lY.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{lY.setState({synchronization:{totalCount:e,pendingCount:e,abortController:o}});for(let e=0;e<a&&n.length>0;e++)for(let e=n.length;e--;){let[a,s]=n[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(r[a]={},await Promise.all(l),t[a]=lX(s,r,o,i),n.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{lY.setState({synchronization:void 0})}}async function lX({type:e,dependsOn:t,process:n},a,r,o){let i=[],s=[],l=await lQ();await lH.syncQueue.where({type:e,userId:l}).each((e,t)=>{i.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<i.length;c++){let[u,p,{id:d,dependencies:f=[]}]=i[c];try{let o=await n(p,{abort:r,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:n})=>t.includes(n)?a[n][e]:void 0)});void 0!==d&&(a[e][d]=o),await lH.syncQueue.delete(u)}catch(e){await lH.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{o()}}}async function lQ(){let e=await a$();return e?.uuid||"*"}async function l0(e,t,n,a){let r=a&&a.id;return void 0!==r&&await lH.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===r).delete().catch(lj.errnames.DatabaseClosed),await lH.syncQueue.add({type:t,content:n,userId:e,descriptor:a||{},createdOn:new Date}).catch(lj.errnames.DatabaseClosed,()=>-1)}async function l1(e,t,n){let a=await lQ();return await l0(a,e,t,n)}async function l2(e,t){return(await l3(e,t)).map(e=>e.content)}async function l3(e,t){return await lH.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(lj.errnames.DatabaseClosed,()=>[])}async function l4(e){let t=await lQ();return await l2(t,e)}async function l5(e){let t=await lQ();return await l3(t,e)}async function l6(e){return await lH.syncQueue.get(e).catch(lj.errnames.DatabaseClosed,()=>void 0)}function l8(e){return!!lK[e]?.options.onBeginEditSyncItem}async function l7(e){let t=await l6(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let n=lK[t.type]?.options.onBeginEditSyncItem;if(!n)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);n(t)}async function l9(e){await lH.syncQueue.delete(e).catch(lj.errnames.DatabaseClosed)}function ce(e,t,n,a={}){lK[e]={type:e,dependsOn:t,process:n,options:a}}var ct=n(8414);let cn="OFFLINE+";function ca(){return cn+(0,ct.A)()}function cr(e){return e.startsWith(cn)}let co={};function ci(){return Object.values(co)}function cs(e){co[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.`),co[e.id]=e}async function cl(e){let t=await cg();return await cc(t,e)}async function cc(e,t){let n=new lU;return await n.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(lj.errnames.DatabaseClosed,()=>[])}async function cu(e,t){let n=await cg();return await cp(n,e,t)}async function cp(e,t,n){let a=new lU,r=await a.dynamicOfflineData.get({type:t,identifier:n}).catch(lj.errnames.DatabaseClosed,()=>void 0);r?r.users.includes(e)||await a.dynamicOfflineData.update(r.id,{users:[...r.users,e]}).catch(lj.errnames.DatabaseClosed):await a.dynamicOfflineData.add({users:[e],type:t,identifier:n}).catch(lj.errnames.DatabaseClosed)}async function cd(e,t){let n=await cg();return await cf(n,e,t)}async function cf(e,t,n){let a=new lU,r=await a.dynamicOfflineData.get({type:t,identifier:n,users:e}).catch(lj.errnames.DatabaseClosed,()=>void 0);r&&(r.users.length>1?await a.dynamicOfflineData.update(r.id,{users:r.users.filter(t=>t!==e)}).catch(lj.errnames.DatabaseClosed):await a.dynamicOfflineData.delete(r.id).catch(lj.errnames.DatabaseClosed))}async function ch(e,t){let n=await cl(e);await Promise.all(n.map(async e=>cm(e.type,e.identifier,t)))}async function cm(e,t,n){await cu(e,t);let a=new lU,r=await cg(),o=await a.dynamicOfflineData.get({type:e,identifier:t}).catch(lj.errnames.DatabaseClosed,()=>void 0),i=ci().filter(t=>t.type===e);if(!o)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(t,n),{id:e.id,error:void 0}}catch(n){let t=n.message?.toString()??n.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),p={syncedOn:new Date,syncedBy:r,succeededHandlers:l,erroredHandlers:c,errors:u};o.id&&await a.dynamicOfflineData.update(o.id,{syncState:p}).catch(lj.errnames.DatabaseClosed)}async function cg(){let e=(await a$()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let cy=U("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function cb(){return c$(),cy}function c_(e,t){c$(),cs({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,n)=>t.onOfflinePatientAdded({patientUuid:e,signal:n??new AbortController().signal})})}async function cv(e){c$(),await cm("patient",e)}function c$(){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 cA(e,t,n=!0){if(e){let a=null,[r,o]=await Promise.all([au(`${as}/Patient/${e}`,t).catch(e=>a=e),n?cw(e):Promise.resolve(null)]);if(r.ok)return r.data;if(o)return o;if(a)throw a}return null}async function cw(e){let t=(await l4("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function ck(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function cx(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}var cC=n(6170);function cE(e){return{uuid:e.uuid,display:e.display}}function cS(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let a=n.toString();return ap(`${ai}/location${a?"?"+a:""}`).pipe((0,cC.map)(e=>e.data.results.map(cE))).pipe((0,cC.take)(1))}function cD(e){return{uuid:e.uuid,display:e.display,name:e.name}}function cM(){return ap(`${ai}/visittype`).pipe((0,cC.map)(e=>e.data.results.map(cD))).pipe((0,cC.take)(1))}var cz=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),cO=function(e){function t(t,n){var a=e.call(this)||this;return a.subject=t,a.subscriber=n,a.closed=!1,a}return ea(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(ep),cP=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return ea(t,e),t}(eh),cT=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return ea(t,e),t.prototype[ef]=function(){return new cP(this)},t.prototype.lift=function(e){var t=new cB(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new cz;if(!this.isStopped)for(var t=this.observers,n=t.length,a=t.slice(),r=0;r<n;r++)a[r].next(e)},t.prototype.error=function(e){if(this.closed)throw new cz;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,a=t.slice(),r=0;r<n;r++)a[r].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new cz;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),a=0;a<t;a++)n[a].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new cz},t.prototype._subscribe=function(e){if(this.closed)throw new cz;return this.hasError?(e.error(this.thrownError),ep.EMPTY):this.isStopped?(e.complete(),ep.EMPTY):(this.observers.push(e),new cO(this,e))},t.prototype.asObservable=function(){var e=new ey;return e.source=this,e},t.create=function(e,t){return new cB(e,t)},t}(ey),cB=function(e){function t(t,n){var a=e.call(this)||this;return a.destination=t,a.source=n,a}return ea(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):ep.EMPTY},t}(cT),cI=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return ea(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new cz},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(cT),cN=((Z={}).NEWVISIT="startVisit",Z.EDITVISIT="editVisit",Z.LOADING="loadingVisit",Z),cj=((X={}).NOTSTARTED="notStarted",X.ONGOING="ongoing",X);let cR="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))",cF=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function cL(){return H("visit",cF)}function cW(e,t){cL().setState({patientUuid:e,manuallySetVisitUuid:t})}function cG(e,t){return au(`${ai}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function cV(e,t,n){return au(`${ai}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function cU(e,t,n){return au(`${ai}/visit?patient=${e}&v=${n??cR}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}cL().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let cq=new cI(null);class cH{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+cH.version}static addUnaryOp(e){return cH.max_unop_len=Math.max(e.length,cH.max_unop_len),cH.unary_ops[e]=1,cH}static addBinaryOp(e,t,n){return cH.max_binop_len=Math.max(e.length,cH.max_binop_len),cH.binary_ops[e]=t,n?cH.right_associative.add(e):cH.right_associative.delete(e),cH}static addIdentifierChar(e){return cH.additional_identifier_chars.add(e),cH}static addLiteral(e,t){return cH.literals[e]=t,cH}static removeUnaryOp(e){return delete cH.unary_ops[e],e.length===cH.max_unop_len&&(cH.max_unop_len=cH.getMaxKeyLen(cH.unary_ops)),cH}static removeAllUnaryOps(){return cH.unary_ops={},cH.max_unop_len=0,cH}static removeIdentifierChar(e){return cH.additional_identifier_chars.delete(e),cH}static removeBinaryOp(e){return delete cH.binary_ops[e],e.length===cH.max_binop_len&&(cH.max_binop_len=cH.getMaxKeyLen(cH.binary_ops)),cH.right_associative.delete(e),cH}static removeAllBinaryOps(){return cH.binary_ops={},cH.max_binop_len=0,cH}static removeLiteral(e){return delete cH.literals[e],cH}static removeAllLiterals(){return cH.literals={},cH}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 cH(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 cH.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!cH.binary_ops[String.fromCharCode(e)]||cH.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return cH.isIdentifierStart(e)||cH.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(cH.hooks[e]){let n={context:this,node:t};return cH.hooks.run(e,n),n.node}return t}searchHook(e){if(cH.hooks[e]){let t={context:this};return cH.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===cH.SPACE_CODE||e===cH.TAB_CODE||e===cH.LF_CODE||e===cH.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:cH.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],n,a;for(;this.index<this.expr.length;)if((n=this.code)===cH.SEMCOL_CODE||n===cH.COMMA_CODE)this.index++;else if(a=this.gobbleExpression())t.push(a);else if(this.index<this.expr.length){if(n===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,cH.max_binop_len),t=e.length;for(;t>0;){if(cH.binary_ops.hasOwnProperty(e)&&(!cH.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!cH.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,n,a,r,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(r={value:t,prec:cH.binaryPrecedence(t),right_a:cH.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),a=[o,r,i];t=this.gobbleBinaryOp();){if(0===(n=cH.binaryPrecedence(t))){this.index-=t.length;break}r={value:t,prec:n,right_a:cH.right_associative.has(t)},l=t;let s=e=>r.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;a.length>2&&s(a[a.length-2]);)i=a.pop(),t=a.pop().value,o=a.pop(),e={type:cH.BINARY_EXP,operator:t,left:o,right:i},a.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),a.push(r,e)}for(s=a.length-1,e=a[s];s>1;)e={type:cH.BINARY_EXP,operator:a[s-1].value,left:a[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,n,a;if(this.gobbleSpaces(),a=this.searchHook("gobble-token"))return this.runHook("after-token",a);if(e=this.code,cH.isDecimalDigit(e)||e===cH.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===cH.SQUOTE_CODE||e===cH.DQUOTE_CODE)a=this.gobbleStringLiteral();else if(e===cH.OBRACK_CODE)a=this.gobbleArray();else{for(n=(t=this.expr.substr(this.index,cH.max_unop_len)).length;n>0;){if(cH.unary_ops.hasOwnProperty(t)&&(!cH.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!cH.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=n;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:cH.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--n)}cH.isIdentifierStart(e)?(a=this.gobbleIdentifier(),cH.literals.hasOwnProperty(a.name)?a={type:cH.LITERAL,value:cH.literals[a.name],raw:a.name}:a.name===cH.this_str&&(a={type:cH.THIS_EXP})):e===cH.OPAREN_CODE&&(a=this.gobbleGroup())}return a?(a=this.gobbleTokenProperty(a),this.runHook("after-token",a)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===cH.PERIOD_CODE||t===cH.OBRACK_CODE||t===cH.OPAREN_CODE||t===cH.QUMARK_CODE;){let n;if(t===cH.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==cH.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===cH.OBRACK_CODE?((e={type:cH.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==cH.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===cH.OPAREN_CODE?e={type:cH.CALL_EXP,arguments:this.gobbleArguments(cH.CPAREN_CODE),callee:e}:(t===cH.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:cH.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,n;for(;cH.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===cH.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);cH.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));cH.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);cH.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return n=this.code,cH.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(n===cH.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===cH.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:cH.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,n=this.expr.charAt(this.index++),a=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){a=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return a||this.throwError('Unclosed quote after "'+e+'"'),{type:cH.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(cH.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,cH.isIdentifierPart(e))this.index++;else break;return{type:cH.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],n=!1,a=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let r=this.code;if(r===e){n=!0,this.index++,e===cH.CPAREN_CODE&&a&&a>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(r===cH.COMMA_CODE){if(this.index++,++a!==t.length){if(e===cH.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===cH.CBRACK_CODE)for(let e=t.length;e<a;e++)t.push(null)}}else if(t.length!==a&&0!==a)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==cH.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(cH.CPAREN_CODE);if(this.code===cH.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:cH.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:cH.ARRAY_EXP,elements:this.gobbleArguments(cH.CBRACK_CODE)}}}Object.assign(cH,{hooks:new class{add(e,t,n){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(cH),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"}),cH.max_unop_len=cH.getMaxKeyLen(cH.unary_ops),cH.max_binop_len=cH.getMaxKeyLen(cH.binary_ops);let cK=e=>new cH(e).parse(),cY=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(cH).filter(e=>!cY.includes(e)&&void 0===cK[e]).forEach(e=>{cK[e]=cH[e]}),cK.Jsep=cH,cK.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:a,alternate:r},n.operator&&e.binary_ops[n.operator]<=.9){let a=n;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=n}}else this.throwError("Expected :")}})}});let cJ="ArrowFunctionExpression",cZ={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)}},cX={...cZ,Promise};function cQ(e,t={}){return c5(e,t,c7)}async function c0(e,t={}){return c6(e,t,c7)}function c1(e,t={}){return c5(e,t,c9)}function c2(e,t={}){return c6(e,t,c9)}function c3(e,t={}){return c5(e,t,ue)}function c4(e,t={}){return c6(e,t,ue)}function c5(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let a=ua(t,cZ),r=ut("string"==typeof e?cK(e):e,a);if(n(r))return r;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 c6(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let a=ua(t,cX);return Promise.resolve(ut("string"==typeof e?cK(e):e,a)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function c8(e){return cK(e)}function c7(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function c9(e){return"boolean"==typeof e}function ue(e){return"number"==typeof e}function ut(e,t){switch(e.type){case"UnaryExpression":var n,a,r,o,i,s,l,c,u,p,d,f,h=e,m=t;let g=ut(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 y=e,b=t;let v=ut(y.left,b),$=ut(y.right,b);switch(y.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 '${y.operator}' operator`}case"ConditionalExpression":return n=e,a=t,ut(n.test,a)?ut(n.consequent,a):ut(n.alternate,a);case"CallExpression":var A=e,w=t;let k=A.arguments?.map(ur(w)),x=ut(A.callee,w);if(x){if("function"!=typeof x)throw`${ui(A.callee)} is not a function`}else throw`No function named ${ui(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return r=e,o=t,C=r.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 t=Object.fromEntries(C.reduce((t,n,a)=>{let r=e[a];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(r)&&t.push([n,r]),t},[]));return ut(r.body,o.addVariables(t))}).bind(o.thisObj??null);case"MemberExpression":return function(e,t){let n,a=ut(e.object,t);if(void 0===a)switch(e.object.type){case"Identifier":{let n=un(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":{let n=un(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${n}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let r=a;if("string"==typeof a)r=String.prototype;else if("number"==typeof a)r=Number.prototype;else if("function"==typeof a);else if("object"!=typeof a)throw`VisitMemberExpression does not support member access on type ${typeof a}`;switch(t.thisObj=r,e.property.type){case"Identifier":case"MemberExpression":n=ut(e.property,t);break;default:{let r=ut(e.property,t);if(void 0===r)throw{type:"Illegal property access",message:"No property was supplied to the property access"};uo(r),n=a[r]}}return"function"==typeof n?n.bind(a):n}(e,t);case"ArrayExpression":return i=e,s=t,i.elements?.map(ur(s));case"SequenceExpression":let E;return l=e,c=t,(E=l.expressions.map(ur(c)))[E.length-1];case"NewExpression":var S=e,D=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(ur(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 uo((u=e).value),u.value;case"Identifier":var M=e,z=t;uo(M.name);let O=z.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&M.name in O){let e=O[M.name];return uo(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return uo(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let P,T;return p=e,d=t,P=p.expressions?.map(ur(d))??[],(T=p.quasis?.map(ur(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.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 un(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return un(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function ua(e,t){let n={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}function ur(e){return function(t){return null===t?null:ut(t,e)}}function uo(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function ui(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function us(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...cX},isLocalExpression:!1,variables:new Set};return ul("string"==typeof e?cK(e):e,t),[...t.variables]}function ul(e,t){switch(e.type){case"UnaryExpression":return a=e,r=t,ul(a.argument,r);case"BinaryExpression":return o=e,i=t,[ul(o.left,i),ul(o.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[ul(s.consequent,l),ul(s.test,l),ul(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return c=e,u=t,n=ul(c.callee,u),c.arguments?.map(uc(u)),n;case"ArrowFunctionExpression":var a,r,o,i,s,l,c,u,p,d,f,h,m,g,y,b,v,$,A=e,w=t;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(uc(k))??[],C=ul(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 p=e,d=t,ul(p.object,d),void((E={...d}).isLocalExpression=!0,ul(p.property,E));case"ArrayExpression":return f=e,h=t,void f.elements?.map(uc(h));case"SequenceExpression":return m=e,g=t,void m.expressions?.map(uc(g));case"NewExpression":return y=e,b=t,void y.arguments?.map(uc(b));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=t;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=t,void(v.expressions?.map(uc($)),v.quasis?.map(uc($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function uc(e){return function(t){return null===t?null:ul(t,e)}}cK.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let n=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let n=this.gobbleBinaryExpression();n||this.throwError("Expected expression after "+e),t.node={type:cJ,params:null,body:n};return}}this.index=n}}),e.hooks.add("after-expression",function(t){!function t(n){n&&(Object.values(n).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===n.operator&&(n.type=cJ,n.params=n.left?[n.left]:null,n.body=n.right,n.params&&n.params[0].type===e.SEQUENCE_EXP&&(n.params=n.params[0].expressions),delete n.left,delete n.right,delete n.operator))}(t.node)})}}),cK.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let n=t.node;if(n&&"new"===n.operator){n.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(n.argument.type)||this.throwError("Expected new function()"),t.node=n.argument;let a=t.node;for(;a.type===e.MEMBER_EXP||a.type===e.CALL_EXP&&a.callee.type===e.MEMBER_EXP;)a=a.type===e.MEMBER_EXP?a.object:a.callee.object;a.type="NewExpression"}})}}),cK.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function n(t){let n=this.index,a="",r=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:a+=this.expr.charAt(this.index++)};r(),this.code===e.PERIOD_CODE&&(a+=this.expr.charAt(this.index++),r());let o=this.char;("e"===o||"E"===o)&&(a+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(a+=this.expr.charAt(this.index++)),r(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+a+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+a+this.char+")");else if(i===e.PERIOD_CODE){a.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:a},null,2)}`),this.index=n;return}t.node={type:e.LITERAL,value:parseFloat(a),raw:this.expr.substring(n,this.index)}}e.hooks.add("gobble-token",function(a){if(48===this.code){var r,o,i;let s=this.index,l=this.expr.charAt(this.index+1),c=t.call(this,l);if(!c)return;let u="";for(;r=this.code,o=c,95===r||o.some(([e,t])=>r>=e&&r<=t);)95===this.code?this.index++:u+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,n.call(this,a);return}this.throwError("unexpected char within number")}a.node={type:e.LITERAL,value:parseInt(u,"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)&&n.call(this,a)})}}),cK.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let n=++this.index,a=!1;for(;this.index<this.expr.length;){if(47===this.code&&!a){let a,r=this.expr.slice(n,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{a=new RegExp(r,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:a,raw:this.expr.slice(n-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?a=!0:a&&this.code===e.CBRACK_CODE&&(a=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),cK.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:a,alternate:r},n.operator&&e.binary_ops[n.operator]<=.9){let a=n;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=n}}else this.throwError("Expected :")}})}}),cK.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,n=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},a="",r="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:r,cooked:a},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=t,n&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),r="",a="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(r+=i,i=this.expr.charAt(++this.index),r+=i,i){case"n":a+="\n";break;case"r":a+="\r";break;case"t":a+=" ";break;case"b":a+="\b";break;case"f":a+="\f";break;case"v":a+="\v";break;default:a+=i}else a+=i,r+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(n){if((n.node.type===e.IDENTIFIER||n.node.type===e.MEMBER_EXP)&&96===this.code)return n.node={type:"TaggedTemplateExpression",tag:n.node,quasi:t.bind(this)(n,!1)},n.node=this.gobbleTokenProperty(n.node),n.node})}}),cK.addBinaryOp("in",7),cK.addBinaryOp("??",1);let uu=H("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),a=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...a}}return e}()});function up(e,t,n){uu.setState(a=>({flags:{...a.flags,[e]:{enabled:a.flags[e]?.enabled??!1,label:t,description:n}}}))}function ud(){let e=uu.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function uf(e){return uu.getState().flags[e].enabled}function uh(e,t){uu.subscribe(n=>{t(n.flags[e].enabled)})}function um(e,t){uu.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}function ug(e){return!window.offlineEnabled||(e??navigator.onLine)}function uy(e=!0,t=!1){return ub(ug(),e,t)}function ub(e,t=!0,n=!1){return!!(e?t:n)}uu.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});let u_=U("extensionsInternal",{slots:{},extensions:{}}),uv=U("extensionRenderings",{renderings:new Map}),u$=()=>H("extensionsInternal",{slots:{},extensions:{}}),uA=()=>H("extensionRenderings",{renderings:new Map});function uw(e){let t=u_.getState(),n=e(t);n!==t&&u_.setState(n)}let uk=null,ux=null;function uC(){let e=uv.getState();return uk&&e===ux||(uk=new Map(e.renderings),ux=e,function(e){for(let t of(uI.clear(),e.values()))uj(t,1);uN=!0}(uk)),uk}function uE(e){ux={renderings:e},uv.setState(ux,!0)}function uS(e){let t=uC();t.has(e.renderingId)||(t.set(e.renderingId,e),uj(e,1),uE(t))}function uD(e){let t=uC(),n=t.get(e);n&&(t.delete(e),uj(n,-1),uE(t))}let uM=()=>H("extensions",{slots:{}}),uz=0,uO=new Set;function uP(e){uz++;try{return e()}finally{if(0==--uz&&uO.size>0){let e=Array.from(uO);for(let t of(uO.clear(),e))uT(t)}}}function uT(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function uB(e){uz>0?uO.add(e):uT(e)}let uI=new Map,uN=!1;function uj(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),a=uI.get(n);if(!a){if(t<0)return;uI.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),uN=!0;return}a.count+=t,a.count<1&&(uI.delete(n),uN=!0)}function uR(){var e,t;if(uC(),!uN)return;uN=!1;let n=Array.from(uI.values(),({record:e})=>e);n.sort(uF),e=eD.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===uF(e,t[n]))||eD.setState({mountedExtensions:n})}function uF(e,t){return uL(e.slotName,t.slotName)||uL(e.extensionId,t.extensionId)||uL(e.slotModuleName,t.slotModuleName)||uL(e.extensionModuleName,t.extensionModuleName)}function uL(e,t){return e===t?0:e<t?-1:1}uR(),uv.subscribe(()=>uB(uR));let uW=u$(),uG=uM(),uV=ez(),uU=eT(),uq=new Set,uH=!1;function uK(e){if(null===e)uq=null;else if(null!==uq)for(let t of e)uq.add(t);uB(uY)}function uY(){if(!uH){uH=!0;try{for(let e=1;;e++){let t=uq;if(null!==t&&0===t.size)return;uq=new Set;try{!function(e,t,n,a,r,o=null){let i=uG.getState().slots,s={},l=!1,c=ug(),u=Object.entries(a.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[a,p]of Object.entries(e.slots)){let d=i[a];if(d&&o&&!o.has(a)){s[a]=d;continue}let{config:f}=eP(t,p.name),h=function(e,t,n,a,r,o,i){let s=function(e,t){let n=e.add||[],a=e.remove||[],r=e.order||[],{extensions:o}=uW.getState();return[...t,...n].filter(e=>!a.includes(e)).sort((e,n)=>u6(e,r,o[uQ(e)]?.order,t)-u6(n,r,o[uQ(n)]?.order,t))}(n,t.slots[e].attachedIds),l=[];for(let c of s){let{config:s}=eI(a,e,c),u=eN(n,e,c),p=u?(0,et.merge)({},s,u):s,d=uQ(c),f=t.extensions[d];if(f){let e=p?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!i?.user||!av(e,i.user))||f.featureFlag&&!r.includes(f.featureFlag)||window.offlineEnabled&&!ub(o,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:p,featureFlag:f.featureFlag,meta:f.meta,online:p?.["Display conditions"]?.online??f.online??!0,offline:p?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:p?.["Display conditions"]?.expression||f.displayExpression})}}return l}(a,e,f,n,u,c,r.session);d&&d.moduleName===p.moduleName&&(0,et.isEqual)(d.candidateExtensions,h)?s[a]=d:(s[a]={moduleName:p.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&uG.setState({slots:s})}(uW.getState(),uV.getState(),uU.getState(),uu.getState(),af.getState(),t)}catch(e){throw uq=null===t||null===uq?null:new Set([...t,...uq]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{uH=!1}}}function uJ(e,t){let n=new Set;for(let a of Object.keys(e))e[a]!==t[a]&&n.add(a);for(let a of Object.keys(t))a in e||n.add(a);return n}function uZ(){uK(null)}function uX(e,t){return{moduleName:t,name:e,attachedIds:[]}}function uQ(e){let[t]=e.split("#");return t}function u0(e,t){let n=uQ(t);return e.extensions[n]}function u1(e){return u0(uW.getState(),e)}uW.subscribe((e,t)=>{uK(e.extensions!==t.extensions?null:uJ(e.slots,t.slots))}),uV.subscribe((e,t)=>{uK(uJ(e.slots,t.slots))}),uU.subscribe((e,t)=>{uK(uJ(e.configs,t.configs))}),uu.subscribe(()=>uK(null)),af.subscribe(()=>uK(null)),uZ(),y(uZ);let u2=e=>uw(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function u3(e,t){uw(n=>{let a=n.slots[e];return a?{...n,slots:{...n.slots,[e]:{...a,attachedIds:[...a.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...uX(e),attachedIds:[t]}}}})}function u4(e,t){uw(n=>{let a=n.slots[e];return a&&a.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...a,attachedIds:a.attachedIds.filter(e=>e!==t)}}}:n})}function u5(e){uw(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function u6(e,t,n,a){let r=t.indexOf(e);if(-1!==r)return r;{if(void 0!==n)return 1e3+n;let t=a.indexOf(e);return -1!==t?2e3+t:3e3}}function u8(e,t){return function(e,t,n=null,a){let r;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;r??(r=t&&"object"==typeof t?{session:n,...t}:{session:n});try{return!!c1(o,r)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(a?` in ${a}`:""),t),!1}})}(u7(e),t,af.getState().session,e)}function u7(e){return uG.getState().slots[e]?.candidateExtensions??[]}let u9=(e,t)=>uW.setState(n=>{let a=n.slots[t]?.moduleName;if(a&&a!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${a}.`),n;if(a&&a==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let r=uX(t,e);return{...n,slots:{...n.slots,[t]:{...r}}}}),pe=()=>{uq=null,uw(()=>({slots:{},extensions:{}})),uA().setState({renderings:new Map}),uG.setState({slots:{}})},pt=U("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function pn({name:e,basePath:t,mode:n,componentContext:a,state:r}){pt.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:a,state:r})}function pa(e){pt.getState().slotName===e&&pt.setState(pt.getInitialState(),!0)}let pr=U("modalRegistry",{modals:{}});function po(e){pr.setState(t=>(t.modals[e.name]=e,t))}function pi(e){let t=pr.getState().modals[e];if(!t){let n=u1(e);n&&(t={name:e,load:n.load,moduleName:n.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.`),po(t))}return t}let ps=U("workspaceRegistrations",{workspaces:{}}),pl=U("workspaceGroups",{workspaceGroups:{}});function pc(e){ps.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function pu(e){pl.setState(t=>{let n=t.workspaceGroups[e.name];return n?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...n,members:Array.from(new Set([...n.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let pp=new Set;function pd(e){let t=ps.getState().workspaces;if(t[e])return t[e];{let t=u1(e);if(t){var n;let a;return pp.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.`),pp.add(e)),{name:t.name,title:(n=t,"string"==typeof(a=n?.meta?.title)?a:a&&"object"==typeof a?rC(n.moduleName,a.key,a.default):n.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function pf(e){let t=pl.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let ph=U("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function pm(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=ph.getState(),a=t[e];if(a){let t=n[a.window];if(t)return t;throw Error(`No workspace window found with name: ${a.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function pg(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=ph.getState(),a=n[e];if(a){let n=t[a.group];if(n)return n;throw Error(`No workspace group found with name: ${a.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function py(e){let{openedWindows:t}=ph.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function pb(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=ph.getState(),a={...n};for(let n of t){if(a[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);a[n.name]={...n,moduleName:e}}ph.setState({registeredGroupsByName:a})}function p_(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=ph.getState(),a={...n};for(let n of t){if(a[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};a[n.name]=t}ph.setState({registeredWindowsByName:a})}function pv(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=ph.getState(),a={...n};for(let n of t){if(a[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};a[n.name]=t}ph.setState({registeredWorkspacesByName:a})}let p$=0,pA=null,pw={bootstrap:{millis:15e3,dieOnTimeout:!0},mount:{millis:15e3,dieOnTimeout:!0},unmount:{millis:15e3,dieOnTimeout:!0}};async function pk(e,t){return(await (pA??(pA=new Promise((e,t)=>{nl({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),nl))),pA))("function"==typeof e?()=>e().then(e=>({timeouts:pw,...e})):{timeouts:pw,...e},t)}function px(){return pC}function pC(e,t){let n,a=pk(e,t).then(e=>n=e);return{mount:()=>a.then(e=>e.mount()),unmount:()=>a.then(e=>e.unmount()),update:e=>a.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return a.then(e=>e.loadPromise)},get bootstrapPromise(){return a.then(e=>e.bootstrapPromise)},get mountPromise(){return a.then(e=>e.mountPromise)},get unmountPromise(){return a.then(e=>e.unmountPromise)}}}async function pE(e,t,n,a,r=e=>e,o={}){let i=uQ(a),s=u1(a),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(uy(p,d)){let s,p=p$++,d=`${t}/${a}-${p}`;e.dataset.extensionRenderingId=d;let h=e=>{try{uD(d)}catch(t){console.error(e,t)}};try{uS({renderingId:d,extensionName:i,extensionModuleName:u,extensionId:a,slotName:t,slotModuleName:n})}catch(e){throw h(`Recomputing configuration after registering '${a}' failed also failed`),e}try{s=await f()}catch(e){throw h(`Recomputing configuration after '${a}' failed to load also failed`),e}try{l=await pk(r({...s,name:`${t}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:a,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:u},domElement:e})}catch(e){throw h(`Recomputing configuration after '${a}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${a}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${a}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${a}' failed`),e=>{console.error(`Extension '${a}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${a}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${a} into ${t} but no DOM element was available.`);return l}var pS=n(7979),pD=n.n(pS);let pM=(0,pS.createContext)({moduleName:"",featureName:""});function pz({to:e,templateParams:t,onBeforeNavigate:n,children:a,...r}){return(0,pS.useEffect)(()=>{r.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${r.href}'`),r.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),pD().createElement("a",{onClick:a=>{0===a.button&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&!a.metaKey&&(a.preventDefault(),n?.(a),n6({to:e,templateParams:t})),0===a.button&&(a.ctrlKey||a.metaKey)&&n?.(a),0===a.button&&a.shiftKey&&n?.(a),1===a.button&&n?.(a)},href:n4(e,t),...r},a)}let pO=({state:e,children:t,...n})=>{let{extension:a}=(0,pS.useContext)(pM),r=(0,pS.useRef)(null),o=(0,pS.useRef)(Promise.resolve()),i=(0,pS.useRef)(!1),s=(0,pS.useRef)(!1),l=(0,pS.useRef)(e),c=(0,pS.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),u=(0,pS.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(r.current?.getStatus()==="MOUNTED"&&r.current.update)return r.current.update({...t})}).catch(e=>{let t=r.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${a?.extensionId}' failed to update`,e)}))},[]),p=(0,pS.useCallback)(t=>{t&&!r.current&&!s.current&&a?.extensionSlotName&&a.extensionSlotModuleName&&(s.current=!0,pE(t,a.extensionSlotName,a.extensionSlotModuleName,a.extensionId,void 0,e).then(t=>{(s.current=!1,r.current=t,i.current)?c(t):t&&l.current!==e&&u(t,l.current)},()=>{s.current=!1}))},[]);return(0,pS.useEffect)(()=>(i.current=!1,()=>{i.current=!0,c(r.current)}),[]),(0,pS.useEffect)(()=>{l.current=e,r.current&&u(r.current,e)},[e]),a?pD().createElement("div",{ref:p,"data-extension-id":a?.extensionId,style:{position:"relative"},...n}):null};function pP(e){let t=(0,pS.useRef)(e);return j(t.current,e)||(t.current=e),t.current}function pT(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[a,r]of Object.entries(t)){let t=function(...t){e.setState(e=>r(e,...t))};n[a]=t}return n}let pB=e=>e;function pI(e,t=pB,n){let a=(0,pS.useCallback)(t=>e.subscribe(t),[e]),r=(0,pS.useCallback)(()=>t(e.getState()),[e,t]),o=(0,pS.useSyncExternalStore)(a,r,r),i=(0,pS.useMemo)(()=>n?pT(e,n):null,[e,n]);return(0,pS.useMemo)(()=>i?{...o,...i}:o,[o,i])}function pN(e,t){return pI(e,pB,t)}function pj(e){return function(t){let n=(0,pS.useCallback)(t=>e.subscribe(t),[]),a=(0,pS.useCallback)(()=>e.getState(),[]),r=(0,pS.useSyncExternalStore)(n,a,a),o=(0,pS.useMemo)(()=>t?pT(e,t):null,[t]);return(0,pS.useMemo)(()=>o?{...r,...o}:r,[r,o])}}let pR=[];Object.freeze(pR);let pF={candidateExtensions:pR};Object.freeze(pF);let pL=e=>{let t=(0,pS.useCallback)(t=>t.slots?.[e]??pF,[e]);return pI(uM(),t)},pW=e=>e.session;function pG(e,t){let{candidateExtensions:n}=pL(e),a=pI(af,pW),r=pP(t);return(0,pS.useMemo)(()=>u8(e,r),[e,r,a,n])}function pV(e,t){let{moduleName:n}=(0,pS.useContext)(pM);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,pS.useEffect)(()=>{u9(n,e)},[n,e]),{extensions:pG(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function pU(e){return e}function pq({name:e,extensionSlotName:t,select:n=pU,children:a,state:r,style:o,...i}){if(a&&r)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,pS.useRef)(null),{extensions:c,extensionSlotModuleName:u}=pV(s,r),p=(0,pS.useMemo)(()=>n(c),[n,c]),d=(0,pS.useMemo)(()=>{if("function"==typeof a&&!pD().isValidElement(a))return p.map(e=>a(e,r))},[a,p]);return pD().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...o,position:"relative"},...i},s&&p?.map((e,t)=>pD().createElement(pM.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[t]??("function"!=typeof a?a:null)??pD().createElement(pO,{state:r}))))}var pH=n(5338);function pK(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function pY(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pK(Object(n),!0).forEach(function(t){var a,r,o;a=e,r=t,o=n[t],r in a?Object.defineProperty(a,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[r]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pK(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pJ(e){return(pJ="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 pZ(e){return(pZ="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 pX(e,t){var n;if("function"!=typeof(n=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var n="single-spa-application:".concat(t);return function(){var e=document.getElementById(n);return e||((e=document.createElement("div")).id=n,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(pZ(n)));return function(){var e=n(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(pZ(e)));return e}}var pQ=null;try{pQ=require("react").createContext()}catch(e){}var p0={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 p1(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function p2(e,t){return new Promise(function(n,a){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var r,o=p6(e,t,function(){n(this)}),i=pX(e,t)(),s=function(e){var t=e.reactDom,n=e.renderType,a=e.elementToRender,r=e.domElement,o=t[n];if("function"!=typeof o)throw Error('renderType "'.concat(n,'" did not return a function.'));switch(n){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(r);return i.render(a),i;case"hydrateRoot":return o(r,a);default:return o(a,r),null}}({elementToRender:o,domElement:i,reactDom:p5(e),renderType:"function"==typeof(r=e).renderType?r.renderType():r.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function p3(e,t){return new Promise(function(n){e.unmountResolves[t.name]=n;var a=e.renderResults[t.name];a&&a.unmount?a.unmount():p5(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function p4(e,t){return new Promise(function(n){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(n);var a=p6(e,t,null),r=e.renderResults[t.name];if(r&&r.render)r.render(a);else{var o=pX(e,t)();p5(e).render(a,o)}})}function p5(e){return e.ReactDOMClient||e.ReactDOM}function p6(e,t,n){var a=e.React.createElement(e.rootComponent,t),r=pQ?e.React.createElement(pQ.Provider,{value:t},a):a;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function n(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},n.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},n.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},n}(e,t),r=e.React.createElement(e.errorBoundaryClass,t,r)),r=e.React.createElement(e.SingleSpaRoot,pY(pY({},t),{},{mountFinished:n,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),r)}var p8=n(3826),p7=n(9324),p9=n(7956);let de={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},dt=new Map;(0,p9.initCache)(dt);let dn={errorRetryCount:3,fetcher:au,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof ad){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>dt};function da(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},de,e),n={...dn,...t.swrConfig};return function(e){var a,r,o,i,s;return o=r=class extends(a=pD().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return pD().createElement("div",null,"An error has occurred. Please try reloading the page.");{let a=pD().createElement(pS.Suspense,{fallback:null},pD().createElement(p7.BE,{value:n},pD().createElement(pM.Provider,{value:this.state.config},t.disableTranslations?pD().createElement(e,this.props):pD().createElement(p8.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},pD().createElement(e,this.props)))));return t.strictMode&&pD().StrictMode?pD().createElement(pD().StrictMode,null,a):a}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,r}}function dr(e,t){return function(e){if("object"!==pJ(e))throw Error("single-spa-react requires a configuration object");var t,n=pY(pY({},p0),e);if(!n.React)throw Error("single-spa-react must be passed opts.React");if(!n.ReactDOM&&!n.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(n.renderType||(null!=(t=n.ReactDOMClient)&&t.createRoot?n.renderType="createRoot":n.renderType="render"),!n.rootComponent&&!n.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(n.errorBoundary&&"function"!=typeof n.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!pQ&&n.React.createContext&&(pQ=n.React.createContext()),n.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(n);var a={bootstrap:p1.bind(null,n),mount:p2.bind(null,n),unmount:p3.bind(null,n)};return n.parcelCanUpdate&&(a.update=p4.bind(null,n)),a}({React:pD(),ReactDOMClient:pH,rootComponent:da(t)(e)})}function di(e,t){return()=>e().then(({default:e})=>dr(e,t))}function ds(e,t){return()=>Promise.resolve(dr(e,t))}let dl=di,dc=W()(()=>({}));q("openmrs-app-context",dc);let du={};function dp(e,t=e=>e){let n=dc.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function dd(e,t){dc.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function df(e){return null===e?null:Object.freeze(Object.assign({},e))}let dh=new Map;function dm(e,t){let n=(0,pS.useRef)(t??{}),a=(0,pS.useRef)(t=>dd(e,t)),r=(0,pS.useRef)(Symbol());return(0,pS.useEffect)(()=>{let n=t??{},a=r.current;return null===dp(e)?!function(e,t=du){dc.setState(n=>{if(e in n)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({},n,{[e]:t===du?{}:t})})}(e,n):(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.`),dd(e,()=>n)),dh.set(e,a),()=>{dh.get(e)===a&&(dc.setState(t=>(e in t&&delete t[e],t)),dh.delete(e))}},[e]),(0,pS.useEffect)(()=>{let a=t??{};j(n.current,a)||(dd(e,()=>a),n.current=a)},[t]),a.current}function dg({namespace:e,value:t}){return dm(e,t),null}let dy=({children:e,value:t,fallback:n})=>t?pD().createElement(pD().Fragment,null,e):n?pD().createElement(pD().Fragment,null,n):null;function db(){let e=(0,pS.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,pS.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function d_(e,t=e=>e??{}){let[n,a]=(0,pS.useState)(()=>{if(dv(e))return;let n=dp(e);if(null!==n)return t?t(n):n});return(0,pS.useEffect)(()=>{if(dv(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,pS.useEffect)(()=>{var n;let r;return(n=e=>{if(null==e)return void a(void 0);let n=t?t(e):e;a(e=>j(e,n)?e:n)})(df(r=dp(e))),dc.subscribe(t=>{let a=e in t?t[e]:null;a!==r&&(r=a,n(df(a)))})},[e,t]),n}function dv(e){return"string"!=typeof e||0===e.trim().length}function d$(e){let t=pG(e);return(0,pS.useMemo)(()=>t.map(e=>e.id),[t])}function dA(e){return pL(e).candidateExtensions}function dw(e,t){let{data:n,error:a,mutate:r,isLoading:o,isValidating:i}=(0,p7.Ay)(`${op}?patient=${e}&includeEncounterless=${t}`,au);return(0,pS.useMemo)(()=>({isLoading:o,data:n?.data.results??[],error:a,mutate:r,isValidating:i}),[n,a,o,i,r])}function dk(e){(0,pS.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let dx={},dC=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function dE(e){let{moduleName:t,extension:n}=(0,pS.useContext)(pM),a=e?.externalModuleName??t;if(!a&&!n)throw Error(dC);let r=function(e){let t=(0,pS.useMemo)(()=>eM(e),[e]),n=function(e){let[t,n]=(0,pS.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,pS.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&n(e.config)}),[e]),t}(t);if(!n)throw dx[e]||(dx[e]=new Promise(e=>{let n=t.subscribe(t=>{t.loaded&&t.config&&(e(t.config),n())})})),dx[e];return n}(a),o=function(e){let t=(0,pS.useMemo)(eT,[]),n=function(e,t){let[n,a]=(0,pS.useState)(t?()=>{let n=eI(e.getState(),t.extensionSlotName,t.extensionId);if(n.loaded&&n.config)return n.config}:null);return(0,pS.useEffect)(()=>{if(t)return e.subscribe(e=>{let r=eI(e,t.extensionSlotName,t.extensionId);r.loaded&&r.config&&!(0,et.isEqual)(r.config,n)&&a(r.config)})},[e,t,n]),n}(t,e);if(!n&&e){let n=`${e.extensionSlotName}-${e.extensionId}`;throw!dx[n]&&t&&(dx[n]=new Promise(n=>{let a=t.subscribe(t=>{let r=eI(t,e.extensionSlotName,e.extensionId);r.loaded&&r.config&&(n(r.config),a())})})),dx[n]}return n||{}}(n);return(0,pS.useMemo)(()=>e?.externalModuleName&&a===e.externalModuleName?{...r}:{...r,...o},[a,e?.externalModuleName,r,o])}let dS=pG;function dD(){let[e,t]=(0,pS.useState)(ug());return(0,pS.useEffect)(()=>y(({online:e})=>t(e)),[]),e}function dM(e,t=300){let[n,a]=(0,pS.useState)(e);return(0,pS.useEffect)(()=>{let n=setTimeout(()=>{a(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}var dz=n(6088),dO=n.n(dz);let dP=`custom:${[["admissionDecisionConcept","ref"],["admissionEncounterType","ref"],["admissionForm","ref"],["atFacilityVisitType","ref"],["bedAssignmentEncounterType","ref"],["cancelADTRequestEncounterType","ref"],["checkInClerkEncounterRole","ref"],["checkInEncounterType","ref"],["clinicianEncounterRole","ref"],["conceptSourcesForDiagnosisSearch","ref"],["consultEncounterType","ref"],["consultFreeTextCommentsConcept","ref"],["denyAdmissionConcept","ref"],["diagnosisMetadata","ref"],["diagnosisSets","ref"],["dischargeForm","ref"],["dispositionDescriptor","ref"],["dispositions","ref"],["emrApiConceptSource","ref"],["exitFromInpatientEncounterType","ref"],["extraPatientIdentifierTypes","ref"],["fullPrivilegeLevel","ref"],["highPrivilegeLevel","ref"],["identifierTypesToSearch","ref"],["inpatientNoteEncounterType","ref"],["lastViewedPatientSizeLimit","ref"],["metadataSourceName","ref"],["motherChildRelationshipType","ref"],["narrowerThanConceptMapType","ref"],["nonDiagnosisConceptSets","ref"],["orderingProviderEncounterRole","ref"],["patientDiedConcept","ref"],["personImageDirectory","ref"],["primaryIdentifierType","ref"],["sameAsConceptMapType","ref"],["suppressedDiagnosisConcepts","ref"],["supportsAdmissionLocationTag","(uuid,display,name,links)"],["supportsLoginLocationTag","(uuid,display,name,links)"],["supportsTransferLocationTag","(uuid,display,name,links)"],["supportsVisitsLocationTag","(uuid,display,name,links)"],["telephoneAttributeType","ref"],["testPatientPersonAttributeType","ref"],["transferForm","ref"],["transferRequestEncounterType","ref"],["transferWithinHospitalEncounterType","ref"],["unknownCauseOfDeathConcept","ref"],["unknownLocation","ref"],["unknownPatientPersonAttributeType","ref"],["unknownProvider","ref"],["visitAssignmentHandlerAdjustEncounterTimeOfDayIfNecessary","ref"],["visitExpireHours","ref"],["visitNoteEncounterType","ref"]].map(([e,t])=>`${e}:${t}`).join(",")}`;function dT(){let e=`${ai}/emrapi/configuration?v=${dP}`,t=dO()(e,au);return(0,pS.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}let dB=pj(u$());function dI(e){let t=pG(e);return(0,pS.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let dN=pj(uM());function dj(e){let{flags:t}=pI(uu);return t[e]?.enabled??!1}function dR(){let[,e]=(0,pS.useState)(0);return(0,pS.useCallback)(()=>{e(e=>e+1)},[])}function dF(e,t,n={}){return dW(e,t,dL,n)}let dL={getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let a=new URL(ac(e.toString()),window.location.toString());return a.searchParams.set("limit",""+t),a.searchParams.set("startIndex",""+n),a.searchParams.set("totalCount","true"),a.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function dW(e,t,n,a={}){let{getPaginatedUrl:r,getTotalCount:o,getCurrentPageSize:i,getData:s}=n,{immutable:l,swrConfig:c}=a,u=a.fetcher??au,[p,d]=(0,pS.useState)(1),f=(0,pS.useRef)(NaN),h=(0,pS.useRef)(NaN),m=(0,pS.useRef)(p),g=(0,pS.useRef)(!1),y=(0,pS.useRef)(!1),b=e?.toString()??"",[v,$]=(0,pS.useState)(b);b!==v&&($(b),d(1),m.current=1,f.current=NaN,h.current=NaN,g.current=!1,y.current=!1);let A=(p-1)*t,w=(0,pS.useMemo)(()=>r(e,t,A),[e,t,A]),{data:k,...x}=(l?dO():p7.Ay)(w,u,c);k?.data&&(f.current=o(k?.data),h.current=i(k?.data),g.current=!0);let C=Math.ceil(f.current/t),E=(0,pS.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let n=Math.ceil(f.current/t);!g.current||Number.isNaN(n)||e<=n?(m.current=e,d(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,pS.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(f.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${b} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(f.current/t));p>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${p}; returning to page ${e}.`),m.current=e,d(e))},[p,t,b,k]);let S=(0,pS.useCallback)(()=>{E(m.current+1)},[E]),D=(0,pS.useCallback)(()=>{E(m.current-1)},[E]);return{data:s(k?.data),totalPages:C,totalCount:f.current,currentPage:p,currentPageSize:h.current,paginated:C>1,showNextButton:p<C,showPreviousButton:p>1,goTo:E,goToNext:S,goToPrevious:D,...x}}function dG(e,t,n={}){return dW(e,t,dV(),n)}function dV(){return{getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let a=new URL(ac(e.toString()),window.location.toString());return a.searchParams.set("_count",""+t),a.searchParams.set("_getpagesoffset",""+n),a.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var dU=n(2398),dq=n.n(dU);function dH(e,t={}){return dK(e,dL,t)}function dK(e,t,n={}){let{swrInfiniteConfig:a,immutable:r}=n,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=n.fetcher??au,c=(0,pS.useCallback)((n,a)=>0==n?e?.toString()??null:t.getNextUrl(a.data),[e]),{data:u,size:p,setSize:d,...f}=dq()(c,l,{...a,...r?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),h=o(u?.[u.length-1].data),m=i(u?.[0]?.data);return{data:u?.flatMap(e=>s(e.data)),totalCount:m,hasMore:null!=h,loadMore:()=>{d((u?.length??0)+1)},nextUri:h,...f}}function dY(e,t={}){return dJ(e,dL,t)}function dJ(e,t,n={}){let a=dK(e,t,n),{hasMore:r,error:o,data:i,loadMore:s,isLoading:l,nextUri:c}=a;return((0,pS.useEffect)(()=>{r&&!o&&s()},[r,c]),n.partialData)?a:{...a,data:r||o?void 0:i,isLoading:l||r}}function dZ(e,t={}){return dJ(e,dV(),t)}function dX(e,t={}){return dK(e,dV(),t)}function dQ(){let e="tablet";return document.body.classList.forEach(t=>{switch(t){case"omrs-breakpoint-lt-tablet":e="phone";break;case"omrs-breakpoint-gt-small-desktop":e="large-desktop";break;case"omrs-breakpoint-gt-tablet":e="small-desktop"}}),e}function d0(){let[e,t]=(0,pS.useState)(dQ);return(0,pS.useEffect)(()=>{let e=()=>{t(dQ())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let d1=e=>"small-desktop"===e||"large-desktop"===e;function d2(e){let t=(0,pS.useContext)(pM);(0,pS.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),pn(e),()=>{pa(e.name)}),[t,e])}function d3(){return pI(pt)}function d4(e=null,t=null){let[n,a]=(0,pS.useState)([]);return(0,pS.useEffect)(()=>{let n=cS(e,t).subscribe(e=>{a(e)},e=>{console.error(e)});return()=>n.unsubscribe()},[e,t]),n}function d5(e,t=!0){let n=(0,pS.useRef)(null);return(0,pS.useEffect)(()=>{let a=a=>{t&&n.current&&a.target&&a.target instanceof Node&&(n.current.contains(a.target)||e(a))};return window.addEventListener("mousedown",a),window.addEventListener("touchstart",a),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("touchstart",a)}},[e,t]),n}function d6(e){let t=(0,pS.useRef)();return(0,pS.useEffect)(()=>{let n=new IntersectionObserver(t=>{for(let n of t)if(n.isIntersecting)return void e()},{threshold:1});return t.current&&n.observe(t.current),()=>{t.current&&n.unobserve(t.current)}},[t.current,e]),t}function d8(e,t={}){let{abortController:n,fetchInit:a,url:r,swrConfig:o}=t,i=db(),s=(0,pS.useMemo)(()=>a?.signal??n?.signal??i.signal,[n?.signal,a?.signal,i.signal]),l=(0,pS.useCallback)(e=>au(function(e,t){if(t)return"function"==typeof t?t(e):t;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,r),{...a,signal:s}),[s,a,r]);return(0,p7.Ay)(e,l,o)}function d7(e=[],t=10){let[n,a]=(0,pS.useState)(1),r=(0,pS.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);n>r&&a(r);let o=Math.min(Math.max(1,n),r),i=(0,pS.useMemo)(()=>{let n=(o-1)*t,a=(o+0)*t;return e.slice(n,a)},[e,o,t]),s=(0,pS.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):a(e)},[]),l=(0,pS.useCallback)(()=>{a(e=>e+1)},[]),c=(0,pS.useCallback)(()=>{a(e=>Math.max(1,e-1))},[]);return(0,pS.useMemo)(()=>({results:i,totalPages:r,currentPage:o,paginated:e.length>t,showNextButton:o<r,showPreviousButton:o>1,goTo:s,goToNext:l,goToPrevious:c}),[i,r,e.length,t,o,s,l,c])}function d9(e,t,n,a){return{pageSizes:(0,pS.useMemo)(()=>{let n=Math.ceil(t/e);return isNaN(n)&&(n=0),[...Array(n).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,pS.useMemo)(()=>e>t?t:e*n>t?e*(n-1)+a:e*n,[e,t,n,a])}}function fe(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function ft(e){let[t,n]=(0,pS.useState)(e??fe()),{data:a,error:r,isValidating:o}=(0,p7.Ay)(t?["patient",t]:null,()=>cA(t,{}));return(0,pS.useEffect)(()=>{let e=()=>{let e=fe();e!==t&&n(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,pS.useMemo)(()=>({isLoading:o&&!r&&!a,patient:a,patientUuid:t,error:r}),[o,r,a,t])}function fn(){let e=`${ai}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:n,isLoading:a}=(0,p7.Ay)(e,au);return(0,pS.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:a,error:n}),[t,n,a])}function fa(e){let{extensions:t,extensionSlotModuleName:n}=pV(e);return e?t.map(t=>({state:a})=>pD().createElement(pM.Provider,{value:{moduleName:n,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:n}}},pD().createElement(pO,{state:a}))):[]}function fr(){let e=(0,pS.useRef)(),[t,n]=(0,pS.useState)(null),a=null;if(!t){if(i){let e=ag().getState();e.loaded&&(a=e.session)}else i=new Promise(t=>{let n=({loaded:n,session:r})=>{n&&(t(r),a=r,e.current&&(e.current(),e.current=void 0))};n(ag().getState()),a||(e.current=ag().subscribe(n))});if(a)n(a);else throw i}(0,pS.useEffect)(()=>(e.current||(e.current=ag().subscribe(({loaded:e,session:t})=>{e&&(a=t,n(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let r=t||a;if(!r)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 r}let fo=({privilege:e,fallback:t,children:n})=>{let[a,r]=(0,pS.useState)(null);return((0,pS.useEffect)(()=>{let e=am({includeAuthStatus:!1}).subscribe(r);return()=>e.unsubscribe()},[]),a&&av(e,a))?pD().createElement(pD().Fragment,null,n):t?pD().createElement(pD().Fragment,null,t):null};var fi=n(4353),fs=n.n(fi),fl=n(7581);let fc=new Map;function fu(){for(let e of Array.from(fc.values()))e()}let fp={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function fd(e){let t=(0,pS.useId)();return(0,pS.useEffect)(()=>{if(e)return fc.set(t,e),()=>{fc.delete(t)}},[t,e]),{...pN(cL(),fp),mutateVisit:fu}}function ff(e,t=cR){let n=(0,pS.useRef)(void 0),{patientUuid:a,manuallySetVisitUuid:r,setVisitContext:o}=fd((0,pS.useCallback)(()=>n.current?.(),[])),i=e&&a==e?r:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${i}?v=${t}`,{data:c,error:u,mutate:p,isValidating:d}=(0,p7.Ay)(e?`${ai}/visit${s}`:null,au),{data:f,error:h,mutate:m,isValidating:g}=(0,p7.Ay)(e&&i?`${ai}/visit${l}`:null,au),y=(0,pS.useMemo)(()=>c?.data.results.find(e=>null===e.stopDatetime)??null,[c]),b=(0,pS.useMemo)(()=>i&&f?f.data:null,[f,i]),v=(0,pS.useRef)(null);(0,pS.useEffect)(()=>{!d&&y&&a===e&&null===r&&o(y),g||(v.current&&b&&v.current.uuid===b.uuid&&!v.current.stopDatetime&&b.stopDatetime&&o(null),v.current=b)},[b,r,y,d,g,a]);let $=(0,pS.useCallback)(()=>{p(),m()},[p,m]);(0,pS.useEffect)(()=>{n.current=$},[$]);let A=!!(!c||i&&!f),w=!!(i?h:u);return{error:u||h,mutate:$,isValidating:d||g,activeVisit:y,currentVisit:b,currentVisitIsRetrospective:!!i,isLoading:A&&!w}}function fh(){let[e,t]=(0,pS.useState)([]);return(0,pS.useEffect)(()=>{let e=cM().subscribe(e=>{t(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}fi.extend(fl);let fm=new Map;async function fg(e,t){let n=t.indexOf("#"),a=n>=0,r=a?t.substring(0,n):e,o=a?t.substring(n+1):t,i=await rZ(r);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?fb(r,i).then(()=>i[o]()):(i?i&&Object.hasOwn(i,o)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${r} does not define a component called "${o}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${r} for ${t} defined in ${e}'s routes.json`),fy)}let fy={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function fb(e,t){if(e in fm)await fm[e];else{let n=t??await rZ(e);await (fm[e]=new Promise((t,a)=>{if(Object.hasOwn(n,"startupApp")){let r=n.startupApp;if("function"==typeof r)return Promise.resolve(r()).then(()=>{e2(e),t(null)}).catch(a)}e2(e),t(null)}))}}function f_(e,t){let n=t.name;if(!n)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
17
17
  registered. To fix this, ensure that you define the "name" field inside the
18
18
  extension definition.`,t);t.slots&&t.slot&&console.warn(`The extension ${n} from ${e} declares both a 'slots' property and