@openmrs/esm-laboratory-app 1.5.3-pre.1820 → 1.5.3-pre.1826

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.
@@ -0,0 +1 @@
1
+ {"hash":"ffdfe81a9e03a7bd","duration":7510}
@@ -1,7 +1,7 @@
1
1
  WARNING in âš  asset size limit: The following asset(s) exceed the recommended size limit (244.141 KiB). This can impact web performance.
2
2
  │ Assets:
3
3
  │ 5945.js (661.979 KiB)
4
- │ 3575.js (587.433 KiB)
4
+ │ 3575.js (587.300 KiB)
5
5
  
6
6
 
7
- Rspack compiled with 1 warning in 7.08 s
7
+ Rspack compiled with 1 warning in 6.44 s
package/dist/3575.js CHANGED
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
12
12
  ${t}`)}return n}let n9=(e,t)=>{let r=structuredClone(t);if(!e)return r;for(let t of Object.keys(e)){let n=r[t],a=e[t];if(a&&(a.hasOwnProperty("_type")||a.hasOwnProperty("_default"))){r.hasOwnProperty(t)||(r[t]=a._default);let e=a._elements;if(n&&n8(e)){if(a._type===nr.Array&&Array.isArray(n)){let a=n.map(t=>n9(e,t));r[t]=a}else if(a._type===nr.Object)for(let t of Object.keys(n))n[t]=n9(e,n[t])}}else if(n7(a)){let e=n??{};n7(e)&&(r[t]=n9(a,e))}}return r};function n8(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function n7(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function ae(e,t){let r=`${e}:::${t}`;n$.has(r)||(console.error(t),n$.add(r))}function at(e){e?n$.forEach(t=>{t.startsWith(e)&&n$.delete(t)}):n$.clear()}function ar(){nN.forEach(e=>e()),nN.length=0,nL.clear(),nq.clear(),nX.clear(),nJ.clear(),nA=null,nI=new WeakMap,nM()}let an={"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:nr.Object,_default:{},_validators:[nn(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let t=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${t.join(", ")}.`})]}},aa={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nr.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nr.String,_default:void 0}},...an},ao=(e,t)=>nn(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),ai=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return nn(e=>{if(!e||"string"!=typeof e)return!1;let r=/\${(.*?)}/g,n=r.exec(e);for(;n;){if(!t.includes(n[1]))return!1;n=r.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},as=ai([]),al=e=>nn(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),au={inRange:ao,isUrl:as,isUrlWithTemplateParameters:ai,oneOf:al};var ac=r(8067);let ad=V("breadcrumbs",[]);function am(e){return af([e])}function af(e){let t=[...ap(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ac.pathToRegexp)(e.matcher).regexp:(0,ac.pathToRegexp)(e.path).regexp,settings:e}))];ad.setState(t,!0)}function ap(){return ad.getState()}function ah(e,t){if(t)return function(e,t){let[r]=e.filter(e=>e.matcher.test(t));return r}(e,t)||function(e,t){let r=t.split("/");for(;r.length>1;){r.pop();let t=ah(e,r.join("/"));if(t)return t}}(e,t)}function ag(e,t){if(e.length>0){let r=ah(e,t);if(r){let t=[r],n=ah(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=ah(e,n.settings.parent);return t.reverse()}}return[]}function ay(e){return ag(ap(),e)}var av=Object.freeze({__proto__:null,get start(){return oU},get ensureJQuerySupport(){return oy},get setBootstrapMaxTime(){return a8},get setMountMaxTime(){return a7},get setUnmountMaxTime(){return oe},get setUnloadMaxTime(){return ot},get registerApplication(){return ok},get unregisterApplication(){return oR},get getMountedApps(){return o_},get getAppStatus(){return oC},get unloadApplication(){return oO},get checkActivityFunctions(){return oT},get getAppNames(){return oS},get pathToActiveWhen(){return oA},get navigateToUrl(){return ol},get patchHistoryApi(){return op},get triggerAppChange(){return oL},get addErrorHandler(){return ax},get removeErrorHandler(){return a_},get mountRootParcel(){return a2},get NOT_LOADED(){return aP},get LOADING_SOURCE_CODE(){return ak},get NOT_BOOTSTRAPPED(){return aT},get BOOTSTRAPPING(){return aR},get NOT_MOUNTED(){return aO},get MOUNTING(){return aN},get UPDATING(){return aA},get LOAD_ERROR(){return aj},get MOUNTED(){return a$},get UNLOADING(){return aM},get UNMOUNTING(){return aI},get SKIP_BECAUSE_BROKEN(){return aL}}),ab=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,aw=!function(){try{var e=new ab("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var r=document.createEvent("CustomEvent");return t?r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):r.initCustomEvent(e,!1,!1,void 0),r}:function(e,t){var r=document.createEventObject();return r.type=e,t?(r.bubbles=!!t.bubbles,r.cancelable=!!t.cancelable,r.detail=t.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r}:ab;let aE=[];function aD(e,t,r){let n=aC(e,t,r);aE.length?aE.forEach(e=>e(n)):setTimeout(()=>{throw n})}function ax(e){if("function"!=typeof e)throw Error(aS(28,!1));aE.push(e)}function a_(e){if("function"!=typeof e)throw Error(aS(29,!1));let t=!1;return aE=aE.filter(r=>{let n=r===e;return t=t||n,!n}),t}function aS(e,t,...r){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${r.length?`&arg=${r.join("&arg=")}`:""}`}function aC(e,t,r){let n,a=`${aW(t)} '${aV(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}n=e}else{console.warn(aS(30,!1,t.status,aV(t)));try{n=Error(a+JSON.stringify(e))}catch(t){n=e}}return n.appOrParcelName=aV(t),t.status=r,n}let aP="NOT_LOADED",ak="LOADING_SOURCE_CODE",aT="NOT_BOOTSTRAPPED",aR="BOOTSTRAPPING",aO="NOT_MOUNTED",aN="MOUNTING",a$="MOUNTED",aA="UPDATING",aI="UNMOUNTING",aM="UNLOADING",aj="LOAD_ERROR",aL="SKIP_BECAUSE_BROKEN";function aF(e){return e.status===a$}function aB(e){try{return e.activeWhen(window.location)}catch(t){return aD(t,e,aL),!1}}function aV(e){return e.name}function aU(e){return!!e.unmountThisParcel}function aW(e){return aU(e)?"parcel":"application"}function aH(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function az(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r];return null}function aK(e){return e&&("function"==typeof e||Array.isArray(e)&&!az(e,e=>"function"!=typeof e))}function aG(e,t){let r=e[t]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[()=>Promise.resolve()]);let n=aW(e),a=aV(e);return function(e){return r.reduce((r,o,i)=>r.then(()=>{let r=o(e);return aZ(r)?r:Promise.reject(aS(15,!1,n,a,t,i))}),Promise.resolve())}}function aZ(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let aY=[];function aq(e,t){return Promise.resolve().then(()=>e.status!==aT?e:(e.status=aR,e.bootstrap?or(e,"bootstrap").then(r).catch(r=>{if(t)throw aC(r,e,aL);return aD(r,e,aL),e}):Promise.resolve().then(r)));function r(){return e.status=aO,e}}function aJ(e,t){return Promise.resolve().then(()=>{if(e.status!==a$)return e;return e.status=aI,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(r,n=>r().then(()=>{let r=Error(n.message);if(t)throw aC(r,e,aL);aD(r,e,aL)})).then(()=>e);function r(){return or(e,"unmount").then(()=>{e.status=aO},r=>{if(t)throw aC(r,e,aL);aD(r,e,aL)})}})}let aX=!1,aQ=!1;function a0(e,t){return Promise.resolve().then(()=>e.status!==aO?e:(aX||(window.dispatchEvent(new aw("single-spa:before-first-mount")),aX=!0),e.status=aN,or(e,"mount").then(()=>(e.status=a$,aQ||(window.dispatchEvent(new aw("single-spa:first-mount")),aQ=!0),e)).catch(r=>{return e.status=a$,aJ(e,!0).then(n,n);function n(){if(t)throw aC(r,e,aL);return aD(r,e,aL),e}})))}let a1=0,a4={parcels:{}};function a2(){return a3.apply(a4,arguments)}function a3(e,t){let r,n,a,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(aS(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(aS(3,!1,typeof e.name));let i=a1++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(aS(4,!1,s,typeof t));if(!t.domElement)throw Error(aS(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:i,parcels:{},status:l?ak:aT,customProps:t,parentName:aV(o),unmountThisParcel:()=>f.then(()=>{if(c.status!==a$)throw Error(aS(6,!1,s,c.status));return aJ(c,!0)}).then(e=>(c.parentName&&delete o.parcels[c.id],e)).then(e=>(n(e),e)).catch(e=>{throw c.status=aL,a(e),e})};o.parcels[i]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(aS(7,!1));let m=(d=d.then(e=>{if(!e)throw Error(aS(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!aK(e.bootstrap))throw Error(aS(9,!1,s));if(!aK(e.mount))throw Error(aS(10,!1,s));if(!aK(e.unmount))throw Error(aS(11,!1,s));if(e.update&&!aK(e.update))throw Error(aS(12,!1,s));let t=aG(e,"bootstrap"),n=aG(e,"mount"),a=aG(e,"unmount");c.status=aT,c.name=s,c.bootstrap=t,c.mount=n,c.unmount=a,c.timeouts=on(e.timeouts),e.update&&(c.update=aG(e,"update"),r.update=function(e){return c.customProps=e,a6(Promise.resolve().then(()=>{if(c.status!==a$)throw Error(aS(32,!1,aV(c)));return c.status=aA,or(c,"update").then(()=>(c.status=a$,c)).catch(e=>{throw aC(e,c,aL)})}))})})).then(()=>aq(c,!0)),f=m.then(()=>a0(c,!0)),p=new Promise((e,t)=>{n=e,a=t});return r={mount:()=>a6(Promise.resolve().then(()=>{if(c.status!==aO)throw Error(aS(13,!1,s,c.status));return o.parcels[i]=c,a0(c)})),unmount:()=>a6(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:a6(d),bootstrapPromise:a6(m),mountPromise:a6(f),unmountPromise:a6(p)}}function a6(e){return e.then(()=>null)}function a5(e){let t=aV(e),r="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(aS(40,!1),t,r));let n=aH({},r,{name:t,mountParcel:a3.bind(e),singleSpa:av});return aU(e)&&(n.unmountSelf=e.unmountThisParcel),n}let a9={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 a8(e,t,r){if("number"!=typeof e||e<=0)throw Error(aS(16,!1));a9.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function a7(e,t,r){if("number"!=typeof e||e<=0)throw Error(aS(17,!1));a9.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function oe(e,t,r){if("number"!=typeof e||e<=0)throw Error(aS(18,!1));a9.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function ot(e,t,r){if("number"!=typeof e||e<=0)throw Error(aS(19,!1));a9.unload={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function or(e,t){let r=e.timeouts[t],n=r.warningMillis,a=aW(e);return new Promise((o,i)=>{let s=!1,l=!1;e[t](a5(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>c(1),n),setTimeout(()=>c(!0),r.millis);let u=aS(31,!1,t,a,aV(e),r.millis);function c(e){s||(!0===e?(l=!0,r.dieOnTimeout?i(Error(u)):console.error(u)):!l&&(console.warn(u),e*n+n<r.millis&&setTimeout(()=>c(e+1),n)))}})}function on(e){let t={};for(let r in a9)t[r]=aH({},a9[r],e&&e[r]||{});return t}function oa(e){return Promise.resolve().then(()=>{let t,r;return e.loadPromise?e.loadPromise:e.status!==aP&&e.status!==aj?e:(e.status=ak,e.loadPromise=Promise.resolve().then(()=>{let n=e.loadApp(a5(e));if(!aZ(n))throw r=!0,Error(aS(33,!1,aV(e)));return n.then(r=>{let n;e.loadErrorTime=null,"object"!=typeof(t=r)&&(n=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!aK(t.bootstrap)&&(n=35),aK(t.mount)||(n=36),aK(t.unmount)||(n=37);let a=aW(t);if(n){let r;try{r=JSON.stringify(t)}catch(e){}return console.error(aS(n,!1,a,aV(e),r),t),aD(void 0,e,aL),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=aH({},e.devtools.overlays,t.devtools.overlays)),e.status=aT,e.bootstrap=aG(t,"bootstrap"),e.mount=aG(t,"mount"),e.unmount=aG(t,"unmount"),e.unload=aG(t,"unload"),e.timeouts=on(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let n;return delete e.loadPromise,r?n=aL:(n=aj,e.loadErrorTime=(new Date).getTime()),aD(t,e,n),e}))})}let oo="u">typeof window,oi={hashchange:[],popstate:[]},os=["hashchange","popstate"];function ol(e){let t;if("string"==typeof e)t=e;else if(this&&this.href)t=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(aS(14,!1));t=e.currentTarget.href,e.preventDefault()}let r=oh(window.location.href),n=oh(t);0===t.indexOf("#")?window.location.hash=n.hash:r.host!==n.host&&n.host?window.location.href=t:n.pathname===r.pathname&&n.search===r.search?window.location.hash=n.hash:window.history.pushState(null,null,t)}function ou(e){if(e){let t=e[0].type;os.indexOf(t)>=0&&oi[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function oc(){oF([],arguments)}function od(e,t){return function(){let r=window.location.href,n=e.apply(this,arguments),o=window.location.href;return a&&r===o||window.dispatchEvent(function(e,t){let r;try{r=new PopStateEvent("popstate",{state:e})}catch(t){(r=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return r.singleSpa=!0,r.singleSpaTrigger=t,r}(window.history.state,t)),n}}let om=null,of=!1;function op(e){if(of)throw Error(aS(43,!1));a=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,of=!0,om=window.history.replaceState,window.addEventListener("hashchange",oc),window.addEventListener("popstate",oc);let t=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(e,r){if(!("function"==typeof r&&os.indexOf(e)>=0)||az(oi[e],e=>e===r))return t.apply(this,arguments);oi[e].push(r)},window.removeEventListener=function(e,t){return"function"==typeof t&&os.indexOf(e)>=0&&(oi[e]=oi[e].filter(e=>e!==t)),r.apply(this,arguments)},window.history.pushState=od(window.history.pushState,"pushState"),window.history.replaceState=od(om,"replaceState")}function oh(e){let t=document.createElement("a");return t.href=e,t}oo&&(window.singleSpaNavigate?console.warn(aS(41,!1)):window.singleSpaNavigate=ol);let og=!1;function oy(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!og){let t=e.fn.on,r=e.fn.off;e.fn.on=function(e,r){return ov.call(this,t,window.addEventListener,e,r,arguments)},e.fn.off=function(e,t){return ov.call(this,r,window.removeEventListener,e,t,arguments)},og=!0}}function ov(e,t,r,n,a){return"string"!=typeof r?e.apply(this,a):(r.split(/\s+/).forEach(e=>{os.indexOf(e)>=0&&(t(e,n),r=r.replace(e,""))}),""===r.trim()?this:e.apply(this,a))}let ob={};function ow(e){return Promise.resolve().then(()=>{let t=ob[aV(e)];if(!t)return e;if(e.status===aP)return oE(e,t),e;if(e.status===aM)return t.promise.then(()=>e);if(e.status!==aO&&e.status!==aj)return e;let r=e.status===aj?Promise.resolve():or(e,"unload");return e.status=aM,r.then(()=>(oE(e,t),e)).catch(r=>(delete ob[aV(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,aD(r,e,aL),t.reject(r),e))})}function oE(e,t){delete ob[aV(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=aP,t.resolve()}function oD(e,t,r,n){ob[aV(e)]={app:e,resolve:r,reject:n},Object.defineProperty(ob[aV(e)],"promise",{get:t})}let ox=[];function o_(){return ox.filter(aF).map(aV)}function oS(){return ox.map(aV)}function oC(e){let t=az(ox,t=>aV(t)===e);return t?t.status:null}let oP=!1;function ok(e,t,r,n){var a,o;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(aS(39,!1));let t=["name","app","activeWhen","customProps"],r=Object.keys(e).reduce((e,r)=>t.indexOf(r)>=0?e:e.concat(r),[]);if(0!==r.length)throw Error(aS(38,!1,t.join(", "),r.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(aS(20,!1));let n=e=>"string"==typeof e||"function"==typeof e;if(!(n(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(n)))throw Error(aS(24,!1));if(!o$(e.customProps))throw Error(aS(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,t,r,n){if("string"!=typeof e||0===e.length)throw Error(aS(20,!1));if(!t)throw Error(aS(23,!1));if("function"!=typeof r)throw Error(aS(24,!1));if(!o$(n))throw Error(aS(22,!1))}(e,t,r,n),i.name=e,i.loadApp=t,i.activeWhen=r,i.customProps=n),i.loadApp="function"!=typeof(a=i.loadApp)?()=>Promise.resolve(a):a,i.customProps=i.customProps||{},s=(s=Array.isArray(o=i.activeWhen)?o:[o]).map(e=>"function"==typeof e?e:oA(e)),i.activeWhen=e=>s.some(t=>t(e)),i);if(oV||oP||(oP=!0,setTimeout(()=>{oV||console.warn(aS(1,!1))},5e3)),-1!==oS().indexOf(l.name))throw Error(aS(21,!1,l.name));ox.push(aH({loadErrorTime:null,status:aP,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),oo&&(oy(),oF())}function oT(e=window.location){return ox.filter(t=>t.activeWhen(e)).map(aV)}function oR(e){if(0===ox.filter(t=>aV(t)===e).length)throw Error(aS(25,!1,e));return(oo?oO(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=ox.map(aV).indexOf(e);ox.splice(t,1)})}function oO(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(aS(26,!1));let r=az(ox,t=>aV(t)===e);if(!r)throw Error(aS(27,!1,e));let n=ob[aV(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{oD(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,oN(r,n.resolve,n.reject)):e=new Promise((t,n)=>{oD(r,()=>e,t,n),oN(r,t,n)}),e}}function oN(e,t,r){Promise.resolve().then(()=>{if(az(oT(),t=>t===aV(e)))return oL()}).then(()=>aJ(e).then(ow).then(()=>{t(),setTimeout(()=>{oF()})})).catch(r)}function o$(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function oA(e,t){let r=function(e,t){let r=0,n=!1,a="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let r=e[t],a=n&&"/"===r;(!n&&":"===r||a)&&o(t)}return o(e.length),RegExp(a,"i");function o(o){let i=e.slice(r,o).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(a+=n?"[^/]+/?":i,o===e.length)if(n)t&&(a+="$");else{let e=t?"":".*";a="/"===a.charAt(a.length-1)?`${a}${e}$`:`${a}(/${e})?(#.*)?$`}n=!n,r=o}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let n=e.href.replace(t,"").replace(e.search,"").split("?")[0];return r.test(n)}}let oI=!1,oM=[],oj=oo&&window.location.href;function oL(){return oF()}function oF(e=[],t,r=!1){let n,a,o,i,s;if(oI)return new Promise((e,r)=>{oM.push({resolve:e,reject:r,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(n=[],a=[],o=[],i=[],s=(new Date).getTime(),ox.forEach(e=>{let t=e.status!==aL&&aB(e);switch(e.status){case aj:t&&s-e.loadErrorTime>=200&&o.push(e);break;case aP:case ak:t&&o.push(e);break;case aT:case aO:!t&&ob[aV(e)]?n.push(e):t&&i.push(e);break;case a$:t||a.push(e)}}),{appsToUnload:n,appsToUnmount:a,appsToLoad:o,appsToMount:i}),m,f=[],p=oj,h=oj=window.location.href;return oV?(oI=!0,m=l.concat(c,u,d),Promise.resolve().then(()=>(w(0===m.length?"before-no-app-change":"before-app-change",b(!0)),w("before-routing-event",b(!0,{cancelNavigation:g})),Promise.all(f).then(r=>{if(r.some(e=>e))return om.call(window.history,history.state,"",p.substring(location.origin.length)),oj=location.href,oI=!1,oF(e,t,!0);let n=l.map(ow),a=Promise.all(u.map(aJ).map(e=>e.then(ow)).concat(n));a.then(()=>{w("before-mount-routing-event",b(!0))},e=>{throw e});let o=c.map(e=>oa(e).then(e=>oB(e,a))),i=d.filter(e=>0>c.indexOf(e)).map(e=>oB(e,a));return a.catch(e=>{throw v(),e}).then(()=>(v(),Promise.all(o.concat(i)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(y).then(()=>{},e=>{throw e})))})))):(m=c,Promise.resolve().then(()=>Promise.all(c.map(oa)).then(v).then(()=>[]).catch(e=>{throw v(),e}).finally(()=>{})));function g(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(t.catch(e=>(console.warn(Error(aS(42,!1))),console.warn(e),!1)))}function y(){let t=o_();e.forEach(e=>e.resolve(t));try{w(0===m.length?"no-app-change":"app-change",b()),w("routing-event",b())}catch(e){setTimeout(()=>{throw e})}if(oI=!1,oM.length>0){let e=oM;oM=[],oF(e)}return t}function v(){r||(e.forEach(e=>{ou(e.eventArguments)}),ou(t))}function b(e=!1,r){let n={},a={[a$]:[],[aO]:[],[aP]:[],[aL]:[]};e?(c.concat(d).forEach((e,t)=>{i(e,a$)}),l.forEach(e=>{i(e,aP)}),u.forEach(e=>{i(e,aO)})):m.forEach(e=>{i(e)});let o={detail:{newAppStatuses:n,appsByNewStatus:a,totalAppChanges:m.length,originalEvent:null==t?void 0:t[0],oldUrl:p,newUrl:h}};return r&&aH(o.detail,r),o;function i(e,t){let r=aV(e);t=t||oC(r),n[r]=t,(a[t]=a[t]||[]).push(r)}}function w(e,t){r||window.dispatchEvent(new aw(`single-spa:${e}`,t))}}function oB(e,t){return aB(e)?aq(e).then(e=>t.then(()=>aB(e)?a0(e):e)):t.then(()=>e)}let oV=!1;function oU(e){oV=!0,oo&&(op(e),oF())}oo&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...ox]},reroute:oF,NOT_LOADED:aP,toLoadPromise:oa,toBootstrapPromise:aq,unregisterApplication:oR,getProfilerData:function(){return aY}});let oW={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",applicationError:"Application Error",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",clearDevOverrides:"Clear dev overrides",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",copied:"Copied!",copyToClipboard:"Copy to clipboard",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",navigateNonHttp:"Could not navigate to the requested page as it is not a safe URL",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",provisional:"Provisional",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",reload:"Reload",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",serverStartingUp:"The server is starting",serverStartingUpExplainer:"This can take a few minutes. OpenMRS will open automatically when the server is ready.",serverStartingUpSlowExplainer:"This is taking longer than usual. First startup after an upgrade can take 10 minutes or more. You can leave this page open.",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",somethingWentWrongTryReloading:"Something went wrong. Please try reloading.",toggleDevTools:"Toggle dev tools",unknown:"Unknown",viewSetupProgress:"View setup progress",waitingForServer:"Waiting for the server",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var oH=r(2635);let oz=oH.Ay.default||oH.Ay;function oK(e,t,r,n){return oz.t(t,{ns:e,defaultValue:r,...n})}function oG(e,t,r){return oW[e]?oK("core",e,t??oW[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function oZ(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=oY(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function oY(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function oq({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=oZ(e,t).replace(window.location.origin,""),a=new URL(n,window.location.origin);if("http:"!=a.protocol&&"https:"!=a.protocol)throw console.error(`Received request to navigate to non-http URL: ${a.toString()}`),Error(oG("navigateNonHttp"));n.startsWith(r)?ol(n):window.location.assign(n)}oz.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let oJ="openmrs:history";function oX(e){let t=JSON.parse(sessionStorage.getItem(oJ)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(oJ,JSON.stringify(t))}function oQ(){0===JSON.parse(sessionStorage.getItem(oJ)??"[]").length&&document.referrer&&oX(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=o0();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(oJ,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?o1({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&oX(window.location.href)})}function o0(){return JSON.parse(sessionStorage.getItem(oJ)??"[]")}function o1({toUrl:e}){let t=o0(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);oq({to:t[r]}),sessionStorage.setItem(oJ,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function o4(){sessionStorage.removeItem(oJ)}let o2="${openmrsSpaBase}/login",o3={redirectAuthFailure:{enabled:{_type:nr.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nr.String,_default:o2,_validators:[au.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:nr.Array,_default:[401],_elements:{_type:nr.Number,_validators:[au.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nr.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:nr.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function o6(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let o5="/ws/rest/v1",o9="/ws/fhir2/R4",o8=`${o5}/session`;function o7(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function ie(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let r=o7(e);t.headers||(t.headers={}),eg(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept;let n=!1;try{let e=new URL(r,window.location.href),t=new URL(o7(o5),window.location.href),a=e.pathname.replace(/\/{2,}/g,"/"),o=t.pathname.replace(/\/{2,}/g,"/");n=e.origin===t.origin&&(a===o||a.startsWith(`${o}/`))}catch{}if(n){let e=!1;for(let[r,n]of Object.entries(t.headers))"disable-www-authenticate"===r.toLowerCase()&&(void 0===n?delete t.headers[r]:e=!0);e||(t.headers["Disable-WWW-Authenticate"]="true")}if(e.startsWith(o9)){let e=new URL(r,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),r=e.toString())}let a=Error();return window.fetch(r,t).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await nG("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(r===o7(o8)||204===e.status)&&oq({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return(r===o7(o8)&&403===e.status||n.enabled&&n.errors.includes(e.status))&&(o4(),oq({to:n.url||e.headers.get("location")||o2}),!0!==t.rejectAuthFailure)?n.resolvePromise?Promise.resolve():new Promise(()=>{}):e.clone().text().then(t=>{let n=t;try{n=JSON.parse(t)}catch(e){}throw new it(r,e,n,a)},()=>{throw new it(r,e,null,a)})})}class it extends Error{constructor(e,t,r,n){super(),o6(this,"response",void 0),o6(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=t,this.stack=`Stacktrace for outgoing request:
13
13
  ${n.stack}
14
14
  Stacktrace for incoming response:
15
- ${this.stack}`}}let ir=V("session",{loaded:!1,session:null}),ia=0,io=null;function ii(){return io||(ir.getState().loaded&&ia>=Date.now()-6e4?null:ic())}function is(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=ii();return n?new Promise(e=>{let t=()=>{let t=ir.getState();t.loaded&&(a(),e(r(t.session)))},a=ir.subscribe(t);n.then(t,t)}):Promise.resolve(r(ir.getState().session))}function il(){return ii(),ir}function iu(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function ic(e,t){ia=Date.now(),o??(o=ia);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=iE(ie(o8,{headers:r,rejectAuthFailure:!0})),a=()=>{io===n&&(io=null)};return n.then(a,a),io=n,n}function id(){ir.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function im(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!G(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!G(n.privileges.find(t=>e===t.display))):(G(r)||console.error(`Could not understand privileges "${r}"`),!0))||!G(t.roles.find(e=>"System Developer"===e.display))}function ip(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(ir.getState()),e||(t=ir.subscribe(n))})}async function ih(){return(await is()).sessionLocation}async function ig(e,t){return iE(ie(o8,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function iy(e,t){return await ie(o8,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),ic()}async function iv(e,t,r){return r||(r=new AbortController),await ie(`${o5}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),ic()}async function ib(e,t=!1){let r=await ie(t?`${o8}?rememberMe=true`:o8,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await ic()).session:r.data}async function iw(){try{await ie(o8,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!iD(e))throw e}id(),await ic().catch(()=>{})}function iE(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};ir.setState(r,!0),t(r)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?r(ix(Error("The session endpoint did not respond with a session"))):r(ix(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(iD(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?ir.setState({loaded:!0,session:e.responseBody},!0):id(),t(ir.getState());return}(a=e)instanceof it&&502===a.response.status&&!ir.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(ix(e,!0)):(k(`Failed to fetch new session information: ${e}`),r(ix(e)))})})}function iD(e){return e instanceof it&&(401===e.response.status||403===e.response.status)}function ix(e,t=!1){return ir.getState().loaded||ir.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),ir.getState()}function i_(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}ir.subscribe(e=>{e.loaded&&e.session&&iu(e.session)});let iS={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function iC(){nB("@openmrs/esm-api",o3),ic()}let iP="import-map-override:",ik="import-map-overrides-disabled",iT="import-map-overrides:change",iR=!1,iO=null,iN=null;async function i$(){return iN??(iN=iA().then(({map:e,complete:t})=>(t||(iN=null),e))),iN}async function iA(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{if(a.src){let e=await fetch(a.src);if(!e.ok)throw Error(`Request for ${a.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else a.textContent&&t.push(JSON.parse(a.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:iI(t),complete:r}}function iI(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function iM(){let e={};try{let t=iV();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(iP)){let r=n.slice(iP.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function ij(){let e=await i$();return iR?iI([e,iO??iM()]):e}async function iL(){return i$()}async function iF(){return iR?iI([await i$(),iM()]):i$()}function iB(e){if(!iR)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(iP)){let t=localStorage.getItem(r);t&&(e[r.slice(iP.length)]=t)}}return{imports:e}}return iM()}function iV(){if(!iR)return[];try{let e=localStorage.getItem(ik);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function iU(e){return!!iR&&iV().includes(e)}function iW(e,t){if(!iR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(iP+e,t),window.dispatchEvent(new CustomEvent(iT))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function iH(e){if(!iR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(iP+e);let t=iV().filter(t=>t!==e);t.length>0?localStorage.setItem(ik,JSON.stringify(t)):localStorage.removeItem(ik),window.dispatchEvent(new CustomEvent(iT))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function iz(){if(!iR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(iP)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(ik),window.dispatchEvent(new CustomEvent(iT))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function iK(e){if(!iR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=iV().filter(t=>t!==e);t.length>0?localStorage.setItem(ik,JSON.stringify(t)):localStorage.removeItem(ik),window.dispatchEvent(new CustomEvent(iT))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let iG=!1;function iZ(){!iG&&(iG=!0,(iR="development"===window.spaEnv)&&(iO=iM()))}function iY(e){return e.replace(/[\/\-@]/g,"_")}async function iq(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([iJ(e,n?.importMap),new Promise((t,r)=>{o=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=iY(e),l=window[s];if(!("object"==typeof(a=l)&&null!==a&&"init"in a&&"function"==typeof a.init&&"get"in a&&"function"==typeof a.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function iJ(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=iY(e);if(!window[r]){let r=t??await iX();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let a=e in iB().imports;try{return await function(e){var t;let r=(t=window)[iQ]??(t[iQ]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&D({kind:"error",title:oG("scriptLoadingFailed","Error: Script failed to load"),description:oG("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:oG("resetOverrides","Reset overrides"),onActionButtonClick(){iz(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function iX(){return ij()}let iQ=Symbol.for("__openmrs_script_loading");function i0(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,"modals")&&(!e.modals||!Array.isArray(e.modals))||Object.hasOwn(e,"workspaces2")&&(!e.workspaces2||!Array.isArray(e.workspaces2))||Object.hasOwn(e,"workspaceWindows2")&&(!e.workspaceWindows2||!Array.isArray(e.workspaceWindows2))||Object.hasOwn(e,"workspaceGroups2")&&(!e.workspaceGroups2||!Array.isArray(e.workspaceGroups2)))}function i1(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&i0(t))}let i4="openmrs-routes:",i2="openmrs-routes:change",i3=!1,i6=null,i5=null;async function i9(){return i5??(i5=i8().then(({map:e,complete:t})=>(t||(i5=null),e))),i5}async function i8(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{let e;if(a.src){let t=await fetch(a.src);if(!t.ok)throw Error(`Request for ${a.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else a.textContent&&(e=JSON.parse(a.textContent));e&&i1(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:i7(t),complete:r}}function i7(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function se(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(i4)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(i4.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(i0(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(i0(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function st(){let e=await i9();return i3?i7([e,i6??await se()]):e}async function sr(){return i9()}async function sn(){return i3?i7([await i9(),await se()]):i9()}function sa(){if(!i3)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(i4)){let t=localStorage.getItem(r);t&&(e[r.slice(i4.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function so(e,t){if(!i3)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(i4+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!i0(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(i4+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(i4+e,JSON.stringify(t.toString()));else{if(!i0(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(i4+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(i2))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function si(e){if(!i3)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(i4+e),window.dispatchEvent(new CustomEvent(i2))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ss(){if(!i3)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(i4)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(i2))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let sl=null;function su(){return sl||(sl=(i3="development"===window.spaEnv)?se().then(e=>{i6=e}):Promise.resolve())}let sc=`${o5}/attachment`;function sd(e,t){return ie(`${sc}/${e}`,{signal:t.signal})}function sm(e,t,r,n){return ie(sf(e,t,n),{signal:r.signal})}function sf(e,t,r){return r?`${sc}?patient=${e}&encounter=${r}`:`${sc}?patient=${e}&includeEncounterless=${t}`}async function sp(e,t,r){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),r&&n.append("encounter",r),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),ie(`${sc}`,{method:"POST",body:n})}function sh(e,t){return ie(`${sc}/${e}`,{method:"DELETE",signal:t.signal})}async function sg(e,t){return e?(await ie(`${o9}/Patient/${e}`,t)).data:null}function sy(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function sv(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}function sb(e){return{uuid:e.uuid,display:e.display}}function sw(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return ie(`${o5}/location${n?"?"+n:""}`).then(e=>e.data.results.map(sb))}function sE(e){return{uuid:e.uuid,display:e.display,name:e.name}}let sD=`${o5}/visittype`;function sx(e=sD){return ie(e).then(e=>e.data.results.map(sE))}var s_=((er={}).NEWVISIT="startVisit",er.EDITVISIT="editVisit",er.LOADING="loadingVisit",er),sS=((en={}).NOTSTARTED="notStarted",en.ONGOING="ongoing",en);let sC="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))",sP=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function sk(){return H("visit",sP)}function sT(e,t){sk().setState({patientUuid:e,manuallySetVisitUuid:t})}function sR(e,t){return ie(`${o5}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function sO(e,t,r){return ie(`${o5}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function sN(e,t,r){return ie(`${o5}/visit?patient=${e}&v=${r??sC}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}sk().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class s${static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+s$.version}static addUnaryOp(e){return s$.max_unop_len=Math.max(e.length,s$.max_unop_len),s$.unary_ops[e]=1,s$}static addBinaryOp(e,t,r){return s$.max_binop_len=Math.max(e.length,s$.max_binop_len),s$.binary_ops[e]=t,r?s$.right_associative.add(e):s$.right_associative.delete(e),s$}static addIdentifierChar(e){return s$.additional_identifier_chars.add(e),s$}static addLiteral(e,t){return s$.literals[e]=t,s$}static removeUnaryOp(e){return delete s$.unary_ops[e],e.length===s$.max_unop_len&&(s$.max_unop_len=s$.getMaxKeyLen(s$.unary_ops)),s$}static removeAllUnaryOps(){return s$.unary_ops={},s$.max_unop_len=0,s$}static removeIdentifierChar(e){return s$.additional_identifier_chars.delete(e),s$}static removeBinaryOp(e){return delete s$.binary_ops[e],e.length===s$.max_binop_len&&(s$.max_binop_len=s$.getMaxKeyLen(s$.binary_ops)),s$.right_associative.delete(e),s$}static removeAllBinaryOps(){return s$.binary_ops={},s$.max_binop_len=0,s$}static removeLiteral(e){return delete s$.literals[e],s$}static removeAllLiterals(){return s$.literals={},s$}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 s$(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 s$.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!s$.binary_ops[String.fromCharCode(e)]||s$.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return s$.isIdentifierStart(e)||s$.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(s$.hooks[e]){let r={context:this,node:t};return s$.hooks.run(e,r),r.node}return t}searchHook(e){if(s$.hooks[e]){let t={context:this};return s$.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===s$.SPACE_CODE||e===s$.TAB_CODE||e===s$.LF_CODE||e===s$.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:s$.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===s$.SEMCOL_CODE||r===s$.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,s$.max_binop_len),t=e.length;for(;t>0;){if(s$.binary_ops.hasOwnProperty(e)&&(!s$.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!s$.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,a,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(a={value:t,prec:s$.binaryPrecedence(t),right_a:s$.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=s$.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:s$.right_associative.has(t)},l=t;let s=e=>a.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)i=n.pop(),t=n.pop().value,o=n.pop(),e={type:s$.BINARY_EXP,operator:t,left:o,right:i},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(a,e)}for(s=n.length-1,e=n[s];s>1;)e={type:s$.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,s$.isDecimalDigit(e)||e===s$.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===s$.SQUOTE_CODE||e===s$.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===s$.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,s$.max_unop_len)).length;r>0;){if(s$.unary_ops.hasOwnProperty(t)&&(!s$.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!s$.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:s$.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}s$.isIdentifierStart(e)?(n=this.gobbleIdentifier(),s$.literals.hasOwnProperty(n.name)?n={type:s$.LITERAL,value:s$.literals[n.name],raw:n.name}:n.name===s$.this_str&&(n={type:s$.THIS_EXP})):e===s$.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===s$.PERIOD_CODE||t===s$.OBRACK_CODE||t===s$.OPAREN_CODE||t===s$.QUMARK_CODE;){let r;if(t===s$.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==s$.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===s$.OBRACK_CODE?((e={type:s$.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==s$.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===s$.OPAREN_CODE?e={type:s$.CALL_EXP,arguments:this.gobbleArguments(s$.CPAREN_CODE),callee:e}:(t===s$.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:s$.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;s$.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===s$.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);s$.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));s$.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);s$.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,s$.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===s$.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===s$.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:s$.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:s$.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(s$.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,s$.isIdentifierPart(e))this.index++;else break;return{type:s$.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){r=!0,this.index++,e===s$.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===s$.COMMA_CODE){if(this.index++,++n!==t.length){if(e===s$.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===s$.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==s$.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(s$.CPAREN_CODE);if(this.code===s$.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:s$.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:s$.ARRAY_EXP,elements:this.gobbleArguments(s$.CBRACK_CODE)}}}Object.assign(s$,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(s$),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"}),s$.max_unop_len=s$.getMaxKeyLen(s$.unary_ops),s$.max_binop_len=s$.getMaxKeyLen(s$.binary_ops);let sA=e=>new s$(e).parse(),sI=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(s$).filter(e=>!sI.includes(e)&&void 0===sA[e]).forEach(e=>{sA[e]=s$[e]}),sA.Jsep=s$,sA.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let sM="ArrowFunctionExpression",sj={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)}},sL={...sj,Promise};function sF(e,t={}){return sz(e,t,sZ)}async function sB(e,t={}){return sK(e,t,sZ)}function sV(e,t={}){return sz(e,t,sY)}function sU(e,t={}){return sK(e,t,sY)}function sW(e,t={}){return sz(e,t,sq)}function sH(e,t={}){return sK(e,t,sq)}function sz(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=s1(t,sj),a=sJ("string"==typeof e?sA(e):e,n);if(r(a))return a;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function sK(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=s1(t,sL);return Promise.resolve(sJ("string"==typeof e?sA(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function sG(e){return sA(e)}function sZ(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function sY(e){return"boolean"==typeof e}function sq(e){return"number"==typeof e}function sJ(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,m,f,p,h=e,g=t;let y=sJ(h.argument,g);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var v=e,b=t;switch(v.operator){case"&&":return sJ(v.left,b)&&sJ(v.right,b);case"||":return sJ(v.left,b)||sJ(v.right,b);case"??":return sJ(v.left,b)??sJ(v.right,b)}let w=sJ(v.left,b),E=sJ(v.right,b);switch(v.operator){case"+":return w+E;case"-":return w-E;case"*":return w*E;case"/":return w/E;case"%":return w%E;case"**":return w**E;case"==":return w==E;case"===":return w===E;case"!=":return w!=E;case"!==":return w!==E;case">":return w>E;case">=":return w>=E;case"<":return w<E;case"<=":return w<=E;case"in":return w in E;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,sJ(r.test,n)?sJ(r.consequent,n):sJ(r.alternate,n);case"CallExpression":return s3(sQ(e,t));case"ArrowFunctionExpression":let D;return a=e,o=t,D=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<D.length)throw`Required argument(s) ${D.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(D.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return sJ(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return s3(s0(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(s6(s));case"SequenceExpression":let x;return l=e,u=t,(x=l.expressions.map(s6(u)))[x.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(s6(S));switch(_.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${_.callee.name}`}}if(_.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return e.value;case"Identifier":return c=e,d=t,(s5(c.name),d.variables&&Object.hasOwn(d.variables,c.name))?d.variables[c.name]:Object.hasOwn(d.globals,c.name)?d.globals[c.name]:void 0;case"TemplateLiteral":let C,P;return m=e,f=t,C=m.expressions?.map(s6(f))??[],(P=m.quasis?.map(s6(f))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+P.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function sX(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return sX(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function sQ(e,t){let r=s2(e.callee,t);if(r===s4||e.optional&&null==r)return s4;let n=e.arguments?.map(s6(t));if(r){if("function"!=typeof r)throw`${s7(e.callee)} is not a function`}else throw`No function named ${s7(e.callee)} is defined in this context`;return r(...n)}function s0(e,t){let r=s2(e.object,t);if(r===s4||e.optional&&null==r)return s4;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${s8(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=sX(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${s8(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof r&&"function"!=typeof r&&"string"!=typeof r&&"number"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;let n=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(sJ(e.property,t)):function(e){if("Identifier"!==e.type)throw`VisitMemberExpression does not support a property of type '${e.type}'`;return e.name}(e.property);s5(n),function(e,t){if(s9.has(String(t)))return;let r=Object(e);for(;null!==r;){if(Object.hasOwn(r,t)){if(r===Object.prototype||r===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}r=Object.getPrototypeOf(r)}}(r,n);let a=r[n];return"function"==typeof a?a.bind(r):a}function s1(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}sA.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:sM,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=sM,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),sA.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),sA.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(n+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(n+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(i===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var a,o,i;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;a=this.code,o=u,95===a||o.some(([e,t])=>a>=e&&a<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&r.call(this,n)})}}),sA.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,a=this.expr.slice(r,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{n=new RegExp(a,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),sA.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),sA.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",a="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:a,cooked:n},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(a+=i,i=this.expr.charAt(++this.index),a+=i,i){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=i}else n+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),sA.addBinaryOp("in",7),sA.addBinaryOp("??",1);let s4=Symbol("optional chain short-circuited");function s2(e,t){switch(e.type){case"MemberExpression":return s0(e,t);case"CallExpression":return sQ(e,t);default:return sJ(e,t)}}function s3(e){return e===s4?void 0:e}function s6(e){return function(t){return null===t?null:sJ(t,e)}}function s5(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let s9=new Set(["toString","valueOf","hasOwnProperty"]);function s8(e,t){try{return sX(e,t)}catch{return"<computed>"}}function s7(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function le(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...sL},isLocalExpression:!1,variables:new Set};return lt("string"==typeof e?sA(e):e,t),[...t.variables]}function lt(e,t){switch(e.type){case"UnaryExpression":return n=e,a=t,lt(n.argument,a);case"BinaryExpression":return o=e,i=t,[lt(o.left,i),lt(o.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[lt(s.consequent,l),lt(s.test,l),lt(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=lt(u.callee,c),u.arguments?.map(lr(c)),r;case"ArrowFunctionExpression":var n,a,o,i,s,l,u,c,d,m,f,p,h,g,y,v,b=e,w=t;let E={...w};E.isLocalExpression=!0;let D=b.params?.map(lr(E))??[],x=lt(b.body,E)??[];if(x&&Array.isArray(x))for(let e of x)D.includes(e)||w.variables.add(e);return;case"MemberExpression":var _=e,S=t;if(lt(_.object,S),_.computed)return void lt(_.property,S);let C={...S};C.isLocalExpression=!0,lt(_.property,C);return;case"ArrayExpression":return d=e,m=t,void d.elements?.map(lr(m));case"SequenceExpression":return f=e,p=t,void f.expressions?.map(lr(p));case"NewExpression":return h=e,g=t,void h.arguments?.map(lr(g));case"Literal":case"TemplateElement":return;case"Identifier":var P=e,k=t;if(!(P.name in k.globals))if(k.isLocalExpression)return P.name;else k.variables.add(P.name);return;case"TemplateLiteral":return y=e,v=t,void(y.expressions?.map(lr(v)),y.quasis?.map(lr(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function lr(e){return function(t){return null===t?null:lt(t,e)}}let ln=H("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function la(e,t,r){ln.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function lo(){let e=ln.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function li(e){return ln.getState().flags[e].enabled}function ls(e,t){ln.subscribe(r=>{t(r.flags[e].enabled)})}function ll(e,t){ln.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}ln.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var lu=tV(function(e,t,r){t$(e,t,r)});let lc=V("extensionsInternal",{slots:{},extensions:{}}),ld=V("extensionRenderings",{renderings:new Map}),lm=()=>H("extensionsInternal",{slots:{},extensions:{}}),lf=()=>H("extensionRenderings",{renderings:new Map});function lp(e){let t=lc.getState(),r=e(t);r!==t&&lc.setState(r)}let lh=null,lg=null;function ly(){let e=ld.getState();return lh&&e===lg||(lh=new Map(e.renderings),lg=e,function(e){for(let t of(lP.clear(),e.values()))lT(t,1);lk=!0}(lh)),lh}function lv(e){lg={renderings:e},ld.setState(lg,!0)}function lb(e){let t=ly();t.has(e.renderingId)||(t.set(e.renderingId,e),lT(e,1),lv(t))}function lw(e){let t=ly(),r=t.get(e);r&&(t.delete(e),lT(r,-1),lv(t))}let lE=()=>H("extensions",{slots:{}}),lD=0,lx=new Set;function l_(e){lD++;try{return e()}finally{if(0==--lD&&lx.size>0){let e=Array.from(lx);for(let t of(lx.clear(),e))lS(t)}}}function lS(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function lC(e){lD>0?lx.add(e):lS(e)}let lP=new Map,lk=!1;function lT(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=lP.get(r);if(!n){if(t<0)return;lP.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),lk=!0;return}n.count+=t,n.count<1&&(lP.delete(r),lk=!0)}function lR(){var e,t;if(ly(),!lk)return;lk=!1;let r=Array.from(lP.values(),({record:e})=>e);r.sort(lO),e=nm.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===lO(e,t[r]))||nm.setState({mountedExtensions:r})}function lO(e,t){return lN(e.slotName,t.slotName)||lN(e.extensionId,t.extensionId)||lN(e.slotModuleName,t.slotModuleName)||lN(e.extensionModuleName,t.extensionModuleName)}function lN(e,t){return e===t?0:e<t?-1:1}lR(),ld.subscribe(()=>lC(lR));let l$=lm(),lA=lE(),lI=np(),lM=ny(),lj=new Set,lL=!1;function lF(e){if(null===e)lj=null;else if(null!==lj)for(let t of e)lj.add(t);lC(lB)}function lB(){if(!lL){lL=!0;try{for(let e=1;;e++){let t=lj;if(null!==t&&0===t.size)return;lj=new Set;try{!function(e,t,r,n,a,o=null){let i=lA.getState().slots,s={},l=!1,u=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,c]of Object.entries(e.slots)){let d=i[n];if(d&&o&&!o.has(n)){s[n]=d;continue}let{config:m}=ng(t,c.name),f=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=l$.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=lq(a),u=lq(t),c=new Map(s.map(e=>[e,function(e,t,r,n){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==r)return 1e3+r;let t=n.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[lW(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(r,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=nv(n,e,l),u=nb(r,e,l),c=u?lu({},i,u):i,d=lW(l),m=t.extensions[d];if(m){let e=c?.["Display conditions"]?.privileges??m.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!im(e,o.user))||m.featureFlag&&!a.includes(m.featureFlag))continue;s.push({id:l,name:d,moduleName:m.moduleName,config:c,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:c?.["Display conditions"]?.expression||m.displayExpression})}}return s}(n,e,m,r,u,a.session);d&&d.moduleName===c.moduleName&&rx(d.candidateExtensions,f)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:f},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&lA.setState({slots:s})}(l$.getState(),lI.getState(),lM.getState(),ln.getState(),ir.getState(),t)}catch(e){throw lj=null===t||null===lj?null:new Set([...t,...lj]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{lL=!1}}}function lV(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function lU(e,t){return{moduleName:t,name:e,attachedIds:[]}}function lW(e){let[t]=e.split("#");return t}function lH(e,t){let r=lW(t);return e.extensions[r]}function lz(e){return lH(l$.getState(),e)}l$.subscribe((e,t)=>{lF(e.extensions!==t.extensions?null:lV(e.slots,t.slots))}),lI.subscribe((e,t)=>{lF(lV(e.slots,t.slots))}),lM.subscribe((e,t)=>{lF(lV(e.configs,t.configs))}),ln.subscribe(()=>lF(null)),ir.subscribe(()=>lF(null)),lF(null);let lK=e=>lp(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function lG(e,t){lp(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...lU(e),attachedIds:[t]}}}})}function lZ(e,t){lp(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function lY(e){lp(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function lq(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function lJ(e,t){return function(e,t,r=null,n){let a;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;a??(a=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!sV(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(lX(e),t,ir.getState().session,e)}function lX(e){return lA.getState().slots[e]?.candidateExtensions??[]}let lQ=(e,t)=>l$.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let a=lU(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),l0=()=>{lj=null,lp(()=>({slots:{},extensions:{}})),lf().setState({renderings:new Map}),lA.setState({slots:{}})},l1=V("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function l4({name:e,basePath:t,mode:r,componentContext:n,state:a}){l1.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function l2(e){l1.getState().slotName===e&&l1.setState(l1.getInitialState(),!0)}let l3=V("modalRegistry",{modals:{}});function l6(e){l3.setState(t=>(t.modals[e.name]=e,t))}function l5(e){let t=l3.getState().modals[e];if(!t){let r=lz(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),l6(t))}return t}let l9=V("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function l8(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=l9.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function l7(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=l9.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function ue(e){let{openedWindows:t}=l9.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function ut(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=l9.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}l9.setState({registeredGroupsByName:n})}function ur(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=l9.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}l9.setState({registeredWindowsByName:n})}function un(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=l9.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}l9.setState({registeredWorkspacesByName:n})}let ua=0,uo=null,ui={bootstrap:15e3,mount:15e3,unmount:15e3};function us(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(ui).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=ui[n],i=Array.isArray(a)?a:[a],s=e=>i.reduce((t,a,o)=>t.then(()=>{let t=a(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${o} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let a,i=new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${o}ms`)),o)});return Promise.race([s(e),i]).finally(()=>clearTimeout(a)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function ul(e,t){var r,n;let a,o,i,s,l,u=await (uo??(uo=new Promise((e,t)=>{a2({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),a2))),uo),c={...t},d=(a=c,o=!1,{retarget:e=>a={...e},release:i=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(a),onSettled(e,t){switch(e){case"bootstrap":t&&i();return;case"mount":o||(o=t);return;case"unmount":(t||o)&&i();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>us(e,r)):us(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function uu(){return uc}function uc(e,t){let r,n=ul(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function ud(e,t,r,n,a=e=>e,o={}){let i=lW(n),s=lz(n),l=null;if(e){let u;if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:d,load:m}=s,f=ua++,p=`${t}/${n}-${f}`;e.dataset.extensionRenderingId=p;let h=e=>{try{lw(p)}catch(t){console.error(e,t)}};try{lb({renderingId:p,extensionName:i,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{u=await m()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await ul(a({...u,name:`${t}/${i}-${f}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var um=r(2153),uf=r.n(um);let up=(0,um.createContext)({moduleName:"",featureName:""});function uh({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,um.useEffect)(()=>{a.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${a.href}'`),a.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),uf().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),oq({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:oZ(e,t),...a},n)}let ug=({state:e,children:t,...r})=>{let{extension:n}=(0,um.useContext)(up),a=(0,um.useRef)(null),o=(0,um.useRef)(Promise.resolve()),i=(0,um.useRef)(!1),s=(0,um.useRef)(!1),l=(0,um.useRef)(e),u=(0,um.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,um.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(a.current?.getStatus()==="MOUNTED"&&a.current.update)return a.current.update({...t})}).catch(e=>{let t=a.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,um.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,ud(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,a.current=t,i.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,um.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,um.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?uf().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function uy(e){let t=(0,um.useRef)(e);return O(t.current,e)||(t.current=e),t.current}function uv(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,a]of Object.entries(t)){let t=function(...t){e.setState(e=>a(e,...t))};r[n]=t}return r}let ub=e=>e;function uw(e,t=ub,r){let n=(0,um.useCallback)(t=>e.subscribe(t),[e]),a=(0,um.useCallback)(()=>t(e.getState()),[e,t]),o=(0,um.useSyncExternalStore)(n,a,a),i=(0,um.useMemo)(()=>r?uv(e,r):null,[e,r]);return(0,um.useMemo)(()=>i?{...o,...i}:o,[o,i])}function uE(e,t){return uw(e,ub,t)}function uD(e){return function(t){let r=(0,um.useCallback)(t=>e.subscribe(t),[]),n=(0,um.useCallback)(()=>e.getState(),[]),a=(0,um.useSyncExternalStore)(r,n,n),o=(0,um.useMemo)(()=>t?uv(e,t):null,[t]);return(0,um.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let ux=[];Object.freeze(ux);let u_={candidateExtensions:ux};Object.freeze(u_);let uS=e=>{let t=(0,um.useCallback)(t=>t.slots?.[e]??u_,[e]);return uw(lE(),t)},uC=e=>e.session;function uP(e,t){let{candidateExtensions:r}=uS(e),n=uw(ir,uC),a=uy(t);return(0,um.useMemo)(()=>lJ(e,a),[e,a,n,r])}function uk(e,t){let{moduleName:r}=(0,um.useContext)(up);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,um.useEffect)(()=>{lQ(r,e)},[r,e]),{extensions:uP(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function uT(e){return e}function uR({name:e,extensionSlotName:t,select:r=uT,children:n,state:a,style:o,...i}){if(n&&a)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,um.useRef)(null),{extensions:u,extensionSlotModuleName:c}=uk(s,a),d=(0,um.useMemo)(()=>r(u),[r,u]),m=(0,um.useMemo)(()=>{if("function"==typeof n&&!uf().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return uf().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i},s&&d?.map((e,t)=>uf().createElement(up.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof n?n:null)??uf().createElement(ug,{state:a}))))}var uO=r(5338);function uN(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function u$(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?uN(Object(r),!0).forEach(function(t){var n,a,o;n=e,a=t,o=r[t],a in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):uN(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function uA(e){return(uA="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 uI(e){return(uI="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 uM(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(uI(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(uI(e)));return e}}var uj=null;try{uj=require("react").createContext()}catch(e){}var uL={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,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function uB(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=uH(e,t,function(){r(this)}),i=uM(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,a=e.domElement,o=t[r];if("function"!=typeof o)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(n),i;case"hydrateRoot":return o(a,n);default:return o(n,a),null}}({elementToRender:o,domElement:i,reactDom:uW(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function uV(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():uW(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function uU(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=uH(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=uM(e,t)();uW(e).render(n,o)}})}function uW(e){return e.ReactDOMClient||e.ReactDOM}function uH(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=uj?e.React.createElement(uj.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),a=e.React.createElement(e.errorBoundaryClass,t,a)),a=e.React.createElement(e.SingleSpaRoot,u$(u$({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),a)}var uz=r(6045),uK=r(5361),uG=r.n(uK),uZ=r(8642);let uY={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},uq=new Map;(0,uZ.initCache)(uq);let uJ={errorRetryCount:3,fetcher:ie,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof it){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>uq};function uX(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},uY,e),r={...uJ,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=uf().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return uf().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=uf().createElement(um.Suspense,{fallback:null},uf().createElement(uK.SWRConfig,{value:r},uf().createElement(up.Provider,{value:this.state.config},t.disableTranslations?uf().createElement(e,this.props):uf().createElement(uz.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},uf().createElement(e,this.props)))));return t.strictMode&&uf().StrictMode?uf().createElement(uf().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function uQ(e,t){return function(e){if("object"!==uA(e))throw Error("single-spa-react requires a configuration object");var t,r=u$(u$({},uL),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!uj&&r.React.createContext&&(uj=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:uF.bind(null,r),mount:uB.bind(null,r),unmount:uV.bind(null,r)};return r.parcelCanUpdate&&(n.update=uU.bind(null,r)),n}({React:uf(),ReactDOMClient:uO,rootComponent:uX(t)(e)})}function u0(e,t){return()=>e().then(({default:e})=>uQ(e,t))}function u1(e,t){return()=>Promise.resolve(uQ(e,t))}let u4=u0,u2=I()(()=>({}));W("openmrs-app-context",u2);let u3={};function u6(e,t=e=>e){let r=u2.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function u5(e,t){u2.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function u9(e){return null===e?null:Object.freeze(Object.assign({},e))}let u8=new Map;function u7(e,t){let r=(0,um.useRef)(t??{}),n=(0,um.useRef)(t=>u5(e,t)),a=(0,um.useRef)(Symbol());return(0,um.useEffect)(()=>{let r=t??{},n=a.current;return null===u6(e)?!function(e,t=u3){u2.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===u3?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),u5(e,()=>r)),u8.set(e,n),()=>{u8.get(e)===n&&(u2.setState(t=>(e in t&&delete t[e],t)),u8.delete(e))}},[e]),(0,um.useEffect)(()=>{let n=t??{};O(r.current,n)||(u5(e,()=>n),r.current=n)},[t]),n.current}function ce({namespace:e,value:t}){return u7(e,t),null}let ct=({children:e,value:t,fallback:r})=>t?uf().createElement(uf().Fragment,null,e):r?uf().createElement(uf().Fragment,null,r):null;function cr(){let e=(0,um.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,um.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function cn(e,t=e=>e??{}){let[r,n]=(0,um.useState)(()=>{if(ca(e))return;let r=u6(e);if(null!==r)return t?t(r):r});return(0,um.useEffect)(()=>{if(ca(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,um.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>O(e,r)?e:r)})(u9(a=u6(e))),u2.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(u9(n)))})},[e,t]),r}function ca(e){return"string"!=typeof e||0===e.trim().length}function co(e){let t=uP(e);return(0,um.useMemo)(()=>t.map(e=>e.id),[t])}function ci(e){return uS(e).candidateExtensions}function cs(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=uG()(e?sf(e,t,r):null,ie);return(0,um.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function cl(e){(0,um.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let cu={},cc=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let ir=V("session",{loaded:!1,session:null}),ia=0,io=null;function ii(){return io||(ir.getState().loaded&&ia>=Date.now()-6e4?null:ic())}function is(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=ii();return n?new Promise(e=>{let t=()=>{let t=ir.getState();t.loaded&&(a(),e(r(t.session)))},a=ir.subscribe(t);n.then(t,t)}):Promise.resolve(r(ir.getState().session))}function il(){return ii(),ir}function iu(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function ic(e,t){ia=Date.now(),o??(o=ia);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=iE(ie(o8,{headers:r,rejectAuthFailure:!0})),a=()=>{io===n&&(io=null)};return n.then(a,a),io=n,n}function id(){ir.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function im(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!G(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!G(n.privileges.find(t=>e===t.display))):(G(r)||console.error(`Could not understand privileges "${r}"`),!0))||!G(t.roles.find(e=>"System Developer"===e.display))}function ip(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(ir.getState()),e||(t=ir.subscribe(n))})}async function ih(){return(await is()).sessionLocation}async function ig(e,t){return iE(ie(o8,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function iy(e,t){return await ie(o8,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),ic()}async function iv(e,t,r){return r||(r=new AbortController),await ie(`${o5}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),ic()}async function ib(e,t=!1){let r=await ie(t?`${o8}?rememberMe=true`:o8,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await ic()).session:r.data}async function iw(){try{await ie(o8,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!iD(e))throw e}id(),await ic().catch(()=>{})}function iE(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};ir.setState(r,!0),t(r)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?r(ix(Error("The session endpoint did not respond with a session"))):r(ix(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(iD(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?ir.setState({loaded:!0,session:e.responseBody},!0):id(),t(ir.getState());return}(a=e)instanceof it&&502===a.response.status&&!ir.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(ix(e,!0)):(k(`Failed to fetch new session information: ${e}`),r(ix(e)))})})}function iD(e){return e instanceof it&&(401===e.response.status||403===e.response.status)}function ix(e,t=!1){return ir.getState().loaded||ir.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),ir.getState()}function i_(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}ir.subscribe(e=>{e.loaded&&e.session&&iu(e.session)});let iS={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function iC(){nB("@openmrs/esm-api",o3),ic()}let iP="import-map-override:",ik="import-map-overrides-disabled",iT="import-map-overrides:change",iR=!1,iO=null,iN=null;async function i$(){return iN??(iN=iA().then(({map:e,complete:t})=>(t||(iN=null),e))),iN}async function iA(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{if(a.src){let e=await fetch(a.src);if(!e.ok)throw Error(`Request for ${a.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else a.textContent&&t.push(JSON.parse(a.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:iI(t),complete:r}}function iI(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function iM(){let e={};try{let t=iV();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(iP)){let r=n.slice(iP.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function ij(){let e=await i$();return iR?iI([e,iO??iM()]):e}async function iL(){return i$()}async function iF(){return iR?iI([await i$(),iM()]):i$()}function iB(e){if(!iR)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(iP)){let t=localStorage.getItem(r);t&&(e[r.slice(iP.length)]=t)}}return{imports:e}}return iM()}function iV(){if(!iR)return[];try{let e=localStorage.getItem(ik);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function iU(e){return!!iR&&iV().includes(e)}function iW(e,t){if(!iR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(iP+e,t),window.dispatchEvent(new CustomEvent(iT))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function iH(e){if(!iR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(iP+e);let t=iV().filter(t=>t!==e);t.length>0?localStorage.setItem(ik,JSON.stringify(t)):localStorage.removeItem(ik),window.dispatchEvent(new CustomEvent(iT))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function iz(){if(!iR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(iP)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(ik),window.dispatchEvent(new CustomEvent(iT))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function iK(e){if(!iR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=iV().filter(t=>t!==e);t.length>0?localStorage.setItem(ik,JSON.stringify(t)):localStorage.removeItem(ik),window.dispatchEvent(new CustomEvent(iT))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let iG=!1;function iZ(){!iG&&(iG=!0,(iR="development"===window.spaEnv)&&(iO=iM()))}function iY(e){return e.replace(/[\/\-@]/g,"_")}async function iq(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([iJ(e,n?.importMap),new Promise((t,r)=>{o=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=iY(e),l=window[s];if(!("object"==typeof(a=l)&&null!==a&&"init"in a&&"function"==typeof a.init&&"get"in a&&"function"==typeof a.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function iJ(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=iY(e);if(!window[r]){let r=t??await iX();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let a=e in iB().imports;try{return await function(e){var t;let r=(t=window)[iQ]??(t[iQ]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&D({kind:"error",title:oG("scriptLoadingFailed","Error: Script failed to load"),description:oG("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:oG("resetOverrides","Reset overrides"),onActionButtonClick(){iz(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function iX(){return ij()}let iQ=Symbol.for("__openmrs_script_loading");function i0(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,"modals")&&(!e.modals||!Array.isArray(e.modals))||Object.hasOwn(e,"workspaces2")&&(!e.workspaces2||!Array.isArray(e.workspaces2))||Object.hasOwn(e,"workspaceWindows2")&&(!e.workspaceWindows2||!Array.isArray(e.workspaceWindows2))||Object.hasOwn(e,"workspaceGroups2")&&(!e.workspaceGroups2||!Array.isArray(e.workspaceGroups2)))}function i1(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&i0(t))}let i4="openmrs-routes:",i2="openmrs-routes:change",i3=!1,i6=null,i5=null;async function i9(){return i5??(i5=i8().then(({map:e,complete:t})=>(t||(i5=null),e))),i5}async function i8(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{let e;if(a.src){let t=await fetch(a.src);if(!t.ok)throw Error(`Request for ${a.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else a.textContent&&(e=JSON.parse(a.textContent));e&&i1(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:i7(t),complete:r}}function i7(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function se(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(i4)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(i4.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(i0(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(i0(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function st(){let e=await i9();return i3?i7([e,i6??await se()]):e}async function sr(){return i9()}async function sn(){return i3?i7([await i9(),await se()]):i9()}function sa(){if(!i3)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(i4)){let t=localStorage.getItem(r);t&&(e[r.slice(i4.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function so(e,t){if(!i3)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(i4+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!i0(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(i4+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(i4+e,JSON.stringify(t.toString()));else{if(!i0(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(i4+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(i2))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function si(e){if(!i3)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(i4+e),window.dispatchEvent(new CustomEvent(i2))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ss(){if(!i3)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(i4)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(i2))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let sl=null;function su(){return sl||(sl=(i3="development"===window.spaEnv)?se().then(e=>{i6=e}):Promise.resolve())}let sc=`${o5}/attachment`;function sd(e,t){return ie(`${sc}/${e}`,{signal:t.signal})}function sm(e,t,r,n){return ie(sf(e,t,n),{signal:r.signal})}function sf(e,t,r){return r?`${sc}?patient=${e}&encounter=${r}`:`${sc}?patient=${e}&includeEncounterless=${t}`}async function sp(e,t,r){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),r&&n.append("encounter",r),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),ie(`${sc}`,{method:"POST",body:n})}function sh(e,t){return ie(`${sc}/${e}`,{method:"DELETE",signal:t.signal})}async function sg(e,t){return e?(await ie(`${o9}/Patient/${e}`,t)).data:null}function sy(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function sv(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}function sb(e){return{uuid:e.uuid,display:e.display}}function sw(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return ie(`${o5}/location${n?"?"+n:""}`).then(e=>e.data.results.map(sb))}function sE(e){return{uuid:e.uuid,display:e.display,name:e.name}}let sD=`${o5}/visittype`;function sx(e=sD){return ie(e).then(e=>e.data.results.map(sE))}var s_=((er={}).NEWVISIT="startVisit",er.EDITVISIT="editVisit",er.LOADING="loadingVisit",er),sS=((en={}).NOTSTARTED="notStarted",en.ONGOING="ongoing",en);let sC="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))",sP=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function sk(){return H("visit",sP)}function sT(e,t){sk().setState({patientUuid:e,manuallySetVisitUuid:t})}function sR(e,t){return ie(`${o5}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function sO(e,t,r){return ie(`${o5}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function sN(e,t,r){return ie(`${o5}/visit?patient=${e}&v=${r??sC}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}sk().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class s${static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+s$.version}static addUnaryOp(e){return s$.max_unop_len=Math.max(e.length,s$.max_unop_len),s$.unary_ops[e]=1,s$}static addBinaryOp(e,t,r){return s$.max_binop_len=Math.max(e.length,s$.max_binop_len),s$.binary_ops[e]=t,r?s$.right_associative.add(e):s$.right_associative.delete(e),s$}static addIdentifierChar(e){return s$.additional_identifier_chars.add(e),s$}static addLiteral(e,t){return s$.literals[e]=t,s$}static removeUnaryOp(e){return delete s$.unary_ops[e],e.length===s$.max_unop_len&&(s$.max_unop_len=s$.getMaxKeyLen(s$.unary_ops)),s$}static removeAllUnaryOps(){return s$.unary_ops={},s$.max_unop_len=0,s$}static removeIdentifierChar(e){return s$.additional_identifier_chars.delete(e),s$}static removeBinaryOp(e){return delete s$.binary_ops[e],e.length===s$.max_binop_len&&(s$.max_binop_len=s$.getMaxKeyLen(s$.binary_ops)),s$.right_associative.delete(e),s$}static removeAllBinaryOps(){return s$.binary_ops={},s$.max_binop_len=0,s$}static removeLiteral(e){return delete s$.literals[e],s$}static removeAllLiterals(){return s$.literals={},s$}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 s$(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 s$.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!s$.binary_ops[String.fromCharCode(e)]||s$.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return s$.isIdentifierStart(e)||s$.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(s$.hooks[e]){let r={context:this,node:t};return s$.hooks.run(e,r),r.node}return t}searchHook(e){if(s$.hooks[e]){let t={context:this};return s$.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===s$.SPACE_CODE||e===s$.TAB_CODE||e===s$.LF_CODE||e===s$.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:s$.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===s$.SEMCOL_CODE||r===s$.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,s$.max_binop_len),t=e.length;for(;t>0;){if(s$.binary_ops.hasOwnProperty(e)&&(!s$.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!s$.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,a,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(a={value:t,prec:s$.binaryPrecedence(t),right_a:s$.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=s$.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:s$.right_associative.has(t)},l=t;let s=e=>a.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)i=n.pop(),t=n.pop().value,o=n.pop(),e={type:s$.BINARY_EXP,operator:t,left:o,right:i},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(a,e)}for(s=n.length-1,e=n[s];s>1;)e={type:s$.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,s$.isDecimalDigit(e)||e===s$.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===s$.SQUOTE_CODE||e===s$.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===s$.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,s$.max_unop_len)).length;r>0;){if(s$.unary_ops.hasOwnProperty(t)&&(!s$.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!s$.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:s$.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}s$.isIdentifierStart(e)?(n=this.gobbleIdentifier(),s$.literals.hasOwnProperty(n.name)?n={type:s$.LITERAL,value:s$.literals[n.name],raw:n.name}:n.name===s$.this_str&&(n={type:s$.THIS_EXP})):e===s$.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===s$.PERIOD_CODE||t===s$.OBRACK_CODE||t===s$.OPAREN_CODE||t===s$.QUMARK_CODE;){let r;if(t===s$.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==s$.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===s$.OBRACK_CODE?((e={type:s$.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==s$.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===s$.OPAREN_CODE?e={type:s$.CALL_EXP,arguments:this.gobbleArguments(s$.CPAREN_CODE),callee:e}:(t===s$.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:s$.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;s$.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===s$.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);s$.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));s$.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);s$.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,s$.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===s$.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===s$.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:s$.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:s$.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(s$.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,s$.isIdentifierPart(e))this.index++;else break;return{type:s$.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){r=!0,this.index++,e===s$.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===s$.COMMA_CODE){if(this.index++,++n!==t.length){if(e===s$.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===s$.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==s$.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(s$.CPAREN_CODE);if(this.code===s$.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:s$.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:s$.ARRAY_EXP,elements:this.gobbleArguments(s$.CBRACK_CODE)}}}Object.assign(s$,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(s$),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"}),s$.max_unop_len=s$.getMaxKeyLen(s$.unary_ops),s$.max_binop_len=s$.getMaxKeyLen(s$.binary_ops);let sA=e=>new s$(e).parse(),sI=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(s$).filter(e=>!sI.includes(e)&&void 0===sA[e]).forEach(e=>{sA[e]=s$[e]}),sA.Jsep=s$,sA.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let sM="ArrowFunctionExpression",sj={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)}},sL={...sj,Promise};function sF(e,t={}){return sz(e,t,sZ)}async function sB(e,t={}){return sK(e,t,sZ)}function sV(e,t={}){return sz(e,t,sY)}function sU(e,t={}){return sK(e,t,sY)}function sW(e,t={}){return sz(e,t,sq)}function sH(e,t={}){return sK(e,t,sq)}function sz(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=s1(t,sj),a=sJ("string"==typeof e?sA(e):e,n);if(r(a))return a;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function sK(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=s1(t,sL);return Promise.resolve(sJ("string"==typeof e?sA(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function sG(e){return sA(e)}function sZ(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function sY(e){return"boolean"==typeof e}function sq(e){return"number"==typeof e}function sJ(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,m,f,p,h=e,g=t;let y=sJ(h.argument,g);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var v=e,b=t;switch(v.operator){case"&&":return sJ(v.left,b)&&sJ(v.right,b);case"||":return sJ(v.left,b)||sJ(v.right,b);case"??":return sJ(v.left,b)??sJ(v.right,b)}let w=sJ(v.left,b),E=sJ(v.right,b);switch(v.operator){case"+":return w+E;case"-":return w-E;case"*":return w*E;case"/":return w/E;case"%":return w%E;case"**":return w**E;case"==":return w==E;case"===":return w===E;case"!=":return w!=E;case"!==":return w!==E;case">":return w>E;case">=":return w>=E;case"<":return w<E;case"<=":return w<=E;case"in":return w in E;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,sJ(r.test,n)?sJ(r.consequent,n):sJ(r.alternate,n);case"CallExpression":return s3(sQ(e,t));case"ArrowFunctionExpression":let D;return a=e,o=t,D=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<D.length)throw`Required argument(s) ${D.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(D.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return sJ(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return s3(s0(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(s6(s));case"SequenceExpression":let x;return l=e,u=t,(x=l.expressions.map(s6(u)))[x.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(s6(S));switch(_.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${_.callee.name}`}}if(_.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return e.value;case"Identifier":return c=e,d=t,(s5(c.name),d.variables&&Object.hasOwn(d.variables,c.name))?d.variables[c.name]:Object.hasOwn(d.globals,c.name)?d.globals[c.name]:void 0;case"TemplateLiteral":let C,P;return m=e,f=t,C=m.expressions?.map(s6(f))??[],(P=m.quasis?.map(s6(f))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+P.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function sX(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return sX(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function sQ(e,t){let r=s2(e.callee,t);if(r===s4||e.optional&&null==r)return s4;let n=e.arguments?.map(s6(t));if(r){if("function"!=typeof r)throw`${s7(e.callee)} is not a function`}else throw`No function named ${s7(e.callee)} is defined in this context`;return r(...n)}function s0(e,t){let r=s2(e.object,t);if(r===s4||e.optional&&null==r)return s4;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${s8(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=sX(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${s8(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof r&&"function"!=typeof r&&"string"!=typeof r&&"number"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;let n=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(sJ(e.property,t)):function(e){if("Identifier"!==e.type)throw`VisitMemberExpression does not support a property of type '${e.type}'`;return e.name}(e.property);s5(n),function(e,t){if(s9.has(String(t)))return;let r=Object(e);for(;null!==r;){if(Object.hasOwn(r,t)){if(r===Object.prototype||r===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}r=Object.getPrototypeOf(r)}}(r,n);let a=r[n];return"function"==typeof a?a.bind(r):a}function s1(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}sA.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:sM,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=sM,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),sA.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),sA.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(n+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(n+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(i===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var a,o,i;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;a=this.code,o=u,95===a||o.some(([e,t])=>a>=e&&a<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&r.call(this,n)})}}),sA.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,a=this.expr.slice(r,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{n=new RegExp(a,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),sA.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),sA.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",a="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:a,cooked:n},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(a+=i,i=this.expr.charAt(++this.index),a+=i,i){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=i}else n+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),sA.addBinaryOp("in",7),sA.addBinaryOp("??",1);let s4=Symbol("optional chain short-circuited");function s2(e,t){switch(e.type){case"MemberExpression":return s0(e,t);case"CallExpression":return sQ(e,t);default:return sJ(e,t)}}function s3(e){return e===s4?void 0:e}function s6(e){return function(t){return null===t?null:sJ(t,e)}}function s5(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let s9=new Set(["toString","valueOf","hasOwnProperty"]);function s8(e,t){try{return sX(e,t)}catch{return"<computed>"}}function s7(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function le(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...sL},boundNames:new Set,variables:new Set};return lt("string"==typeof e?sA(e):e,t),[...t.variables]}function lt(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void lt(r.argument,n);case"BinaryExpression":return a=e,o=t,void(lt(a.left,o),lt(a.right,o));case"ConditionalExpression":return i=e,s=t,void(lt(i.consequent,s),lt(i.test,s),lt(i.alternate,s));case"CallExpression":return l=e,u=t,void(lt(l.callee,u),l.arguments?.map(lr(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,m,f,p,h,g,y,v,b,w,E,D=e,x=t;let _=new Set(x.boundNames);for(let e of D.params??[])e?.type==="Identifier"&&_.add(e.name);lt(D.body,{...x,boundNames:_});return;case"MemberExpression":return c=e,d=t,void(lt(c.object,d),c.computed&&lt(c.property,d));case"ArrayExpression":return m=e,f=t,void m.elements?.map(lr(f));case"SequenceExpression":return p=e,h=t,void p.expressions?.map(lr(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(lr(y));case"Literal":case"TemplateElement":return;case"Identifier":return v=e,b=t,void(v.name in b.globals||b.boundNames.has(v.name)||b.variables.add(v.name));case"TemplateLiteral":return w=e,E=t,void(w.expressions?.map(lr(E)),w.quasis?.map(lr(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function lr(e){return function(t){return null===t?null:lt(t,e)}}let ln=H("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function la(e,t,r){ln.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function lo(){let e=ln.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function li(e){return ln.getState().flags[e].enabled}function ls(e,t){ln.subscribe(r=>{t(r.flags[e].enabled)})}function ll(e,t){ln.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}ln.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var lu=tV(function(e,t,r){t$(e,t,r)});let lc=V("extensionsInternal",{slots:{},extensions:{}}),ld=V("extensionRenderings",{renderings:new Map}),lm=()=>H("extensionsInternal",{slots:{},extensions:{}}),lf=()=>H("extensionRenderings",{renderings:new Map});function lp(e){let t=lc.getState(),r=e(t);r!==t&&lc.setState(r)}let lh=null,lg=null;function ly(){let e=ld.getState();return lh&&e===lg||(lh=new Map(e.renderings),lg=e,function(e){for(let t of(lP.clear(),e.values()))lT(t,1);lk=!0}(lh)),lh}function lv(e){lg={renderings:e},ld.setState(lg,!0)}function lb(e){let t=ly();t.has(e.renderingId)||(t.set(e.renderingId,e),lT(e,1),lv(t))}function lw(e){let t=ly(),r=t.get(e);r&&(t.delete(e),lT(r,-1),lv(t))}let lE=()=>H("extensions",{slots:{}}),lD=0,lx=new Set;function l_(e){lD++;try{return e()}finally{if(0==--lD&&lx.size>0){let e=Array.from(lx);for(let t of(lx.clear(),e))lS(t)}}}function lS(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function lC(e){lD>0?lx.add(e):lS(e)}let lP=new Map,lk=!1;function lT(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=lP.get(r);if(!n){if(t<0)return;lP.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),lk=!0;return}n.count+=t,n.count<1&&(lP.delete(r),lk=!0)}function lR(){var e,t;if(ly(),!lk)return;lk=!1;let r=Array.from(lP.values(),({record:e})=>e);r.sort(lO),e=nm.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===lO(e,t[r]))||nm.setState({mountedExtensions:r})}function lO(e,t){return lN(e.slotName,t.slotName)||lN(e.extensionId,t.extensionId)||lN(e.slotModuleName,t.slotModuleName)||lN(e.extensionModuleName,t.extensionModuleName)}function lN(e,t){return e===t?0:e<t?-1:1}lR(),ld.subscribe(()=>lC(lR));let l$=lm(),lA=lE(),lI=np(),lM=ny(),lj=new Set,lL=!1;function lF(e){if(null===e)lj=null;else if(null!==lj)for(let t of e)lj.add(t);lC(lB)}function lB(){if(!lL){lL=!0;try{for(let e=1;;e++){let t=lj;if(null!==t&&0===t.size)return;lj=new Set;try{!function(e,t,r,n,a,o=null){let i=lA.getState().slots,s={},l=!1,u=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,c]of Object.entries(e.slots)){let d=i[n];if(d&&o&&!o.has(n)){s[n]=d;continue}let{config:m}=ng(t,c.name),f=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=l$.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=lq(a),u=lq(t),c=new Map(s.map(e=>[e,function(e,t,r,n){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==r)return 1e3+r;let t=n.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[lW(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(r,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=nv(n,e,l),u=nb(r,e,l),c=u?lu({},i,u):i,d=lW(l),m=t.extensions[d];if(m){let e=c?.["Display conditions"]?.privileges??m.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!im(e,o.user))||m.featureFlag&&!a.includes(m.featureFlag))continue;s.push({id:l,name:d,moduleName:m.moduleName,config:c,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:c?.["Display conditions"]?.expression||m.displayExpression})}}return s}(n,e,m,r,u,a.session);d&&d.moduleName===c.moduleName&&rx(d.candidateExtensions,f)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:f},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&lA.setState({slots:s})}(l$.getState(),lI.getState(),lM.getState(),ln.getState(),ir.getState(),t)}catch(e){throw lj=null===t||null===lj?null:new Set([...t,...lj]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{lL=!1}}}function lV(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function lU(e,t){return{moduleName:t,name:e,attachedIds:[]}}function lW(e){let[t]=e.split("#");return t}function lH(e,t){let r=lW(t);return e.extensions[r]}function lz(e){return lH(l$.getState(),e)}l$.subscribe((e,t)=>{lF(e.extensions!==t.extensions?null:lV(e.slots,t.slots))}),lI.subscribe((e,t)=>{lF(lV(e.slots,t.slots))}),lM.subscribe((e,t)=>{lF(lV(e.configs,t.configs))}),ln.subscribe(()=>lF(null)),ir.subscribe(()=>lF(null)),lF(null);let lK=e=>lp(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function lG(e,t){lp(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...lU(e),attachedIds:[t]}}}})}function lZ(e,t){lp(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function lY(e){lp(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function lq(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function lJ(e,t){return function(e,t,r=null,n){let a;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;a??(a=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!sV(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(lX(e),t,ir.getState().session,e)}function lX(e){return lA.getState().slots[e]?.candidateExtensions??[]}let lQ=(e,t)=>l$.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let a=lU(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),l0=()=>{lj=null,lp(()=>({slots:{},extensions:{}})),lf().setState({renderings:new Map}),lA.setState({slots:{}})},l1=V("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function l4({name:e,basePath:t,mode:r,componentContext:n,state:a}){l1.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function l2(e){l1.getState().slotName===e&&l1.setState(l1.getInitialState(),!0)}let l3=V("modalRegistry",{modals:{}});function l6(e){l3.setState(t=>(t.modals[e.name]=e,t))}function l5(e){let t=l3.getState().modals[e];if(!t){let r=lz(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),l6(t))}return t}let l9=V("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function l8(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=l9.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function l7(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=l9.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function ue(e){let{openedWindows:t}=l9.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function ut(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=l9.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}l9.setState({registeredGroupsByName:n})}function ur(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=l9.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}l9.setState({registeredWindowsByName:n})}function un(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=l9.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}l9.setState({registeredWorkspacesByName:n})}let ua=0,uo=null,ui={bootstrap:15e3,mount:15e3,unmount:15e3};function us(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(ui).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=ui[n],i=Array.isArray(a)?a:[a],s=e=>i.reduce((t,a,o)=>t.then(()=>{let t=a(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${o} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let a,i=new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${o}ms`)),o)});return Promise.race([s(e),i]).finally(()=>clearTimeout(a)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function ul(e,t){var r,n;let a,o,i,s,l,u=await (uo??(uo=new Promise((e,t)=>{a2({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),a2))),uo),c={...t},d=(a=c,o=!1,{retarget:e=>a={...e},release:i=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(a),onSettled(e,t){switch(e){case"bootstrap":t&&i();return;case"mount":o||(o=t);return;case"unmount":(t||o)&&i();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>us(e,r)):us(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function uu(){return uc}function uc(e,t){let r,n=ul(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function ud(e,t,r,n,a=e=>e,o={}){let i=lW(n),s=lz(n),l=null;if(e){let u;if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:d,load:m}=s,f=ua++,p=`${t}/${n}-${f}`;e.dataset.extensionRenderingId=p;let h=e=>{try{lw(p)}catch(t){console.error(e,t)}};try{lb({renderingId:p,extensionName:i,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{u=await m()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await ul(a({...u,name:`${t}/${i}-${f}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var um=r(2153),uf=r.n(um);let up=(0,um.createContext)({moduleName:"",featureName:""});function uh({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,um.useEffect)(()=>{a.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${a.href}'`),a.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),uf().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),oq({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:oZ(e,t),...a},n)}let ug=({state:e,children:t,...r})=>{let{extension:n}=(0,um.useContext)(up),a=(0,um.useRef)(null),o=(0,um.useRef)(Promise.resolve()),i=(0,um.useRef)(!1),s=(0,um.useRef)(!1),l=(0,um.useRef)(e),u=(0,um.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,um.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(a.current?.getStatus()==="MOUNTED"&&a.current.update)return a.current.update({...t})}).catch(e=>{let t=a.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,um.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,ud(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,a.current=t,i.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,um.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,um.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?uf().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function uy(e){let t=(0,um.useRef)(e);return O(t.current,e)||(t.current=e),t.current}function uv(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,a]of Object.entries(t)){let t=function(...t){e.setState(e=>a(e,...t))};r[n]=t}return r}let ub=e=>e;function uw(e,t=ub,r){let n=(0,um.useCallback)(t=>e.subscribe(t),[e]),a=(0,um.useCallback)(()=>t(e.getState()),[e,t]),o=(0,um.useSyncExternalStore)(n,a,a),i=(0,um.useMemo)(()=>r?uv(e,r):null,[e,r]);return(0,um.useMemo)(()=>i?{...o,...i}:o,[o,i])}function uE(e,t){return uw(e,ub,t)}function uD(e){return function(t){let r=(0,um.useCallback)(t=>e.subscribe(t),[]),n=(0,um.useCallback)(()=>e.getState(),[]),a=(0,um.useSyncExternalStore)(r,n,n),o=(0,um.useMemo)(()=>t?uv(e,t):null,[t]);return(0,um.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let ux=[];Object.freeze(ux);let u_={candidateExtensions:ux};Object.freeze(u_);let uS=e=>{let t=(0,um.useCallback)(t=>t.slots?.[e]??u_,[e]);return uw(lE(),t)},uC=e=>e.session;function uP(e,t){let{candidateExtensions:r}=uS(e),n=uw(ir,uC),a=uy(t);return(0,um.useMemo)(()=>lJ(e,a),[e,a,n,r])}function uk(e,t){let{moduleName:r}=(0,um.useContext)(up);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,um.useEffect)(()=>{lQ(r,e)},[r,e]),{extensions:uP(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function uT(e){return e}function uR({name:e,extensionSlotName:t,select:r=uT,children:n,state:a,style:o,...i}){if(n&&a)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,um.useRef)(null),{extensions:u,extensionSlotModuleName:c}=uk(s,a),d=(0,um.useMemo)(()=>r(u),[r,u]),m=(0,um.useMemo)(()=>{if("function"==typeof n&&!uf().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return uf().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i},s&&d?.map((e,t)=>uf().createElement(up.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof n?n:null)??uf().createElement(ug,{state:a}))))}var uO=r(5338);function uN(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function u$(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?uN(Object(r),!0).forEach(function(t){var n,a,o;n=e,a=t,o=r[t],a in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):uN(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function uA(e){return(uA="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 uI(e){return(uI="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 uM(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(uI(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(uI(e)));return e}}var uj=null;try{uj=require("react").createContext()}catch(e){}var uL={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,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function uB(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=uH(e,t,function(){r(this)}),i=uM(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,a=e.domElement,o=t[r];if("function"!=typeof o)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(n),i;case"hydrateRoot":return o(a,n);default:return o(n,a),null}}({elementToRender:o,domElement:i,reactDom:uW(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function uV(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():uW(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function uU(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=uH(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=uM(e,t)();uW(e).render(n,o)}})}function uW(e){return e.ReactDOMClient||e.ReactDOM}function uH(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=uj?e.React.createElement(uj.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),a=e.React.createElement(e.errorBoundaryClass,t,a)),a=e.React.createElement(e.SingleSpaRoot,u$(u$({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),a)}var uz=r(6045),uK=r(5361),uG=r.n(uK),uZ=r(8642);let uY={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},uq=new Map;(0,uZ.initCache)(uq);let uJ={errorRetryCount:3,fetcher:ie,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof it){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>uq};function uX(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},uY,e),r={...uJ,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=uf().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return uf().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=uf().createElement(um.Suspense,{fallback:null},uf().createElement(uK.SWRConfig,{value:r},uf().createElement(up.Provider,{value:this.state.config},t.disableTranslations?uf().createElement(e,this.props):uf().createElement(uz.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},uf().createElement(e,this.props)))));return t.strictMode&&uf().StrictMode?uf().createElement(uf().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function uQ(e,t){return function(e){if("object"!==uA(e))throw Error("single-spa-react requires a configuration object");var t,r=u$(u$({},uL),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!uj&&r.React.createContext&&(uj=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:uF.bind(null,r),mount:uB.bind(null,r),unmount:uV.bind(null,r)};return r.parcelCanUpdate&&(n.update=uU.bind(null,r)),n}({React:uf(),ReactDOMClient:uO,rootComponent:uX(t)(e)})}function u0(e,t){return()=>e().then(({default:e})=>uQ(e,t))}function u1(e,t){return()=>Promise.resolve(uQ(e,t))}let u4=u0,u2=I()(()=>({}));W("openmrs-app-context",u2);let u3={};function u6(e,t=e=>e){let r=u2.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function u5(e,t){u2.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function u9(e){return null===e?null:Object.freeze(Object.assign({},e))}let u8=new Map;function u7(e,t){let r=(0,um.useRef)(t??{}),n=(0,um.useRef)(t=>u5(e,t)),a=(0,um.useRef)(Symbol());return(0,um.useEffect)(()=>{let r=t??{},n=a.current;return null===u6(e)?!function(e,t=u3){u2.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===u3?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),u5(e,()=>r)),u8.set(e,n),()=>{u8.get(e)===n&&(u2.setState(t=>(e in t&&delete t[e],t)),u8.delete(e))}},[e]),(0,um.useEffect)(()=>{let n=t??{};O(r.current,n)||(u5(e,()=>n),r.current=n)},[t]),n.current}function ce({namespace:e,value:t}){return u7(e,t),null}let ct=({children:e,value:t,fallback:r})=>t?uf().createElement(uf().Fragment,null,e):r?uf().createElement(uf().Fragment,null,r):null;function cr(){let e=(0,um.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,um.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function cn(e,t=e=>e??{}){let[r,n]=(0,um.useState)(()=>{if(ca(e))return;let r=u6(e);if(null!==r)return t?t(r):r});return(0,um.useEffect)(()=>{if(ca(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,um.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>O(e,r)?e:r)})(u9(a=u6(e))),u2.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(u9(n)))})},[e,t]),r}function ca(e){return"string"!=typeof e||0===e.trim().length}function co(e){let t=uP(e);return(0,um.useMemo)(()=>t.map(e=>e.id),[t])}function ci(e){return uS(e).candidateExtensions}function cs(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=uG()(e?sf(e,t,r):null,ie);return(0,um.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function cl(e){(0,um.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let cu={},cc=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function cd(e,t,r){let n=cu[e];if(n)return n;let a=new Promise(e=>{let n=r(t.getState());if(n)return void e(n);let a=t.subscribe(t=>{let n=r(t);n&&(a(),e(n))})});return cu[e]=a,a.then(()=>{cu[e]===a&&delete cu[e]}),a}function cm(e){let{moduleName:t,extension:r}=(0,um.useContext)(up),n=e?.externalModuleName??t;if(!n&&!r)throw Error(cc);let a=function(e){let t=(0,um.useMemo)(()=>nf(e),[e]),r=function(e){let[t,r]=(0,um.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,um.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw cd(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,um.useMemo)(ny,[]),r=function(e,t){let[r,n]=(0,um.useState)(t?()=>{let r=nv(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,um.useEffect)(()=>{if(t)return e.subscribe(e=>{let a=nv(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!rx(a.config,r)&&n(a.config)})},[e,t,r]),r}(t,e);if(!r&&e)throw cd(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let r=nv(t,e.extensionSlotName,e.extensionId);return r.loaded?r.config:null});return r||{}}(r);return(0,um.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...a}:{...a,...o},[n,e?.externalModuleName,a,o])}let cf=uP;function cp(e,t=300){let[r,n]=(0,um.useState)(e);return(0,um.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var ch=r(5394),cg=r.n(ch);let cy=`custom:${[["admissionDecisionConcept","ref"],["admissionEncounterType","ref"],["admissionForm","ref"],["atFacilityVisitType","ref"],["bedAssignmentEncounterType","ref"],["cancelADTRequestEncounterType","ref"],["checkInClerkEncounterRole","ref"],["checkInEncounterType","ref"],["clinicianEncounterRole","ref"],["conceptSourcesForDiagnosisSearch","ref"],["consultEncounterType","ref"],["consultFreeTextCommentsConcept","ref"],["denyAdmissionConcept","ref"],["diagnosisMetadata","ref"],["diagnosisSets","ref"],["dischargeForm","ref"],["dispositionDescriptor","ref"],["dispositions","ref"],["emrApiConceptSource","ref"],["exitFromInpatientEncounterType","ref"],["extraPatientIdentifierTypes","ref"],["fullPrivilegeLevel","ref"],["highPrivilegeLevel","ref"],["identifierTypesToSearch","ref"],["inpatientNoteEncounterType","ref"],["lastViewedPatientSizeLimit","ref"],["metadataSourceName","ref"],["motherChildRelationshipType","ref"],["narrowerThanConceptMapType","ref"],["nonDiagnosisConceptSets","ref"],["orderingProviderEncounterRole","ref"],["patientDiedConcept","ref"],["personImageDirectory","ref"],["primaryIdentifierType","ref"],["sameAsConceptMapType","ref"],["suppressedDiagnosisConcepts","ref"],["supportsAdmissionLocationTag","(uuid,display,name,links)"],["supportsLoginLocationTag","(uuid,display,name,links)"],["supportsTransferLocationTag","(uuid,display,name,links)"],["supportsVisitsLocationTag","(uuid,display,name,links)"],["telephoneAttributeType","ref"],["testPatientPersonAttributeType","ref"],["transferForm","ref"],["transferRequestEncounterType","ref"],["transferWithinHospitalEncounterType","ref"],["unknownCauseOfDeathConcept","ref"],["unknownLocation","ref"],["unknownPatientPersonAttributeType","ref"],["unknownProvider","ref"],["visitAssignmentHandlerAdjustEncounterTimeOfDayIfNecessary","ref"],["visitExpireHours","ref"],["visitNoteEncounterType","ref"]].map(([e,t])=>`${e}:${t}`).join(",")}`;function cv(){let e=`${o5}/emrapi/configuration?v=${cy}`,t=cg()(e,ie);return(0,um.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function cb(){return(0,um.useContext)(up).extension}let cw=uD(lm());function cE(e){let t=uP(e);return(0,um.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let cD=uD(lE());function cx(e){let{flags:t}=uw(ln);return t[e]?.enabled??!1}function c_(){let[,e]=(0,um.useState)(0);return(0,um.useCallback)(()=>{e(e=>e+1)},[])}function cS(e,t,r={}){return cP(e,t,cC,r)}let cC={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(o7(e.toString()),window.location.toString());return n.searchParams.set("limit",""+t),n.searchParams.set("startIndex",""+r),n.searchParams.set("totalCount","true"),n.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function cP(e,t,r,n={}){let{getPaginatedUrl:a,getTotalCount:o,getCurrentPageSize:i,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??ie,[d,m]=(0,um.useState)(1),f=(0,um.useRef)(NaN),p=(0,um.useRef)(NaN),h=(0,um.useRef)(d),g=(0,um.useRef)(!1),y=(0,um.useRef)(!1),v=e?.toString()??"",[b,w]=(0,um.useState)(v);v!==b&&(w(v),m(1),h.current=1,f.current=NaN,p.current=NaN,g.current=!1,y.current=!1);let E=(d-1)*t,D=(0,um.useMemo)(()=>a(e,t,E),[e,t,E]),{data:x,..._}=(l?cg():uG())(D,c,u);x?.data&&(f.current=o(x?.data),p.current=i(x?.data),g.current=!0);let S=Math.ceil(f.current/t),C=(0,um.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(f.current/t);!g.current||Number.isNaN(r)||e<=r?(h.current=e,m(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,um.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(f.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${v} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(f.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),h.current=e,m(e))},[d,t,v,x]);let P=(0,um.useCallback)(()=>{C(h.current+1)},[C]),k=(0,um.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(x?.data),totalPages:S,totalCount:f.current,currentPage:d,currentPageSize:p.current,paginated:S>1,showNextButton:d<S,showPreviousButton:d>1,goTo:C,goToNext:P,goToPrevious:k,..._}}function ck(e,t,r={}){return cP(e,t,cT(),r)}function cT(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(o7(e.toString()),window.location.toString());return n.searchParams.set("_count",""+t),n.searchParams.set("_getpagesoffset",""+r),n.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var cR=r(9532),cO=r.n(cR);function cN(e,t={}){return c$(e,cC,t)}function c$(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??ie,u=(0,um.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:m,...f}=cO()(u,l,{...n,...a?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),p=o(c?.[c.length-1].data),h=i(c?.[0]?.data);return{data:c?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=p,loadMore:()=>{m((c?.length??0)+1)},nextUri:p,...f}}function cA(e,t={}){return cI(e,cC,t)}function cI(e,t,r={}){let n=c$(e,t,r),{hasMore:a,error:o,data:i,loadMore:s,isLoading:l,nextUri:u}=n;return((0,um.useEffect)(()=>{a&&!o&&s()},[a,u]),r.partialData)?n:{...n,data:a||o?void 0:i,isLoading:l||a}}function cM(e,t={}){return cI(e,cT(),t)}function cj(e,t={}){return c$(e,cT(),t)}function cL(){let e="tablet";return document.body.classList.forEach(t=>{switch(t){case"omrs-breakpoint-lt-tablet":e="phone";break;case"omrs-breakpoint-gt-small-desktop":e="large-desktop";break;case"omrs-breakpoint-gt-tablet":e="small-desktop"}}),e}function cF(){let[e,t]=(0,um.useState)(cL);return(0,um.useEffect)(()=>{let e=()=>{t(cL())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let cB=e=>"small-desktop"===e||"large-desktop"===e;function cV(e){let t=(0,um.useContext)(up);(0,um.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),l4(e),()=>{l2(e.name)}),[t,e])}function cU(){return uw(l1)}let cW=[];function cH(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=cA(`${o5}/location${n?"?"+n:""}`,{immutable:!0});return a??cW}function cz(e,t=!0){let r=(0,um.useRef)(null);return(0,um.useEffect)(()=>{let n=n=>{t&&r.current&&n.target&&n.target instanceof Node&&(r.current.contains(n.target)||e(n))};return window.addEventListener("mousedown",n),window.addEventListener("touchstart",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("touchstart",n)}},[e,t]),r}function cK(e){let t=(0,um.useRef)();return(0,um.useEffect)(()=>{let r=new IntersectionObserver(t=>{for(let r of t)if(r.isIntersecting)return void e()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t.current,e]),t}function cG(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=cr(),s=(0,um.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,um.useCallback)(e=>ie(function(e,t){if(t)return"function"==typeof t?t(e):t;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,a),{...n,signal:s}),[s,n,a]);return uG()(e,l,o)}function cZ(e=[],t=10){let[r,n]=(0,um.useState)(1),a=(0,um.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);r>a&&n(a);let o=Math.min(Math.max(1,r),a),i=(0,um.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,um.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,um.useCallback)(()=>{n(e=>e+1)},[]),u=(0,um.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,um.useMemo)(()=>({results:i,totalPages:a,currentPage:o,paginated:e.length>t,showNextButton:o<a,showPreviousButton:o>1,goTo:s,goToNext:l,goToPrevious:u}),[i,a,e.length,t,o,s,l,u])}function cY(e,t,r,n){return{pageSizes:(0,um.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,um.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function cq(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function cJ(e){let[t,r]=(0,um.useState)(e??cq()),{data:n,error:a,isValidating:o}=uG()(t?["patient",t]:null,()=>sg(t,{}));return(0,um.useEffect)(()=>{let e=()=>{let e=cq();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,um.useMemo)(()=>({isLoading:o&&!a&&!n,patient:n,patientUuid:t,error:a}),[o,a,n,t])}function cX(){let e=`${o5}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=uG()(e,ie);return(0,um.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function cQ(e){let{extensions:t,extensionSlotModuleName:r}=uk(e);return e?t.map(t=>({state:n})=>uf().createElement(up.Provider,{value:{moduleName:r,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:r,extensionMeta:t.meta}}},uf().createElement(ug,{state:n}))):[]}function c0(){let e=(0,um.useRef)(),[t,r]=(0,um.useState)(null),n=null;if(!t){if(i){let e=il().getState();e.loaded&&(n=e.session)}else i=new Promise(t=>{let r=({loaded:r,session:a})=>{r&&(t(a),n=a,e.current&&(e.current(),e.current=void 0))};r(il().getState()),n||(e.current=il().subscribe(r))});if(n)r(n);else throw i}(0,um.useEffect)(()=>(e.current||(e.current=il().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let a=t||n;if(!a)if(i)throw console.warn("useSession is in an unexpected state. Attempting to recover."),i;else throw Error("useSession is in an invalid state.");return a}let c1=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,um.useState)(null);return((0,um.useEffect)(()=>{let e=il(),t=e.subscribe(({loaded:e,session:t})=>{a(e?t?.user??null:null)}),{loaded:r,session:n}=e.getState();return r&&a(n?.user??null),t},[]),n&&im(e,n))?uf().createElement(uf().Fragment,null,r):t?uf().createElement(uf().Fragment,null,t):null};var c4=r(2492),c2=r.n(c4),c3=r(7581);let c6=new Map;function c5(){for(let e of Array.from(c6.values()))e()}let c9={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function c8(e){let t=(0,um.useId)();return(0,um.useEffect)(()=>{if(e)return c6.set(t,e),()=>{c6.delete(t)}},[t,e]),{...uE(sk(),c9),mutateVisit:c5}}function c7(e,t=sC){let r=(0,um.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=c8((0,um.useCallback)(()=>r.current?.(),[])),i=e&&n==e?a:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${i}?v=${t}`,{data:u,error:c,mutate:d,isValidating:m}=uG()(e?`${o5}/visit${s}`:null,ie),{data:f,error:p,mutate:h,isValidating:g}=uG()(e&&i?`${o5}/visit${l}`:null,ie),y=(0,um.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,um.useMemo)(()=>i&&f?f.data:null,[f,i]),b=(0,um.useRef)(null);(0,um.useEffect)(()=>{!m&&y&&n===e&&null===a&&o(y),g||(b.current&&v&&b.current.uuid===v.uuid&&!b.current.stopDatetime&&v.stopDatetime&&o(null),b.current=v)},[v,a,y,m,g,n]);let w=(0,um.useCallback)(()=>{d(),h()},[d,h]);(0,um.useEffect)(()=>{r.current=w},[w]);let E=!!(!u||i&&!f),D=!!(i?p:c);return{error:c||p,mutate:w,isValidating:m||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:E&&!D}}c2().extend(c3);let de=[];function dt(){let{data:e}=cg()(sD,sx);return e??de}let dr=new Map;async function dn(e,t){let r=t.indexOf("#"),n=r>=0,a=n?t.substring(0,r):e,o=n?t.substring(r+1):t,i=await iq(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?di(a,i).then(()=>i[o]()):(i?i&&Object.hasOwn(i,o)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${a} does not define a component called "${o}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${a} for ${t} defined in ${e}'s routes.json`),da)}let da={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function di(e,t){if(e in dr)await dr[e];else{let r=t??await iq(e);await (dr[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let a=r.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{nU(e),t(null)}).catch(n)}nU(e),t(null)}))}}function ds(e,t){let r=t.name;if(!r)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
17
17
  registered. To fix this, ensure that you define the "name" field inside the
18
18
  extension definition.`,t);t.slots&&t.slot&&console.warn(`The extension ${r} from ${e} declares both a 'slots' property and