@openmrs/esm-form-engine-app 12.3.4 → 12.3.5-pre.11553
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/432.js
CHANGED
|
@@ -9,7 +9,7 @@ If you're the maintainer: the allowed types are ${Object.values(nV).join(", ")}.
|
|
|
9
9
|
If you're the maintainer: all config elements must have a default. Received ${JSON.stringify(a)}`),s&&l&&![nV.Array,nV.Object].includes(l)&&console.error(`${e} has bad config schema definition for key '${i}'. ${o}.
|
|
10
10
|
|
|
11
11
|
If you're the maintainer: the 'elements' key only works with '_type' equal to 'Array' or 'Object'. Received ${JSON.stringify(l)}`)}}function tm(e,n){return th(n.map(({[e]:n})=>n).filter(e=>!!e))}function th(e){return e.reduce((e,n)=>n9(e,n),{})}function tg(e,n,t=""){for(let o of Object.keys(n)){let r=n[o],i=t+"."+o,a=e[o];if(!e.hasOwnProperty(o)){("extensionSlots"!==o||""===t)&&tx(i,`Unknown config key '${i}' provided. Ignoring.`);continue}(function e(n,t,o){ty(o,n._type,t),tA(t)?n._type===nV.Object?function(n,t,o){if(n._elements)for(let r of Object.keys(t)){let i=t[r];e(n._elements,i,`${o}.${r}`)}}(n,t,o):n.hasOwnProperty("_default")||n.hasOwnProperty("_type")||tg(n,t,o):n._type===nV.Array&&function(n,t,o){if(ty(o,nV.Array,t)){if(t$(n._elements))for(let r=0;r<t.length;r++)e(n._elements,t[r],`${o}[${r}]`);for(let e=0;e<t.length;e++)ty(`${o}[${e}]`,n._elements?._type,t[e])}}(n,t,o)})(a,r,i)}}tt();function t_(e,n,t=""){if(e){if(n!==e._default&&tb(t,e._validators,n),tA(n))for(let o of Object.keys(n)){let r=n[o],i=t+"."+o,a=e[o];e._type===nV.Object&&e._elements?t_(e._elements,r,i):t_(a,r,i)}else if(Array.isArray(n)&&e._elements)for(let o=0;o<n.length;o++)t_(e._elements,n[o],`${t}[${o}]`)}}function ty(e,n,t){return!n||tb(e,[{Array:nU,Boolean:nq,ConceptUuid:nY,Number:nH,Object:nZ,String:nK,UUID:nY,PersonAttributeTypeUuid:nY,PatientIdentifierTypeUuid:nY}[n]],t)}function tb(e,n,t){let o=!0;if(n)try{for(let r of n){let n=r(t);if("string"==typeof n){let r="object"==typeof t?`Invalid configuration for ${e}: ${n}`:`Invalid configuration value ${t} for ${e}: ${n}`;tx(e,r),o=!1}}}catch(n){console.error(`Skipping invalid validator at "${e}". Encountered error
|
|
12
|
-
${n}`)}return o}let tv=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let o=t[n],r=e[n];if(r&&(r.hasOwnProperty("_type")||r.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=r._default);let e=r._elements;if(o&&t$(e)){if(r._type===nV.Array&&Array.isArray(o)){let r=o.map(n=>tv(e,n));t[n]=r}else if(r._type===nV.Object)for(let n of Object.keys(o))o[n]=tv(e,o[n])}}else if(tA(r)){let e=o??{};tA(e)&&(t[n]=tv(r,e))}}return t};function t$(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function tA(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let tk=new Set;function tx(e,n){let t=`${e}:::${n}`;tk||(tk=new Set),tk.has(t)||(console.error(n),tk.add(t))}function tw(e){e?tk.forEach(n=>{n.startsWith(e)&&tk.delete(n)}):tk.clear()}function tC(){te.forEach(e=>e()),te.length=0,tt()}let tE={"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:nV.Object,_default:{},_validators:[nG(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${n.join(", ")}.`})]}},tS={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nV.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nV.String,_default:void 0}},...tE},tz=(e,n)=>nG(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),tD=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return nG(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,o=t.exec(e);for(;o;){if(!n.includes(o[1]))return!1;o=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},tP=tD([]),tM=e=>nG(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),tT={inRange:tz,isUrl:tP,isUrlWithTemplateParameters:tD,oneOf:tM};var tN=t(82034);let tO=U("breadcrumbs",[]);function tB(e){return tI([e])}function tI(e){let n=[...tj(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,tN.pathToRegexp)(e.matcher).regexp:(0,tN.pathToRegexp)(e.path).regexp,settings:e}))];tO.setState(n,!0)}function tj(){return tO.getState()}function tR(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=tR(e,t.join("/"));if(n)return n}}(e,n)}function tF(e,n){if(e.length>0){let t=tR(e,n);if(t){let n=[t],o=tR(e,t.settings.parent);for(;void 0!==o;)n.push(o),o=tR(e,o.settings.parent);return n.reverse()}}return[]}function tL(e){return tF(tj(),e)}var tW=Object.freeze({__proto__:null,get start(){return rt},get ensureJQuerySupport(){return oL},get setBootstrapMaxTime(){return oA},get setMountMaxTime(){return ok},get setUnmountMaxTime(){return ox},get setUnloadMaxTime(){return ow},get registerApplication(){return oX},get unregisterApplication(){return o0},get getMountedApps(){return oK},get getAppStatus(){return oY},get unloadApplication(){return o1},get checkActivityFunctions(){return oQ},get getAppNames(){return oZ},get pathToActiveWhen(){return o5},get navigateToUrl(){return oM},get patchHistoryApi(){return oj},get triggerAppChange(){return o7},get addErrorHandler(){return tH},get removeErrorHandler(){return tK},get mountRootParcel(){return o_},get NOT_LOADED(){return tJ},get LOADING_SOURCE_CODE(){return tX},get NOT_BOOTSTRAPPED(){return tQ},get BOOTSTRAPPING(){return t0},get NOT_MOUNTED(){return t1},get MOUNTING(){return t2},get UPDATING(){return t5},get LOAD_ERROR(){return t8},get MOUNTED(){return t3},get UNLOADING(){return t6},get UNMOUNTING(){return t4},get SKIP_BECAUSE_BROKEN(){return t7}}),tV=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,tG=!function(){try{var e=new tV("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:tV;let tU=[];function tq(e,n,t){let o=tY(e,n,t);tU.length?tU.forEach(e=>e(o)):setTimeout(()=>{throw o})}function tH(e){if("function"!=typeof e)throw Error(tZ(28,!1));tU.push(e)}function tK(e){if("function"!=typeof e)throw Error(tZ(29,!1));let n=!1;return tU=tU.filter(t=>{let o=t===e;return n=n||o,!o}),n}function tZ(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function tY(e,n,t){let o,r=`${oo(n)} '${on(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=r+e.message}catch(e){}o=e}else{console.warn(tZ(30,!1,n.status,on(n)));try{o=Error(r+JSON.stringify(e))}catch(n){o=e}}return o.appOrParcelName=on(n),n.status=t,o}let tJ="NOT_LOADED",tX="LOADING_SOURCE_CODE",tQ="NOT_BOOTSTRAPPED",t0="BOOTSTRAPPING",t1="NOT_MOUNTED",t2="MOUNTING",t3="MOUNTED",t5="UPDATING",t4="UNMOUNTING",t6="UNLOADING",t8="LOAD_ERROR",t7="SKIP_BECAUSE_BROKEN";function t9(e){return e.status===t3}function oe(e){try{return e.activeWhen(window.location)}catch(n){return tq(n,e,t7),!1}}function on(e){return e.name}function ot(e){return!!e.unmountThisParcel}function oo(e){return ot(e)?"parcel":"application"}function or(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function oi(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function oa(e){return e&&("function"==typeof e||Array.isArray(e)&&!oi(e,e=>"function"!=typeof e))}function os(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let o=oo(e),r=on(e);return function(e){return t.reduce((t,i,a)=>t.then(()=>{let t=i(e);return ol(t)?t:Promise.reject(tZ(15,!1,o,r,n,a))}),Promise.resolve())}}function ol(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let oc=[];function op(e,n){return Promise.resolve().then(()=>e.status!==tQ?e:(e.status=t0,e.bootstrap?oC(e,"bootstrap").then(t).catch(t=>{if(n)throw tY(t,e,t7);return tq(t,e,t7),e}):Promise.resolve().then(t)));function t(){return e.status=t1,e}}function od(e,n){return Promise.resolve().then(()=>{if(e.status!==t3)return e;return e.status=t4,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,o=>t().then(()=>{let t=Error(o.message);if(n)throw tY(t,e,t7);tq(t,e,t7)})).then(()=>e);function t(){return oC(e,"unmount").then(()=>{e.status=t1},t=>{if(n)throw tY(t,e,t7);tq(t,e,t7)})}})}let ou=!1,of=!1;function om(e,n){return Promise.resolve().then(()=>e.status!==t1?e:(ou||(window.dispatchEvent(new tG("single-spa:before-first-mount")),ou=!0),e.status=t2,oC(e,"mount").then(()=>(e.status=t3,of||(window.dispatchEvent(new tG("single-spa:first-mount")),of=!0),e)).catch(t=>{return e.status=t3,od(e,!0).then(o,o);function o(){if(n)throw tY(t,e,t7);return tq(t,e,t7),e}})))}let oh=0,og={parcels:{}};function o_(){return oy.apply(og,arguments)}function oy(e,n){let t,o,r,i=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(tZ(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(tZ(3,!1,typeof e.name));let a=oh++,s=e.name||`parcel-${a}`;if("object"!=typeof n)throw Error(tZ(4,!1,s,typeof n));if(!n.domElement)throw Error(tZ(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:a,parcels:{},status:l?tX:tQ,customProps:n,parentName:on(i),unmountThisParcel:()=>f.then(()=>{if(p.status!==t3)throw Error(tZ(6,!1,s,p.status));return od(p,!0)}).then(e=>(p.parentName&&delete i.parcels[p.id],e)).then(e=>(o(e),e)).catch(e=>{throw p.status=t7,r(e),e})};i.parcels[a]=p;let d=c();if(!d||"function"!=typeof d.then)throw Error(tZ(7,!1));let u=(d=d.then(e=>{if(!e)throw Error(tZ(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!oa(e.bootstrap))throw Error(tZ(9,!1,s));if(!oa(e.mount))throw Error(tZ(10,!1,s));if(!oa(e.unmount))throw Error(tZ(11,!1,s));if(e.update&&!oa(e.update))throw Error(tZ(12,!1,s));let n=os(e,"bootstrap"),o=os(e,"mount"),r=os(e,"unmount");p.status=tQ,p.name=s,p.bootstrap=n,p.mount=o,p.unmount=r,p.timeouts=oE(e.timeouts),e.update&&(p.update=os(e,"update"),t.update=function(e){return p.customProps=e,ob(Promise.resolve().then(()=>{if(p.status!==t3)throw Error(tZ(32,!1,on(p)));return p.status=t5,oC(p,"update").then(()=>(p.status=t3,p)).catch(e=>{throw tY(e,p,t7)})}))})})).then(()=>op(p,!0)),f=u.then(()=>om(p,!0)),m=new Promise((e,n)=>{o=e,r=n});return t={mount:()=>ob(Promise.resolve().then(()=>{if(p.status!==t1)throw Error(tZ(13,!1,s,p.status));return i.parcels[a]=p,om(p)})),unmount:()=>ob(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:ob(d),bootstrapPromise:ob(u),mountPromise:ob(f),unmountPromise:ob(m)}}function ob(e){return e.then(()=>null)}function ov(e){let n=on(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(tZ(40,!1),n,t));let o=or({},t,{name:n,mountParcel:oy.bind(e),singleSpa:tW});return ot(e)&&(o.unmountSelf=e.unmountThisParcel),o}let o$={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 oA(e,n,t){if("number"!=typeof e||e<=0)throw Error(tZ(16,!1));o$.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ok(e,n,t){if("number"!=typeof e||e<=0)throw Error(tZ(17,!1));o$.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ox(e,n,t){if("number"!=typeof e||e<=0)throw Error(tZ(18,!1));o$.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ow(e,n,t){if("number"!=typeof e||e<=0)throw Error(tZ(19,!1));o$.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function oC(e,n){let t=e.timeouts[n],o=t.warningMillis,r=oo(e);return new Promise((i,a)=>{let s=!1,l=!1;e[n](ov(e)).then(e=>{s=!0,i(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>p(1),o),setTimeout(()=>p(!0),t.millis);let c=tZ(31,!1,n,r,on(e),t.millis);function p(e){s||(!0===e?(l=!0,t.dieOnTimeout?a(Error(c)):console.error(c)):!l&&(console.warn(c),e*o+o<t.millis&&setTimeout(()=>p(e+1),o)))}})}function oE(e){let n={};for(let t in o$)n[t]=or({},o$[t],e&&e[t]||{});return n}function oS(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==tJ&&e.status!==t8?e:(e.status=tX,e.loadPromise=Promise.resolve().then(()=>{let o=e.loadApp(ov(e));if(!ol(o))throw t=!0,Error(tZ(33,!1,on(e)));return o.then(t=>{let o;e.loadErrorTime=null,"object"!=typeof(n=t)&&(o=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!oa(n.bootstrap)&&(o=35),oa(n.mount)||(o=36),oa(n.unmount)||(o=37);let r=oo(n);if(o){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(tZ(o,!1,r,on(e),t),n),tq(void 0,e,t7),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=or({},e.devtools.overlays,n.devtools.overlays)),e.status=tQ,e.bootstrap=os(n,"bootstrap"),e.mount=os(n,"mount"),e.unmount=os(n,"unmount"),e.unload=os(n,"unload"),e.timeouts=oE(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let o;return delete e.loadPromise,t?o=t7:(o=t8,e.loadErrorTime=(new Date).getTime()),tq(n,e,o),e}))})}let oz="u">typeof window,oD={hashchange:[],popstate:[]},oP=["hashchange","popstate"];function oM(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(tZ(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=oR(window.location.href),o=oR(n);0===n.indexOf("#")?window.location.hash=o.hash:t.host!==o.host&&o.host?window.location.href=n:o.pathname===t.pathname&&o.search===t.search?window.location.hash=o.hash:window.history.pushState(null,null,n)}function oT(e){if(e){let n=e[0].type;oP.indexOf(n)>=0&&oD[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function oN(){o9([],arguments)}function oO(e,n){return function(){let t=window.location.href,r=e.apply(this,arguments),i=window.location.href;return o&&t===i||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),r}}let oB=null,oI=!1;function oj(e){if(oI)throw Error(tZ(43,!1));o=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,oI=!0,oB=window.history.replaceState,window.addEventListener("hashchange",oN),window.addEventListener("popstate",oN);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&oP.indexOf(e)>=0)||oi(oD[e],e=>e===t))return n.apply(this,arguments);oD[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&oP.indexOf(e)>=0&&(oD[e]=oD[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=oO(window.history.pushState,"pushState"),window.history.replaceState=oO(oB,"replaceState")}function oR(e){let n=document.createElement("a");return n.href=e,n}oz&&(window.singleSpaNavigate?console.warn(tZ(41,!1)):window.singleSpaNavigate=oM);let oF=!1;function oL(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!oF){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return oW.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return oW.call(this,t,window.removeEventListener,e,n,arguments)},oF=!0}}function oW(e,n,t,o,r){return"string"!=typeof t?e.apply(this,r):(t.split(/\s+/).forEach(e=>{oP.indexOf(e)>=0&&(n(e,o),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,r))}let oV={};function oG(e){return Promise.resolve().then(()=>{let n=oV[on(e)];if(!n)return e;if(e.status===tJ)return oU(e,n),e;if(e.status===t6)return n.promise.then(()=>e);if(e.status!==t1&&e.status!==t8)return e;let t=e.status===t8?Promise.resolve():oC(e,"unload");return e.status=t6,t.then(()=>(oU(e,n),e)).catch(t=>(delete oV[on(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,tq(t,e,t7),n.reject(t),e))})}function oU(e,n){delete oV[on(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=tJ,n.resolve()}function oq(e,n,t,o){oV[on(e)]={app:e,resolve:t,reject:o},Object.defineProperty(oV[on(e)],"promise",{get:n})}let oH=[];function oK(){return oH.filter(t9).map(on)}function oZ(){return oH.map(on)}function oY(e){let n=oi(oH,n=>on(n)===e);return n?n.status:null}let oJ=!1;function oX(e,n,t,o){var r,i;let a,s,l=(a={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(tZ(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(tZ(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(tZ(20,!1));let o=e=>"string"==typeof e||"function"==typeof e;if(!(o(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(o)))throw Error(tZ(24,!1));if(!o3(e.customProps))throw Error(tZ(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,n,t,o){if("string"!=typeof e||0===e.length)throw Error(tZ(20,!1));if(!n)throw Error(tZ(23,!1));if("function"!=typeof t)throw Error(tZ(24,!1));if(!o3(o))throw Error(tZ(22,!1))}(e,n,t,o),a.name=e,a.loadApp=n,a.activeWhen=t,a.customProps=o),a.loadApp="function"!=typeof(r=a.loadApp)?()=>Promise.resolve(r):r,a.customProps=a.customProps||{},s=(s=Array.isArray(i=a.activeWhen)?i:[i]).map(e=>"function"==typeof e?e:o5(e)),a.activeWhen=e=>s.some(n=>n(e)),a);if(rn||oJ||(oJ=!0,setTimeout(()=>{rn||console.warn(tZ(1,!1))},5e3)),-1!==oZ().indexOf(l.name))throw Error(tZ(21,!1,l.name));oH.push(or({loadErrorTime:null,status:tJ,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),oz&&(oL(),o9())}function oQ(e=window.location){return oH.filter(n=>n.activeWhen(e)).map(on)}function o0(e){if(0===oH.filter(n=>on(n)===e).length)throw Error(tZ(25,!1,e));return(oz?o1(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=oH.map(on).indexOf(e);oH.splice(n,1)})}function o1(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(tZ(26,!1));let t=oi(oH,n=>on(n)===e);if(!t)throw Error(tZ(27,!1,e));let o=oV[on(t)];if(n&&n.waitForUnmount){if(o)return o.promise;{let e=new Promise((n,o)=>{oq(t,()=>e,n,o)});return e}}{let e;return o?(e=o.promise,o2(t,o.resolve,o.reject)):e=new Promise((n,o)=>{oq(t,()=>e,n,o),o2(t,n,o)}),e}}function o2(e,n,t){Promise.resolve().then(()=>{if(oi(oQ(),n=>n===on(e)))return o7()}).then(()=>od(e).then(oG).then(()=>{n(),setTimeout(()=>{o9()})})).catch(t)}function o3(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function o5(e,n){let t=function(e,n){let t=0,o=!1,r="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],r=o&&"/"===t;(!o&&":"===t||r)&&i(n)}return i(e.length),RegExp(r,"i");function i(i){let a=e.slice(t,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(r+=o?"[^/]+/?":a,i===e.length)if(o)n&&(r+="$");else{let e=n?"":".*";r="/"===r.charAt(r.length-1)?`${r}${e}$`:`${r}(/${e})?(#.*)?$`}o=!o,t=i}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let o=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(o)}}let o4=!1,o6=[],o8=oz&&window.location.href;function o7(){return o9()}function o9(e=[],n,t=!1){let o,r,i,a,s;if(o4)return new Promise((e,t)=>{o6.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:d}=(o=[],r=[],i=[],a=[],s=(new Date).getTime(),oH.forEach(e=>{let n=e.status!==t7&&oe(e);switch(e.status){case t8:n&&s-e.loadErrorTime>=200&&i.push(e);break;case tJ:case tX:n&&i.push(e);break;case tQ:case t1:!n&&oV[on(e)]?o.push(e):n&&a.push(e);break;case t3:n||r.push(e)}}),{appsToUnload:o,appsToUnmount:r,appsToLoad:i,appsToMount:a}),u,f=[],m=o8,h=o8=window.location.href;return rn?(o4=!0,u=l.concat(p,c,d),Promise.resolve().then(()=>($(0===u.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return oB.call(window.history,history.state,"",m.substring(location.origin.length)),o8=location.href,o4=!1,o9(e,n,!0);let o=l.map(oG),r=Promise.all(c.map(od).map(e=>e.then(oG)).concat(o));r.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let i=p.map(e=>oS(e).then(e=>re(e,r))),a=d.filter(e=>0>p.indexOf(e)).map(e=>re(e,r));return r.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(i.concat(a)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(y).then(()=>{},e=>{throw e})))})))):(u=p,Promise.resolve().then(()=>Promise.all(p.map(oS)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(tZ(42,!1))),console.warn(e),!1)))}function y(){let n=oK();e.forEach(e=>e.resolve(n));try{$(0===u.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(o4=!1,o6.length>0){let e=o6;o6=[],o9(e)}return n}function b(){t||(e.forEach(e=>{oT(e.eventArguments)}),oT(n))}function v(e=!1,t){let o={},r={[t3]:[],[t1]:[],[tJ]:[],[t7]:[]};e?(p.concat(d).forEach((e,n)=>{a(e,t3)}),l.forEach(e=>{a(e,tJ)}),c.forEach(e=>{a(e,t1)})):u.forEach(e=>{a(e)});let i={detail:{newAppStatuses:o,appsByNewStatus:r,totalAppChanges:u.length,originalEvent:null==n?void 0:n[0],oldUrl:m,newUrl:h}};return t&&or(i.detail,t),i;function a(e,n){let t=on(e);n=n||oY(t),o[t]=n,(r[n]=r[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new tG(`single-spa:${e}`,n))}}function re(e,n){return oe(e)?op(e).then(e=>n.then(()=>oe(e)?om(e):e)):n.then(()=>e)}let rn=!1;function rt(e){rn=!0,oz&&(oj(e),o9())}function ro(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return rr(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function rr(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function ri({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),o=ro(e,n).replace(window.location.origin,"");o.startsWith(t)?oM(o):window.location.assign(o)}oz&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...oH]},reroute:o9,NOT_LOADED:tJ,toLoadPromise:oS,toBootstrapPromise:op,unregisterApplication:o0,getProfilerData:function(){return oc}});let ra="openmrs:history";function rs(e){let n=JSON.parse(sessionStorage.getItem(ra)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(ra,JSON.stringify(n))}function rl(){0===JSON.parse(sessionStorage.getItem(ra)??"[]").length&&document.referrer&&rs(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=rc();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(ra,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?rp({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&rs(window.location.href)})}function rc(){return JSON.parse(sessionStorage.getItem(ra)??"[]")}function rp({toUrl:e}){let n=rc(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);ri({to:n[t]}),sessionStorage.setItem(ra,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function rd(){sessionStorage.removeItem(ra)}let ru="${openmrsSpaBase}/login",rf={redirectAuthFailure:{enabled:{_type:nV.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nV.String,_default:ru,_validators:[tT.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:nV.Array,_default:[401],_elements:{_type:nV.Number,_validators:[tT.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nV.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:nV.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function rm(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let rh="/ws/rest/v1",rg="/ws/fhir2/R4",r_=`${rh}/session`;function ry(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function rb(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let t=ry(e);if(n.headers||(n.headers={}),e$(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(rh)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(rg)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let o=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:r}=await tc("@openmrs/esm-api");if(e.ok)if(204!==e.status)return e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e});else{if(r&&e.headers.has("location")){let n=e.headers.get("location");n&&ri({to:n})}return e.data=null,e}return t===ry(r_)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(rd(),ri({to:n.url||e.headers.get("location")||ru}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let r=n;try{r=JSON.parse(n)}catch(e){}throw new r$(t,e,r,o)},n=>{throw new r$(t,e,null,o)})})}function rv(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new ef.c(o=>{let r=!1;return rb(e,n).then(e=>{r=!0,o.next(e),o.complete()},e=>{r=!0,o.error(e)}),()=>{r||t.abort()}})}class r$ extends Error{constructor(e,n,t,o){super(),rm(this,"response",void 0),rm(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,o.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
12
|
+
${n}`)}return o}let tv=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let o=t[n],r=e[n];if(r&&(r.hasOwnProperty("_type")||r.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=r._default);let e=r._elements;if(o&&t$(e)){if(r._type===nV.Array&&Array.isArray(o)){let r=o.map(n=>tv(e,n));t[n]=r}else if(r._type===nV.Object)for(let n of Object.keys(o))o[n]=tv(e,o[n])}}else if(tA(r)){let e=o??{};tA(e)&&(t[n]=tv(r,e))}}return t};function t$(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function tA(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let tk=new Set;function tx(e,n){let t=`${e}:::${n}`;tk||(tk=new Set),tk.has(t)||(console.error(n),tk.add(t))}function tw(e){e?tk.forEach(n=>{n.startsWith(e)&&tk.delete(n)}):tk.clear()}function tC(){te.forEach(e=>e()),te.length=0,tt()}let tE={"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:nV.Object,_default:{},_validators:[nG(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${n.join(", ")}.`})]}},tS={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nV.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nV.String,_default:void 0}},...tE},tz=(e,n)=>nG(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),tD=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return nG(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,o=t.exec(e);for(;o;){if(!n.includes(o[1]))return!1;o=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},tP=tD([]),tM=e=>nG(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),tT={inRange:tz,isUrl:tP,isUrlWithTemplateParameters:tD,oneOf:tM};var tN=t(82034);let tO=U("breadcrumbs",[]);function tB(e){return tI([e])}function tI(e){let n=[...tj(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,tN.pathToRegexp)(e.matcher).regexp:(0,tN.pathToRegexp)(e.path).regexp,settings:e}))];tO.setState(n,!0)}function tj(){return tO.getState()}function tR(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=tR(e,t.join("/"));if(n)return n}}(e,n)}function tF(e,n){if(e.length>0){let t=tR(e,n);if(t){let n=[t],o=tR(e,t.settings.parent);for(;void 0!==o;)n.push(o),o=tR(e,o.settings.parent);return n.reverse()}}return[]}function tL(e){return tF(tj(),e)}var tW=Object.freeze({__proto__:null,get start(){return rt},get ensureJQuerySupport(){return oL},get setBootstrapMaxTime(){return oA},get setMountMaxTime(){return ok},get setUnmountMaxTime(){return ox},get setUnloadMaxTime(){return ow},get registerApplication(){return oX},get unregisterApplication(){return o0},get getMountedApps(){return oK},get getAppStatus(){return oY},get unloadApplication(){return o1},get checkActivityFunctions(){return oQ},get getAppNames(){return oZ},get pathToActiveWhen(){return o5},get navigateToUrl(){return oM},get patchHistoryApi(){return oj},get triggerAppChange(){return o7},get addErrorHandler(){return tH},get removeErrorHandler(){return tK},get mountRootParcel(){return o_},get NOT_LOADED(){return tJ},get LOADING_SOURCE_CODE(){return tX},get NOT_BOOTSTRAPPED(){return tQ},get BOOTSTRAPPING(){return t0},get NOT_MOUNTED(){return t1},get MOUNTING(){return t2},get UPDATING(){return t5},get LOAD_ERROR(){return t8},get MOUNTED(){return t3},get UNLOADING(){return t6},get UNMOUNTING(){return t4},get SKIP_BECAUSE_BROKEN(){return t7}}),tV=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,tG=!function(){try{var e=new tV("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:tV;let tU=[];function tq(e,n,t){let o=tY(e,n,t);tU.length?tU.forEach(e=>e(o)):setTimeout(()=>{throw o})}function tH(e){if("function"!=typeof e)throw Error(tZ(28,!1));tU.push(e)}function tK(e){if("function"!=typeof e)throw Error(tZ(29,!1));let n=!1;return tU=tU.filter(t=>{let o=t===e;return n=n||o,!o}),n}function tZ(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function tY(e,n,t){let o,r=`${oo(n)} '${on(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=r+e.message}catch(e){}o=e}else{console.warn(tZ(30,!1,n.status,on(n)));try{o=Error(r+JSON.stringify(e))}catch(n){o=e}}return o.appOrParcelName=on(n),n.status=t,o}let tJ="NOT_LOADED",tX="LOADING_SOURCE_CODE",tQ="NOT_BOOTSTRAPPED",t0="BOOTSTRAPPING",t1="NOT_MOUNTED",t2="MOUNTING",t3="MOUNTED",t5="UPDATING",t4="UNMOUNTING",t6="UNLOADING",t8="LOAD_ERROR",t7="SKIP_BECAUSE_BROKEN";function t9(e){return e.status===t3}function oe(e){try{return e.activeWhen(window.location)}catch(n){return tq(n,e,t7),!1}}function on(e){return e.name}function ot(e){return!!e.unmountThisParcel}function oo(e){return ot(e)?"parcel":"application"}function or(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function oi(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function oa(e){return e&&("function"==typeof e||Array.isArray(e)&&!oi(e,e=>"function"!=typeof e))}function os(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let o=oo(e),r=on(e);return function(e){return t.reduce((t,i,a)=>t.then(()=>{let t=i(e);return ol(t)?t:Promise.reject(tZ(15,!1,o,r,n,a))}),Promise.resolve())}}function ol(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let oc=[];function op(e,n){return Promise.resolve().then(()=>e.status!==tQ?e:(e.status=t0,e.bootstrap?oC(e,"bootstrap").then(t).catch(t=>{if(n)throw tY(t,e,t7);return tq(t,e,t7),e}):Promise.resolve().then(t)));function t(){return e.status=t1,e}}function od(e,n){return Promise.resolve().then(()=>{if(e.status!==t3)return e;return e.status=t4,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,o=>t().then(()=>{let t=Error(o.message);if(n)throw tY(t,e,t7);tq(t,e,t7)})).then(()=>e);function t(){return oC(e,"unmount").then(()=>{e.status=t1},t=>{if(n)throw tY(t,e,t7);tq(t,e,t7)})}})}let ou=!1,of=!1;function om(e,n){return Promise.resolve().then(()=>e.status!==t1?e:(ou||(window.dispatchEvent(new tG("single-spa:before-first-mount")),ou=!0),e.status=t2,oC(e,"mount").then(()=>(e.status=t3,of||(window.dispatchEvent(new tG("single-spa:first-mount")),of=!0),e)).catch(t=>{return e.status=t3,od(e,!0).then(o,o);function o(){if(n)throw tY(t,e,t7);return tq(t,e,t7),e}})))}let oh=0,og={parcels:{}};function o_(){return oy.apply(og,arguments)}function oy(e,n){let t,o,r,i=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(tZ(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(tZ(3,!1,typeof e.name));let a=oh++,s=e.name||`parcel-${a}`;if("object"!=typeof n)throw Error(tZ(4,!1,s,typeof n));if(!n.domElement)throw Error(tZ(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:a,parcels:{},status:l?tX:tQ,customProps:n,parentName:on(i),unmountThisParcel:()=>f.then(()=>{if(p.status!==t3)throw Error(tZ(6,!1,s,p.status));return od(p,!0)}).then(e=>(p.parentName&&delete i.parcels[p.id],e)).then(e=>(o(e),e)).catch(e=>{throw p.status=t7,r(e),e})};i.parcels[a]=p;let d=c();if(!d||"function"!=typeof d.then)throw Error(tZ(7,!1));let u=(d=d.then(e=>{if(!e)throw Error(tZ(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!oa(e.bootstrap))throw Error(tZ(9,!1,s));if(!oa(e.mount))throw Error(tZ(10,!1,s));if(!oa(e.unmount))throw Error(tZ(11,!1,s));if(e.update&&!oa(e.update))throw Error(tZ(12,!1,s));let n=os(e,"bootstrap"),o=os(e,"mount"),r=os(e,"unmount");p.status=tQ,p.name=s,p.bootstrap=n,p.mount=o,p.unmount=r,p.timeouts=oE(e.timeouts),e.update&&(p.update=os(e,"update"),t.update=function(e){return p.customProps=e,ob(Promise.resolve().then(()=>{if(p.status!==t3)throw Error(tZ(32,!1,on(p)));return p.status=t5,oC(p,"update").then(()=>(p.status=t3,p)).catch(e=>{throw tY(e,p,t7)})}))})})).then(()=>op(p,!0)),f=u.then(()=>om(p,!0)),m=new Promise((e,n)=>{o=e,r=n});return t={mount:()=>ob(Promise.resolve().then(()=>{if(p.status!==t1)throw Error(tZ(13,!1,s,p.status));return i.parcels[a]=p,om(p)})),unmount:()=>ob(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:ob(d),bootstrapPromise:ob(u),mountPromise:ob(f),unmountPromise:ob(m)}}function ob(e){return e.then(()=>null)}function ov(e){let n=on(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(tZ(40,!1),n,t));let o=or({},t,{name:n,mountParcel:oy.bind(e),singleSpa:tW});return ot(e)&&(o.unmountSelf=e.unmountThisParcel),o}let o$={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 oA(e,n,t){if("number"!=typeof e||e<=0)throw Error(tZ(16,!1));o$.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ok(e,n,t){if("number"!=typeof e||e<=0)throw Error(tZ(17,!1));o$.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ox(e,n,t){if("number"!=typeof e||e<=0)throw Error(tZ(18,!1));o$.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ow(e,n,t){if("number"!=typeof e||e<=0)throw Error(tZ(19,!1));o$.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function oC(e,n){let t=e.timeouts[n],o=t.warningMillis,r=oo(e);return new Promise((i,a)=>{let s=!1,l=!1;e[n](ov(e)).then(e=>{s=!0,i(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>p(1),o),setTimeout(()=>p(!0),t.millis);let c=tZ(31,!1,n,r,on(e),t.millis);function p(e){s||(!0===e?(l=!0,t.dieOnTimeout?a(Error(c)):console.error(c)):!l&&(console.warn(c),e*o+o<t.millis&&setTimeout(()=>p(e+1),o)))}})}function oE(e){let n={};for(let t in o$)n[t]=or({},o$[t],e&&e[t]||{});return n}function oS(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==tJ&&e.status!==t8?e:(e.status=tX,e.loadPromise=Promise.resolve().then(()=>{let o=e.loadApp(ov(e));if(!ol(o))throw t=!0,Error(tZ(33,!1,on(e)));return o.then(t=>{let o;e.loadErrorTime=null,"object"!=typeof(n=t)&&(o=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!oa(n.bootstrap)&&(o=35),oa(n.mount)||(o=36),oa(n.unmount)||(o=37);let r=oo(n);if(o){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(tZ(o,!1,r,on(e),t),n),tq(void 0,e,t7),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=or({},e.devtools.overlays,n.devtools.overlays)),e.status=tQ,e.bootstrap=os(n,"bootstrap"),e.mount=os(n,"mount"),e.unmount=os(n,"unmount"),e.unload=os(n,"unload"),e.timeouts=oE(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let o;return delete e.loadPromise,t?o=t7:(o=t8,e.loadErrorTime=(new Date).getTime()),tq(n,e,o),e}))})}let oz="u">typeof window,oD={hashchange:[],popstate:[]},oP=["hashchange","popstate"];function oM(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(tZ(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=oR(window.location.href),o=oR(n);0===n.indexOf("#")?window.location.hash=o.hash:t.host!==o.host&&o.host?window.location.href=n:o.pathname===t.pathname&&o.search===t.search?window.location.hash=o.hash:window.history.pushState(null,null,n)}function oT(e){if(e){let n=e[0].type;oP.indexOf(n)>=0&&oD[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function oN(){o9([],arguments)}function oO(e,n){return function(){let t=window.location.href,r=e.apply(this,arguments),i=window.location.href;return o&&t===i||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),r}}let oB=null,oI=!1;function oj(e){if(oI)throw Error(tZ(43,!1));o=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,oI=!0,oB=window.history.replaceState,window.addEventListener("hashchange",oN),window.addEventListener("popstate",oN);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&oP.indexOf(e)>=0)||oi(oD[e],e=>e===t))return n.apply(this,arguments);oD[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&oP.indexOf(e)>=0&&(oD[e]=oD[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=oO(window.history.pushState,"pushState"),window.history.replaceState=oO(oB,"replaceState")}function oR(e){let n=document.createElement("a");return n.href=e,n}oz&&(window.singleSpaNavigate?console.warn(tZ(41,!1)):window.singleSpaNavigate=oM);let oF=!1;function oL(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!oF){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return oW.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return oW.call(this,t,window.removeEventListener,e,n,arguments)},oF=!0}}function oW(e,n,t,o,r){return"string"!=typeof t?e.apply(this,r):(t.split(/\s+/).forEach(e=>{oP.indexOf(e)>=0&&(n(e,o),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,r))}let oV={};function oG(e){return Promise.resolve().then(()=>{let n=oV[on(e)];if(!n)return e;if(e.status===tJ)return oU(e,n),e;if(e.status===t6)return n.promise.then(()=>e);if(e.status!==t1&&e.status!==t8)return e;let t=e.status===t8?Promise.resolve():oC(e,"unload");return e.status=t6,t.then(()=>(oU(e,n),e)).catch(t=>(delete oV[on(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,tq(t,e,t7),n.reject(t),e))})}function oU(e,n){delete oV[on(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=tJ,n.resolve()}function oq(e,n,t,o){oV[on(e)]={app:e,resolve:t,reject:o},Object.defineProperty(oV[on(e)],"promise",{get:n})}let oH=[];function oK(){return oH.filter(t9).map(on)}function oZ(){return oH.map(on)}function oY(e){let n=oi(oH,n=>on(n)===e);return n?n.status:null}let oJ=!1;function oX(e,n,t,o){var r,i;let a,s,l=(a={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(tZ(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(tZ(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(tZ(20,!1));let o=e=>"string"==typeof e||"function"==typeof e;if(!(o(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(o)))throw Error(tZ(24,!1));if(!o3(e.customProps))throw Error(tZ(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,n,t,o){if("string"!=typeof e||0===e.length)throw Error(tZ(20,!1));if(!n)throw Error(tZ(23,!1));if("function"!=typeof t)throw Error(tZ(24,!1));if(!o3(o))throw Error(tZ(22,!1))}(e,n,t,o),a.name=e,a.loadApp=n,a.activeWhen=t,a.customProps=o),a.loadApp="function"!=typeof(r=a.loadApp)?()=>Promise.resolve(r):r,a.customProps=a.customProps||{},s=(s=Array.isArray(i=a.activeWhen)?i:[i]).map(e=>"function"==typeof e?e:o5(e)),a.activeWhen=e=>s.some(n=>n(e)),a);if(rn||oJ||(oJ=!0,setTimeout(()=>{rn||console.warn(tZ(1,!1))},5e3)),-1!==oZ().indexOf(l.name))throw Error(tZ(21,!1,l.name));oH.push(or({loadErrorTime:null,status:tJ,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),oz&&(oL(),o9())}function oQ(e=window.location){return oH.filter(n=>n.activeWhen(e)).map(on)}function o0(e){if(0===oH.filter(n=>on(n)===e).length)throw Error(tZ(25,!1,e));return(oz?o1(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=oH.map(on).indexOf(e);oH.splice(n,1)})}function o1(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(tZ(26,!1));let t=oi(oH,n=>on(n)===e);if(!t)throw Error(tZ(27,!1,e));let o=oV[on(t)];if(n&&n.waitForUnmount){if(o)return o.promise;{let e=new Promise((n,o)=>{oq(t,()=>e,n,o)});return e}}{let e;return o?(e=o.promise,o2(t,o.resolve,o.reject)):e=new Promise((n,o)=>{oq(t,()=>e,n,o),o2(t,n,o)}),e}}function o2(e,n,t){Promise.resolve().then(()=>{if(oi(oQ(),n=>n===on(e)))return o7()}).then(()=>od(e).then(oG).then(()=>{n(),setTimeout(()=>{o9()})})).catch(t)}function o3(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function o5(e,n){let t=function(e,n){let t=0,o=!1,r="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],r=o&&"/"===t;(!o&&":"===t||r)&&i(n)}return i(e.length),RegExp(r,"i");function i(i){let a=e.slice(t,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(r+=o?"[^/]+/?":a,i===e.length)if(o)n&&(r+="$");else{let e=n?"":".*";r="/"===r.charAt(r.length-1)?`${r}${e}$`:`${r}(/${e})?(#.*)?$`}o=!o,t=i}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let o=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(o)}}let o4=!1,o6=[],o8=oz&&window.location.href;function o7(){return o9()}function o9(e=[],n,t=!1){let o,r,i,a,s;if(o4)return new Promise((e,t)=>{o6.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:d}=(o=[],r=[],i=[],a=[],s=(new Date).getTime(),oH.forEach(e=>{let n=e.status!==t7&&oe(e);switch(e.status){case t8:n&&s-e.loadErrorTime>=200&&i.push(e);break;case tJ:case tX:n&&i.push(e);break;case tQ:case t1:!n&&oV[on(e)]?o.push(e):n&&a.push(e);break;case t3:n||r.push(e)}}),{appsToUnload:o,appsToUnmount:r,appsToLoad:i,appsToMount:a}),u,f=[],m=o8,h=o8=window.location.href;return rn?(o4=!0,u=l.concat(p,c,d),Promise.resolve().then(()=>($(0===u.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return oB.call(window.history,history.state,"",m.substring(location.origin.length)),o8=location.href,o4=!1,o9(e,n,!0);let o=l.map(oG),r=Promise.all(c.map(od).map(e=>e.then(oG)).concat(o));r.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let i=p.map(e=>oS(e).then(e=>re(e,r))),a=d.filter(e=>0>p.indexOf(e)).map(e=>re(e,r));return r.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(i.concat(a)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(y).then(()=>{},e=>{throw e})))})))):(u=p,Promise.resolve().then(()=>Promise.all(p.map(oS)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(tZ(42,!1))),console.warn(e),!1)))}function y(){let n=oK();e.forEach(e=>e.resolve(n));try{$(0===u.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(o4=!1,o6.length>0){let e=o6;o6=[],o9(e)}return n}function b(){t||(e.forEach(e=>{oT(e.eventArguments)}),oT(n))}function v(e=!1,t){let o={},r={[t3]:[],[t1]:[],[tJ]:[],[t7]:[]};e?(p.concat(d).forEach((e,n)=>{a(e,t3)}),l.forEach(e=>{a(e,tJ)}),c.forEach(e=>{a(e,t1)})):u.forEach(e=>{a(e)});let i={detail:{newAppStatuses:o,appsByNewStatus:r,totalAppChanges:u.length,originalEvent:null==n?void 0:n[0],oldUrl:m,newUrl:h}};return t&&or(i.detail,t),i;function a(e,n){let t=on(e);n=n||oY(t),o[t]=n,(r[n]=r[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new tG(`single-spa:${e}`,n))}}function re(e,n){return oe(e)?op(e).then(e=>n.then(()=>oe(e)?om(e):e)):n.then(()=>e)}let rn=!1;function rt(e){rn=!0,oz&&(oj(e),o9())}function ro(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return rr(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function rr(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function ri({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),o=ro(e,n).replace(window.location.origin,"");o.startsWith(t)?oM(o):window.location.assign(o)}oz&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...oH]},reroute:o9,NOT_LOADED:tJ,toLoadPromise:oS,toBootstrapPromise:op,unregisterApplication:o0,getProfilerData:function(){return oc}});let ra="openmrs:history";function rs(e){let n=JSON.parse(sessionStorage.getItem(ra)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(ra,JSON.stringify(n))}function rl(){0===JSON.parse(sessionStorage.getItem(ra)??"[]").length&&document.referrer&&rs(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=rc();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(ra,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?rp({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&rs(window.location.href)})}function rc(){return JSON.parse(sessionStorage.getItem(ra)??"[]")}function rp({toUrl:e}){let n=rc(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);ri({to:n[t]}),sessionStorage.setItem(ra,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function rd(){sessionStorage.removeItem(ra)}let ru="${openmrsSpaBase}/login",rf={redirectAuthFailure:{enabled:{_type:nV.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nV.String,_default:ru,_validators:[tT.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:nV.Array,_default:[401],_elements:{_type:nV.Number,_validators:[tT.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nV.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:nV.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function rm(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let rh="/ws/rest/v1",rg="/ws/fhir2/R4",r_=`${rh}/session`;function ry(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function rb(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let t=ry(e);if(n.headers||(n.headers={}),e$(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(rh)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(rg)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let o=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:r}=await tc("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(r&&n&&(t===ry(r_)||204===e.status)&&ri({to:n}),204===e.status)?(e.data=null,e):e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e})}return t===ry(r_)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(rd(),ri({to:n.url||e.headers.get("location")||ru}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let r=n;try{r=JSON.parse(n)}catch(e){}throw new r$(t,e,r,o)},n=>{throw new r$(t,e,null,o)})})}function rv(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new ef.c(o=>{let r=!1;return rb(e,n).then(e=>{r=!0,o.next(e),o.complete()},e=>{r=!0,o.error(e)}),()=>{r||t.abort()}})}class r$ extends Error{constructor(e,n,t,o){super(),rm(this,"response",void 0),rm(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,o.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${o.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
15
|
${this.stack}`}}let rA=U("session",{loaded:!1,session:null}),rk=0;function rx(e={includeAuthStatus:!0}){return(rk<Date.now()-6e4||!rA.getState().loaded)&&rE(),new ef.c(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(rA.getState()),rA.subscribe(t)})}function rw(){return(rk<Date.now()-6e4||!rA.getState().loaded)&&rE(),rA}function rC(e){let n=e.locale??e.user?.userProperties?.defaultLocale;n&&n.includes("_")&&(n=n.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(n)&&n!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",n)}function rE(e,n){rk=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),rN(rb(r_,{headers:t}))}function rS(){rA.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function rz(e,n){var t,o;if(void 0===n)return!e;if(!e)return!0;return t=e,o=n,("string"==typeof t?!Y(o.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Y(o.privileges.find(n=>e===n.display))):(Y(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Y(n.roles.find(e=>"System Developer"===e.display))}function rD(){let e,n;return new Promise(t=>{let o=o=>{o.loaded&&o.session.user&&(e=o.session.user,t(o.session.user),n&&n())};o(rA.getState()),e||(n=rA.subscribe(o))})}function rP(){return new Promise((e,n)=>{rx().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function rM(e,n){return rN(rb(r_,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function rT(e,n,t){return t||(t=new AbortController),await rb(`${rh}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),rE()}function rN(e){return new Promise((n,t)=>{e.then(e=>{let o;"object"==typeof e?.data?(o={loaded:!0,session:e.data},rA.setState(o),n(o)):(o={loaded:!1,session:null},rA.setState(o),t(o))}).catch(e=>{O(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};rA.setState(n),t(n)})})}function rO(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}rA.subscribe(e=>{e.loaded&&e.session&&rC(e.session)});let rB={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function rI(){to("@openmrs/esm-api",rf),rE()}let rj={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",closeWorkspaces2PromptTitle:"Close workspace(s)",closeWorkspaces2PromptBody:"You are about to close the following workspace(s), which might have unsaved changes:",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"},rR=e=>"string"==typeof e,rF=()=>{let e,n,t=new Promise((t,o)=>{e=t,n=o});return t.resolve=e,t.reject=n,t},rL=e=>null==e?"":""+e,rW=/###/g,rV=e=>e&&e.indexOf("###")>-1?e.replace(rW,"."):e,rG=e=>!e||rR(e),rU=(e,n,t)=>{let o=rR(n)?n.split("."):n,r=0;for(;r<o.length-1;){if(rG(e))return{};let n=rV(o[r]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++r}return rG(e)?{}:{obj:e,k:rV(o[r])}},rq=(e,n,t)=>{let{obj:o,k:r}=rU(e,n,Object);if(void 0!==o||1===n.length){o[r]=t;return}let i=n[n.length-1],a=n.slice(0,n.length-1),s=rU(e,a,Object);for(;void 0===s.obj&&a.length;)i=`${a[a.length-1]}.${i}`,s=rU(e,a=a.slice(0,a.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${i}`]&&(s.obj=void 0);s.obj[`${s.k}.${i}`]=t},rH=(e,n)=>{let{obj:t,k:o}=rU(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,o))return t[o]},rK=(e,n,t)=>{for(let o in n)"__proto__"!==o&&"constructor"!==o&&(o in e?rR(e[o])||e[o]instanceof String||rR(n[o])||n[o]instanceof String?t&&(e[o]=n[o]):rK(e[o],n[o],t):e[o]=n[o]);return e};var rZ={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let rY=e=>rR(e)?e.replace(/[&<>"'\/]/g,e=>rZ[e]):e,rJ=[" ",",","?","!",";"],rX=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(void 0!==n)return n;let t=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,t),this.regExpQueue.push(e),t}}(20),rQ=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let o=n.split(t),r=e;for(let e=0;e<o.length;){let n;if(!r||"object"!=typeof r)return;let i="";for(let a=e;a<o.length;++a)if(a!==e&&(i+=t),i+=o[a],void 0!==(n=r[i])){if(["string","number","boolean"].indexOf(typeof n)>-1&&a<o.length-1)continue;e+=a-e+1;break}r=n}return r},r0=e=>e?.replace("_","-"),r1={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,n){console?.[e]?.apply?.(console,n)}};class r2{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||r1,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,t,o){return o&&!this.debug?null:(rR(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new r2(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new r2(this.logger,e)}}var r3=new r2;class r5{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let t=this.observers[e].get(n)||0;this.observers[e].set(n,t+1)}),this}off(e,n){if(this.observers[e]){if(!n)return void delete this.observers[e];this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,t])=>{for(let o=0;o<t;o++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,o])=>{for(let r=0;r<o;r++)t.apply(t,[e,...n])})}}class r4 extends r5{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,t,o={}){let r,i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=void 0!==o.ignoreJSONStructure?o.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?r=e.split("."):(r=[e,n],t&&(Array.isArray(t)?r.push(...t):rR(t)&&i?r.push(...t.split(i)):r.push(t)));let s=rH(this.data,r);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=r[0],n=r[1],t=r.slice(2).join(".")),!s&&a&&rR(t))?rQ(this.data?.[e]?.[n],t,i):s}addResource(e,n,t,o,r={silent:!1}){let i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,a=[e,n];t&&(a=a.concat(i?t.split(i):t)),e.indexOf(".")>-1&&(a=e.split("."),o=n,n=a[1]),this.addNamespaces(n),rq(this.data,a,o),r.silent||this.emit("added",e,n,t,o)}addResources(e,n,t,o={silent:!1}){for(let o in t)(rR(t[o])||Array.isArray(t[o]))&&this.addResource(e,n,o,t[o],{silent:!0});o.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,o,r,i={silent:!1,skipCopy:!1}){let a=[e,n];e.indexOf(".")>-1&&(a=e.split("."),o=t,t=n,n=a[1]),this.addNamespaces(n);let s=rH(this.data,a)||{};i.skipCopy||(t=JSON.parse(JSON.stringify(t))),o?rK(s,t,r):s={...s,...t},rq(this.data,a,s),i.silent||this.emit("added",e,n,t)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return void 0!==this.getResource(e,n)}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(e=>n[e]&&Object.keys(n[e]).length>0)}toJSON(){return this.data}}var r6={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,o,r){return e.forEach(e=>{n=this.processors[e]?.process(n,t,o,r)??n}),n}};let r8=Symbol("i18next/PATH_KEY");function r7(e,n){let t,o,r,{[r8]:i}=e((o=[],(r=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===r8)?o:(o.push(n),(t=Proxy.revocable(e,r)).proxy),Proxy.revocable(Object.create(null),r).proxy));return i.join(n?.keySeparator??".")}let r9={},ie=e=>!rR(e)&&"boolean"!=typeof e&&"number"!=typeof e;class it extends r5{constructor(e,n={}){super(),((e,n,t)=>{e.forEach(e=>{n[e]&&(t[e]=n[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=r3.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let o=this.resolve(e,t);if(o?.res===void 0)return!1;let r=ie(o.res);return!1!==t.returnObjects||!r}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,r=n.ns||this.options.defaultNS||[],i=t&&e.indexOf(t)>-1,a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let o=rJ.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===o.length)return!0;let r=rX.getRegExp(`(${o.map(e=>"?"===e?"\\?":e).join("|")})`),i=!r.test(e);if(!i){let n=e.indexOf(t);n>0&&!r.test(e.substring(0,n))&&(i=!0)}return i})(e,t,o);if(i&&!a){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:rR(r)?[r]:r};let i=e.split(t);(t!==o||t===o&&this.options.ns.indexOf(i[0])>-1)&&(r=i.shift()),e=i.join(o)}return{key:e,namespaces:rR(r)?[r]:r}}translate(e,n,t){let o="object"==typeof n?{...n}:n;if("object"!=typeof o&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof o&&(o={...o}),o||(o={}),null==e)return"";"function"==typeof e&&(e=r7(e,{...this.options,...o})),Array.isArray(e)||(e=[String(e)]);let r=void 0!==o.returnDetails?o.returnDetails:this.options.returnDetails,i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],o),l=s[s.length-1],c=void 0!==o.nsSeparator?o.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let p=o.lng||this.language,d=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return d?r?{res:`${l}${c}${a}`,usedKey:a,exactUsedKey:a,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:`${l}${c}${a}`:r?{res:a,usedKey:a,exactUsedKey:a,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:a;let u=this.resolve(e,o),f=u?.res,m=u?.usedKey||a,h=u?.exactUsedKey||a,g=void 0!==o.joinArrays?o.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==o.count&&!rR(o.count),v=it.hasDefaultValue(o),$=b?this.pluralResolver.getSuffix(p,o.count,o):"",A=o.ordinal&&b?this.pluralResolver.getSuffix(p,o.count,{ordinal:!1}):"",k=b&&!o.ordinal&&0===o.count,x=k&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${$}`]||o[`defaultValue${A}`]||o.defaultValue,w=f;y&&!f&&v&&(w=x);let C=ie(w),E=Object.prototype.toString.apply(w);if(y&&w&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(rR(g)&&Array.isArray(w))){if(!o.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,w,{...o,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return r?(u.res=e,u.usedParams=this.getUsedParamsDetails(o),u):e}if(i){let e=Array.isArray(w),n=e?[]:{},t=e?h:m;for(let e in w)if(Object.prototype.hasOwnProperty.call(w,e)){let r=`${t}${i}${e}`;v&&!f?n[e]=this.translate(r,{...o,defaultValue:ie(x)?x[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(r,{...o,joinArrays:!1,ns:s}),n[e]===r&&(n[e]=w[e])}f=n}}else if(y&&rR(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,o,t));else{let n=!1,r=!1;!this.isValidLookup(f)&&v&&(n=!0,f=x),this.isValidLookup(f)||(r=!0,f=a);let s=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&r?void 0:f,d=v&&x!==f&&this.options.updateMissing;if(r||n||d){if(this.logger.log(d?"updateKey":"missingKey",p,l,a,d?x:f),i){let e=this.resolve(a,{...o,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if("fallback"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t<n.length;t++)e.push(n[t]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(o.lng||this.language):e.push(o.lng||this.language);let t=(e,n,t)=>{let r=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,r,d,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,r,d,o),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,o);k&&o[`defaultValue${this.options.pluralSeparator}zero`]&&0>n.indexOf(`${this.options.pluralSeparator}zero`)&&n.push(`${this.options.pluralSeparator}zero`),n.forEach(n=>{t([e],a+n,o[`defaultValue${n}`]||x)})}):t(e,a,x))}f=this.extendTranslation(f,e,o,u,t),r&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${a}`),(r||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${a}`:a,n?f:void 0,o))}return r?(u.res=f,u.usedParams=this.getUsedParamsDetails(o),u):f}extendTranslation(e,n,t,o,r){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!t.skipInterpolation){let i;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let a=rR(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let n=e.match(this.interpolator.nestingRegexp);i=n&&n.length}let s=t.replace&&!rR(t.replace)?t.replace:t;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,t.lng||this.language||o.usedLng,t),a){let n=e.match(this.interpolator.nestingRegexp);i<(n&&n.length)&&(t.nest=!1)}!t.lng&&o&&o.res&&(t.lng=this.language||o.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>r?.[0]!==e[0]||t.context?this.translate(...e,n):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null),t)),t.interpolation&&this.interpolator.reset()}let i=t.postProcess||this.options.postProcess,a=rR(i)?[i]:i;return null!=e&&a?.length&&!1!==t.applyPostProcessor&&(e=r6.handle(a,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,o,r,i,a;return rR(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;o=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let p=void 0!==n.count&&!rR(n.count),d=p&&!n.ordinal&&0===n.count,u=void 0!==n.context&&(rR(n.context)||"number"==typeof n.context)&&""!==n.context,f=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(e=>{this.isValidLookup(t)||(a=e,!r9[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(r9[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${o}" for languages "${f.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),f.forEach(o=>{let a;if(this.isValidLookup(t))return;i=o;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,o,e,n);else{let e;p&&(e=this.pluralResolver.getSuffix(o,n.count,n));let t=`${this.options.pluralSeparator}zero`,r=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&0===e.indexOf(r)&&s.push(l+e.replace(r,this.options.pluralSeparator)),s.push(l+e),d&&s.push(l+t)),u){let o=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(o),p&&(n.ordinal&&0===e.indexOf(r)&&s.push(o+e.replace(r,this.options.pluralSeparator)),s.push(o+e),d&&s.push(o+t))}}for(;a=s.pop();)this.isValidLookup(t)||(r=a,t=this.getResource(o,e,a,n))}))})}),{res:t,usedKey:o,exactUsedKey:r,usedLng:i,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,o={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,o):this.resourceStore.getResource(e,n,t,o)}getUsedParamsDetails(e={}){let n=e.replace&&!rR(e.replace),t=n?e.replace:e;if(n&&void 0!==e.count&&(t.count=e.count),this.options.interpolation.defaultVariables&&(t={...this.options.interpolation.defaultVariables,...t}),!n)for(let e of(t={...t},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete t[e];return t}static hasDefaultValue(e){let n="defaultValue";for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n===t.substring(0,n.length)&&void 0!==e[t])return!0;return!1}}class io{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=r3.create("languageUtils")}getScriptPartFromCode(e){if(!(e=r0(e))||0>e.indexOf("-"))return null;let n=e.split("-");return 2===n.length||(n.pop(),"x"===n[n.length-1].toLowerCase())?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(!(e=r0(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(rR(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch(e){}return(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)?n:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let n;return e?(e.forEach(e=>{if(n)return;let t=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(t))&&(n=t)}),!n&&this.options.supportedLngs&&e.forEach(e=>{if(n)return;let t=this.getScriptPartFromCode(e);if(this.isSupportedCode(t))return n=t;let o=this.getLanguagePartFromCode(e);if(this.isSupportedCode(o))return n=o;n=this.options.supportedLngs.find(e=>{if(e===o||!(0>e.indexOf("-")&&0>o.indexOf("-"))&&(e.indexOf("-")>0&&0>o.indexOf("-")&&e.substring(0,e.indexOf("-"))===o||0===e.indexOf(o)&&o.length>1))return e})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n):null}getFallbackCodes(e,n){if(!e)return[];if("function"==typeof e&&(e=e(n)),rR(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let t=e[n];return t||(t=e[this.getScriptPartFromCode(n)]),t||(t=e[this.formatLanguageCode(n)]),t||(t=e[this.getLanguagePartFromCode(n)]),t||(t=e.default),t||[]}toResolveHierarchy(e,n){let t=this.getFallbackCodes((!1===n?[]:n)||this.options.fallbackLng||[],e),o=[],r=e=>{e&&(this.isSupportedCode(e)?o.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return rR(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&r(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(e))):rR(e)&&r(this.formatLanguageCode(e)),t.forEach(e=>{0>o.indexOf(e)&&r(this.formatLanguageCode(e))}),o}}let ir={zero:0,one:1,two:2,few:3,many:4,other:5},ii={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class ia{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=r3.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,o=r0("dev"===e?"en":e),r=n.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:o,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];try{t=new Intl.PluralRules(o,{type:r})}catch(r){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ii;if(!e.match(/-|_/))return ii;let o=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(o,n)}return this.pluralRulesCache[i]=t,t}needsPlural(e,n={}){let t=this.getRule(e,n);return t||(t=this.getRule("dev",n)),t?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,t={}){return this.getSuffixes(e,t).map(e=>`${n}${e}`)}getSuffixes(e,n={}){let t=this.getRule(e,n);return(t||(t=this.getRule("dev",n)),t)?t.resolvedOptions().pluralCategories.sort((e,n)=>ir[e]-ir[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let o=this.getRule(e,t);return o?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${o.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let is=(e,n,t,o=".",r=!0)=>{let i,a=void 0!==(i=rH(e,t))?i:rH(n,t);return!a&&r&&rR(t)&&void 0===(a=rQ(e,t,o))&&(a=rQ(n,t,o)),a};class il{constructor(e={}){this.logger=r3.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:n,escapeValue:t,useRawValueToEscape:o,prefix:r,prefixEscaped:i,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:p,nestingPrefix:d,nestingPrefixEscaped:u,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==n?n:rY,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==o&&o,this.prefix=r?r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):i||"{{",this.suffix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=d?d.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):u||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):m||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=h||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,n)=>e?.source===n?(e.lastIndex=0,e):RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,t,o){let r,i,a,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let r=is(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(r,void 0,t,{...o,...n,interpolationkey:e}):r}let r=e.split(this.formatSeparator),i=r.shift().trim(),a=r.join(this.formatSeparator).trim();return this.format(is(n,s,i,this.options.keySeparator,this.options.ignoreJSONStructure),a,t,{...o,...n,interpolationkey:i})};this.resetRegExp();let c=o?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(n=>{for(a=0;r=n.regex.exec(e);){let t=r[1].trim();if(void 0===(i=l(t)))if("function"==typeof c){let n=c(e,r,o);i=rR(n)?n:""}else if(o&&Object.prototype.hasOwnProperty.call(o,t))i="";else if(p){i=r[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),i="";else rR(i)||this.useRawValueToEscape||(i=rL(i));let s=n.safeValue(i);if(e=e.replace(r[0],s),p?(n.regex.lastIndex+=i.length,n.regex.lastIndex-=r[0].length):n.regex.lastIndex=0,++a>=this.maxReplaces)break}}),e}nest(e,n,t={}){let o,r,i,a=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let o=e.split(RegExp(`${t}[ ]*{`)),r=`{${o[1]}`;e=o[0];let a=(r=this.interpolate(r,i)).match(/'/g),s=r.match(/"/g);((a?.length??0)%2!=0||s)&&s.length%2==0||(r=r.replace(/'/g,'"'));try{i=JSON.parse(r),n&&(i={...n,...i})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${r}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,e};for(;o=this.nestingRegexp.exec(e);){let s=[];(i=(i={...t}).replace&&!rR(i.replace)?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;let l=/{.*}/.test(o[1])?o[1].lastIndexOf("}")+1:o[1].indexOf(this.formatSeparator);if(-1!==l&&(s=o[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),o[1]=o[1].slice(0,l)),(r=n(a.call(this,o[1].trim(),i),i))&&o[0]===e&&!rR(r))return r;rR(r)||(r=rL(r)),r||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${e}`),r=""),s.length&&(r=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:o[1].trim()}),r.trim())),e=e.replace(o[0],r),this.regexp.lastIndex=0}return e}}let ic=e=>{let n={};return(t,o,r)=>{let i=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(i={...i,[r.interpolationkey]:void 0});let a=o+JSON.stringify(i),s=n[a];return s||(s=e(r0(o),r),n[a]=s),s(t)}},ip=e=>(n,t,o)=>e(r0(t),o)(n);class id{constructor(e={}){this.logger=r3.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?ic:ip;this.formats={number:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n});return e=>t.format(e)}),currency:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n,style:"currency"});return e=>t.format(e)}),datetime:t((e,n)=>{let t=new Intl.DateTimeFormat(e,{...n});return e=>t.format(e)}),relativetime:t((e,n)=>{let t=new Intl.RelativeTimeFormat(e,{...n});return e=>t.format(e,n.range||"day")}),list:t((e,n)=>{let t=new Intl.ListFormat(e,{...n});return e=>t.format(e)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=ic(n)}format(e,n,t,o={}){let r=n.split(this.formatSeparator);if(r.length>1&&r[0].indexOf("(")>1&&0>r[0].indexOf(")")&&r.find(e=>e.indexOf(")")>-1)){let e=r.findIndex(e=>e.indexOf(")")>-1);r[0]=[r[0],...r.splice(1,e)].join(this.formatSeparator)}return r.reduce((e,n)=>{let{formatName:r,formatOptions:i}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let o=e.split("(");n=o[0].toLowerCase().trim();let r=o[1].substring(0,o[1].length-1);"currency"===n&&0>r.indexOf(":")?t.currency||(t.currency=r.trim()):"relativetime"===n&&0>r.indexOf(":")?t.range||(t.range=r.trim()):r.split(";").forEach(e=>{if(e){let[n,...o]=e.split(":"),r=o.join(":").trim().replace(/^'+|'+$/g,""),i=n.trim();t[i]||(t[i]=r),"false"===r&&(t[i]=!1),"true"===r&&(t[i]=!0),isNaN(r)||(t[i]=parseInt(r,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[r]){let n=e;try{let a=o?.formatParams?.[o.interpolationkey]||{},s=a.locale||a.lng||o.locale||o.lng||t;n=this.formats[r](e,s,{...i,...o,...a})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${r}`),e},e)}}class iu extends r5{constructor(e,n,t,o={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=o,this.logger=r3.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=o.maxParallelReads||10,this.readingCalls=0,this.maxRetries=o.maxRetries>=0?o.maxRetries:5,this.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,o.backend,o)}queueLoad(e,n,t,o){let r={},i={},a={},s={};return e.forEach(e=>{let o=!0;n.forEach(n=>{let a=`${e}|${n}`;!t.reload&&this.store.hasResourceBundle(e,n)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===i[a]&&(i[a]=!0):(this.state[a]=1,o=!1,void 0===i[a]&&(i[a]=!0),void 0===r[a]&&(r[a]=!0),void 0===s[n]&&(s[n]=!0)))}),o||(a[e]=!0)}),(Object.keys(r).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:o}),{toLoad:Object.keys(r),pending:Object.keys(i),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let o=e.split("|"),r=o[0],i=o[1];n&&this.emit("failedLoading",r,i,n),!n&&t&&this.store.addResourceBundle(r,i,t,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&t&&(this.state[e]=0);let a={};this.queue.forEach(t=>{((e,n,t,o)=>{let{obj:r,k:i}=rU(e,n,Object);r[i]=r[i]||[],r[i].push(t)})(t.loaded,[r],i),void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--),n&&t.errors.push(n),0!==t.pendingCount||t.done||(Object.keys(t.loaded).forEach(e=>{a[e]||(a[e]={});let n=t.loaded[e];n.length&&n.forEach(n=>{void 0===a[e][n]&&(a[e][n]=!0)})}),t.done=!0,t.errors.length?t.callback(t.errors):t.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,n,t,o=0,r=this.retryTimeout,i){if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:o,wait:r,callback:i});this.readingCalls++;let a=(a,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&s&&o<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,o+1,2*r,i)},r):i(a,s)},s=this.backend[t].bind(this.backend);if(2===s.length){try{let t=s(e,n);t&&"function"==typeof t.then?t.then(e=>a(null,e)).catch(a):a(null,t)}catch(e){a(e)}return}return s(e,n,a)}prepareLoading(e,n,t={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();rR(e)&&(e=this.languageUtils.toResolveHierarchy(e)),rR(n)&&(n=[n]);let r=this.queueLoad(e,n,t,o);if(!r.toLoad.length)return r.pending.length||o(),null;r.toLoad.forEach(e=>{this.loadOne(e)})}load(e,n,t){this.prepareLoading(e,n,{},t)}reload(e,n,t){this.prepareLoading(e,n,{reload:!0},t)}loadOne(e,n=""){let t=e.split("|"),o=t[0],r=t[1];this.read(o,r,"read",void 0,void 0,(t,i)=>{t&&this.logger.warn(`${n}loading namespace ${r} for language ${o} failed`,t),!t&&i&&this.logger.log(`${n}loaded namespace ${r} for language ${o}`,i),this.loaded(e,t,i)})}saveMissing(e,n,t,o,r,i={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n))return void this.logger.warn(`did not save key "${t}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=t&&""!==t){if(this.backend?.create){let s={...i,isUpdate:r},l=this.backend.create.bind(this.backend);if(l.length<6)try{let r;(r=5===l.length?l(e,n,t,o,s):l(e,n,t,o))&&"function"==typeof r.then?r.then(e=>a(null,e)).catch(a):a(null,r)}catch(e){a(e)}else l(e,n,t,o,a,s)}e&&e[0]&&this.store.addResource(e[0],n,t,o)}}}let im=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let n={};if("object"==typeof e[1]&&(n=e[1]),rR(e[1])&&(n.defaultValue=e[1]),rR(e[2])&&(n.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let t=e[3]||e[2];Object.keys(t).forEach(e=>{n[e]=t[e]})}return n},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),ih=e=>(rR(e.ns)&&(e.ns=[e.ns]),rR(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),rR(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),ig=()=>{};class i_ extends r5{constructor(e={},n){if(super(),this.options=ih(e),this.services={},this.logger=r3,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{"function"==typeof e[n]&&(e[n]=e[n].bind(e))})})(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,"function"==typeof e&&(n=e,e={}),null==e.defaultNS&&e.ns&&(rR(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=im();this.options={...t,...this.options,...ih(e)},this.options.interpolation={...t.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let o=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?r3.init(o(this.modules.logger),this.options):r3.init(null,this.options),e=this.modules.formatter?this.modules.formatter:id;let n=new io(this.options);this.store=new r4(this.options.resources,this.options);let r=this.services;r.logger=r3,r.resourceStore=this.store,r.languageUtils=n,r.pluralResolver=new ia(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==t.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===t.interpolation.format)&&(r.formatter=o(e),r.formatter.init&&r.formatter.init(r,this.options),this.options.interpolation.format=r.formatter.format.bind(r.formatter)),r.interpolator=new il(this.options),r.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},r.backendConnector=new iu(o(this.modules.backend),r.resourceStore,r,this.options),r.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(r.languageDetector=o(this.modules.languageDetector),r.languageDetector.init&&r.languageDetector.init(r,this.options.detection,this.options)),this.modules.i18nFormat&&(r.i18nFormat=o(this.modules.i18nFormat),r.i18nFormat.init&&r.i18nFormat.init(this)),this.translator=new it(this.services,this.options),this.translator.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||(n=ig),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...n)=>this.store[e](...n)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...n)=>(this.store[e](...n),this)});let r=rF(),i=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),r.resolve(t),n(e,t)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?i():setTimeout(i,0),r}loadResources(e,n=ig){let t=n,o=rR(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(o?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return t();let e=[],n=n=>{n&&"cimode"!==n&&this.services.languageUtils.toResolveHierarchy(n).forEach(n=>{"cimode"!==n&&0>e.indexOf(n)&&e.push(n)})};o?n(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>n(e)),this.options.preload?.forEach?.(e=>n(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,n,t){let o=rF();return"function"==typeof e&&(t=e,e=void 0),"function"==typeof n&&(t=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),t||(t=ig),this.services.backendConnector.reload(e,n,e=>{o.resolve(),t(e)}),o}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&r6.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let n=this.languages[e];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;let t=rF();this.emit("languageChanging",e);let o=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},r=(r,i)=>{i?this.isLanguageChangingTo===e&&(o(i),this.translator.changeLanguage(i),this.isLanguageChangingTo=void 0,this.emit("languageChanged",i),this.logger.log("languageChanged",i)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(r,(...e)=>this.t(...e))},i=n=>{e||n||!this.services.languageDetector||(n=[]);let t=rR(n)?n:n&&n[0],i=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(rR(n)?[n]:n);i&&(this.language||o(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,e=>{r(e,i)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),t}getFixedT(e,n,t){let o=(e,n,...r)=>{let i,a;(i="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(r)):{...n}).lng=i.lng||o.lng,i.lngs=i.lngs||o.lngs,i.ns=i.ns||o.ns,""!==i.keyPrefix&&(i.keyPrefix=i.keyPrefix||t||o.keyPrefix);let s=this.options.keySeparator||".";return i.keyPrefix&&Array.isArray(e)?a=e.map(e=>("function"==typeof e&&(e=r7(e,{...this.options,...n})),`${i.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=r7(e,{...this.options,...n})),a=i.keyPrefix?`${i.keyPrefix}${s}${e}`:e),this.t(a,i)};return rR(e)?o.lng=e:o.lngs=e,o.ns=n,o.keyPrefix=t,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let t=n.lng||this.resolvedLanguage||this.languages[0],o=!!this.options&&this.options.fallbackLng,r=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let i=(e,n)=>{let t=this.services.backendConnector.state[`${e}|${n}`];return -1===t||0===t||2===t};if(n.precheck){let e=n.precheck(this,i);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(t,e)&&(!o||i(r,e)))}loadNamespaces(e,n){let t=rF();return this.options.ns?(rR(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}loadLanguages(e,n){let t=rF();rR(e)&&(e=[e]);let o=this.options.preload||[],r=e.filter(e=>0>o.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return r.length?(this.options.preload=o.concat(r),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let n=new Intl.Locale(e);if(n&&n.getTextInfo){let e=n.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let n=this.services?.languageUtils||new io(im());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){return new i_(e,n)}cloneInstance(e={},n=ig){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let o={...this.options,...e,isClone:!0},r=new i_(o);return(void 0!==e.debug||void 0!==e.prefix)&&(r.logger=r.logger.clone(e)),["store","services","language"].forEach(e=>{r[e]=this[e]}),r.services={...this.services},r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},t&&(r.store=new r4(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,o)=>(t[o]={...e[n][o]},t),e[n]),e),{}),o),r.services.resourceStore=r.store),r.translator=new it(r.services,o),r.translator.on("*",(e,...n)=>{r.emit(e,...n)}),r.init(o,n),r.translator.options=o,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let iy=i_.createInstance();iy.createInstance=i_.createInstance,iy.createInstance,iy.dir,iy.init,iy.loadResources,iy.reloadResources,iy.use,iy.changeLanguage,iy.getFixedT,iy.t,iy.exists,iy.setDefaultNamespace,iy.hasLoadedNamespace,iy.loadNamespaces,iy.loadLanguages;let ib=iy.default||iy;function iv(e,n,t,o){return ib.t(n,{ns:e,defaultValue:t,...o})}function i$(e,n,t){return rj[e]?iv("core",e,n??rj[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}ib.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let iA="import-map-override:",ik="import-map-overrides-disabled",ix="import-map-overrides:change",iw=!1,iC=null;async function iE(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let o=e[t];try{if(o.src){let e=await fetch(o.src);n.push(await e.json())}else o.textContent&&n.push(JSON.parse(o.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return iS(n)}function iS(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function iz(){let e={};try{let n=iN();for(let t=0;t<localStorage.length;t++){let o=localStorage.key(t);if(o?.startsWith(iA)){let t=o.slice(iA.length);if(!n.includes(t)){let n=localStorage.getItem(o);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function iD(){let e=await iE();return iw?iS([e,iC??iz()]):e}async function iP(){return iE()}async function iM(){return iw?iS([await iE(),iz()]):iE()}function iT(e){if(!iw)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(iA)){let n=localStorage.getItem(t);n&&(e[t.slice(iA.length)]=n)}}return{imports:e}}return iz()}function iN(){if(!iw)return[];try{let e=localStorage.getItem(ik);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function iO(e){return!!iw&&iN().includes(e)}function iB(e,n){if(!iw)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(iA+e,n),window.dispatchEvent(new CustomEvent(ix))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function iI(e){if(!iw)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(iA+e);let n=iN().filter(n=>n!==e);n.length>0?localStorage.setItem(ik,JSON.stringify(n)):localStorage.removeItem(ik),window.dispatchEvent(new CustomEvent(ix))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function ij(){if(!iw)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(iA)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(ik),window.dispatchEvent(new CustomEvent(ix))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function iR(e){if(!iw)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=iN().filter(n=>n!==e);n.length>0?localStorage.setItem(ik,JSON.stringify(n)):localStorage.removeItem(ik),window.dispatchEvent(new CustomEvent(ix))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let iF=!1;function iL(){!iF&&(iF=!0,(iw="development"===window.spaEnv)&&(iC=iz()))}function iW(e){return e.replace(/[\/\-@]/g,"_")}async function iV(e,n="./start",o){var r;let i,a=!o?.maxLoadingTime||o.maxLoadingTime<=0?6e5:o.maxLoadingTime;await Promise.race([iG(e,o?.importMap),new Promise((n,t)=>{i=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=a)<1e3?`${n} milliseconds`:n<6e4?`${Math.floor(n/1e3)} seconds`:n<36e5?`${Math.floor(n/6e4)} minutes`:n<864e5?`${Math.floor(n/36e5)} hours`:`${Math.floor(n/864e5)} days`}.`))},a)})]),i&&clearTimeout(i);let s=iW(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(t.S.default);let c=(await l.get(n))();if("object"!=typeof c||null===c){let n=`Container for ${e} did not return an ESM module as expected`;throw console.error(n),Error(n)}return c}async function iG(e,n){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let t=iW(e);if(!window[t]){let t=n??await iU();if(!t.imports.hasOwnProperty(e)){let n=`Could not find the package ${e} defined in the current importmap`;throw console.error(n),Error(n)}let o=t.imports[e];o.startsWith("./")&&(o=window.spaBase+o.substring(1));let r=e in iT().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let o=document.head.querySelector(`script[src="${e}"]`),r=window[iq];if(r||(r=window[iq]=new Set([])),o)if(r.has(e)){let e,r,i;i=()=>{e&&o.removeEventListener("load",e),r&&o.removeEventListener("error",r)},e=()=>{i(),n(null)},r=e=>{i(),t(e.message)},o.addEventListener("load",e),o.addEventListener("error",r)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(null);else{let o,i,a;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);a=()=>{clearTimeout(l),r.delete(e),o&&s.removeEventListener("load",o),i&&s.removeEventListener("error",i)},o=()=>{a(),n(null)},i=n=>{a();let o=`Failed to load script from ${e}`;console.error(o,n),t(n.message??o)},s.addEventListener("load",o),s.addEventListener("error",i),document.head.appendChild(s)}}(o,e,n)})}catch(e){return r&&D({kind:"error",title:i$("scriptLoadingFailed","Error: Script failed to load"),description:i$("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:o}),actionButtonLabel:i$("resetOverrides","Reset overrides"),onActionButtonClick(){ij(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function iU(){return iD()}let iq=Symbol("__openmrs_script_loading");function iH(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 iK(e){return!!e&&"object"==typeof e&&Object.entries(e).every(([e,n])=>"string"==typeof e&&iH(n))}let iZ="openmrs-routes:",iY="openmrs-routes:change",iJ=!1,iX=null;async function iQ(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[];for(let t=0;t<e.length;t++){let o=e[t];try{let e;if(o.src){let n=await fetch(o.src);e=await n.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&iK(e)&&n.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${t}`,e)}}return i0(n)}function i0(e){let n={};for(let t of e)t&&"object"==typeof t&&Object.assign(n,t);return n}async function i1(){let e={};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(iZ)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(iZ.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(iH(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),o=await n.json();if(iH(o))return{moduleName:e,routes:o};throw Error(`${t} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===t.status?e[t.value.moduleName]=t.value.routes:console.warn("[route-maps] Failed to load route override",t.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function i2(){let e=await iQ();return iJ?i0([e,iX??await i1()]):e}async function i3(){return iQ()}async function i5(){return iJ?i0([await iQ(),await i1()]):iQ()}function i4(){if(!iJ)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(iZ)){let n=localStorage.getItem(t);n&&(e[t.slice(iZ.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function i6(e,n){if(!iJ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(iZ+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!iH(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(iZ+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(iZ+e,JSON.stringify(n.toString()));else{if(!iH(n))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,n);localStorage.setItem(iZ+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(iY))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function i8(e){if(!iJ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(iZ+e),window.dispatchEvent(new CustomEvent(iY))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function i7(){if(!iJ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(iZ)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(iY))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let i9=null;function ae(){return i9||(i9=(iJ="development"===window.spaEnv)?i1().then(e=>{iX=e}):Promise.resolve())}let an=`${rh}/attachment`;function at(e,n){return rb(`${an}/${e}`,{signal:n.signal})}function ao(e,n,t){return rb(`${an}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function ar(e,n){let t=new FormData;return t.append("fileCaption",n.fileDescription),t.append("patient",e),n.file?t.append("file",n.file,n.fileName):(t.append("file",new File([""],n.fileName),n.fileName),t.append("base64Content",n.base64Content)),rb(`${an}`,{method:"POST",body:t})}function ai(e,n){return rb(`${an}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function aa(e,n){return new Promise(function(t){var o=new MessageChannel;o.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[o.port2])})}function as(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function al(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,o=Array(n);t<n;t++)o[t]=e[t];return o}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var ac=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function ap(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var ad=function(e,n){this.type=e,Object.assign(this,n)};function au(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function af(){}var am={type:"SKIP_WAITING"};function ah(e,n){if(!n)return e&&e.then?e.then(af):Promise.resolve()}var ag=function(e){function n(n,t){var o,r;return void 0===t&&(t={}),(o=e.call(this)||this).nn={},o.tn=0,o.rn=new ac,o.en=new ac,o.on=new ac,o.un=0,o.an=new Set,o.cn=function(){var e=o.fn,n=e.installing;o.tn>0||!ap(n.scriptURL,o.sn.toString())||performance.now()>o.un+6e4?(o.vn=n,e.removeEventListener("updatefound",o.cn)):(o.hn=n,o.an.add(n),o.rn.resolve(n)),++o.tn,n.addEventListener("statechange",o.ln)},o.ln=function(e){var n=o.fn,t=e.target,r=t.state,i=t===o.vn,a={sw:t,isExternal:i,originalEvent:e};!i&&o.mn&&(a.isUpdate=!0),o.dispatchEvent(new ad(r,a)),"installed"===r?o.wn=self.setTimeout(function(){"installed"===r&&n.waiting===t&&o.dispatchEvent(new ad("waiting",a))},200):"activating"===r&&(clearTimeout(o.wn),i||o.en.resolve(t))},o.dn=function(e){var n=o.hn,t=n!==navigator.serviceWorker.controller;o.dispatchEvent(new ad("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:o.mn})),t||o.on.resolve(n)},r=function(e){var n=e.data,t=e.ports,r=e.source;return au(o.getSW(),function(){o.an.has(r)&&o.dispatchEvent(new ad("message",{data:n,originalEvent:e,ports:t,sw:r}))})},o.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(r.apply(this,e))}catch(e){return Promise.reject(e)}},o.sn=n,o.nn=t,navigator.serviceWorker.addEventListener("message",o.gn),o}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,o,r=n.prototype;return r.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var o,r,i,a=this;return o=function(){if(!t&&"complete"!==document.readyState)return ah(new Promise(function(e){return window.addEventListener("load",e)}))},r=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),au(a.bn(),function(e){a.fn=e,a.yn&&(a.hn=a.yn,a.en.resolve(a.yn),a.on.resolve(a.yn),a.yn.addEventListener("statechange",a.ln,{once:!0}));var n=a.fn.waiting;return n&&ap(n.scriptURL,a.sn.toString())&&(a.hn=n,Promise.resolve().then(function(){a.dispatchEvent(new ad("waiting",{sw:n,wasWaitingBeforeRegister:!0}))}).then(function(){})),a.hn&&(a.rn.resolve(a.hn),a.an.add(a.hn)),a.fn.addEventListener("updatefound",a.cn),navigator.serviceWorker.addEventListener("controllerchange",a.dn),a.fn})},(i=o())&&i.then?i.then(r):r(i)}catch(e){return Promise.reject(e)}},r.update=function(){try{return this.fn?ah(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 au(this.getSW(),function(n){return aa(n,e)})}catch(e){return Promise.reject(e)}},r.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&aa(this.fn.waiting,am)},r.pn=function(){var e=navigator.serviceWorker.controller;return e&&ap(e.scriptURL,this.sn.toString())?e:void 0},r.bn=function(){try{var e=this;return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return au(navigator.serviceWorker.register(e.sn,e.nn),function(n){return e.un=performance.now(),n})},function(e){throw e})}catch(e){return Promise.reject(e)}},t=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],as(n.prototype,t),o&&as(n,o),n}(function(){function e(){this.Pn=new Map}var n=e.prototype;return n.addEventListener=function(e,n){this.Sn(e).add(n)},n.removeEventListener=function(e,n){this.Sn(e).delete(n)},n.dispatchEvent=function(e){e.target=this;for(var n,t=function(e){var n;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return al(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?al(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(this.Sn(e.type));!(n=t()).done;)(0,n.value)(e)},n.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function a_(e,n){if(void 0!==d)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),d;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new ag(e,n);return d=t.register().then(()=>t.controlling.then(()=>t))}function ay(){return d??Promise.resolve(void 0)}let ab="x-omrs-offline-response-body",av="x-omrs-offline-response-status",a$="x-omrs-offline-caching-strategy";async function aA(e){let n=await ay();return n?await n.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function ak(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(n){if(n.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function ax(){return!window.indexedDB}async function aw(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function aC(){return await aw()||await ax()||await ak()}let aE="openmrs3:offline-mode",aS="unavailable";function az(){return{current:aS,notAvailable:"unavailable"===aS,active:"on"===aS}}function aD(e){"unavailable"!==aS&&"unavailable"!==e&&(localStorage.setItem(aE,"on"===e?"active":"disabled"),aS=e)}async function aP(){await aC()||(aS="active"===localStorage.getItem(aE)?"on":"off"),navigator.onLine}let aM="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,aT=Object.keys,aN=Array.isArray;function aO(e,n){return"object"!=typeof n||aT(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||aM.Promise||(aM.Promise=Promise);let aB=Object.getPrototypeOf,aI={}.hasOwnProperty;function aj(e,n){return aI.call(e,n)}function aR(e,n){"function"==typeof n&&(n=n(aB(e))),("u"<typeof Reflect?aT:Reflect.ownKeys)(n).forEach(t=>{aL(e,t,n[t])})}let aF=Object.defineProperty;function aL(e,n,t,o){aF(e,n,aO(t&&aj(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},o))}function aW(e){return{from:function(n){return e.prototype=Object.create(n.prototype),aL(e.prototype,"constructor",e),{extend:aR.bind(null,e.prototype)}}}}let aV=Object.getOwnPropertyDescriptor;function aG(e,n){let t;return aV(e,n)||(t=aB(e))&&aG(t,n)}let aU=[].slice;function aq(e,n,t){return aU.call(e,n,t)}function aH(e,n){return n(e)}function aK(e){if(!e)throw Error("Assertion Failed")}function aZ(e){aM.setImmediate?setImmediate(e):setTimeout(e,0)}function aY(e,n){return e.reduce((e,t,o)=>{var r=n(t,o);return r&&(e[r[0]]=r[1]),e},{})}function aJ(e,n){if(aj(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],o=0,r=n.length;o<r;++o){var i=aJ(e,n[o]);t.push(i)}return t}var a=n.indexOf(".");if(-1!==a){var s=e[n.substr(0,a)];return void 0===s?void 0:aJ(s,n.substr(a+1))}}function aX(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){aK("string"!=typeof t&&"length"in t);for(var o=0,r=n.length;o<r;++o)aX(e,n[o],t[o])}else{var i=n.indexOf(".");if(-1!==i){var a=n.substr(0,i),s=n.substr(i+1);if(""===s)void 0===t?aN(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=t;else{var l=e[a];l&&aj(e,a)||(l=e[a]={}),aX(l,s,t)}}else void 0===t?aN(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function aQ(e){var n={};for(var t in e)aj(e,t)&&(n[t]=e[t]);return n}let a0=[].concat;function a1(e){return a0.apply([],e)}let a2="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(a1([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>aM[e]),a3=a2.map(e=>aM[e]);aY(a2,e=>[e,!0]);let a5=null;function a4(e){a5="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=a5&&a5.get(n);if(t)return t;if(aN(n)){t=[],a5&&a5.set(n,t);for(var o=0,r=n.length;o<r;++o)t.push(e(n[o]))}else if(a3.indexOf(n.constructor)>=0)t=n;else{let o=aB(n);for(var i in t=o===Object.prototype?{}:Object.create(o),a5&&a5.set(n,t),n)aj(n,i)&&(t[i]=e(n[i]))}return t}(e);return a5=null,n}let{toString:a6}={};function a8(e){return a6.call(e).slice(8,-1)}let a7="u">typeof Symbol?Symbol.iterator:"@@iterator",a9="symbol"==typeof a7?function(e){var n;return null!=e&&(n=e[a7])&&n.apply(e)}:function(){return null},se={};function sn(e){var n,t,o,r;if(1==arguments.length){if(aN(e))return e.slice();if(this===se&&"string"==typeof e)return[e];if(r=a9(e)){for(t=[];!(o=r.next()).done;)t.push(o.value);return t}if(null==e)return[e];if("number"==typeof(n=e.length)){for(t=Array(n);n--;)t[n]=e[n];return t}return[e]}for(n=arguments.length,t=Array(n);n--;)t[n]=arguments[n];return t}let st="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var so="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),sr=()=>!0;let si=!Error("").stack;function sa(){if(si)try{throw sa.arguments,Error()}catch(e){return e}return Error()}function ss(e,n){var t=e.stack;return t?(n=n||0,0===t.indexOf(e.name)&&(n+=(e.name+e.message).split("\n").length),t.split("\n").slice(n).filter(sr).map(e=>"\n"+e).join("")):""}var sl=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],sc=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(sl),sp={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 sd(e,n){this._e=sa(),this.name=e,this.message=n}function su(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function sf(e,n,t,o){this._e=sa(),this.failures=n,this.failedKeys=o,this.successCount=t,this.message=su(e,n)}function sm(e,n){this._e=sa(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=su(e,n)}aW(sd).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+ss(this._e,2))}},toString:function(){return this.name+": "+this.message}}),aW(sf).from(sd),aW(sm).from(sd);var sh=sc.reduce((e,n)=>(e[n]=n+"Error",e),{}),sg=sc.reduce((e,n)=>{var t=n+"Error";function o(e,o){this._e=sa(),this.name=t,e?"string"==typeof e?(this.message=`${e}${o?"\n "+o:""}`,this.inner=o||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=sp[n]||t,this.inner=null)}return aW(o).from(sd),e[n]=o,e},{});sg.Syntax=SyntaxError,sg.Type=TypeError,sg.Range=RangeError;var s_=sl.reduce((e,n)=>(e[n+"Error"]=sg[n],e),{}),sy=sc.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=sg[n]),e),{});function sb(){}function sv(e){return e}function s$(e,n){return null==e||e===sv?n:function(t){return n(e(t))}}function sA(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function sk(e,n){return e===sb?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var o=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?sA(o,this.onsuccess):o),r&&(this.onerror=this.onerror?sA(r,this.onerror):r),void 0!==i?i:t}}function sx(e,n){return e===sb?n:function(){e.apply(this,arguments);var t=this.onsuccess,o=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?sA(t,this.onsuccess):t),o&&(this.onerror=this.onerror?sA(o,this.onerror):o)}}function sw(e,n){return e===sb?n:function(t){var o=e.apply(this,arguments);aO(t,o);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var a=n.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?sA(r,this.onsuccess):r),i&&(this.onerror=this.onerror?sA(i,this.onerror):i),void 0===o?void 0===a?void 0:a:aO(o,a)}}function sC(e,n){return e===sb?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function sE(e,n){return e===sb?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var o=this,r=arguments.length,i=Array(r);r--;)i[r]=arguments[r];return t.then(function(){return n.apply(o,i)})}return n.apply(this,arguments)}}sy.ModifyError=sf,sy.DexieError=sd,sy.BulkError=sm;var sS={};let[sz,sD,sP]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,aB(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,aB(n),e]})(),sM=sD&&sD.then,sT=sz&&sz.constructor,sN=!!sP;var sO=!1,sB=sP?()=>{sP.then(s3)}:aM.setImmediate?setImmediate.bind(null,s3):aM.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{s3(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(s3,0)},sI=function(e,n){sq.push([e,n]),sR&&(sB(),sR=!1)},sj=!0,sR=!0,sF=[],sL=[],sW=null,sV=sv,sG={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lg,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{lg(e[0],e[1])}catch(e){}})}},sU=sG,sq=[],sH=0,sK=[];function sZ(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=sb,this._lib=!1;var n=this._PSD=sU;if(so&&(this._stackHolder=sa(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==sS)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&sX(this,this._value))}this._state=null,this._value=null,++n.ref,function e(n,t){try{t(t=>{if(null===n._state){if(t===n)throw TypeError("A promise cannot be resolved with itself.");var o=n._lib&&s5();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof sZ?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,sQ(n)),o&&s4()}},sX.bind(null,n))}catch(e){sX(n,e)}}(this,e)}let sY={get:function(){var e=sU,n=lo;function t(t,o){var r=!e.global&&(e!==sU||n!==lo);let i=r&&!ls();var a=new sZ((n,a)=>{s0(this,new sJ(lm(t,e,r,i),lm(o,e,r,i),n,a,e))});return so&&s2(a,this),a}return t.prototype=sS,t},set:function(e){aL(this,"then",e&&e.prototype===sS?sY:{get:function(){return e},set:sY.set})}};function sJ(e,n,t,o,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=o,this.psd=r}function sX(e,n){if(sL.push(n),null===e._state){var t=e._lib&&s5();n=sV(n),e._state=!1,e._value=n,so&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=aG(n,"stack");n._promise=e,aL(n,"stack",{get:()=>sO?t&&(t.get?t.get.apply(n):t.value):e.stack})}),sF.some(n=>n._value===e._value)||sF.push(e),sQ(e),t&&s4()}}function sQ(e){var n=e._listeners;e._listeners=[];for(var t=0,o=n.length;t<o;++t)s0(e,n[t]);var r=e._PSD;--r.ref||r.finalize(),0===sH&&(++sH,sI(()=>{0==--sH&&s6()},[]))}function s0(e,n){if(null!==e._state){var t=e._state?n.onFulfilled:n.onRejected;if(null===t)return(e._state?n.resolve:n.reject)(e._value);++n.psd.ref,++sH,sI(s1,[t,e,n])}else e._listeners.push(n)}function s1(e,n,t){try{sW=n;var o,r=n._value;n._state?o=e(r):(sL.length&&(sL=[]),o=e(r),-1===sL.indexOf(r)&&function(e){for(var n=sF.length;n;)if(sF[--n]._value===e._value)return void sF.splice(n,1)}(n)),t.resolve(o)}catch(e){t.reject(e)}finally{sW=null,0==--sH&&s6(),--t.psd.ref||t.psd.finalize()}}function s2(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function s3(){s5()&&s4()}function s5(){var e=sj;return sj=!1,sR=!1,e}function s4(){var e,n,t;do for(;sq.length>0;)for(e=sq,sq=[],t=e.length,n=0;n<t;++n){var o=e[n];o[0].apply(null,o[1])}while(sq.length>0);sj=!0,sR=!0}function s6(){var e=sF;sF=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=sK.slice(0),t=n.length;t;)n[--t]()}function s8(e){return new sZ(sS,!1,e)}function s7(e,n){var t=sU;return function(){var o=s5(),r=sU;try{return ld(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{ld(r,!1),o&&s4()}}}aR(sZ.prototype,{then:sY,_then:function(e,n){s0(this,new sJ(null,null,e,n,sU))},catch:function(e){if(1==arguments.length)return this.then(null,e);var n=arguments[0],t=arguments[1];return"function"==typeof n?this.then(null,e=>e instanceof n?t(e):s8(e)):this.then(null,e=>e&&e.name===n?t(e):s8(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),s8(n)))},stack:{get:function(){if(this._stack)return this._stack;try{sO=!0;var e=(function e(n,t,o){if(t.length===o)return t;var r="";if(!1===n._state){var i,a,s=n._value;null!=s?(i=s.name||"Error",a=s.message||s,r=ss(s,0)):(i=s,a=""),t.push(i+(a?": "+a:"")+r)}return so&&((r=ss(n._stackHolder,2))&&-1===t.indexOf(r)&&t.push(r),n._prev&&e(n._prev,t,o)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{sO=!1}}},timeout:function(e,n){return e<1/0?new sZ((t,o)=>{var r=setTimeout(()=>o(new sg.Timeout(n)),e);this.then(t,o).finally(clearTimeout.bind(null,r))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&aL(sZ.prototype,Symbol.toStringTag,"Dexie.Promise"),sG.env=lu(),aR(sZ,{all:function(){var e=sn.apply(null,arguments).map(ll);return new sZ(function(n,t){0===e.length&&n([]);var o=e.length;e.forEach((r,i)=>sZ.resolve(r).then(t=>{e[i]=t,--o||n(e)},t))})},resolve:e=>{if(e instanceof sZ)return e;if(e&&"function"==typeof e.then)return new sZ((n,t)=>{e.then(n,t)});var n=new sZ(sS,!0,e);return s2(n,sW),n},reject:s8,race:function(){var e=sn.apply(null,arguments).map(ll);return new sZ((n,t)=>{e.map(e=>sZ.resolve(e).then(n,t))})},PSD:{get:()=>sU,set:e=>sU=e},totalEchoes:{get:()=>lo},newPSD:li,usePSD:lf,scheduler:{get:()=>sI,set:e=>{sI=e}},rejectionMapper:{get:()=>sV,set:e=>{sV=e}},follow:(e,n)=>new sZ((t,o)=>li((n,t)=>{var o=sU;o.unhandleds=[],o.onunhandled=t,o.finalize=sA(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},sK.push(function n(){e(),sK.splice(sK.indexOf(n),1)}),++sH,sI(()=>{0==--sH&&s6()},[])},o.finalize),e()},n,t,o))}),sT&&(sT.allSettled&&aL(sZ,"allSettled",function(){let e=sn.apply(null,arguments).map(ll);return new sZ(n=>{0===e.length&&n([]);let t=e.length,o=Array(t);e.forEach((e,r)=>sZ.resolve(e).then(e=>o[r]={status:"fulfilled",value:e},e=>o[r]={status:"rejected",reason:e}).then(()=>--t||n(o)))})}),sT.any&&"u">typeof AggregateError&&aL(sZ,"any",function(){let e=sn.apply(null,arguments).map(ll);return new sZ((n,t)=>{0===e.length&&t(AggregateError([]));let o=e.length,r=Array(o);e.forEach((e,i)=>sZ.resolve(e).then(e=>n(e),e=>{r[i]=e,--o||t(AggregateError(r))}))})}));let s9={awaits:0,echoes:0,id:0};var le=0,ln=[],lt=0,lo=0,lr=0;function li(e,n,t,o){var r=sU,i=Object.create(r);i.parent=r,i.ref=0,i.global=!1,i.id=++lr;var a=sG.env;i.env=sN?{Promise:sZ,PromiseProp:{value:sZ,configurable:!0,writable:!0},all:sZ.all,race:sZ.race,allSettled:sZ.allSettled,any:sZ.any,resolve:sZ.resolve,reject:sZ.reject,nthen:lh(a.nthen,i),gthen:lh(a.gthen,i)}:{},n&&aO(i,n),++r.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=lf(i,e,t,o);return 0===i.ref&&i.finalize(),s}function la(){return s9.id||(s9.id=++le),++s9.awaits,s9.echoes+=100,s9.id}function ls(){return!!s9.awaits&&(0==--s9.awaits&&(s9.id=0),s9.echoes=100*s9.awaits,!0)}function ll(e){return s9.echoes&&e&&e.constructor===sT?(la(),e.then(e=>(ls(),e),e=>(ls(),l_(e)))):e}function lc(e){++lo,s9.echoes&&0!=--s9.echoes||(s9.echoes=s9.id=0),ln.push(sU),ld(e,!0)}function lp(){var e=ln[ln.length-1];ln.pop(),ld(e,!1)}function ld(e,n){var t,o=sU;if((n?!s9.echoes||lt++&&e===sU:!lt||--lt&&e===sU)||(t=n?lc.bind(null,e):lp,sM.call(sz,t)),e!==sU&&(sU=e,o===sG&&(sG.env=lu()),sN)){var r=sG.env.Promise,i=e.env;sD.then=i.nthen,r.prototype.then=i.gthen,(o.global||e.global)&&(Object.defineProperty(aM,"Promise",i.PromiseProp),r.all=i.all,r.race=i.race,r.resolve=i.resolve,r.reject=i.reject,i.allSettled&&(r.allSettled=i.allSettled),i.any&&(r.any=i.any))}}function lu(){var e=aM.Promise;return sN?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(aM,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:sD.then,gthen:e.prototype.then}:{}}function lf(e,n,t,o,r){var i=sU;try{return ld(e,!0),n(t,o,r)}finally{ld(i,!1)}}function lm(e,n,t,o){return"function"!=typeof e?e:function(){var r,i=sU;t&&la(),ld(n,!0);try{return e.apply(this,arguments)}finally{ld(i,!1),o&&(r=ls,sM.call(sz,r))}}}function lh(e,n){return function(t,o){return e.call(this,lm(t,n),lm(o,n))}}function lg(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var o,r={promise:n,reason:e};if(aM.document&&document.createEvent?((o=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),aO(o,r)):aM.CustomEvent&&aO(o=new CustomEvent("unhandledrejection",{detail:r}),r),o&&aM.dispatchEvent&&(dispatchEvent(o),!aM.PromiseRejectionEvent&&aM.onunhandledrejection))try{aM.onunhandledrejection(o)}catch(e){}so&&o&&!o.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+sM).indexOf("[native code]")&&(la=ls=sb);var l_=sZ.reject;let ly=String.fromCharCode(65535),lb="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lv=[],l$="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lA=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function lk(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let lx={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lw(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=a4(n))[e],n)}class lC{_trans(e,n,t){let o=this._tx||sU.trans,r=this.name;function i(e,t,o){if(!o.schema[r])throw new sg.NotFound("Table "+r+" not part of transaction");return n(o.idbtrans,o)}let a=s5();try{return o&&o.db===this.db?o===sU.trans?o._promise(e,i,t):li(()=>o._promise(e,i,t),{trans:o,transless:sU.transless||sU}):function e(n,t,o,r){if(n.idbdb&&(n._state.openComplete||sU.letThrough||n._vip)){var i=n._createTransaction(t,o,n._dbSchema);try{i.create(),n._state.PR1398_maxLoop=3}catch(i){return i.name===sh.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,o,r))):l_(i)}return i._promise(t,(e,n)=>li(()=>(sU.trans=i,r(e,n,i)))).then(e=>i._completion.then(()=>e))}if(n._state.openComplete)return l_(new sg.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return l_(new sg.DatabaseClosed);n.open().catch(sb)}return n._state.dbReadyPromise.then(()=>e(n,t,o,r))}(this.db,e,[this.name],i)}finally{a&&s4()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(e=>this.hook.reading.fire(e))).then(n)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(aN(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=aT(e);if(1===n.length)return this.where(n[0]).equals(e[n[0]]);let t=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)&&e.keyPath.every(e=>n.indexOf(e)>=0))[0];if(t&&this.db._maxKey!==ly)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&so&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:o}=this.schema,r=this.db._deps.indexedDB;function i(e,n){try{return 0===r.cmp(e,n)}catch(e){return!1}}let[a,s]=n.reduce(([n,t],r)=>{let a=o[r],s=e[r];return[n||a,n||!a?lk(t,a&&a.multi?e=>{let n=aJ(e,r);return aN(n)&&n.some(e=>i(s,e))}:e=>i(s,aJ(e,r))):t]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):t?this.filter(s):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,aN(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let n=n=>{if(!n)return n;let t=Object.create(e.prototype);for(var o in n)if(aj(n,o))try{t[o]=n[o]}catch(e){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){aO(this,e)})}add(e,n){let{auto:t,keyPath:o}=this.schema.primKey,r=e;return o&&t&&(r=lw(o)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[r]})).then(e=>e.numFailures?sZ.reject(e.failures[0]):e.lastResult).then(n=>{if(o)try{aX(e,o,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||aN(e))return this.where(":id").equals(e).modify(n);{let t=aJ(e,this.schema.primKey.keyPath);if(void 0===t)return l_(new sg.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?aT(n).forEach(t=>{aX(e,t,n[t])}):n(e,{value:e,primKey:t})}catch(e){}return this.where(":id").equals(t).modify(n)}}put(e,n){let{auto:t,keyPath:o}=this.schema.primKey,r=e;return o&&t&&(r=lw(o)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[r],keys:null!=n?[n]:null})).then(e=>e.numFailures?sZ.reject(e.failures[0]):e.lastResult).then(n=>{if(o)try{aX(e,o,n)}catch(e){}return n})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(e=>e.numFailures?sZ.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:lx})).then(e=>e.numFailures?sZ.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,n,t){let o=Array.isArray(n)?n:void 0,r=(t=t||(o?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:i}=this.schema.primKey;if(i&&o)throw new sg.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new sg.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&t?e.map(lw(i)):e;return this.core.mutate({trans:n,type:"add",keys:o,values:s,wantResults:r}).then(({numFailures:e,results:n,lastResult:t,failures:o})=>{if(0===e)return r?n:t;throw new sm(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,o)})})}bulkPut(e,n,t){let o=Array.isArray(n)?n:void 0,r=(t=t||(o?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:i}=this.schema.primKey;if(i&&o)throw new sg.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new sg.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&t?e.map(lw(i)):e;return this.core.mutate({trans:n,type:"put",keys:o,values:s,wantResults:r}).then(({numFailures:e,results:n,lastResult:t,failures:o})=>{if(0===e)return r?n:t;throw new sm(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,o)})})}bulkDelete(e){let n=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:e,lastResult:t,failures:o})=>{if(0===e)return t;throw new sm(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,o)})}}function lE(e){var n={},t=function(t,o){if(o){for(var r=arguments.length,i=Array(r-1);--r;)i[r-1]=arguments[r];return n[t].subscribe.apply(null,i),e}if("string"==typeof t)return n[t]};t.addEventType=i;for(var o=1,r=arguments.length;o<r;++o)i(arguments[o]);return t;function i(e,o,r){if("object"==typeof e){var a;return void aT(a=e).forEach(function(e){var n=a[e];if(aN(n))i(e,a[e][0],a[e][1]);else{if("asap"!==n)throw new sg.InvalidArgument("Invalid event config");var t=i(e,sv,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];t.subscribers.forEach(function(e){aZ(function(){e.apply(null,n)})})})}})}o||(o=sC),r||(r=sb);var s={subscribers:[],fire:r,subscribe:function(e){-1===s.subscribers.indexOf(e)&&(s.subscribers.push(e),s.fire=o(s.fire,e))},unsubscribe:function(e){s.subscribers=s.subscribers.filter(function(n){return n!==e}),s.fire=s.subscribers.reduce(o,r)}};return n[e]=t[e]=s,s}}function lS(e,n){return aW(n).from({prototype:e}),n}function lz(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function lD(e,n){e.filter=lk(e.filter,n)}function lP(e,n,t){var o=e.replayFilter;e.replayFilter=o?()=>lk(o(),n()):n,e.justLimit=t&&!o}function lM(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new sg.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function lT(e,n,t){let o=lM(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:o,range:e.range}})}function lN(e,n,t,o){let r=e.replayFilter?lk(e.filter,e.replayFilter()):e.filter;if(e.or){let i={},a=(e,t,o)=>{if(!r||r(t,o,e=>t.stop(e),e=>t.fail(e))){var a=t.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),aj(i,s)||(i[s]=!0,n(e,t,o))}};return Promise.all([e.or._iterate(a,t),lO(lT(e,o,t),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return lO(lT(e,o,t),lk(e.algorithm,r),n,!e.keysOnly&&e.valueMapper)}function lO(e,n,t,o){var r=s7(o?(e,n,r)=>t(o(e),n,r):t);return e.then(e=>{if(e)return e.start(()=>{var t=()=>e.continue();n&&!n(e,e=>t=e,n=>{e.stop(n),t=sb},n=>{e.fail(n),t=sb})||r(e.value,e,e=>t=e),t()})})}function lB(e,n){try{let t=lI(e),o=lI(n);if(t!==o)return"Array"===t?1:"Array"===o?-1:"binary"===t?1:"binary"===o?-1:"string"===t?1:"string"===o?-1:"Date"===t?1:"Date"!==o?NaN:-1;switch(t){case"number":case"Date":case"string":return e>n?1:e<n?-1:0;case"binary":return function(e,n){let t=e.length,o=n.length,r=t<o?t:o;for(let t=0;t<r;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===o?0:t<o?-1:1}(lj(e),lj(n));case"Array":return function(e,n){let t=e.length,o=n.length,r=t<o?t:o;for(let t=0;t<r;++t){let o=lB(e[t],n[t]);if(0!==o)return o}return t===o?0:t<o?-1:1}(e,n)}}catch(e){}return NaN}function lI(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=a8(e);return"ArrayBuffer"===t?"binary":t}function lj(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class lR{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,l_.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,l_.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=lk(n.algorithm,e)}_iterate(e,n){return lN(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&aO(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>lN(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(lz(n,!0))return t.count({trans:e,query:{index:lM(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var o=0;return lN(n,()=>(++o,!1),e,t).then(()=>o)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),o=t[0],r=t.length-1;function i(e,n){return n?i(e[t[n]],n-1):e[o]}var a="next"===this._ctx.dir?1:-1;function s(e,n){var t=i(e,r),o=i(n,r);return t<o?-a:t>o?a:0}return this.toArray(function(e){return e.sort(s)}).then(n)}toArray(e){return this._read(e=>{var n=this._ctx;if("next"===n.dir&&lz(n,!0)&&n.limit>0){let{valueMapper:t}=n,o=lM(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:o,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return lN(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,lz(n)?lP(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):lP(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),lP(this._ctx,()=>{var n=e;return function(e,t,o){return--n<=0&&t(o),n>=0}},!0),this}until(e,n){return lD(this._ctx,function(t,o,r){return!e(t.value)||(o(r),n)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n;return lD(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=lk(n.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.key,t)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.primaryKey,t)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.key)}).then(function(){return t}).then(e)}primaryKeys(e){var n=this._ctx;if("next"===n.dir&&lz(n,!0)&&n.limit>0)return this._read(e=>{var t=lM(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(({result:e})=>e).then(e);n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.primaryKey)}).then(function(){return t}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var t={};return lD(this._ctx,function(e){var n=e.primaryKey.toString(),o=aj(t,n);return t[n]=!0,!o}),this}modify(e){var n=this._ctx;return this._write(t=>{var o;if("function"==typeof e)o=e;else{var r=aT(e),i=r.length;o=function(n){for(var t=!1,o=0;o<i;++o){var a=r[o],s=e[a];aJ(n,a)!==s&&(aX(n,a,s),t=!0)}return t}}let a=n.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,c=this.db._options.modifyChunkSize||200,p=[],d=0,u=[],f=(e,n)=>{let{failures:t,numFailures:o}=n;for(let n of(d+=e-o,aT(t)))p.push(t[n])};return this.clone().primaryKeys().then(r=>{let i=p=>{let d=Math.min(c,r.length-p);return a.getMany({trans:t,keys:r.slice(p,p+d),cache:"immutable"}).then(u=>{let m=[],h=[],g=s?[]:null,y=[];for(let e=0;e<d;++e){let n=u[e],t={value:a4(n),primKey:r[p+e]};!1!==o.call(t,t.value,t)&&(null==t.value?y.push(r[p+e]):s||0===lB(l(n),l(t.value))?(h.push(t.value),s&&g.push(r[p+e])):(y.push(r[p+e]),m.push(t.value)))}let b=lz(n)&&n.limit===1/0&&("function"!=typeof e||e===lF)&&{index:n.index,range:n.range};return Promise.resolve(m.length>0&&a.mutate({trans:t,type:"add",values:m}).then(e=>{for(let n in e.failures)y.splice(parseInt(n),1);f(m.length,e)})).then(()=>(h.length>0||b&&"object"==typeof e)&&a.mutate({trans:t,type:"put",keys:g,values:h,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(h.length,e))).then(()=>(y.length>0||b&&e===lF)&&a.mutate({trans:t,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>r.length>p+d&&i(p+c))})};return i(0).then(()=>{if(p.length>0)throw new sf("Error modifying one or more objects",p,d,u);return r.length})})})}delete(){var e=this._ctx,n=e.range;return lz(e)&&(e.isPrimKey&&!l$||3===n.type)?this._write(t=>{let{primaryKey:o}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:o,range:n}}).then(o=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:r})=>{if(r)throw new sf("Could not delete some values",Object.keys(e).map(n=>e[n]),o-r);return o-r}))}):this.modify(lF)}}let lF=(e,n)=>n.value=null;function lL(e,n){return e<n?-1:+(e!==n)}function lW(e,n){return e>n?-1:+(e!==n)}function lV(e,n,t){var o=e instanceof lK?new e.Collection(e):e;return o._ctx.error=t?new t(n):TypeError(n),o}function lG(e){return new e.Collection(e,()=>lH("")).limit(0)}function lU(e,n,t,o){var r,i,a,s,l,c,p,d=t.length;if(!t.every(e=>"string"==typeof e))return lV(e,"String expected.");function u(e){r="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),i="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?lL:lW;var n=t.map(function(e){return{lower:i(e),upper:r(e)}}).sort(function(e,n){return a(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,p="next"===e?"":o}u("next");var f=new e.Collection(e,()=>lq(s[0],l[d-1]+o));f._ondirectionchange=function(e){u(e)};var m=0;return f._addAlgorithm(function(e,t,o){var r=e.key;if("string"!=typeof r)return!1;var u=i(r);if(n(u,l,m))return!0;for(var f=null,h=m;h<d;++h){var g=function(e,n,t,o,r,i){for(var a=Math.min(e.length,o.length),s=-1,l=0;l<a;++l){var c=n[l];if(c!==o[l])return 0>r(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>r(e[l],o[l])?e.substr(0,l)+o[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>r(e[l],c)&&(s=l)}return a<o.length&&"next"===i?e+t.substr(e.length):a<e.length&&"prev"===i?e.substr(0,t.length):s<0?null:e.substr(0,s)+o[s]+t.substr(s+1)}(r,u,s[h],l[h],a,c);null===g&&null===f?m=h+1:(null===f||a(f,g)>0)&&(f=g)}return t(null!==f?function(){e.continue(f+p)}:o),!1}),f}function lq(e,n,t,o){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:o}}function lH(e){return{type:1,lower:e,upper:e}}class lK{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,o){t=!1!==t,o=!0===o;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||o)&&(!t||!o)?lG(this):new this.Collection(this,()=>lq(e,n,!t,!o))}catch(e){return lV(this,lb)}}equals(e){return null==e?lV(this,lb):new this.Collection(this,()=>lH(e))}above(e){return null==e?lV(this,lb):new this.Collection(this,()=>lq(e,void 0,!0))}aboveOrEqual(e){return null==e?lV(this,lb):new this.Collection(this,()=>lq(e,void 0,!1))}below(e){return null==e?lV(this,lb):new this.Collection(this,()=>lq(void 0,e,!1,!0))}belowOrEqual(e){return null==e?lV(this,lb):new this.Collection(this,()=>lq(void 0,e))}startsWith(e){return"string"!=typeof e?lV(this,"String expected."):this.between(e,e+ly,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):lU(this,(e,n)=>0===e.indexOf(n[0]),[e],ly)}equalsIgnoreCase(e){return lU(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=sn.apply(se,arguments);return 0===e.length?lG(this):lU(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=sn.apply(se,arguments);return 0===e.length?lG(this):lU(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,ly)}anyOf(){let e=sn.apply(se,arguments),n=this._cmp;try{e.sort(n)}catch(e){return lV(this,lb)}if(0===e.length)return lG(this);let t=new this.Collection(this,()=>lq(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let o=0;return t._addAlgorithm((t,r,i)=>{let a=t.key;for(;n(a,e[o])>0;)if(++o===e.length)return r(i),!1;return 0===n(a,e[o])||(r(()=>{t.continue(e[o])}),!1)}),t}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=sn.apply(se,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return lV(this,lb)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[-1/0,n]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){let t=this._cmp,o=this._ascending,r=this._descending,i=this._min,a=this._max;if(0===e.length)return lG(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=o(e[0],e[1])))return lV(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",sg.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,p=o;function d(e,n){return p(e[0],n[0])}try{(c=e.reduce(function(e,n){let o=0,r=e.length;for(;o<r;++o){let r=e[o];if(0>t(n[0],r[1])&&t(n[1],r[0])>0){r[0]=i(r[0],n[0]),r[1]=a(r[1],n[1]);break}}return o===r&&e.push(n),e},[])).sort(d)}catch(e){return lV(this,lb)}let u=0,f=l?e=>o(e,c[u][1])>0:e=>o(e,c[u][1])>=0,m=s?e=>r(e,c[u][0])>0:e=>r(e,c[u][0])>=0,h=f,g=new this.Collection(this,()=>lq(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(h=f,p=o):(h=m,p=r),c.sort(d)},g._addAlgorithm((e,n,t)=>{for(var r=e.key;h(r);)if(++u===c.length)return n(t),!1;return!!(!f(r)&&!m(r))||(0===this._cmp(r,c[u][1])||0===this._cmp(r,c[u][0])||n(()=>{p===o?e.continue(c[u][0]):e.continue(c[u][1])}),!1)}),g}startsWithAnyOf(){let e=sn.apply(se,arguments);return e.every(e=>"string"==typeof e)?0===e.length?lG(this):this.inAnyRange(e.map(e=>[e,e+ly])):lV(this,"startsWithAnyOf() only works with strings")}}function lZ(e){return s7(function(n){return lY(n),e(n.target.error),!1})}function lY(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let lJ=lE(null,"storagemutated");class lX{_lock(){return aK(!sU.global),++this._reculock,1!==this._reculock||sU.global||(sU.lockOwnerFor=this),this}_unlock(){if(aK(!sU.global),0==--this._reculock)for(sU.global||(sU.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{lf(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&sU.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(aK(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new sg.DatabaseClosed(t);case"MissingAPIError":throw new sg.MissingAPI(t.message,t);default:throw new sg.OpenFailed(t)}if(!this.active)throw new sg.TransactionInactive;return aK(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=s7(n=>{lY(n),this._reject(e.error)}),e.onabort=s7(n=>{lY(n),this.active&&this._reject(new sg.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=s7(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&lJ.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return l_(new sg.ReadOnly("Transaction is readonly"));if(!this.active)return l_(new sg.TransactionInactive);if(this._locked())return new sZ((o,r)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(o,r)},sU])});if(t)return li(()=>{var e=new sZ((e,t)=>{this._lock();let o=n(e,t,this);o&&o.then&&o.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var o=new sZ((e,t)=>{var o=n(e,t,this);o&&o.then&&o.then(e,t)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=sZ.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var o=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=e)}()}var r=n._waitingFor;return new sZ((e,o)=>{t.then(t=>n._waitingQueue.push(s7(e.bind(null,t))),e=>n._waitingQueue.push(s7(o.bind(null,e)))).finally(()=>{n._waitingFor===r&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sg.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(aj(n,e))return n[e];let t=this.schema[e];if(!t)throw new sg.NotFound("Table "+e+" not part of transaction");let o=new this.db.Table(e,t,this);return o.core=this.db.core.table(e),n[e]=o,o}}function lQ(e,n,t,o,r,i,a){return{name:e,keyPath:n,unique:t,multi:o,auto:r,compound:i,src:(t&&!a?"&":"")+(o?"*":"")+(r?"++":"")+l0(n)}}function l0(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function l1(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:aY(t,e=>[e.name,e])}}let l2=e=>{try{return e.only([[]]),l2=()=>[[]],[[]]}catch(e){return l2=()=>ly,ly}};function l3(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>aJ(n,e):n=>aJ(n,e)}function l5(e){return[].slice.call(e)}let l4=0;function l6(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function l8({_novip:e},n){let t=n.db,o=function(e,n,{IDBKeyRange:t,indexedDB:o},r){var i;return{dbcore:(i=function(e,n,t){let o;function r(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:o,lowerOpen:r,upperOpen:i}=e;return void 0===t?void 0===o?null:n.upperBound(o,!!i):void 0===o?n.lowerBound(t,!!r):n.bound(t,o,!!r,!!i)}let{schema:i,hasGetAll:a}=(o=l5(e.objectStoreNames),{schema:{name:e.name,tables:o.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,o=aN(n),r=null==n,i={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:r,compound:o,keyPath:n,autoIncrement:t,unique:!0,extractKey:l3(n)},indexes:l5(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:o,keyPath:r}=e,a={name:n,compound:aN(r),keyPath:r,unique:t,multiEntry:o,extractKey:l3(r)};return i[l6(r)]=a,a}),getIndexByKeyPath:e=>i[l6(e)]};return i[":id"]=a.primaryKey,null!=n&&(i[l6(n)]=a.primaryKey),a})},hasGetAll:o.length>0&&"getAll"in t.objectStore(o[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=i.tables.map(e=>{let n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:o,values:i,range:a}){return new Promise((s,l)=>{let c;s=s7(s);let p=e.objectStore(n),d=null==p.keyPath,u="put"===t||"add"===t;if(!u&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=o||i||{length:1};if(o&&i&&o.length!==i.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 m=[],h=[],g=0,y=e=>{++g,lY(e)};if("deleteRange"===t){if(4===a.type)return s({numFailures:g,failures:h,results:[],lastResult:void 0});3===a.type?m.push(c=p.clear()):m.push(c=p.delete(r(a)))}else{let[e,n]=u?d?[i,o]:[i,null]:[o,null];if(u)for(let o=0;o<f;++o)m.push(c=n&&void 0!==n[o]?p[t](e[o],n[o]):p[t](e[o])),c.onerror=y;else for(let n=0;n<f;++n)m.push(c=p[t](e[n])),c.onerror=y}let b=e=>{let n=e.target.result;m.forEach((e,n)=>null!=e.error&&(h[n]=e.error)),s({numFailures:g,failures:h,results:"delete"===t?o:m.map(e=>e.result),lastResult:n})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:t})=>new Promise((o,r)=>{o=s7(o);let i=e.objectStore(n),a=t.length,s=Array(a),l,c=0,p=0,d=e=>{let n=e.target;s[n._pos]=n.result,++p===c&&o(s)},u=lZ(r);for(let e=0;e<a;++e)null!=t[e]&&((l=i.get(t[e]))._pos=e,l.onsuccess=d,l.onerror=u,++c);0===c&&o(s)}),get:({trans:e,key:t})=>new Promise((o,r)=>{o=s7(o);let i=e.objectStore(n).get(t);i.onsuccess=e=>o(e.target.result),i.onerror=lZ(r)}),query:e=>new Promise((t,o)=>{t=s7(t);let{trans:i,values:s,limit:l,query:c}=e,p=l===1/0?void 0:l,{index:d,range:u}=c,f=i.objectStore(n),m=d.isPrimaryKey?f:f.index(d.name),h=r(u);if(0===l)return t({result:[]});if(a){let e=s?m.getAll(h,p):m.getAllKeys(h,p);e.onsuccess=e=>t({result:e.target.result}),e.onerror=lZ(o)}else{let e=0,n=!s&&"openKeyCursor"in m?m.openKeyCursor(h):m.openCursor(h),r=[];n.onsuccess=o=>{let i=n.result;return i?(r.push(s?i.value:i.primaryKey),++e===l?t({result:r}):void i.continue()):t({result:r})},n.onerror=lZ(o)}}),openCursor:function({trans:e,values:t,query:o,reverse:i,unique:a}){return new Promise((s,l)=>{s=s7(s);let{index:c,range:p}=o,d=e.objectStore(n),u=c.isPrimaryKey?d:d.index(c.name),f=i?a?"prevunique":"prev":a?"nextunique":"next",m=!t&&"openKeyCursor"in u?u.openKeyCursor(r(p),f):u.openCursor(r(p),f);m.onerror=lZ(l),m.onsuccess=s7(n=>{let t=m.result;if(!t)return void s(null);t.___id=++l4,t.done=!1;let o=t.continue.bind(t),r=t.continuePrimaryKey;r&&(r=r.bind(t));let i=t.advance.bind(t),a=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=s7(l),t.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},t.start=e=>{let n=new Promise((e,n)=>{e=s7(e),m.onerror=lZ(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=a,e(n)}}),s=()=>{if(m.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return m.onsuccess=s7(e=>{m.onsuccess=s,s()}),t.continue=o,t.continuePrimaryKey=r,t.advance=i,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:o,range:i}=e;return new Promise((e,a)=>{let s=t.objectStore(n),l=o.isPrimaryKey?s:s.index(o.name),c=r(i),p=c?l.count(c):l.count();p.onsuccess=s7(n=>e(n.target.result)),p.onerror=lZ(a)})}}}),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:l2(n),schema:i}}(n,t,r),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),i))}}(e._middlewares,t,e._deps,n);e.core=o.dbcore,e.tables.forEach(n=>{let t=n.name;e.core.schema.tables.some(e=>e.name===t)&&(n.core=e.core.table(t),e[t]instanceof e.Table&&(e[t].core=n.core))})}function l7({_novip:e},n,t,o){t.forEach(t=>{let r=o[t];n.forEach(n=>{let o=aG(n,t);(!o||"value"in o&&void 0===o.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?aL(n,t,{get(){return this.table(t)},set(e){aF(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,r))})})}function l9({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function ce(e,n){return e._cfg.version-n._cfg.version}function cn(e,n){let t,o={del:[],add:[],change:[]};for(t in e)n[t]||o.del.push(t);for(t in n){let r=e[t],i=n[t];if(r){let e={name:t,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(r.primKey.keyPath||"")==""+(i.primKey.keyPath||"")&&(r.primKey.auto===i.primKey.auto||l$)){let n,t=r.idxByName,a=i.idxByName;for(n in t)a[n]||e.del.push(n);for(n in a){let o=t[n],r=a[n];o?o.src!==r.src&&e.change.push(r):e.add.push(r)}(e.del.length>0||e.add.length>0||e.change.length>0)&&o.change.push(e)}else e.recreate=!0,o.change.push(e)}else o.add.push([t,i])}return o}function ct(e,n,t,o){let r=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return o.forEach(e=>co(r,e)),r}function co(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function cr(e,n,t){let o={};return aq(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),r=n.keyPath,i=lQ(l0(r),r||"",!1,!1,!!n.autoIncrement,r&&"string"!=typeof r,!0),a=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);r=t.keyPath;var s=lQ(t.name,r,!!t.unique,!!t.multiEntry,!1,r&&"string"!=typeof r,!1);a.push(s)}o[e]=l1(e,i,a)}),o}function ci({_novip:e},n,t){let o=t.db.objectStoreNames;for(let r=0;r<o.length;++r){let i=o[r],a=t.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let t=a.indexNames[e],o=a.index(t).keyPath,r="string"==typeof o?o:"["+aq(o).join("+")+"]";if(n[i]){let e=n[i].idxByName[r];e&&(e.name=t,delete n[i].idxByName[r],n[i].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&aM.WorkerGlobalScope&&aM instanceof aM.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class ca{_parseStoresSpec(e,n){aT(e).forEach(t=>{if(null!==e[t]){var o=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),o=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return lQ(t,o||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),aN(o),0===n)}),r=o.shift();if(r.multi)throw new sg.Schema("Primary key cannot be multi-valued");o.forEach(e=>{if(e.auto)throw new sg.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new sg.Schema("Index must have a name and cannot be an empty string")}),n[t]=l1(t,r,o)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?aO(this._cfg.storesSource,e):e;let t=n._versions,o={},r={};return t.forEach(e=>{aO(o,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(o,r)}),n._dbSchema=r,l9(n,[n._allTables,n,n.Transaction.prototype]),l7(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],aT(r),r),n._storeNames=aT(r),this}upgrade(e){return this._cfg.contentUpgrade=sE(this._cfg.contentUpgrade||sb,e),this}}function cs(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new cC("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function cl(e){return e&&"function"==typeof e.databases}function cc(e){return li(function(){return sU.letThrough=!0,e()})}function cp(e){var n=n=>e.next(n),t=r(n),o=r(n=>e.throw(n));function r(e){return n=>{var r=e(n),i=r.value;return r.done?i:i&&"function"==typeof i.then?i.then(t,o):aN(i)?Promise.all(i).then(t,o):t(i)}}return r(n)()}function cd(e,n,t){var o=arguments.length;if(o<2)throw new sg.InvalidArgument("Too few arguments");for(var r=Array(o-1);--o;)r[o-1]=arguments[o];return t=r.pop(),[e,a1(r),t]}function cu(e,n,t){let o=aN(e)?e.slice():[e];for(let e=0;e<t;++e)o.push(n);return o}let cf={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:o}=t,r={},i=[];function a(e,n,t){let o=l6(e),s=r[o]=r[o]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,p={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:l3(e),unique:!c&&t.unique};return s.push(p),p.isPrimaryKey||i.push(p),l>1&&a(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),p}let s=a(o.primaryKey.keyPath,0,o.primaryKey);for(let e of(r[":id"]=[s],o.indexes))a(e.keyPath,0,e);function l(n){var t,o;let r=n.query.index;return r.isVirtual?{...n,query:{index:r,range:(t=n.query.range,o=r.keyTail,{type:1===t.type?2:t.type,lower:cu(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,o),lowerOpen:!0,upper:cu(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,o),upperOpen:!0})}}:n}return{...t,schema:{...o,primaryKey:s,indexes:i,getIndexByKeyPath:function(e){let n=r[l6(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:o,isVirtual:r,keyLength:i}=n.query.index;return r?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(r){null!=r?t.continue(cu(r,n.reverse?e.MAX_KEY:e.MIN_KEY,o)):n.unique?t.continue(t.key.slice(0,i).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,o)):t.continue()}},continuePrimaryKey:{value(n,r){t.continuePrimaryKey(cu(n,e.MAX_KEY,o),r)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function cm(e,n,t,o){return t=t||{},o=o||"",aT(e).forEach(r=>{if(aj(n,r)){var i=e[r],a=n[r];if("object"==typeof i&&"object"==typeof a&&i&&a){let e=a8(i);e!==a8(a)?t[o+r]=n[r]:"Object"===e?cm(i,a,t,o+r+"."):i!==a&&(t[o+r]=n[r])}else i!==a&&(t[o+r]=n[r])}else t[o+r]=void 0}),aT(n).forEach(r=>{aj(e,r)||(t[o+r]=n[r])}),t}let ch={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:o}=t.schema;return{...t,mutate(e){let r=sU.trans,{deleting:i,creating:a,updating:s}=r.table(n).hook;switch(e.type){case"add":if(a.fire===sb)break;return r._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===sb&&s.fire===sb)break;return r._promise("readwrite",()=>l(e),!0);case"delete":if(i.fire===sb)break;return r._promise("readwrite",()=>l(e),!0);case"deleteRange":if(i.fire===sb)break;return r._promise("readwrite",()=>(function e(n,r,i){return t.query({trans:n,values:!1,query:{index:o,range:r},limit:i}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(o=>o.numFailures>0?Promise.reject(o.failures[0]):t.length<i?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...r,lower:t[t.length-1],lowerOpen:!0},i)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,r;let l=sU.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(o.extractKey));if(!c)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:c}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(r=e).type?Promise.resolve([]):t.getMany({trans:r.trans,keys:c,cache:"immutable"})).then(n=>{let r=c.map((t,r)=>{let c=n[r],p={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(p,t,c,l);else if("add"===e.type||void 0===c){let n=a.fire.call(p,t,e.values[r],l);null==t&&null!=n&&(t=n,e.keys[r]=t,o.outbound||aX(e.values[r],o.keyPath,t))}else{let n=cm(c,e.values[r]),o=s.fire.call(p,n,t,c,l);if(o){let n=e.values[r];Object.keys(o).forEach(e=>{aj(n,e)?n[e]=o[e]:aX(n,e,o[e])})}}return p});return t.mutate(e).then(({failures:t,results:o,numFailures:i,lastResult:a})=>{for(let i=0;i<c.length;++i){let a=o?o[i]:c[i],s=r[i];null==a?s.onerror&&s.onerror(t[i]):s.onsuccess&&s.onsuccess("put"===e.type&&n[i]?e.values[i]:a)}return{failures:t,results:o,numFailures:i,lastResult:a}}).catch(e=>(r.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function cg(e,n,t){try{if(!n||n.keys.length<e.length)return null;let o=[];for(let r=0,i=0;r<n.keys.length&&i<e.length;++r)0===lB(n.keys[r],e[i])&&(o.push(t?a4(n.values[r]):n.values[r]),++i);return o.length===e.length?o:null}catch(e){return null}}let c_={stack:"dbcore",level:-1,create:e=>({table:n=>{let t=e.table(n);return{...t,getMany:e=>{if(!e.cache)return t.getMany(e);let n=cg(e.keys,e.trans._cache,"clone"===e.cache);return n?sZ.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?a4(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function cy(e){return!("from"in e)}let cb=function(e,n){if(!this){let n=new cb;return e&&"d"in e&&aO(n,e),n}aO(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function cv(e,n,t){let o=lB(n,t);if(isNaN(o))return;if(o>0)throw RangeError();if(cy(e))return aO(e,{from:n,to:t,d:1});let r=e.l,i=e.r;if(0>lB(t,e.from))return r?cv(r,n,t):e.l={from:n,to:t,d:1,l:null,r:null},ck(e);if(lB(n,e.to)>0)return i?cv(i,n,t):e.r={from:n,to:t,d:1,l:null,r:null},ck(e);0>lB(n,e.from)&&(e.from=n,e.l=null,e.d=i?i.d+1:1),lB(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;r&&!e.l&&c$(e,r),i&&a&&c$(e,i)}function c$(e,n){cy(n)||function e(n,{from:t,to:o,l:r,r:i}){cv(n,t,o),r&&e(n,r),i&&e(n,i)}(e,n)}function cA(e){let n=cy(e)?null:{s:0,n:e};return{next(e){let t=arguments.length>0;for(;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&0>lB(e,n.n.from);)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||0>=lB(e,n.n.to))return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function ck(e){var n,t;let o=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),r=o>1?"r":o<-1?"l":"";if(r){let n="r"===r?"l":"r",t={...e},o=e[r];e.from=o.from,e.to=o.to,e[r]=o[r],t[r]=o[n],e[n]=t,t.d=cx(t)}e.d=cx(e)}function cx({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}aR(cb.prototype,{add(e){return c$(this,e),this},addKey(e){return cv(this,e,e),this},addKeys(e){return e.forEach(e=>cv(this,e,e)),this},[a7](){return cA(this)}});let cw={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new cb(e.MIN_KEY,e.MAX_KEY);return{...e,table:o=>{let r=e.table(o),{schema:i}=r,{primaryKey:a}=i,{extractKey:s,outbound:l}=a,c={...r,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),l=e=>{let t=`idb://${n}/${o}/${e}`;return s[t]||(s[t]=new cb)},c=l(""),p=l(":dels"),{type:d}=e,[u,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],m=e.trans._cache;return r.mutate(e).then(e=>{if(aN(u)){"delete"!==d&&(u=e.results),c.addKeys(u);let n=cg(u,m);n||"add"===d||p.addKeys(u),(n||f)&&i.indexes.forEach(function(e){let t=l(e.name||"");function o(n){return null!=n?e.extractKey(n):null}let r=n=>e.multiEntry&&aN(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let i=n&&o(n[t]),a=f&&o(f[t]);0!==lB(i,a)&&(null!=i&&r(i),null!=a&&r(a))})})}else if(u){let e={from:u.lower,to:u.upper};p.add(e),c.add(e)}else c.add(t),p.add(t),i.indexes.forEach(e=>l(e.name).add(t));return e})}},p=({query:{index:n,range:t}})=>{var o,r;return[n,new cb(null!=(o=t.lower)?o:e.MIN_KEY,null!=(r=t.upper)?r:e.MAX_KEY)]},d={get:e=>[a,new cb(e.key)],getMany:e=>[a,(new cb).addKeys(e.keys)],count:p,query:p,openCursor:p};return aT(d).forEach(e=>{c[e]=function(i){let{subscr:a}=sU;if(a){let c=e=>{let t=`idb://${n}/${o}/${e}`;return a[t]||(a[t]=new cb)},p=c(""),u=c(":dels"),[f,m]=d[e](i);if(c(f.name||"").add(m),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&i.values&&r.query({...i,values:!1});return r[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&i.values)return n.then(({result:e})=>(p.addKeys(e),t));let e=i.values?t.result.map(s):t.result;i.values?p.addKeys(e):u.addKeys(e)}else if("openCursor"===e){let e=i.values;return t&&Object.create(t,{key:{get:()=>(u.addKey(t.primaryKey),t.key)},primaryKey:{get(){let e=t.primaryKey;return u.addKey(e),e}},value:{get:()=>(e&&p.addKey(t.primaryKey),t.value)}})}return t})}u.add(t)}}return r[e].apply(this,arguments)}}),c}}}};class cC{constructor(e,n){var t;this._middlewares={},this.verno=0;const o=cC.dependencies;this._options=n={addons:cC.addons,autoOpen:!0,indexedDB:o.indexedDB,IDBKeyRange:o.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:r}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:sb,dbReadyPromise:null,cancelOpen:sb,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};i.dbReadyPromise=new sZ(e=>{i.dbReadyResolve=e}),i.openCanceller=new sZ((e,n)=>{i.cancelOpen=n}),this._state=i,this.name=e,this.on=lE(this,"populate","blocked","versionchange","close",{ready:[sE,sb]}),this.on.ready.subscribe=aH(this.on.ready.subscribe,e=>(n,t)=>{cC.vip(()=>{let o=this._state;if(o.openComplete)o.dbOpenError||sZ.resolve().then(n),t&&e(n);else if(o.onReadyBeingFired)o.onReadyBeingFired.push(n),t&&e(n);else{e(n);let o=this;t||e(function e(){o.on.ready.unsubscribe(n),o.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,lS(lR.prototype,function(e,n){this.db=t;let o=lx,r=null;if(n)try{o=n()}catch(e){r=e}let i=e._ctx,a=i.table,s=a.hook.reading.fire;this._ctx={table:a,index:i.index,isPrimKey:!i.index||a.schema.primKey.keyPath&&i.index===a.schema.primKey.name,range:o,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:i.or,valueMapper:s!==sv?s:null}})),this.Table=function(e){return lS(lC.prototype,function(n,t,o){this.db=e,this._tx=o,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:lE(null,{creating:[sk,sb],reading:[s$,sv],updating:[sw,sb],deleting:[sx,sb]})})}(this),this.Transaction=function(e){return lS(lX.prototype,function(n,t,o,r,i){this.db=e,this.mode=n,this.storeNames=t,this.schema=o,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=lE(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new sZ((e,n)=>{this._resolve=e,this._reject=n}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var n=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):n&&this.idbtrans&&this.idbtrans.abort(),l_(e)})})}(this),this.Version=function(e){return lS(ca.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return lS(lK.prototype,function(n,t,o){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:o};let r=e._deps.indexedDB;if(!r)throw new sg.MissingAPI;this._cmp=this._ascending=r.cmp.bind(r),this._descending=(e,n)=>r.cmp(n,e),this._max=(e,n)=>r.cmp(e,n)>0?e:n,this._min=(e,n)=>0>r.cmp(e,n)?e:n,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=l2(n.IDBKeyRange),this._createTransaction=(e,n,t,o)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,o),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lv.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(cf),this.use(ch),this.use(cw),this.use(c_),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new sg.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new sg.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var t=n.filter(n=>n._cfg.version===e)[0];return t||(t=new this.Version(e),n.push(t),n.sort(ce),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||sU.letThrough||this._vip)?e():new sZ((e,n)=>{if(this._state.openComplete)return n(new sg.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new sg.DatabaseClosed);this.open().catch(sb)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:o}){o&&this.unuse({stack:e,name:o});let r=this._middlewares[e]||(this._middlewares[e]=[]);return r.push({stack:e,create:n,level:null==t?10:t,name:o}),r.sort((e,n)=>e.level-n.level),this}unuse({stack:e,name:n,create:t}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>t?e.create!==t:!!n&&e.name!==n)),this}open(){return function(e){var n;let t=e._state,{indexedDB:o}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?l_(t.dbOpenError):e);so&&(t.openCanceller._stackHolder=sa()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let r=t.openCanceller;function i(){if(t.openCanceller!==r)throw new sg.DatabaseClosed("db.open() was cancelled")}let a=t.dbReadyResolve,s=null,l=!1;return sZ.race([r,("u"<typeof navigator?sZ.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var t=function(){return indexedDB.databases().finally(e)};n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(()=>new sZ((n,r)=>{if(i(),!o)throw new sg.MissingAPI;let a=e.name,c=t.autoSchema?o.open(a):o.open(a,Math.round(10*e.verno));if(!c)throw new sg.MissingAPI;c.onerror=lZ(r),c.onblocked=s7(e._fireOnBlocked),c.onupgradeneeded=s7(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=lY,s.abort(),c.result.close();let e=o.deleteDatabase(a);e.onsuccess=e.onerror=s7(()=>{r(new sg.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let t,o,a,u;s.onerror=lZ(r);var i,p,d=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=d<1,e._novip.idbdb=c.result,i=d/10,p=s,t=e._dbSchema,(o=e._createTransaction("readwrite",e._storeNames,t)).create(p),o._completion.catch(r),a=o._reject.bind(o),u=sU.transless||sU,li(()=>{sU.trans=o,sU.transless=u,0===i?(aT(t).forEach(e=>{ct(p,e,t[e].primKey,t[e].indexes)}),l8(e,p),sZ.follow(()=>e.on.populate.fire(o)).catch(a)):(function({_novip:e},n,t,o){let r=[],i=e._versions,a=e._dbSchema=cr(e,e.idbdb,o),s=!1;return i.filter(e=>e._cfg.version>=n).forEach(i=>{r.push(()=>{let r=a,l=i._cfg.dbschema;ci(e,r,o),ci(e,l,o),a=e._dbSchema=l;let c=cn(r,l);c.add.forEach(e=>{ct(o,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new sg.Upgrade("Not yet support for changing primary key");{let n=o.objectStore(e.name);e.add.forEach(e=>co(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),co(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let p=i._cfg.contentUpgrade;if(p&&i._cfg.version>n){let n;l8(e,o),t._memoizedTables={},s=!0;let i=aQ(l);c.del.forEach(e=>{i[e]=r[e]}),l9(e,[e.Transaction.prototype]),l7(e,[e.Transaction.prototype],aT(i),i),t.schema=i;let a=st(p);a&&la();let d=sZ.follow(()=>{if((n=p(t))&&a){var e=ls.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?sZ.resolve(n):d.then(()=>n)}}),r.push(n=>{var o;s&&l$||(o=i._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==o[e]&&n.db.deleteObjectStore(e))),l9(e,[e.Transaction.prototype]),l7(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return r.length?sZ.resolve(r.shift()(t.idbtrans)).then(e):sZ.resolve()})().then(()=>{var e;aT(e=a).forEach(n=>{o.db.objectStoreNames.contains(n)||ct(o,n,e[n].primKey,e[n].indexes)})})})(e,i,o,p).catch(a)})}},r),c.onsuccess=s7(()=>{s=null;let o=e._novip.idbdb=c.result,r=aq(o.objectStoreNames);if(r.length>0)try{let n,i=o.transaction(1===r.length?r[0]:r,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let o=e._dbSchema=cr(0,n,t);e._storeNames=aq(n.objectStoreNames,0),l7(e,[e._allTables],aT(o),o)}(e,o,i):(ci(e,e._dbSchema,i),((n=cn(cr(0,e.idbdb,i),e._dbSchema)).add.length||n.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),l8(e,i)}catch(e){}lv.push(e),o.onversionchange=s7(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),o.onclose=s7(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){cl(e)||"__dbnames"===t||cs(e,n).put({name:t}).catch(sb)}(e._deps,a),n()},r)}))]).then(()=>(i(),t.onReadyBeingFired=[],sZ.resolve(cc(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let o=t.onReadyBeingFired.reduce(sE,sb);return t.onReadyBeingFired=[],sZ.resolve(cc(()=>o(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return r===t.openCanceller&&e._close(),l_(n)}).finally(()=>{t.openComplete=!0,a()})}(this)}_close(){let e=this._state,n=lv.indexOf(this);if(n>=0&&lv.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new sZ(n=>{e.dbReadyResolve=n}),e.openCanceller=new sZ((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new sg.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new sZ((t,o)=>{let r=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=s7(()=>{!function({indexedDB:e,IDBKeyRange:n},t){cl(e)||"__dbnames"===t||cs(e,n).delete(t).catch(sb)}(this._deps,this.name),t()}),e.onerror=lZ(o),e.onblocked=this._fireOnBlocked};if(e)throw new sg.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.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 aT(this._allTables).map(e=>this._allTables[e])}transaction(){let e=cd.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let o,r,i=sU.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(r=n.map(e=>{var n=e instanceof this.Table?e.name:e;if("string"!=typeof n)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}),"r"==e||"readonly"===e)o="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new sg.InvalidArgument("Invalid transaction mode: "+e);o="readwrite"}if(i){if("readonly"===i.mode&&"readwrite"===o){if(!a)throw new sg.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&r.forEach(e=>{if(i&&-1===i.storeNames.indexOf(e)){if(!a)throw new sg.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),a&&i&&!i.active&&(i=null)}}catch(e){return i?i._promise(null,(n,t)=>{t(e)}):l_(e)}let s=(function e(n,t,o,r,i){return sZ.resolve().then(()=>{let a,s=sU.transless||sU,l=n._createTransaction(t,o,n._dbSchema,r);if(r)l.idbtrans=r.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(r){return r.name===sh.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,o,null,i))):l_(r)}let c=st(i);c&&la();let p=sZ.follow(()=>{if(a=i.call(l,l))if(c){var e=ls.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=cp(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?sZ.resolve(a).then(e=>l.active?e:l_(new sg.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):p.then(()=>a)).then(e=>(r&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),l_(e)))})}).bind(null,this,o,r,i,t);return i?i._promise(o,s,"lock"):sU.trans?lf(sU.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!aj(this._allTables,e))throw new sg.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let cE="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class cS{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[cE](){return this}}function cz(e,n){return aT(n).forEach(t=>{c$(e[t]||(e[t]=new cb),n[t])}),e}try{r={indexedDB:aM.indexedDB||aM.mozIndexedDB||aM.webkitIndexedDB||aM.msIndexedDB,IDBKeyRange:aM.IDBKeyRange||aM.webkitIDBKeyRange}}catch(e){r={indexedDB:null,IDBKeyRange:null}}function cD(e){let n=cP;try{cP=!0,lJ.storagemutated.fire(e)}finally{cP=n}}aR(cC,{...sy,delete:e=>new cC(e,{addons:[]}).delete(),exists:e=>new cC(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return cl(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>"__dbnames"!==e)):cs(e,n).toCollection().primaryKeys()})(cC.dependencies).then(e)}catch(e){return l_(new sg.MissingAPI)}},defineClass:()=>function(e){aO(this,e)},ignoreTransaction:e=>sU.trans?lf(sU.transless,e):e(),vip:cc,async:function(e){return function(){try{var n=cp(e.apply(this,arguments));return n&&"function"==typeof n.then?n:sZ.resolve(n)}catch(e){return l_(e)}}},spawn:function(e,n,t){try{var o=cp(e.apply(t,n||[]));return o&&"function"==typeof o.then?o:sZ.resolve(o)}catch(e){return l_(e)}},currentTransaction:{get:()=>sU.trans||null},waitFor:function(e,n){let t=sZ.resolve("function"==typeof e?cC.ignoreTransaction(e):e).timeout(n||6e4);return sU.trans?sU.trans.waitFor(t):t},Promise:sZ,debug:{get:()=>so,set:e=>{so=e,sr="dexie"===e?()=>!0:lA}},derive:aW,extend:aO,props:aR,override:aH,Events:lE,on:lJ,liveQuery:function(e){return new cS(n=>{let t=st(e),o=!1,r={},i={},a={get closed(){return o},unsubscribe:()=>{o=!0,lJ.storagemutated.unsubscribe(p)}};n.start&&n.start(a);let s=!1,l=!1;function c(){return aT(i).some(e=>r[e]&&function(e,n){let t=cA(n),o=t.next();if(o.done)return!1;let r=o.value,i=cA(e),a=i.next(r.from),s=a.value;for(;!o.done&&!a.done;){if(0>=lB(s.from,r.to)&&lB(s.to,r.from)>=0)return!0;0>lB(r.from,s.from)?r=(o=t.next(s.from)).value:s=(a=i.next(r.from)).value}return!1}(r[e],i[e]))}let p=e=>{cz(r,e),c()&&d()},d=()=>{let u,f;if(s||o)return;r={};let m={},h=(t&&la(),u=()=>li(e,{subscr:m,trans:null}),f=sU.trans?lf(sU.transless,u):u(),t&&f.then(ls,ls),f);l||(lJ("storagemutated",p),l=!0),s=!0,Promise.resolve(h).then(e=>{s=!1,o||(c()?d():(r={},i=m,n.next&&n.next(e)))},e=>{s=!1,n.error&&n.error(e),a.unsubscribe()})};return d(),a})},extendObservabilitySet:cz,getByKeyPath:aJ,setByKeyPath:aX,delByKeyPath:function(e,n){"string"==typeof n?aX(e,n,void 0):"length"in n&&[].map.call(n,function(n){aX(e,n,void 0)})},shallowClone:aQ,deepClone:a4,getObjectDiff:cm,cmp:lB,asap:aZ,minKey:-1/0,addons:[],connections:lv,errnames:sh,dependencies:r,semVer:"3.2.2",version:"3.2.2".split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),cC.maxKey=l2(cC.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(lJ("storagemutated",e=>{if(!cP){let n;l$?(n=document.createEvent("CustomEvent")).initCustomEvent("x-storagemutated-1",!0,!0,e):n=new CustomEvent("x-storagemutated-1",{detail:e}),cP=!0,dispatchEvent(n),cP=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{cP||cD(e)}));let cP=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel("x-storagemutated-1");lJ("storagemutated",n=>{cP||e.postMessage(n)}),e.onmessage=e=>{e.data&&cD(e.data)}}else if("u">typeof self&&"u">typeof navigator){lJ("storagemutated",e=>{try{cP||("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(n=>n.postMessage({type:"x-storagemutated-1",changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if("x-storagemutated-1"===e.key){let n=JSON.parse(e.newValue);n&&cD(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&"x-storagemutated-1"===e.type&&cD(e.changedParts)})}function cM(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}sZ.rejectionMapper=function(e,n){if(!e||e instanceof sd||e instanceof TypeError||e instanceof SyntaxError||!e.name||!s_[e.name])return e;var t=new s_[e.name](n||e.message,e);return"stack"in e&&aL(t,"stack",{get:function(){return this.inner.stack}}),t},sr=lA;class cT extends cC{constructor(){super("EsmOffline"),cM(this,"syncQueue",void 0),cM(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 cN(){return new cT}let cO=new cT,cB={},cI=U("offline-synchronization",{});function cj(){return cI}async function cR(){if(cI.getState().synchronization)return;let e=await cO.syncQueue.count(),n={},t=Object.entries(cB),o=t.length,r={},i=new AbortController,a=()=>{let e=cI.getState().synchronization;cI.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{cI.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<o&&t.length>0;e++)for(let e=t.length;e--;){let[o,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(r[o]={},await Promise.all(l),n[o]=cF(s,r,i,a),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{cI.setState({synchronization:void 0})}}async function cF({type:e,dependsOn:n,process:t},o,r,i){let a=[],s=[],l=await cL();await cO.syncQueue.where({type:e,userId:l}).each((e,n)=>{a.push([n.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<a.length;c++){let[p,d,{id:u,dependencies:f=[]}]=a[c];try{let i=await t(d,{abort:r,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?o[t][e]:void 0)});void 0!==u&&(o[e][u]=i),await cO.syncQueue.delete(p)}catch(e){await cO.syncQueue.update(p,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function cL(){let e=await rD();return e?.uuid||"*"}async function cW(e,n,t,o){let r=o&&o.id;return void 0!==r&&await cO.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===r).delete().catch(cC.errnames.DatabaseClosed),await cO.syncQueue.add({type:n,content:t,userId:e,descriptor:o||{},createdOn:new Date}).catch(cC.errnames.DatabaseClosed,()=>-1)}async function cV(e,n,t){let o=await cL();return await cW(o,e,n,t)}async function cG(e,n){return(await cU(e,n)).map(e=>e.content)}async function cU(e,n){return await cO.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(cC.errnames.DatabaseClosed,()=>[])}async function cq(e){let n=await cL();return await cG(n,e)}async function cH(e){let n=await cL();return await cU(n,e)}async function cK(e){return await cO.syncQueue.get(e).catch(cC.errnames.DatabaseClosed,()=>void 0)}function cZ(e){return!!cB[e]?.options.onBeginEditSyncItem}async function cY(e){let n=await cK(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=cB[n.type]?.options.onBeginEditSyncItem;if(!t)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${n.type}" supports editing items.`);t(n)}async function cJ(e){await cO.syncQueue.delete(e).catch(cC.errnames.DatabaseClosed)}function cX(e,n,t,o={}){cB[e]={type:e,dependsOn:n,process:t,options:o}}let cQ="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),c0=new Uint8Array(16),c1=[];for(let e=0;e<256;++e)c1.push((e+256).toString(16).slice(1));let c2=function(e,n,t){if(cQ&&!n&&!e)return cQ();let o=(e=e||{}).random||(e.rng||function(){if(!i&&!(i="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(c0)})();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=o[e];return n}return function(e,n=0){return c1[e[n+0]]+c1[e[n+1]]+c1[e[n+2]]+c1[e[n+3]]+"-"+c1[e[n+4]]+c1[e[n+5]]+"-"+c1[e[n+6]]+c1[e[n+7]]+"-"+c1[e[n+8]]+c1[e[n+9]]+"-"+c1[e[n+10]]+c1[e[n+11]]+c1[e[n+12]]+c1[e[n+13]]+c1[e[n+14]]+c1[e[n+15]]}(o)},c3="OFFLINE+";function c5(){return c3+c2()}function c4(e){return e.startsWith(c3)}let c6={};function c8(){return Object.values(c6)}function c7(e){c6[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.`),c6[e.id]=e}async function c9(e){let n=await ps();return await pe(n,e)}async function pe(e,n){let t=new cT;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(cC.errnames.DatabaseClosed,()=>[])}async function pn(e,n){let t=await ps();return await pt(t,e,n)}async function pt(e,n,t){let o=new cT,r=await o.dynamicOfflineData.get({type:n,identifier:t}).catch(cC.errnames.DatabaseClosed,()=>void 0);r?r.users.includes(e)||await o.dynamicOfflineData.update(r.id,{users:[...r.users,e]}).catch(cC.errnames.DatabaseClosed):await o.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(cC.errnames.DatabaseClosed)}async function po(e,n){let t=await ps();return await pr(t,e,n)}async function pr(e,n,t){let o=new cT,r=await o.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(cC.errnames.DatabaseClosed,()=>void 0);r&&(r.users.length>1?await o.dynamicOfflineData.update(r.id,{users:r.users.filter(n=>n!==e)}).catch(cC.errnames.DatabaseClosed):await o.dynamicOfflineData.delete(r.id).catch(cC.errnames.DatabaseClosed))}async function pi(e,n){let t=await c9(e);await Promise.all(t.map(async e=>pa(e.type,e.identifier,n)))}async function pa(e,n,t){await pn(e,n);let o=new cT,r=await ps(),i=await o.dynamicOfflineData.get({type:e,identifier:n}).catch(cC.errnames.DatabaseClosed,()=>void 0),a=c8().filter(n=>n.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(n,t),{id:e.id,error:void 0}}catch(t){let n=t.message?.toString()??t.toString();return{id:e.id,error:n}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),p=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),d={syncedOn:new Date,syncedBy:r,succeededHandlers:l,erroredHandlers:c,errors:p};i.id&&await o.dynamicOfflineData.update(i.id,{syncState:d}).catch(cC.errnames.DatabaseClosed)}async function ps(){let e=(await rD()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let pl=U("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function pc(){return pu(),pl}function pp(e,n){pu(),c7({type:"patient",displayName:n.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,t)=>n.onOfflinePatientAdded({patientUuid:e,signal:t??new AbortController().signal})})}async function pd(e){pu(),await pa("patient",e)}function pu(){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 pf(e,n,t=!0){if(e){let o=null,[r,i]=await Promise.all([rb(`${rg}/Patient/${e}`,n).catch(e=>o=e),t?pm(e):Promise.resolve(null)]);if(r.ok)return r.data;if(i)return i;if(o)throw o}return null}async function pm(e){let n=(await cq("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function ph(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function pg(e,n){let t=e=>{n("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,t),()=>{window.removeEventListener(`openmrs:${e}`,t)}}var p_=t(99549);function py(e){return{uuid:e.uuid,display:e.display}}function pb(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let o=t.toString();return rv(`${rh}/location${o?"?"+o:""}`).pipe((0,p_.map)(e=>e.data.results.map(py))).pipe((0,p_.take)(1))}function pv(e){return{uuid:e.uuid,display:e.display,name:e.name}}function p$(){return rv(`${rh}/visittype`).pipe((0,p_.map)(e=>e.data.results.map(pv))).pipe((0,p_.take)(1))}var pA=t(29827),pk=((eo={}).NEWVISIT="startVisit",eo.EDITVISIT="editVisit",eo.LOADING="loadingVisit",eo),px=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let pw="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))",pC=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function pE(){return H("visit",pC)}function pS(e,n){pE().setState({patientUuid:e,manuallySetVisitUuid:n})}function pz(e,n){return rb(`${rh}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function pD(e,n,t){return rb(`${rh}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function pP(e,n,t){return rb(`${rh}/visit?patient=${e}&v=${t??pw}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}pE().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let pM=new pA.t(null);class pT{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+pT.version}static addUnaryOp(e){return pT.max_unop_len=Math.max(e.length,pT.max_unop_len),pT.unary_ops[e]=1,pT}static addBinaryOp(e,n,t){return pT.max_binop_len=Math.max(e.length,pT.max_binop_len),pT.binary_ops[e]=n,t?pT.right_associative.add(e):pT.right_associative.delete(e),pT}static addIdentifierChar(e){return pT.additional_identifier_chars.add(e),pT}static addLiteral(e,n){return pT.literals[e]=n,pT}static removeUnaryOp(e){return delete pT.unary_ops[e],e.length===pT.max_unop_len&&(pT.max_unop_len=pT.getMaxKeyLen(pT.unary_ops)),pT}static removeAllUnaryOps(){return pT.unary_ops={},pT.max_unop_len=0,pT}static removeIdentifierChar(e){return pT.additional_identifier_chars.delete(e),pT}static removeBinaryOp(e){return delete pT.binary_ops[e],e.length===pT.max_binop_len&&(pT.max_binop_len=pT.getMaxKeyLen(pT.binary_ops)),pT.right_associative.delete(e),pT}static removeAllBinaryOps(){return pT.binary_ops={},pT.max_binop_len=0,pT}static removeLiteral(e){return delete pT.literals[e],pT}static removeAllLiterals(){return pT.literals={},pT}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 pT(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 pT.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!pT.binary_ops[String.fromCharCode(e)]||pT.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return pT.isIdentifierStart(e)||pT.isDecimalDigit(e)}throwError(e){let n=Error(e+" at character "+this.index);throw n.index=this.index,n.description=e,n}runHook(e,n){if(pT.hooks[e]){let t={context:this,node:n};return pT.hooks.run(e,t),t.node}return n}searchHook(e){if(pT.hooks[e]){let n={context:this};return pT.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===pT.SPACE_CODE||e===pT.TAB_CODE||e===pT.LF_CODE||e===pT.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),n=1===e.length?e[0]:{type:pT.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,o;for(;this.index<this.expr.length;)if((t=this.code)===pT.SEMCOL_CODE||t===pT.COMMA_CODE)this.index++;else if(o=this.gobbleExpression())n.push(o);else if(this.index<this.expr.length){if(t===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,pT.max_binop_len),n=e.length;for(;n>0;){if(pT.binary_ops.hasOwnProperty(e)&&(!pT.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!pT.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=n,e;e=e.substr(0,--n)}return!1}gobbleBinaryExpression(){let e,n,t,o,r,i,a,s,l;if(!(i=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return i;for(r={value:n,prec:pT.binaryPrecedence(n),right_a:pT.right_associative.has(n)},(a=this.gobbleToken())||this.throwError("Expected expression after "+n),o=[i,r,a];n=this.gobbleBinaryOp();){if(0===(t=pT.binaryPrecedence(n))){this.index-=n.length;break}r={value:n,prec:t,right_a:pT.right_associative.has(n)},l=n;let s=e=>r.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;o.length>2&&s(o[o.length-2]);)a=o.pop(),n=o.pop().value,i=o.pop(),e={type:pT.BINARY_EXP,operator:n,left:i,right:a},o.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),o.push(r,e)}for(s=o.length-1,e=o[s];s>1;)e={type:pT.BINARY_EXP,operator:o[s-1].value,left:o[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,o;if(this.gobbleSpaces(),o=this.searchHook("gobble-token"))return this.runHook("after-token",o);if(e=this.code,pT.isDecimalDigit(e)||e===pT.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===pT.SQUOTE_CODE||e===pT.DQUOTE_CODE)o=this.gobbleStringLiteral();else if(e===pT.OBRACK_CODE)o=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,pT.max_unop_len)).length;t>0;){if(pT.unary_ops.hasOwnProperty(n)&&(!pT.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!pT.isIdentifierPart(this.expr.charCodeAt(this.index+n.length)))){this.index+=t;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:pT.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}pT.isIdentifierStart(e)?(o=this.gobbleIdentifier(),pT.literals.hasOwnProperty(o.name)?o={type:pT.LITERAL,value:pT.literals[o.name],raw:o.name}:o.name===pT.this_str&&(o={type:pT.THIS_EXP})):e===pT.OPAREN_CODE&&(o=this.gobbleGroup())}return o?(o=this.gobbleTokenProperty(o),this.runHook("after-token",o)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===pT.PERIOD_CODE||n===pT.OBRACK_CODE||n===pT.OPAREN_CODE||n===pT.QUMARK_CODE;){let t;if(n===pT.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==pT.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===pT.OBRACK_CODE?((e={type:pT.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==pT.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===pT.OPAREN_CODE?e={type:pT.CALL_EXP,arguments:this.gobbleArguments(pT.CPAREN_CODE),callee:e}:(n===pT.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:pT.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),t&&(e.optional=!0),this.gobbleSpaces(),n=this.code}return e}gobbleNumericLiteral(){let e="",n,t;for(;pT.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===pT.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);pT.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(n=this.char)||"E"===n){for(e+=this.expr.charAt(this.index++),("+"===(n=this.char)||"-"===n)&&(e+=this.expr.charAt(this.index++));pT.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);pT.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,pT.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===pT.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===pT.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:pT.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),o=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){o=!0;break}if("\\"===n)switch(n=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=n}else e+=n}return o||this.throwError('Unclosed quote after "'+e+'"'),{type:pT.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(pT.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,pT.isIdentifierPart(e))this.index++;else break;return{type:pT.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,o=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let r=this.code;if(r===e){t=!0,this.index++,e===pT.CPAREN_CODE&&o&&o>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(r===pT.COMMA_CODE){if(this.index++,++o!==n.length){if(e===pT.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===pT.CBRACK_CODE)for(let e=n.length;e<o;e++)n.push(null)}}else if(n.length!==o&&0!==o)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==pT.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(pT.CPAREN_CODE);if(this.code===pT.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:pT.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:pT.ARRAY_EXP,elements:this.gobbleArguments(pT.CBRACK_CODE)}}}Object.assign(pT,{hooks:new class{add(e,n,t){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],n&&this[e][t?"unshift":"push"](n)},this)}run(e,n){this[e]=this[e]||[],this[e].forEach(function(e){e.call(n&&n.context?n.context:n,n)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(pT),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"}),pT.max_unop_len=pT.getMaxKeyLen(pT.unary_ops),pT.max_binop_len=pT.getMaxKeyLen(pT.binary_ops);let pN=e=>new pT(e).parse(),pO=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(pT).filter(e=>!pO.includes(e)&&void 0===pN[e]).forEach(e=>{pN[e]=pT[e]}),pN.Jsep=pT,pN.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:o,alternate:r},t.operator&&e.binary_ops[t.operator]<=.9){let o=t;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let pB="ArrowFunctionExpression",pI={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)}},pj={...pI,Promise};function pR(e,n={}){return pU(e,n,pK)}async function pF(e,n={}){return pq(e,n,pK)}function pL(e,n={}){return pU(e,n,pZ)}function pW(e,n={}){return pq(e,n,pZ)}function pV(e,n={}){return pU(e,n,pY)}function pG(e,n={}){return pq(e,n,pY)}function pU(e,n={},t){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==n&&(n={});let o=pQ(n,pI),r=pJ("string"==typeof e?pN(e):e,o);if(t(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 pq(e,n={},t){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==n&&(n={});let o=pQ(n,pj);return Promise.resolve(pJ("string"==typeof e?pN(e):e,o)).then(n=>{if(t(n))return n;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function pH(e){return pN(e)}function pK(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function pZ(e){return"boolean"==typeof e}function pY(e){return"number"==typeof e}function pJ(e,n){switch(e.type){case"UnaryExpression":var t,o,r,i,a,s,l,c,p,d,u,f,m=e,h=n;let g=pJ(m.argument,h);switch(m.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${m.operator}''`}case"BinaryExpression":var y=e,b=n;let v=pJ(y.left,b),$=pJ(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 t=e,o=n,pJ(t.test,o)?pJ(t.consequent,o):pJ(t.alternate,o);case"CallExpression":var A=e,k=n;let x=A.arguments?.map(p0(k)),w=pJ(A.callee,k);if(w){if("function"!=typeof w)throw`${p2(A.callee)} is not a function`}else throw`No function named ${p2(A.callee)} is defined in this context`;return w(...x);case"ArrowFunctionExpression":let C;return r=e,i=n,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 n=Object.fromEntries(C.reduce((n,t,o)=>{let r=e[o];return function e(n){if("string"==typeof n||"number"==typeof n||"boolean"==typeof n||"function"==typeof n||null===n||n instanceof RegExp)return!0;if("object"==typeof n){for(let t of Object.keys(n))if(!e(n[t]))return!1;return!0}if(Array.isArray(n)){for(let t of n)if(!e(t))break}return!1}(r)&&n.push([t,r]),n},[]));return pJ(r.body,i.addVariables(n))}).bind(i.thisObj??null);case"MemberExpression":return function(e,n){let t,o=pJ(e.object,n);if(void 0===o)switch(e.object.type){case"Identifier":{let t=pX(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=pX(e.property,n);throw TypeError(`TypeError: cannot read properties of undefined (reading '${t}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let r=o;if("string"==typeof o)r=String.prototype;else if("number"==typeof o)r=Number.prototype;else if("function"==typeof o);else if("object"!=typeof o)throw`VisitMemberExpression does not support member access on type ${typeof o}`;switch(n.thisObj=r,e.property.type){case"Identifier":case"MemberExpression":t=pJ(e.property,n);break;default:{let r=pJ(e.property,n);if(void 0===r)throw{type:"Illegal property access",message:"No property was supplied to the property access"};p1(r),t=o[r]}}return"function"==typeof t?t.bind(o):t}(e,n);case"ArrayExpression":return a=e,s=n,a.elements?.map(p0(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(p0(c)))[E.length-1];case"NewExpression":var S=e,z=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(p0(z));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 p1((p=e).value),p.value;case"Identifier":var D=e,P=n;p1(D.name);let M=P.thisObj;if(M&&("object"==typeof M||"function"==typeof M)&&D.name in M){let e=M[D.name];return p1(e),e}if(P.variables&&D.name in P.variables){let e=P.variables[D.name];return p1(e),e}return D.name in P.globals?P.globals[D.name]:void 0;case"TemplateLiteral":let T,N;return d=e,u=n,T=d.expressions?.map(p0(u))??[],(N=d.quasis?.map(p0(u))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+T.join("")+N.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 pX(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return pX(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function pQ(e,n){let t={thisObj:void 0,variables:{...e},globals:{...n},addVariables(e){return this.variables={...this.variables,...e},this}};return t.addVariables.bind(t),t}function p0(e){return function(n){return null===n?null:pJ(n,e)}}function p1(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function p2(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function p3(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let n={globals:{...pj},isLocalExpression:!1,variables:new Set};return p5("string"==typeof e?pN(e):e,n),[...n.variables]}function p5(e,n){switch(e.type){case"UnaryExpression":return o=e,r=n,p5(o.argument,r);case"BinaryExpression":return i=e,a=n,[p5(i.left,a),p5(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[p5(s.consequent,l),p5(s.test,l),p5(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,p=n,t=p5(c.callee,p),c.arguments?.map(p4(p)),t;case"ArrowFunctionExpression":var o,r,i,a,s,l,c,p,d,u,f,m,h,g,y,b,v,$,A=e,k=n;let x={...k};x.isLocalExpression=!0;let w=A.params?.map(p4(x))??[],C=p5(A.body,x)??[];if(C&&Array.isArray(C))for(let e of C)w.includes(e)||k.variables.add(e);return;case"MemberExpression":let E;return d=e,u=n,p5(d.object,u),void((E={...u}).isLocalExpression=!0,p5(d.property,E));case"ArrayExpression":return f=e,m=n,void f.elements?.map(p4(m));case"SequenceExpression":return h=e,g=n,void h.expressions?.map(p4(g));case"NewExpression":return y=e,b=n,void y.arguments?.map(p4(b));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,z=n;if(!(S.name in z.globals))if(z.isLocalExpression)return S.name;else z.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=n,void(v.expressions?.map(p4($)),v.quasis?.map(p4($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function p4(e){return function(n){return null===n?null:p5(n,e)}}pN.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(n){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let t=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let t=this.gobbleBinaryExpression();t||this.throwError("Expected expression after "+e),n.node={type:pB,params:null,body:t};return}}this.index=t}}),e.hooks.add("after-expression",function(n){!function n(t){t&&(Object.values(t).forEach(e=>{e&&"object"==typeof e&&n(e)}),"=>"===t.operator&&(t.type=pB,t.params=t.left?[t.left]:null,t.body=t.right,t.params&&t.params[0].type===e.SEQUENCE_EXP&&(t.params=t.params[0].expressions),delete t.left,delete t.right,delete t.operator))}(n.node)})}}),pN.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(n){let t=n.node;if(t&&"new"===t.operator){t.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(t.argument.type)||this.throwError("Expected new function()"),n.node=t.argument;let o=n.node;for(;o.type===e.MEMBER_EXP||o.type===e.CALL_EXP&&o.callee.type===e.MEMBER_EXP;)o=o.type===e.MEMBER_EXP?o.object:o.callee.object;o.type="NewExpression"}})}}),pN.plugins.register({name:"numbers",init(e){function n(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function t(n){let t=this.index,o="",r=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:o+=this.expr.charAt(this.index++)};r(),this.code===e.PERIOD_CODE&&(o+=this.expr.charAt(this.index++),r());let i=this.char;("e"===i||"E"===i)&&(o+=this.expr.charAt(this.index++),("+"===(i=this.char)||"-"===i)&&(o+=this.expr.charAt(this.index++)),r(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+o+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+o+this.char+")");else if(a===e.PERIOD_CODE){o.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:o},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(o),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(o){if(48===this.code){var r,i,a;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let p="";for(;r=this.code,i=c,95===r||i.some(([e,n])=>r>=e&&r<=n);)95===this.code?this.index++:p+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,t.call(this,o);return}this.throwError("unexpected char within number")}o.node={type:e.LITERAL,value:parseInt(p,"x"===(a=l)||"X"===a?16:"b"===a||"B"===a?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&t.call(this,o)})}}),pN.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,o=!1;for(;this.index<this.expr.length;){if(47===this.code&&!o){let o,r=this.expr.slice(t,this.index),i="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)i+=this.char;else break}try{o=new RegExp(r,i)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:o,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?o=!0:o&&this.code===e.CBRACK_CODE&&(o=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),pN.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:o,alternate:r},t.operator&&e.binary_ops[t.operator]<=.9){let o=t;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),pN.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},o="",r="",i=!1,a=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:r,cooked:o},tail:i});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,i=!0,s(),e.node=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),r="",o="",n.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(r+=a,a=this.expr.charAt(++this.index),r+=a,a){case"n":o+="\n";break;case"r":o+="\r";break;case"t":o+=" ";break;case"b":o+="\b";break;case"f":o+="\f";break;case"v":o+="\v";break;default:o+=a}else o+=a,r+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",n),e.hooks.add("after-token",function(t){if((t.node.type===e.IDENTIFIER||t.node.type===e.MEMBER_EXP)&&96===this.code)return t.node={type:"TaggedTemplateExpression",tag:t.node,quasi:n.bind(this)(t,!1)},t.node=this.gobbleTokenProperty(t.node),t.node})}}),pN.addBinaryOp("in",7),pN.addBinaryOp("??",1);let p6=H("feature-flags",{flags:function(){let e={};for(let n of Object.keys(localStorage))if(n.startsWith("openmrs:feature-flag:")){let t=n.replace("openmrs:feature-flag:",""),o=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...o}}return e}()});function p8(e,n,t){p6.setState(o=>({flags:{...o.flags,[e]:{enabled:o.flags[e]?.enabled??!1,label:n,description:t}}}))}function p7(){let e=p6.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(n=>{let t=n.replace("openmrs:feature-flag:","");e[t]||(localStorage.removeItem(n),localStorage.removeItem(`openmrs:feature-flag-meta:${t}`))})}function p9(e){return p6.getState().flags[e].enabled}function de(e,n){p6.subscribe(t=>{n(t.flags[e].enabled)})}function dn(e,n){p6.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function dt(e){return!window.offlineEnabled||(e??navigator.onLine)}p6.subscribe(e=>{for(let[n,t]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${n}`,t.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${n}`,JSON.stringify({label:t.label,description:t.description}))});var dr=eQ(function(e,n,t){eW(e,n,t)});function di(e=!0,n=!1){return da(dt(),e,n)}function da(e,n=!0,t=!1){return!!(e?n:t)}let ds=U("extensionsInternal",{slots:{},extensions:{}}),dl=()=>H("extensionsInternal",{slots:{},extensions:{}});function dc(e){let n=ds.getState(),t=e(n);t!==n&&ds.setState(t)}let dp=()=>H("extensions",{slots:{}});function dd(e){let n=[];for(let t of Object.values(e.extensions))for(let e of t.instances)n.push({slotModuleName:e.slotModuleName,extensionModuleName:t.moduleName,slotName:e.slotName,extensionId:e.id});nd(nQ.getState().mountedExtensions,n)||nQ.setState({mountedExtensions:n})}dd(ds.getState()),ds.subscribe(dd);let du=dl(),df=dp(),dm=n1(),dh=n5();function dg(e,n,t,o,r){let i={},a=dt(),s=Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[o,l]of Object.entries(e.slots)){let{config:c}=n3(n,l.name),p=dE(o,e,c,t,s,a,r.session);i[o]={moduleName:l.moduleName,assignedExtensions:p}}nd(df.getState().slots,i)||df.setState({slots:i})}function d_(){dg(du.getState(),dm.getState(),dh.getState(),p6.getState(),rA.getState())}function dy(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function db(e){let[n]=e.split("#");return n}function dv(e,n){let t=db(n);return e.extensions[t]}function d$(e){return dv(du.getState(),e)}du.subscribe(e=>{dg(e,dm.getState(),dh.getState(),p6.getState(),rA.getState())}),dm.subscribe(e=>{dg(du.getState(),e,dh.getState(),p6.getState(),rA.getState())}),dh.subscribe(e=>{dg(du.getState(),dm.getState(),e,p6.getState(),rA.getState())}),p6.subscribe(e=>{dg(du.getState(),dm.getState(),dh.getState(),e,rA.getState())}),rA.subscribe(e=>{dg(du.getState(),dm.getState(),dh.getState(),p6.getState(),e)}),d_(),y(d_);let dA=e=>du.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function dk(e,n){dc(t=>{let o=t.slots[e];return o?{...t,slots:{...t.slots,[e]:{...o,attachedIds:[...o.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...dy(e),attachedIds:[n]}}}})}function dx(e,n){dc(t=>{let o=t.slots[e];return o&&o.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...o,attachedIds:o.attachedIds.filter(e=>e!==n)}}}:t})}function dw(e){dc(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function dC(e,n,t,o){let r=n.indexOf(e);if(-1!==r)return r;{if(void 0!==t)return 1e3+t;let n=o.indexOf(e);return -1!==n?2e3+n:-1}}function dE(e,n,t,o,r,i,a){let s=function(e,n){let t=e.add||[],o=e.remove||[],r=e.order||[],{extensions:i}=du.getState();return[...n,...t].filter(e=>!o.includes(e)).sort((e,t)=>{let o=dC(e,r,i[db(e)]?.order,n),a=dC(t,r,i[db(t)]?.order,n);return -1===a?-1:-1===o?1:o-a})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,p=c&&"object"==typeof c?{session:a,...c}:{session:a};for(let c of s){let{config:s}=n6(o,e,c),d=dr(s,n8(t,e,c)),u=db(c),f=n.extensions[u];if(f){let n=d?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!a?.user||!rz(n,a.user)))continue;let t=d?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!pL(t,p))continue}catch(n){console.error(`Error while evaluating expression '${t}' for extension ${u} in slot ${e}`,n);continue}if(f.featureFlag&&!r.includes(f.featureFlag)||window.offlineEnabled&&!da(i,f.online,f.offline))continue;l.push({id:c,name:u,moduleName:f.moduleName,config:d,featureFlag:f.featureFlag,meta:f.meta,online:d?.["Display conditions"]?.online??f.online??!0,offline:d?.["Display conditions"]?.offline??f.offline??!1})}}return l}function dS(e){let n=du.getState(),{config:t}=n2(e),o=dh.getState(),r=p6.getState(),i=rA.getState(),a=dt();return dE(e,n,t,o,Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),a,i.session)}let dz=(e,n,t)=>du.setState(o=>{let r=o.slots[n]?.moduleName;if(r&&r!=e)return console.warn(`An extension slot with the name '${n}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${r}.`),o;if(r&&r==e)return o;if(o.slots[n])return{...o,slots:{...o.slots,[n]:{...o.slots[n],moduleName:e,state:t}}};let i=dy(n,e,t);return{...o,slots:{...o.slots,[n]:{...i}}}});function dD(e,n,t=!1){du.setState(o=>{let r=t?dr(o.slots[e].state,n):n;return{...o,slots:{...o.slots,[e]:{...o.slots[e],state:r}}}})}let dP=()=>df.setState(()=>({slots:{},extensions:{}})),dM=U("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function dT({name:e,basePath:n,mode:t,componentContext:o,state:r}){dM.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:o,state:r})}function dN(e){dM.getState().slotName===e&&dM.setState(dM.getInitialState(),!0)}let dO=U("modalRegistry",{modals:{}});function dB(e){dO.setState(n=>(n.modals[e.name]=e,n))}function dI(e){let n=dO.getState().modals[e];if(!n){let t=d$(e);t&&(n={name:e,load:t.load,moduleName:t.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),dB(n))}return n}let dj=U("workspaceRegistrations",{workspaces:{}}),dR=U("workspaceGroups",{workspaceGroups:{}});function dF(e){dj.setState(n=>({workspaces:{...n.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function dL(e){dR.setState(n=>{let t=n.workspaceGroups[e.name];return t?{workspaceGroups:{...n.workspaceGroups,[e.name]:{...t,members:Array.from(new Set([...t.members,...e.members]))}}}:{workspaceGroups:{...n.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let dW=new Set;function dV(e){let n=dj.getState().workspaces;if(n[e])return n[e];{let n=d$(e);if(n){var t;let o;return dW.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.`),dW.add(e)),{name:n.name,title:(t=n,"string"==typeof(o=t?.meta?.title)?o:o&&"object"==typeof o?iv(t.moduleName,o.key,o.default):t.name),moduleName:n.moduleName,preferredWindowSize:n.meta?.screenSize??"normal",load:n.load,type:n.meta?.type??"form",canHide:n.meta?.canHide??!1,canMaximize:n.meta?.canMaximize??!1,width:n.meta?.width??"narrow",groups:n.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function dG(e){let n=dR.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let dU=U("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function dq(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=dU.getState(),o=n[e];if(o){let n=t[o.window];if(n)return n;throw Error(`No workspace window found with name: ${o.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function dH(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=dU.getState(),o=t[e];if(o){let t=n[o.group];if(t)return t;throw Error(`No workspace group found with name: ${o.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function dK(e){let{openedWindows:n}=dU.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function dZ(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=dU.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);o[t.name]={...t,moduleName:e}}dU.setState({registeredGroupsByName:o})}function dY(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=dU.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};o[t.name]=n}dU.setState({registeredWindowsByName:o})}function dJ(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=dU.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};o[t.name]=n}dU.setState({registeredWorkspacesByName:o})}let dX=0;async function dQ(e,n,t,o,r=e=>e,i={}){let a=db(o),s=d$(o),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${n}'`);let{meta:c,moduleName:p,online:d,offline:u,load:f}=s;if(di(d,u)){dc(r=>({...r,extensions:{...r.extensions,[a]:{...r.extensions[a],instances:[...r.extensions[a].instances,{domElement:e,id:o,slotName:n,slotModuleName:t}]}}}));let s=await f(),d=dX++;l=o_(r({...s,name:`${n}/${a}-${d}`}),{...i,_meta:c,_extensionContext:{extensionId:o,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:p},domElement:e})}}else console.warn(`Tried to render ${o} into ${n} but no DOM element was available.`);return l}var d0=t(35399),d1=t.n(d0);let d2=(0,d0.createContext)({moduleName:"",featureName:""});function d3({to:e,templateParams:n,onBeforeNavigate:t,children:o,...r}){return(0,d0.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}`)},[]),d1().createElement("a",{onClick:o=>{0===o.button&&!o.ctrlKey&&!o.shiftKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),t?.(o),ri({to:e,templateParams:n})),0===o.button&&(o.ctrlKey||o.metaKey)&&t?.(o),0===o.button&&o.shiftKey&&t?.(o),1===o.button&&t?.(o)},href:ro(e,n),...r},o)}let d5=({state:e,children:n,...t})=>{let{extension:o}=(0,d0.useContext)(d2),r=(0,d0.useRef)(null),i=(0,d0.useRef)(Promise.resolve()),a=(0,d0.useCallback)(n=>{o?.extensionSlotName&&o.extensionSlotModuleName&&o.extensionSlotModuleName&&!r.current&&dQ(n,o.extensionSlotName,o.extensionSlotModuleName,o.extensionId,void 0,e).then(e=>{r.current=e})},[]);return(0,d0.useEffect)(()=>()=>{if(r&&r.current)switch(r.current.getStatus()){case"MOUNTING":r.current.mountPromise.then(()=>{r.current?.getStatus()==="MOUNTED"&&r.current.unmount()});break;case"MOUNTED":r.current.unmount();break;case"UPDATING":i.current&&i.current.then(()=>{r.current?.getStatus()==="MOUNTED"&&r.current.unmount()})}},[]),(0,d0.useEffect)(()=>{r.current&&r.current.update&&"UNMOUNTING"!==r.current.getStatus()&&Promise.all([r.current.mountPromise,i.current]).then(()=>{r?.current?.getStatus()==="MOUNTED"&&r.current.update&&(i.current=r.current.update({...e}).catch(e=>{if(!(e instanceof Error)||!e.message.includes("minified message #32")||r.current?.getStatus()==="MOUNTED")throw e}))})},[e]),o?d1().createElement("div",{ref:a,"data-extension-id":o?.extensionId,style:{position:"relative"},...t}):null};function d4(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[o,r]of Object.entries(n)){let n=function(...n){e.setState(e=>r(e,...n))};t[o]=n}return t}let d6=()=>e=>e;function d8(e,n=d6(),t){let o=(0,d0.useCallback)(n=>e.subscribe(n),[e]),r=(0,d0.useCallback)(()=>n(e.getState()),[e,n]),i=(0,d0.useSyncExternalStore)(o,r,r),a=(0,d0.useMemo)(()=>t?d4(e,t):{},[e,t]);return{...i,...a}}function d7(e,n){return d8(e,d6(),n)}function d9(e){return function(n){let t=(0,d0.useCallback)(n=>e.subscribe(n),[]),o=(0,d0.useCallback)(()=>e.getState(),[]),r=(0,d0.useSyncExternalStore)(t,o,o),i=(0,d0.useMemo)(()=>n?d4(e,n):{},[n]);return{...r,...i}}}let ue=e=>d8(dp(),n=>n.slots?.[e]);function un(e){let n=ue(e);return n?.assignedExtensions??[]}function ut(e,n){let{moduleName:t}=(0,d0.useContext)(d2),o=(0,d0.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,d0.useEffect)(()=>{dz(t,e,n),o.current=!1},[]),(0,d0.useEffect)(()=>{o.current||dD(e,n)},[e,n]),{extensions:un(e),extensionSlotName:e,extensionSlotModuleName:t}}function uo(e){return e}function ur({name:e,extensionSlotName:n,select:t=uo,children:o,state:r,style:i,...a}){if(o&&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??n,l=(0,d0.useRef)(null),{extensions:c,extensionSlotModuleName:p}=ut(s,r),d=(0,d0.useMemo)(()=>t(c),[t,c]),u=(0,d0.useMemo)(()=>{if("function"==typeof o&&!d1().isValidElement(o))return d.map(e=>o(e,r))},[o,d]);return d1().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":p,style:{...i,position:"relative"},...a},s&&d?.map((e,n)=>d1().createElement(d2.Provider,{key:e.id,value:{moduleName:p,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:p}}},u?.[n]??("function"!=typeof o?o:null)??d1().createElement(d5,{state:r}))))}var ui=t(25873);function ua(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,o)}return t}function us(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?ua(Object(t),!0).forEach(function(n){var o,r,i;o=e,r=n,i=t[n],r in o?Object.defineProperty(o,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):o[r]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ua(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function ul(e){return(ul="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 uc(e){return(uc="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 up(e,n){var t;if("function"!=typeof(t=n.domElement?function(){return n.domElement}:n.domElementGetter?n.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var n=e.appName||e.name;if(!n)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var t="single-spa-application:".concat(n);return function(){var e=document.getElementById(t);return e||((e=document.createElement("div")).id=t,document.body.appendChild(e)),e}}(n)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(n.name,"'. Expected a function, received ").concat(uc(t)));return function(){var e=t(n);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(n.name,"'. Expected HTMLElement, received ").concat(uc(e)));return e}}var ud=null;try{ud=require("react").createContext()}catch(e){}var uu={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 uf(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function um(e,n){return new Promise(function(t,o){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var n=e.version.slice(0,e.version.indexOf("."));try{return Number(n)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var r,i=uy(e,n,function(){t(this)}),a=up(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,o=e.elementToRender,r=e.domElement,i=n[t];if("function"!=typeof i)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=i(r);return a.render(o),a;case"hydrateRoot":return i(r,o);default:return i(o,r),null}}({elementToRender:i,domElement:a,reactDom:u_(e),renderType:"function"==typeof(r=e).renderType?r.renderType():r.renderType});e.domElements[n.name]=a,e.renderResults[n.name]=s})}function uh(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var o=e.renderResults[n.name];o&&o.unmount?o.unmount():u_(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function ug(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var o=uy(e,n,null),r=e.renderResults[n.name];if(r&&r.render)r.render(o);else{var i=up(e,n)();u_(e).render(o,i)}})}function u_(e){return e.ReactDOMClient||e.ReactDOM}function uy(e,n,t){var o=e.React.createElement(e.rootComponent,n),r=ud?e.React.createElement(ud.Provider,{value:n},o):o;return(e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,n){function t(n){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},t.displayName="SingleSpaReactErrorBoundary(".concat(n.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||n.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},t.prototype.componentDidCatch=function(e,n){this.setState({caughtError:e,caughtErrorInfo:n})},t}(e,n),r=e.React.createElement(e.errorBoundaryClass,n,r)),r=e.React.createElement(e.SingleSpaRoot,us(us({},n),{},{mountFinished:t,updateFinished:function(){e.updateResolves[n.name]&&(e.updateResolves[n.name].forEach(function(e){return e()}),delete e.updateResolves[n.name])},unmountFinished:function(){e.unmountResolves[n.name]&&(e.unmountResolves[n.name](),delete e.unmountResolves[n.name])}}),r)}var ub=t(27807),uv=t(71123),u$=t(43432);let uA={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},uk=new Map;(0,u$.initCache)(uk);let ux={errorRetryCount:3,fetcher:rb,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof r$){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>uk};function uw(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},uA,e),t={...ux,...n.swrConfig};return function(e){var o,r,i,a,s;return i=r=class extends(o=d1().Component){componentDidCatch(e,t){t&&t.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:t.componentStack})),n.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:t})}render(){if(this.state.caughtError)return d1().createElement("div",null,"An error has occurred. Please try reloading the page.");{let o=d1().createElement(d0.Suspense,{fallback:null},d1().createElement(uv.BE,{value:t},d1().createElement(d2.Provider,{value:this.state.config},n.disableTranslations?d1().createElement(e,this.props):d1().createElement(ub.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},d1().createElement(e,this.props)))));return n.strictMode&&d1().StrictMode?d1().createElement(d1().StrictMode,null,o):o}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${n.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,r}}function uC(e,n){return function(e){if("object"!==ul(e))throw Error("single-spa-react requires a configuration object");var n,t=us(us({},uu),e);if(!t.React)throw Error("single-spa-react must be passed opts.React");if(!t.ReactDOM&&!t.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(t.renderType||(null!=(n=t.ReactDOMClient)&&n.createRoot?t.renderType="createRoot":t.renderType="render"),!t.rootComponent&&!t.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(t.errorBoundary&&"function"!=typeof t.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!ud&&t.React.createContext&&(ud=t.React.createContext()),t.SingleSpaRoot=function(e){function n(e){n.displayName="SingleSpaRoot(".concat(e.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},n.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},n.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},n}(t);var o={bootstrap:uf.bind(null,t),mount:um.bind(null,t),unmount:uh.bind(null,t)};return t.parcelCanUpdate&&(o.update=ug.bind(null,t)),o}({React:d1(),ReactDOMClient:ui,rootComponent:uw(n)(e)})}function uE(e,n){return()=>e().then(({default:e})=>uC(e,n))}function uS(e,n){return()=>Promise.resolve(uC(e,n))}let uz=uE,uD=W()(()=>({}));q("openmrs-app-context",uD);let uP={};function uM(e,n=e=>e){let t=uD.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function uT(e,n){uD.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function uN(e){return null===e?null:Object.freeze(Object.assign({},e))}let uO=new Map;function uB(e,n){let t=(0,d0.useRef)(n??{}),o=(0,d0.useRef)(n=>uT(e,n)),r=(0,d0.useRef)(Symbol());return(0,d0.useEffect)(()=>{let t=n??{},o=r.current;return null===uM(e)?!function(e,n=uP){uD.setState(t=>{if(e in t)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},t,{[e]:n===uP?{}:n})})}(e,t):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),uT(e,()=>t)),uO.set(e,o),()=>{uO.get(e)===o&&(uD.setState(n=>(e in n&&delete n[e],n)),uO.delete(e))}},[e]),(0,d0.useEffect)(()=>{let o=n??{};j(t.current,o)||(uT(e,()=>o),t.current=o)},[n]),o.current}function uI({namespace:e,value:n}){return uB(e,n),null}let uj=({children:e,value:n,fallback:t})=>n?d1().createElement(d1().Fragment,null,e):t?d1().createElement(d1().Fragment,null,t):null;function uR(){let e=(0,d0.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,d0.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function uF(e,n=e=>e??{}){let[t,o]=(0,d0.useState)(()=>{if(uL(e))return;let t=uM(e);if(null!==t)return n?n(t):t});return(0,d0.useEffect)(()=>{if(uL(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,d0.useEffect)(()=>{var t;let r;return(t=e=>{if(null==e)return void o(void 0);let t=n?n(e):e;o(e=>j(e,t)?e:t)})(uN(r=uM(e))),uD.subscribe(n=>{let o=e in n?n[e]:null;o!==r&&(r=o,t(uN(o)))})},[e,n]),t}function uL(e){return"string"!=typeof e||0===e.trim().length}function uW(e){let[n,t]=(0,d0.useState)([]);return(0,d0.useEffect)(()=>dp().subscribe(o=>{let r=o.slots[e]?.assignedExtensions.map(e=>e.id)??[];nd(r,n)||t(r)}),[]),n}function uV(e,n){let{data:t,error:o,mutate:r,isLoading:i,isValidating:a}=(0,uv.Ay)(`${an}?patient=${e}&includeEncounterless=${n}`,rb);return(0,d0.useMemo)(()=>({isLoading:i,data:t?.data.results??[],error:o,mutate:r,isValidating:a}),[t,o,i,a,r])}function uG(e){(0,d0.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let uU={},uq=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|