@openmrs/esm-metadataexport-app 4.6.2-pre.1016 → 4.6.2-pre.1021

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.
@@ -4,4 +4,4 @@
4
4
  │ 7362.js (654.708 KiB)
5
5
  
6
6
 
7
- Rspack compiled with 1 warning in 20.05 s
7
+ Rspack compiled with 1 warning in 20.55 s
package/dist/1511.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 ao=(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&&ai(e)){if(a._type===nc.Array&&Array.isArray(n)){let a=n.map(t=>ao(e,t));r[t]=a}else if(a._type===nc.Object)for(let t of Object.keys(n))n[t]=ao(e,n[t])}}else if(as(a)){let e=n??{};as(e)&&(r[t]=ao(a,e))}}return r};function ai(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function as(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function al(e,t){let r=`${e}:::${t}`;nU.has(r)||(console.error(t),nU.add(r))}function au(e){e?nU.forEach(t=>{t.startsWith(e)&&nU.delete(t)}):nU.clear()}function ac(){nB.forEach(e=>e()),nB.length=0,nK.clear(),n3.clear(),n5.clear(),n6.clear(),nV=null,nW=new WeakMap,nH()}let ad={"Translation overrides":{_description:"Per-language overrides for frontend translations should be keyed by language code and each language dictionary contains the translation key and the display value",_type:nc.Object,_default:{},_validators:[nd(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(", ")}.`})]}},am={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nc.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nc.String,_default:void 0}},...ad},ap=(e,t)=>nd(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),af=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return nd(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(", "))},ah=af([]),ag=e=>nd(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),ay={inRange:ap,isUrl:ah,isUrlWithTemplateParameters:af,oneOf:ag};var av=r(2034);let ab=B("breadcrumbs",[]);function aw(e){return aE([e])}function aE(e){let t=[...ax(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,av.pathToRegexp)(e.matcher).regexp:(0,av.pathToRegexp)(e.path).regexp,settings:e}))];ab.setState(t,!0)}function ax(){return ab.getState()}function aD(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=aD(e,r.join("/"));if(t)return t}}(e,t)}function a_(e,t){if(e.length>0){let r=aD(e,t);if(r){let t=[r],n=aD(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=aD(e,n.settings.parent);return t.reverse()}}return[]}function aS(e){return a_(ax(),e)}var aC=Object.freeze({__proto__:null,get start(){return oq},get ensureJQuerySupport(){return oS},get setBootstrapMaxTime(){return oi},get setMountMaxTime(){return os},get setUnmountMaxTime(){return ol},get setUnloadMaxTime(){return ou},get registerApplication(){return oA},get unregisterApplication(){return oL},get getMountedApps(){return oN},get getAppStatus(){return oj},get unloadApplication(){return oF},get checkActivityFunctions(){return oM},get getAppNames(){return o$},get pathToActiveWhen(){return oV},get navigateToUrl(){return og},get patchHistoryApi(){return ox},get triggerAppChange(){return oK},get addErrorHandler(){return aO},get removeErrorHandler(){return aN},get mountRootParcel(){return ot},get NOT_LOADED(){return aI},get LOADING_SOURCE_CODE(){return aA},get NOT_BOOTSTRAPPED(){return aM},get BOOTSTRAPPING(){return aL},get NOT_MOUNTED(){return aF},get MOUNTING(){return aB},get UPDATING(){return aV},get LOAD_ERROR(){return az},get MOUNTED(){return aU},get UNLOADING(){return aH},get UNMOUNTING(){return aW},get SKIP_BECAUSE_BROKEN(){return aK}}),aP=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,ak=!function(){try{var e=new aP("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}:aP;let aT=[];function aR(e,t,r){let n=aj(e,t,r);aT.length?aT.forEach(e=>e(n)):setTimeout(()=>{throw n})}function aO(e){if("function"!=typeof e)throw Error(a$(28,!1));aT.push(e)}function aN(e){if("function"!=typeof e)throw Error(a$(29,!1));let t=!1;return aT=aT.filter(r=>{let n=r===e;return t=t||n,!n}),t}function a$(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 aj(e,t,r){let n,a=`${aJ(t)} '${aY(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}n=e}else{console.warn(a$(30,!1,t.status,aY(t)));try{n=Error(a+JSON.stringify(e))}catch(t){n=e}}return n.appOrParcelName=aY(t),t.status=r,n}let aI="NOT_LOADED",aA="LOADING_SOURCE_CODE",aM="NOT_BOOTSTRAPPED",aL="BOOTSTRAPPING",aF="NOT_MOUNTED",aB="MOUNTING",aU="MOUNTED",aV="UPDATING",aW="UNMOUNTING",aH="UNLOADING",az="LOAD_ERROR",aK="SKIP_BECAUSE_BROKEN";function aG(e){return e.status===aU}function aZ(e){try{return e.activeWhen(window.location)}catch(t){return aR(t,e,aK),!1}}function aY(e){return e.name}function aq(e){return!!e.unmountThisParcel}function aJ(e){return aq(e)?"parcel":"application"}function aX(){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 aQ(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r];return null}function a0(e){return e&&("function"==typeof e||Array.isArray(e)&&!aQ(e,e=>"function"!=typeof e))}function a1(e,t){let r=e[t]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[()=>Promise.resolve()]);let n=aJ(e),a=aY(e);return function(e){return r.reduce((r,o,i)=>r.then(()=>{let r=o(e);return a4(r)?r:Promise.reject(a$(15,!1,n,a,t,i))}),Promise.resolve())}}function a4(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let a2=[];function a3(e,t){return Promise.resolve().then(()=>e.status!==aM?e:(e.status=aL,e.bootstrap?oc(e,"bootstrap").then(r).catch(r=>{if(t)throw aj(r,e,aK);return aR(r,e,aK),e}):Promise.resolve().then(r)));function r(){return e.status=aF,e}}function a6(e,t){return Promise.resolve().then(()=>{if(e.status!==aU)return e;return e.status=aW,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 aj(r,e,aK);aR(r,e,aK)})).then(()=>e);function r(){return oc(e,"unmount").then(()=>{e.status=aF},r=>{if(t)throw aj(r,e,aK);aR(r,e,aK)})}})}let a5=!1,a9=!1;function a8(e,t){return Promise.resolve().then(()=>e.status!==aF?e:(a5||(window.dispatchEvent(new ak("single-spa:before-first-mount")),a5=!0),e.status=aB,oc(e,"mount").then(()=>(e.status=aU,a9||(window.dispatchEvent(new ak("single-spa:first-mount")),a9=!0),e)).catch(r=>{return e.status=aU,a6(e,!0).then(n,n);function n(){if(t)throw aj(r,e,aK);return aR(r,e,aK),e}})))}let a7=0,oe={parcels:{}};function ot(){return or.apply(oe,arguments)}function or(e,t){let r,n,a,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(a$(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(a$(3,!1,typeof e.name));let i=a7++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(a$(4,!1,s,typeof t));if(!t.domElement)throw Error(a$(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:i,parcels:{},status:l?aA:aM,customProps:t,parentName:aY(o),unmountThisParcel:()=>p.then(()=>{if(c.status!==aU)throw Error(a$(6,!1,s,c.status));return a6(c,!0)}).then(e=>(c.parentName&&delete o.parcels[c.id],e)).then(e=>(n(e),e)).catch(e=>{throw c.status=aK,a(e),e})};o.parcels[i]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(a$(7,!1));let m=(d=d.then(e=>{if(!e)throw Error(a$(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!a0(e.bootstrap))throw Error(a$(9,!1,s));if(!a0(e.mount))throw Error(a$(10,!1,s));if(!a0(e.unmount))throw Error(a$(11,!1,s));if(e.update&&!a0(e.update))throw Error(a$(12,!1,s));let t=a1(e,"bootstrap"),n=a1(e,"mount"),a=a1(e,"unmount");c.status=aM,c.name=s,c.bootstrap=t,c.mount=n,c.unmount=a,c.timeouts=od(e.timeouts),e.update&&(c.update=a1(e,"update"),r.update=function(e){return c.customProps=e,on(Promise.resolve().then(()=>{if(c.status!==aU)throw Error(a$(32,!1,aY(c)));return c.status=aV,oc(c,"update").then(()=>(c.status=aU,c)).catch(e=>{throw aj(e,c,aK)})}))})})).then(()=>a3(c,!0)),p=m.then(()=>a8(c,!0)),f=new Promise((e,t)=>{n=e,a=t});return r={mount:()=>on(Promise.resolve().then(()=>{if(c.status!==aF)throw Error(a$(13,!1,s,c.status));return o.parcels[i]=c,a8(c)})),unmount:()=>on(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:on(d),bootstrapPromise:on(m),mountPromise:on(p),unmountPromise:on(f)}}function on(e){return e.then(()=>null)}function oa(e){let t=aY(e),r="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(a$(40,!1),t,r));let n=aX({},r,{name:t,mountParcel:or.bind(e),singleSpa:aC});return aq(e)&&(n.unmountSelf=e.unmountThisParcel),n}let oo={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 oi(e,t,r){if("number"!=typeof e||e<=0)throw Error(a$(16,!1));oo.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function os(e,t,r){if("number"!=typeof e||e<=0)throw Error(a$(17,!1));oo.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function ol(e,t,r){if("number"!=typeof e||e<=0)throw Error(a$(18,!1));oo.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function ou(e,t,r){if("number"!=typeof e||e<=0)throw Error(a$(19,!1));oo.unload={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function oc(e,t){let r=e.timeouts[t],n=r.warningMillis,a=aJ(e);return new Promise((o,i)=>{let s=!1,l=!1;e[t](oa(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>c(1),n),setTimeout(()=>c(!0),r.millis);let u=a$(31,!1,t,a,aY(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 od(e){let t={};for(let r in oo)t[r]=aX({},oo[r],e&&e[r]||{});return t}function om(e){return Promise.resolve().then(()=>{let t,r;return e.loadPromise?e.loadPromise:e.status!==aI&&e.status!==az?e:(e.status=aA,e.loadPromise=Promise.resolve().then(()=>{let n=e.loadApp(oa(e));if(!a4(n))throw r=!0,Error(a$(33,!1,aY(e)));return n.then(r=>{let n;e.loadErrorTime=null,"object"!=typeof(t=r)&&(n=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!a0(t.bootstrap)&&(n=35),a0(t.mount)||(n=36),a0(t.unmount)||(n=37);let a=aJ(t);if(n){let r;try{r=JSON.stringify(t)}catch(e){}return console.error(a$(n,!1,a,aY(e),r),t),aR(void 0,e,aK),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=aX({},e.devtools.overlays,t.devtools.overlays)),e.status=aM,e.bootstrap=a1(t,"bootstrap"),e.mount=a1(t,"mount"),e.unmount=a1(t,"unmount"),e.unload=a1(t,"unload"),e.timeouts=od(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let n;return delete e.loadPromise,r?n=aK:(n=az,e.loadErrorTime=(new Date).getTime()),aR(t,e,n),e}))})}let op="u">typeof window,of={hashchange:[],popstate:[]},oh=["hashchange","popstate"];function og(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(a$(14,!1));t=e.currentTarget.href,e.preventDefault()}let r=oD(window.location.href),n=oD(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 oy(e){if(e){let t=e[0].type;oh.indexOf(t)>=0&&of[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function ov(){oG([],arguments)}function ob(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 ow=null,oE=!1;function ox(e){if(oE)throw Error(a$(43,!1));a=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,oE=!0,ow=window.history.replaceState,window.addEventListener("hashchange",ov),window.addEventListener("popstate",ov);let t=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(e,r){if(!("function"==typeof r&&oh.indexOf(e)>=0)||aQ(of[e],e=>e===r))return t.apply(this,arguments);of[e].push(r)},window.removeEventListener=function(e,t){return"function"==typeof t&&oh.indexOf(e)>=0&&(of[e]=of[e].filter(e=>e!==t)),r.apply(this,arguments)},window.history.pushState=ob(window.history.pushState,"pushState"),window.history.replaceState=ob(ow,"replaceState")}function oD(e){let t=document.createElement("a");return t.href=e,t}op&&(window.singleSpaNavigate?console.warn(a$(41,!1)):window.singleSpaNavigate=og);let o_=!1;function oS(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!o_){let t=e.fn.on,r=e.fn.off;e.fn.on=function(e,r){return oC.call(this,t,window.addEventListener,e,r,arguments)},e.fn.off=function(e,t){return oC.call(this,r,window.removeEventListener,e,t,arguments)},o_=!0}}function oC(e,t,r,n,a){return"string"!=typeof r?e.apply(this,a):(r.split(/\s+/).forEach(e=>{oh.indexOf(e)>=0&&(t(e,n),r=r.replace(e,""))}),""===r.trim()?this:e.apply(this,a))}let oP={};function ok(e){return Promise.resolve().then(()=>{let t=oP[aY(e)];if(!t)return e;if(e.status===aI)return oT(e,t),e;if(e.status===aH)return t.promise.then(()=>e);if(e.status!==aF&&e.status!==az)return e;let r=e.status===az?Promise.resolve():oc(e,"unload");return e.status=aH,r.then(()=>(oT(e,t),e)).catch(r=>(delete oP[aY(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,aR(r,e,aK),t.reject(r),e))})}function oT(e,t){delete oP[aY(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=aI,t.resolve()}function oR(e,t,r,n){oP[aY(e)]={app:e,resolve:r,reject:n},Object.defineProperty(oP[aY(e)],"promise",{get:t})}let oO=[];function oN(){return oO.filter(aG).map(aY)}function o$(){return oO.map(aY)}function oj(e){let t=aQ(oO,t=>aY(t)===e);return t?t.status:null}let oI=!1;function oA(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(a$(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(a$(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(a$(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(a$(24,!1));if(!oU(e.customProps))throw Error(a$(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,t,r,n){if("string"!=typeof e||0===e.length)throw Error(a$(20,!1));if(!t)throw Error(a$(23,!1));if("function"!=typeof r)throw Error(a$(24,!1));if(!oU(n))throw Error(a$(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:oV(e)),i.activeWhen=e=>s.some(t=>t(e)),i);if(oY||oI||(oI=!0,setTimeout(()=>{oY||console.warn(a$(1,!1))},5e3)),-1!==o$().indexOf(l.name))throw Error(a$(21,!1,l.name));oO.push(aX({loadErrorTime:null,status:aI,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),op&&(oS(),oG())}function oM(e=window.location){return oO.filter(t=>t.activeWhen(e)).map(aY)}function oL(e){if(0===oO.filter(t=>aY(t)===e).length)throw Error(a$(25,!1,e));return(op?oF(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=oO.map(aY).indexOf(e);oO.splice(t,1)})}function oF(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(a$(26,!1));let r=aQ(oO,t=>aY(t)===e);if(!r)throw Error(a$(27,!1,e));let n=oP[aY(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{oR(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,oB(r,n.resolve,n.reject)):e=new Promise((t,n)=>{oR(r,()=>e,t,n),oB(r,t,n)}),e}}function oB(e,t,r){Promise.resolve().then(()=>{if(aQ(oM(),t=>t===aY(e)))return oK()}).then(()=>a6(e).then(ok).then(()=>{t(),setTimeout(()=>{oG()})})).catch(r)}function oU(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function oV(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 oW=!1,oH=[],oz=op&&window.location.href;function oK(){return oG()}function oG(e=[],t,r=!1){let n,a,o,i,s;if(oW)return new Promise((e,r)=>{oH.push({resolve:e,reject:r,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(n=[],a=[],o=[],i=[],s=(new Date).getTime(),oO.forEach(e=>{let t=e.status!==aK&&aZ(e);switch(e.status){case az:t&&s-e.loadErrorTime>=200&&o.push(e);break;case aI:case aA:t&&o.push(e);break;case aM:case aF:!t&&oP[aY(e)]?n.push(e):t&&i.push(e);break;case aU:t||a.push(e)}}),{appsToUnload:n,appsToUnmount:a,appsToLoad:o,appsToMount:i}),m,p=[],f=oz,h=oz=window.location.href;return oY?(oW=!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(p).then(r=>{if(r.some(e=>e))return ow.call(window.history,history.state,"",f.substring(location.origin.length)),oz=location.href,oW=!1,oG(e,t,!0);let n=l.map(ok),a=Promise.all(u.map(a6).map(e=>e.then(ok)).concat(n));a.then(()=>{w("before-mount-routing-event",b(!0))},e=>{throw e});let o=c.map(e=>om(e).then(e=>oZ(e,a))),i=d.filter(e=>0>c.indexOf(e)).map(e=>oZ(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(om)).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);p.push(t.catch(e=>(console.warn(Error(a$(42,!1))),console.warn(e),!1)))}function y(){let t=oN();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(oW=!1,oH.length>0){let e=oH;oH=[],oG(e)}return t}function v(){r||(e.forEach(e=>{oy(e.eventArguments)}),oy(t))}function b(e=!1,r){let n={},a={[aU]:[],[aF]:[],[aI]:[],[aK]:[]};e?(c.concat(d).forEach((e,t)=>{i(e,aU)}),l.forEach(e=>{i(e,aI)}),u.forEach(e=>{i(e,aF)})):m.forEach(e=>{i(e)});let o={detail:{newAppStatuses:n,appsByNewStatus:a,totalAppChanges:m.length,originalEvent:null==t?void 0:t[0],oldUrl:f,newUrl:h}};return r&&aX(o.detail,r),o;function i(e,t){let r=aY(e);t=t||oj(r),n[r]=t,(a[t]=a[t]||[]).push(r)}}function w(e,t){r||window.dispatchEvent(new ak(`single-spa:${e}`,t))}}function oZ(e,t){return aZ(e)?a3(e).then(e=>t.then(()=>aZ(e)?a8(e):e)):t.then(()=>e)}let oY=!1;function oq(e){oY=!0,op&&(ox(e),oG())}op&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...oO]},reroute:oG,NOT_LOADED:aI,toLoadPromise:om,toBootstrapPromise:a3,unregisterApplication:oL,getProfilerData:function(){return a2}});var oJ=r(4557),oX=r.n(oJ);let oQ={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"},o0=oX().default||oX(),o1="___",o4=new Map,o2=!1;function o3(){o2=!0,o0.emit("languageChanged",o0.language)}function o6(){o2=!1,o4.clear()}function o5(){return o2}function o9(e){if(!o2)return;let t=o4.get(e.value);if(!t){o4.size>=2e4&&o4.delete(o4.keys().next().value),o4.set(e.value,[{...e}]);return}let r=t.find(t=>t.key===e.key&&t.namespace===e.namespace&&t.extensionNamespace===e.extensionNamespace);r?r.hasCount||(r.hasCount=e.hasCount):t.push({...e}),o4.delete(e.value),o4.set(e.value,t)}function o8(e){return e&&o2?(o4.get(e)??o4.get(e.trim())??[]).map(e=>({...e})):[]}let o7=oX().default||oX();function ie(e,t,r,n){return o7.t(t,{ns:e,defaultValue:r,...n})}function it(e,t,r){return oQ[e]?ie("core",e,t??oQ[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function ir(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=ia(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function ia(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function io({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=ir(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(it("navigateNonHttp"));n.startsWith(r)?og(n):window.location.assign(n)}o7.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let ii="openmrs:history";function is(e){let t=JSON.parse(sessionStorage.getItem(ii)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(ii,JSON.stringify(t))}function il(){0===JSON.parse(sessionStorage.getItem(ii)??"[]").length&&document.referrer&&is(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=iu();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(ii,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?ic({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&is(window.location.href)})}function iu(){return JSON.parse(sessionStorage.getItem(ii)??"[]")}function ic({toUrl:e}){let t=iu(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);io({to:t[r]}),sessionStorage.setItem(ii,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function id(){sessionStorage.removeItem(ii)}let im="${openmrsSpaBase}/login",ip={redirectAuthFailure:{enabled:{_type:nc.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nc.String,_default:im,_validators:[ay.isUrl],_description:"The url to which users will be redirected when they are logged out. If set to blank, the `location` header from the response will be used."},errors:{_type:nc.Array,_default:[401],_elements:{_type:nc.Number,_validators:[ay.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nc.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}},followRedirects:{_type:nc.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function ih(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let ig="/ws/rest/v1",iy="/ws/fhir2/R4",iv=`${ig}/session`;function ib(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function iw(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=ib(e);t.headers||(t.headers={}),e_(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(ib(ig),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(iy)){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 n1("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(r===ib(iv)||204===e.status)&&io({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===ib(iv)&&403===e.status||n.enabled&&n.errors.includes(e.status))&&(id(),io({to:n.url||e.headers.get("location")||im}),!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 iE(r,e,n,a)},()=>{throw new iE(r,e,null,a)})})}class iE extends Error{constructor(e,t,r,n){super(),ih(this,"response",void 0),ih(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 ix=B("session",{loaded:!1,session:null}),iD=0,i_=null;function iS(){return i_||(ix.getState().loaded&&iD>=Date.now()-6e4?null:iT())}function iC(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=iS();return n?new Promise(e=>{let t=()=>{let t=ix.getState();t.loaded&&(a(),e(r(t.session)))},a=ix.subscribe(t);n.then(t,t)}):Promise.resolve(r(ix.getState().session))}function iP(){return iS(),ix}function ik(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 iT(e,t){iD=Date.now(),o??(o=iD);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=iF(iw(iv,{headers:r,rejectAuthFailure:!0})),a=()=>{i_===n&&(i_=null)};return n.then(a,a),i_=n,n}function iR(){ix.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function iO(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!K(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!K(n.privileges.find(t=>e===t.display))):(K(r)||console.error(`Could not understand privileges "${r}"`),!0))||!K(t.roles.find(e=>"System Developer"===e.display))}function iN(){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(ix.getState()),e||(t=ix.subscribe(n))})}async function i$(){return(await iC()).sessionLocation}async function ij(e,t){return iF(iw(iv,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function iI(e,t){return await iw(iv,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),iT()}async function iA(e,t,r){return r||(r=new AbortController),await iw(`${ig}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),iT()}async function iM(e,t=!1){let r=await iw(t?`${iv}?rememberMe=true`:iv,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await iT()).session:r.data}async function iL(){try{await iw(iv,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!iB(e))throw e}iR(),await iT().catch(()=>{})}function iF(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};ix.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(iU(Error("The session endpoint did not respond with a session"))):r(iU(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(iB(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?ix.setState({loaded:!0,session:e.responseBody},!0):iR(),t(ix.getState());return}(a=e)instanceof iE&&502===a.response.status&&!ix.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(iU(e,!0)):(P(`Failed to fetch new session information: ${e}`),r(iU(e)))})})}function iB(e){return e instanceof iE&&(401===e.response.status||403===e.response.status)}function iU(e,t=!1){return ix.getState().loaded||ix.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),ix.getState()}function iV(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}ix.subscribe(e=>{e.loaded&&e.session&&ik(e.session)});let iW={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function iH(){nZ("@openmrs/esm-api",ip),iT()}let iz="import-map-override:",iK="import-map-overrides-disabled",iG="import-map-overrides:change",iZ=!1,iY=null,iq=null;async function iJ(){return iq??(iq=iX().then(({map:e,complete:t})=>(t||(iq=null),e))),iq}async function iX(){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:iQ(t),complete:r}}function iQ(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function i0(){let e={};try{let t=i6();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(iz)){let r=n.slice(iz.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 i1(){let e=await iJ();return iZ?iQ([e,iY??i0()]):e}async function i4(){return iJ()}async function i2(){return iZ?iQ([await iJ(),i0()]):iJ()}function i3(e){if(!iZ)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(iz)){let t=localStorage.getItem(r);t&&(e[r.slice(iz.length)]=t)}}return{imports:e}}return i0()}function i6(){if(!iZ)return[];try{let e=localStorage.getItem(iK);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function i5(e){return!!iZ&&i6().includes(e)}function i9(e,t){if(!iZ)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(iz+e,t),window.dispatchEvent(new CustomEvent(iG))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function i8(e){if(!iZ)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(iz+e);let t=i6().filter(t=>t!==e);t.length>0?localStorage.setItem(iK,JSON.stringify(t)):localStorage.removeItem(iK),window.dispatchEvent(new CustomEvent(iG))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function i7(){if(!iZ)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(iz)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(iK),window.dispatchEvent(new CustomEvent(iG))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function se(e){if(!iZ)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=i6().filter(t=>t!==e);t.length>0?localStorage.setItem(iK,JSON.stringify(t)):localStorage.removeItem(iK),window.dispatchEvent(new CustomEvent(iG))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let st=!1;function sr(){!st&&(st=!0,(iZ="development"===window.spaEnv)&&(iY=i0()))}function sn(e){return e.replace(/[\/\-@]/g,"_")}async function sa(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([so(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=sn(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 so(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=sn(e);if(!window[r]){let r=t??await si();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 i3().imports;try{return await function(e){var t;let r=(t=window)[ss]??(t[ss]=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&&E({kind:"error",title:it("scriptLoadingFailed","Error: Script failed to load"),description:it("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:it("resetOverrides","Reset overrides"),onActionButtonClick(){i7(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function si(){return i1()}let ss=Symbol.for("__openmrs_script_loading");function sl(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 su(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&&sl(t))}let sc="openmrs-routes:",sd="openmrs-routes:change",sm=!1,sp=null,sf=null;async function sh(){return sf??(sf=sg().then(({map:e,complete:t})=>(t||(sf=null),e))),sf}async function sg(){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&&su(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:sy(t),complete:r}}function sy(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 sv(){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(sc)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(sc.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(sl(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(sl(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 sb(){let e=await sh();return sm?sy([e,sp??await sv()]):e}async function sw(){return sh()}async function sE(){return sm?sy([await sh(),await sv()]):sh()}function sx(){if(!sm)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sc)){let t=localStorage.getItem(r);t&&(e[r.slice(sc.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function sD(e,t){if(!sm)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(sc+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!sl(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(sc+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(sc+e,JSON.stringify(t.toString()));else{if(!sl(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(sc+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(sd))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function s_(e){if(!sm)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(sc+e),window.dispatchEvent(new CustomEvent(sd))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function sS(){if(!sm)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(sc)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sd))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let sC=null;function sP(){return sC||(sC=(sm="development"===window.spaEnv)?sv().then(e=>{sp=e}):Promise.resolve())}let sk=`${ig}/attachment`;function sT(e,t){return iw(`${sk}/${e}`,{signal:t.signal})}function sR(e,t,r,n){return iw(sO(e,t,n),{signal:r.signal})}function sO(e,t,r){return r?`${sk}?patient=${e}&encounter=${r}`:`${sk}?patient=${e}&includeEncounterless=${t}`}async function sN(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)),iw(`${sk}`,{method:"POST",body:n})}function s$(e,t){return iw(`${sk}/${e}`,{method:"DELETE",signal:t.signal})}async function sj(e,t){return e?(await iw(`${iy}/Patient/${e}`,t)).data:null}function sI(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function sA(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 sM(e){return{uuid:e.uuid,display:e.display}}function sL(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return iw(`${ig}/location${n?"?"+n:""}`).then(e=>e.data.results.map(sM))}function sF(e){return{uuid:e.uuid,display:e.display,name:e.name}}let sB=`${ig}/visittype`;function sU(e=sB){return iw(e).then(e=>e.data.results.map(sF))}var sV=((et={}).NEWVISIT="startVisit",et.EDITVISIT="editVisit",et.LOADING="loadingVisit",et),sW=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let sH="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))",sz=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function sK(){return W("visit",sz)}function sG(e,t){sK().setState({patientUuid:e,manuallySetVisitUuid:t})}function sZ(e,t){return iw(`${ig}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function sY(e,t,r){return iw(`${ig}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function sq(e,t,r){return iw(`${ig}/visit?patient=${e}&v=${r??sH}`,{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 sJ{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+sJ.version}static addUnaryOp(e){return sJ.max_unop_len=Math.max(e.length,sJ.max_unop_len),sJ.unary_ops[e]=1,sJ}static addBinaryOp(e,t,r){return sJ.max_binop_len=Math.max(e.length,sJ.max_binop_len),sJ.binary_ops[e]=t,r?sJ.right_associative.add(e):sJ.right_associative.delete(e),sJ}static addIdentifierChar(e){return sJ.additional_identifier_chars.add(e),sJ}static addLiteral(e,t){return sJ.literals[e]=t,sJ}static removeUnaryOp(e){return delete sJ.unary_ops[e],e.length===sJ.max_unop_len&&(sJ.max_unop_len=sJ.getMaxKeyLen(sJ.unary_ops)),sJ}static removeAllUnaryOps(){return sJ.unary_ops={},sJ.max_unop_len=0,sJ}static removeIdentifierChar(e){return sJ.additional_identifier_chars.delete(e),sJ}static removeBinaryOp(e){return delete sJ.binary_ops[e],e.length===sJ.max_binop_len&&(sJ.max_binop_len=sJ.getMaxKeyLen(sJ.binary_ops)),sJ.right_associative.delete(e),sJ}static removeAllBinaryOps(){return sJ.binary_ops={},sJ.max_binop_len=0,sJ}static removeLiteral(e){return delete sJ.literals[e],sJ}static removeAllLiterals(){return sJ.literals={},sJ}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 sJ(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 sJ.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!sJ.binary_ops[String.fromCharCode(e)]||sJ.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return sJ.isIdentifierStart(e)||sJ.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(sJ.hooks[e]){let r={context:this,node:t};return sJ.hooks.run(e,r),r.node}return t}searchHook(e){if(sJ.hooks[e]){let t={context:this};return sJ.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===sJ.SPACE_CODE||e===sJ.TAB_CODE||e===sJ.LF_CODE||e===sJ.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:sJ.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)===sJ.SEMCOL_CODE||r===sJ.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,sJ.max_binop_len),t=e.length;for(;t>0;){if(sJ.binary_ops.hasOwnProperty(e)&&(!sJ.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!sJ.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:sJ.binaryPrecedence(t),right_a:sJ.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=sJ.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:sJ.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:sJ.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:sJ.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,sJ.isDecimalDigit(e)||e===sJ.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===sJ.SQUOTE_CODE||e===sJ.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===sJ.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,sJ.max_unop_len)).length;r>0;){if(sJ.unary_ops.hasOwnProperty(t)&&(!sJ.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!sJ.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:sJ.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}sJ.isIdentifierStart(e)?(n=this.gobbleIdentifier(),sJ.literals.hasOwnProperty(n.name)?n={type:sJ.LITERAL,value:sJ.literals[n.name],raw:n.name}:n.name===sJ.this_str&&(n={type:sJ.THIS_EXP})):e===sJ.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===sJ.PERIOD_CODE||t===sJ.OBRACK_CODE||t===sJ.OPAREN_CODE||t===sJ.QUMARK_CODE;){let r;if(t===sJ.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==sJ.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===sJ.OBRACK_CODE?((e={type:sJ.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==sJ.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===sJ.OPAREN_CODE?e={type:sJ.CALL_EXP,arguments:this.gobbleArguments(sJ.CPAREN_CODE),callee:e}:(t===sJ.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:sJ.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(;sJ.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===sJ.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);sJ.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++));sJ.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);sJ.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,sJ.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===sJ.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===sJ.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:sJ.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:sJ.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(sJ.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,sJ.isIdentifierPart(e))this.index++;else break;return{type:sJ.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===sJ.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===sJ.COMMA_CODE){if(this.index++,++n!==t.length){if(e===sJ.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===sJ.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!==sJ.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(sJ.CPAREN_CODE);if(this.code===sJ.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:sJ.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:sJ.ARRAY_EXP,elements:this.gobbleArguments(sJ.CBRACK_CODE)}}}Object.assign(sJ,{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)})}}(sJ),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"}),sJ.max_unop_len=sJ.getMaxKeyLen(sJ.unary_ops),sJ.max_binop_len=sJ.getMaxKeyLen(sJ.binary_ops);let sX=e=>new sJ(e).parse(),sQ=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(sJ).filter(e=>!sQ.includes(e)&&void 0===sX[e]).forEach(e=>{sX[e]=sJ[e]}),sX.Jsep=sJ,sX.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 s0="ArrowFunctionExpression",s1={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)}},s4={...s1,Promise};function s2(e,t={}){return s7(e,t,lr)}async function s3(e,t={}){return le(e,t,lr)}function s6(e,t={}){return s7(e,t,ln)}function s5(e,t={}){return le(e,t,ln)}function s9(e,t={}){return s7(e,t,la)}function s8(e,t={}){return le(e,t,la)}function s7(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=lu(t,s1),a=lo("string"==typeof e?sX(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 le(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=lu(t,s4);return Promise.resolve(lo("string"==typeof e?sX(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 lt(e){return sX(e)}function lr(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function ln(e){return"boolean"==typeof e}function la(e){return"number"==typeof e}function lo(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h=e,g=t;let y=lo(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 lo(v.left,b)&&lo(v.right,b);case"||":return lo(v.left,b)||lo(v.right,b);case"??":return lo(v.left,b)??lo(v.right,b)}let w=lo(v.left,b),E=lo(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,lo(r.test,n)?lo(r.consequent,n):lo(r.alternate,n);case"CallExpression":return lm(ls(e,t));case"ArrowFunctionExpression":let x;return a=e,o=t,x=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.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 lo(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return lm(ll(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(lp(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(lp(u)))[D.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(lp(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,(lf(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,p=t,C=m.expressions?.map(lp(p))??[],(P=m.quasis?.map(lp(p))??[]).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:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function li(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return li(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function ls(e,t){let r=ld(e.callee,t);if(r===lc||e.optional&&null==r)return lc;let n=e.arguments?.map(lp(t));if(r){if("function"!=typeof r)throw`${ly(e.callee)} is not a function`}else throw`No function named ${ly(e.callee)} is defined in this context`;return r(...n)}function ll(e,t){let r=ld(e.object,t);if(r===lc||e.optional&&null==r)return lc;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${lg(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=li(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${lg(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}(lo(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);lf(n),function(e,t){if(lh.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 lu(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}sX.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:s0,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=s0,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)})}}),sX.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"}})}}),sX.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)})}}),sX.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")}})}}),sX.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 :")}})}}),sX.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})}}),sX.addBinaryOp("in",7),sX.addBinaryOp("??",1);let lc=Symbol("optional chain short-circuited");function ld(e,t){switch(e.type){case"MemberExpression":return ll(e,t);case"CallExpression":return ls(e,t);default:return lo(e,t)}}function lm(e){return e===lc?void 0:e}function lp(e){return function(t){return null===t?null:lo(t,e)}}function lf(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let lh=new Set(["toString","valueOf","hasOwnProperty"]);function lg(e,t){try{return li(e,t)}catch{return"<computed>"}}function ly(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function lv(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:{...s4},boundNames:new Set,variables:new Set};return lb("string"==typeof e?sX(e):e,t),[...t.variables]}function lb(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void lb(r.argument,n);case"BinaryExpression":return a=e,o=t,void(lb(a.left,o),lb(a.right,o));case"ConditionalExpression":return i=e,s=t,void(lb(i.consequent,s),lb(i.test,s),lb(i.alternate,s));case"CallExpression":return l=e,u=t,void(lb(l.callee,u),l.arguments?.map(lw(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b,w,E,x=e,D=t;let _=new Set(D.boundNames);for(let e of x.params??[])e?.type==="Identifier"&&_.add(e.name);lb(x.body,{...D,boundNames:_});return;case"MemberExpression":return c=e,d=t,void(lb(c.object,d),c.computed&&lb(c.property,d));case"ArrayExpression":return m=e,p=t,void m.elements?.map(lw(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(lw(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(lw(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(lw(E)),w.quasis?.map(lw(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function lw(e){return function(t){return null===t?null:lb(t,e)}}let lE=W("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 lx(e,t,r){lE.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function lD(){let e=lE.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 l_(e){return lE.getState().flags[e].enabled}function lS(e,t){lE.subscribe(r=>{t(r.flags[e].enabled)})}function lC(e,t){lE.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}lE.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 lP=tG(function(e,t,r){tF(e,t,r)});let lk=B("extensionsInternal",{slots:{},extensions:{}}),lT=B("extensionRenderings",{renderings:new Map}),lR=()=>W("extensionsInternal",{slots:{},extensions:{}}),lO=()=>W("extensionRenderings",{renderings:new Map});function lN(e){let t=lk.getState(),r=e(t);r!==t&&lk.setState(r)}let l$=null,lj=null;function lI(){let e=lT.getState();return l$&&e===lj||(l$=new Map(e.renderings),lj=e,function(e){for(let t of(lz.clear(),e.values()))lG(t,1);lK=!0}(l$)),l$}function lA(e){lj={renderings:e},lT.setState(lj,!0)}function lM(e){let t=lI();t.has(e.renderingId)||(t.set(e.renderingId,e),lG(e,1),lA(t))}function lL(e){let t=lI(),r=t.get(e);r&&(t.delete(e),lG(r,-1),lA(t))}let lF=()=>W("extensions",{slots:{}}),lB=0,lU=new Set;function lV(e){lB++;try{return e()}finally{if(0==--lB&&lU.size>0){let e=Array.from(lU);for(let t of(lU.clear(),e))lW(t)}}}function lW(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function lH(e){lB>0?lU.add(e):lW(e)}let lz=new Map,lK=!1;function lG(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=lz.get(r);if(!n){if(t<0)return;lz.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&&(lz.delete(r),lK=!0)}function lZ(){var e,t;if(lI(),!lK)return;lK=!1;let r=Array.from(lz.values(),({record:e})=>e);r.sort(lY),e=nw.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===lY(e,t[r]))||nw.setState({mountedExtensions:r})}function lY(e,t){return lq(e.slotName,t.slotName)||lq(e.extensionId,t.extensionId)||lq(e.slotModuleName,t.slotModuleName)||lq(e.extensionModuleName,t.extensionModuleName)}function lq(e,t){return e===t?0:e<t?-1:1}lZ(),lT.subscribe(()=>lH(lZ));let lJ=lR(),lX=lF(),lQ=nx(),l0=nS(),l1=new Set,l4=!1;function l2(e){if(null===e)l1=null;else if(null!==l1)for(let t of e)l1.add(t);lH(l3)}function l3(){if(!l4){l4=!0;try{for(let e=1;;e++){let t=l1;if(null!==t&&0===t.size)return;l1=new Set;try{!function(e,t,r,n,a,o=null){let i=lX.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}=n_(t,c.name),p=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=lJ.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=ua(a),u=ua(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[l9(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}=nC(n,e,l),u=nP(r,e,l),c=u?lP({},i,u):i,d=l9(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||!iO(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&&rk(d.candidateExtensions,p)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&lX.setState({slots:s})}(lJ.getState(),lQ.getState(),l0.getState(),lE.getState(),ix.getState(),t)}catch(e){throw l1=null===t||null===l1?null:new Set([...t,...l1]),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{l4=!1}}}function l6(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 l5(e,t){return{moduleName:t,name:e,attachedIds:[]}}function l9(e){let[t]=e.split("#");return t}function l8(e,t){let r=l9(t);return e.extensions[r]}function l7(e){return l8(lJ.getState(),e)}lJ.subscribe((e,t)=>{l2(e.extensions!==t.extensions?null:l6(e.slots,t.slots))}),lQ.subscribe((e,t)=>{l2(l6(e.slots,t.slots))}),l0.subscribe((e,t)=>{l2(l6(e.configs,t.configs))}),lE.subscribe(()=>l2(null)),ix.subscribe(()=>l2(null)),l2(null);let ue=e=>lN(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function ut(e,t){lN(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...l5(e),attachedIds:[t]}}}})}function ur(e,t){lN(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 un(e){lN(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function ua(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function uo(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!!s6(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(ui(e),t,ix.getState().session,e)}function ui(e){return lX.getState().slots[e]?.candidateExtensions??[]}let us=(e,t)=>lJ.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=l5(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),ul=()=>{l1=null,lN(()=>({slots:{},extensions:{}})),lO().setState({renderings:new Map}),lX.setState({slots:{}})},uu=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function uc({name:e,basePath:t,mode:r,componentContext:n,state:a}){uu.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function ud(e){uu.getState().slotName===e&&uu.setState(uu.getInitialState(),!0)}let um=B("modalRegistry",{modals:{}});function up(e){um.setState(t=>(t.modals[e.name]=e,t))}function uf(e){let t=um.getState().modals[e];if(!t){let r=l7(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.`),up(t))}return t}let uh=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function ug(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=uh.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 uy(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=uh.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 uv(e){let{openedWindows:t}=uh.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function ub(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=uh.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}}uh.setState({registeredGroupsByName:n})}function uw(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=uh.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}uh.setState({registeredWindowsByName:n})}function uE(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=uh.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}uh.setState({registeredWorkspacesByName:n})}let ux=0,uD=null,u_={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(u_).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=u_[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 uC(e,t){var r,n;let a,o,i,s,l,u=await (uD??(uD=new Promise((e,t)=>{ot({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),ot))),uD),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 uP(){return uk}function uk(e,t){let r,n=uC(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 uT(e,t,r,n,a=e=>e,o={}){let i=l9(n),s=l7(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,p=ux++,f=`${t}/${n}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{lL(f)}catch(t){console.error(e,t)}};try{lM({renderingId:f,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 uC(a({...u,name:`${t}/${i}-${p}`}),{...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 uR=r(2491),uO=r.n(uR);let uN=(0,uR.createContext)({moduleName:"",featureName:""});var u$=r(1982);function uj({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,uR.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}`)},[]),(0,u$.jsx)("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),io({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:ir(e,t),...a,children:n})}let uI=({state:e,children:t,...r})=>{let{extension:n}=(0,uR.useContext)(uN),a=(0,uR.useRef)(null),o=(0,uR.useRef)(Promise.resolve()),i=(0,uR.useRef)(!1),s=(0,uR.useRef)(!1),l=(0,uR.useRef)(e),u=(0,uR.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,uR.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,uR.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,uT(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,uR.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,uR.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?(0,u$.jsx)("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function uA(e){let t=(0,uR.useRef)(e);return R(t.current,e)||(t.current=e),t.current}function uM(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 uL=e=>e;function uF(e,t=uL,r){let n=(0,uR.useCallback)(t=>e.subscribe(t),[e]),a=(0,uR.useCallback)(()=>t(e.getState()),[e,t]),o=(0,uR.useSyncExternalStore)(n,a,a),i=(0,uR.useMemo)(()=>r?uM(e,r):null,[e,r]);return(0,uR.useMemo)(()=>i?{...o,...i}:o,[o,i])}function uB(e,t){return uF(e,uL,t)}function uU(e){return function(t){let r=(0,uR.useCallback)(t=>e.subscribe(t),[]),n=(0,uR.useCallback)(()=>e.getState(),[]),a=(0,uR.useSyncExternalStore)(r,n,n),o=(0,uR.useMemo)(()=>t?uM(e,t):null,[t]);return(0,uR.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let uV=[];Object.freeze(uV);let uW={candidateExtensions:uV};Object.freeze(uW);let uH=e=>{let t=(0,uR.useCallback)(t=>t.slots?.[e]??uW,[e]);return uF(lF(),t)},uz=e=>e.session;function uK(e,t){let{candidateExtensions:r}=uH(e),n=uF(ix,uz),a=uA(t);return(0,uR.useMemo)(()=>uo(e,a),[e,a,n,r])}function uG(e,t){let{moduleName:r}=(0,uR.useContext)(uN);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,uR.useEffect)(()=>{us(r,e)},[r,e]),{extensions:uK(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function uZ(e){return e}function uY({name:e,extensionSlotName:t,select:r=uZ,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,uR.useRef)(null),{extensions:u,extensionSlotModuleName:c}=uG(s,a),d=(0,uR.useMemo)(()=>r(u),[r,u]),m=(0,uR.useMemo)(()=>{if("function"==typeof n&&!uO().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return(0,u$.jsx)("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i,children:s&&d?.map((e,t)=>(0,u$.jsx)(uN.Provider,{value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}},children:m?.[t]??("function"!=typeof n?n:null)??(0,u$.jsx)(uI,{state:a})},e.id))})}var uq=r(2870),uJ=r.n(uq);function uX(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 uQ(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?uX(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)):uX(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function u0(e){return(u0="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 u1(e){return(u1="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 u4(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(u1(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(u1(e)));return e}}var u2=null;try{u2=require("react").createContext()}catch(e){}var u3={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 u6(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function u5(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=ce(e,t,function(){r(this)}),i=u4(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:u7(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function u9(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():u7(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function u8(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=ce(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=u4(e,t)();u7(e).render(n,o)}})}function u7(e){return e.ReactDOMClient||e.ReactDOM}function ce(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=u2?e.React.createElement(u2.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,uQ(uQ({},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 ct=r(4011),cr=r(5327),cn=r.n(cr),ca=r(3780);let co={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ci=new Map;(0,ca.initCache)(ci);let cs={errorRetryCount:3,fetcher:iw,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof iE){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>ci};function cl(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},co,e),r={...cs,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=uO().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(0,u$.jsx)("div",{children:"An error has occurred. Please try reloading the page."});{let n=(0,u$.jsx)(uR.Suspense,{fallback:null,children:(0,u$.jsx)(cr.SWRConfig,{value:r,children:(0,u$.jsx)(uN.Provider,{value:this.state.config,children:t.disableTranslations?(0,u$.jsx)(e,{...this.props}):(0,u$.jsx)(ct.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,children:(0,u$.jsx)(e,{...this.props})})})})});return t.strictMode&&uO().StrictMode?(0,u$.jsx)(uO().StrictMode,{children: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 cu(e,t){return function(e){if("object"!==u0(e))throw Error("single-spa-react requires a configuration object");var t,r=uQ(uQ({},u3),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");!u2&&r.React.createContext&&(u2=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:u6.bind(null,r),mount:u5.bind(null,r),unmount:u9.bind(null,r)};return r.parcelCanUpdate&&(n.update=u8.bind(null,r)),n}({React:uO(),ReactDOMClient:uJ(),rootComponent:cl(t)(e)})}function cc(e,t){return()=>e().then(({default:e})=>cu(e,t))}function cd(e,t){return()=>Promise.resolve(cu(e,t))}let cm=cc,cp=j()(()=>({}));V("openmrs-app-context",cp);let cf={};function ch(e,t=e=>e){let r=cp.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function cg(e,t){cp.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function cy(e){return null===e?null:Object.freeze(Object.assign({},e))}let cv=new Map;function cb(e,t){let r=(0,uR.useRef)(t??{}),n=(0,uR.useRef)(t=>cg(e,t)),a=(0,uR.useRef)(Symbol());return(0,uR.useEffect)(()=>{let r=t??{},n=a.current;return null===ch(e)?!function(e,t=cf){cp.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===cf?{}: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.`),cg(e,()=>r)),cv.set(e,n),()=>{cv.get(e)===n&&(cp.setState(t=>(e in t&&delete t[e],t)),cv.delete(e))}},[e]),(0,uR.useEffect)(()=>{let n=t??{};R(r.current,n)||(cg(e,()=>n),r.current=n)},[t]),n.current}function cw({namespace:e,value:t}){return cb(e,t),null}let cE=({children:e,value:t,fallback:r})=>t?(0,u$.jsx)(u$.Fragment,{children:e}):r?(0,u$.jsx)(u$.Fragment,{children:r}):null;function cx(){let e=(0,uR.useRef)(null);return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,uR.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function cD(e,t=e=>e??{}){let[r,n]=(0,uR.useState)(()=>{if(c_(e))return;let r=ch(e);if(null!==r)return t?t(r):r});return(0,uR.useEffect)(()=>{if(c_(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,uR.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>R(e,r)?e:r)})(cy(a=ch(e))),cp.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(cy(n)))})},[e,t]),r}function c_(e){return"string"!=typeof e||0===e.trim().length}function cS(e){let t=uK(e);return(0,uR.useMemo)(()=>t.map(e=>e.id),[t])}function cC(e){return uH(e).candidateExtensions}function cP(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=cn()(e?sO(e,t,r):null,iw);return(0,uR.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function ck(e){(0,uR.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let cT={},cR=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let ix=B("session",{loaded:!1,session:null}),iD=0,i_=null;function iS(){return i_||(ix.getState().loaded&&iD>=Date.now()-6e4?null:iT())}function iC(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=iS();return n?new Promise(e=>{let t=()=>{let t=ix.getState();t.loaded&&(a(),e(r(t.session)))},a=ix.subscribe(t);n.then(t,t)}):Promise.resolve(r(ix.getState().session))}function iP(){return iS(),ix}function ik(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 iT(e,t){iD=Date.now(),o??(o=iD);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=iF(iw(iv,{headers:r,rejectAuthFailure:!0})),a=()=>{i_===n&&(i_=null)};return n.then(a,a),i_=n,n}function iR(){ix.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function iO(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!K(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!K(n.privileges.find(t=>e===t.display))):(K(r)||console.error(`Could not understand privileges "${r}"`),!0))||!K(t.roles.find(e=>"System Developer"===e.display))}function iN(){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(ix.getState()),e||(t=ix.subscribe(n))})}async function i$(){return(await iC()).sessionLocation}async function ij(e,t){return iF(iw(iv,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function iI(e,t){return await iw(iv,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),iT()}async function iA(e,t,r){return r||(r=new AbortController),await iw(`${ig}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),iT()}async function iM(e,t=!1){let r=await iw(t?`${iv}?rememberMe=true`:iv,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await iT()).session:r.data}async function iL(){try{await iw(iv,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!iB(e))throw e}iR(),await iT().catch(()=>{})}function iF(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};ix.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(iU(Error("The session endpoint did not respond with a session"))):r(iU(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(iB(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?ix.setState({loaded:!0,session:e.responseBody},!0):iR(),t(ix.getState());return}(a=e)instanceof iE&&502===a.response.status&&!ix.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(iU(e,!0)):(P(`Failed to fetch new session information: ${e}`),r(iU(e)))})})}function iB(e){return e instanceof iE&&(401===e.response.status||403===e.response.status)}function iU(e,t=!1){return ix.getState().loaded||ix.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),ix.getState()}function iV(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}ix.subscribe(e=>{e.loaded&&e.session&&ik(e.session)});let iW={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function iH(){nZ("@openmrs/esm-api",ip),iT()}let iz="import-map-override:",iK="import-map-overrides-disabled",iG="import-map-overrides:change",iZ=!1,iY=null,iq=null;async function iJ(){return iq??(iq=iX().then(({map:e,complete:t})=>(t||(iq=null),e))),iq}async function iX(){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:iQ(t),complete:r}}function iQ(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function i0(){let e={};try{let t=i6();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(iz)){let r=n.slice(iz.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 i1(){let e=await iJ();return iZ?iQ([e,iY??i0()]):e}async function i4(){return iJ()}async function i2(){return iZ?iQ([await iJ(),i0()]):iJ()}function i3(e){if(!iZ)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(iz)){let t=localStorage.getItem(r);t&&(e[r.slice(iz.length)]=t)}}return{imports:e}}return i0()}function i6(){if(!iZ)return[];try{let e=localStorage.getItem(iK);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function i5(e){return!!iZ&&i6().includes(e)}function i9(e,t){if(!iZ)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(iz+e,t),window.dispatchEvent(new CustomEvent(iG))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function i8(e){if(!iZ)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(iz+e);let t=i6().filter(t=>t!==e);t.length>0?localStorage.setItem(iK,JSON.stringify(t)):localStorage.removeItem(iK),window.dispatchEvent(new CustomEvent(iG))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function i7(){if(!iZ)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(iz)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(iK),window.dispatchEvent(new CustomEvent(iG))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function se(e){if(!iZ)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=i6().filter(t=>t!==e);t.length>0?localStorage.setItem(iK,JSON.stringify(t)):localStorage.removeItem(iK),window.dispatchEvent(new CustomEvent(iG))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let st=!1;function sr(){!st&&(st=!0,(iZ="development"===window.spaEnv)&&(iY=i0()))}function sn(e){return e.replace(/[\/\-@]/g,"_")}async function sa(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([so(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=sn(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 so(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=sn(e);if(!window[r]){let r=t??await si();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 i3().imports;try{return await function(e){var t;let r=(t=window)[ss]??(t[ss]=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&&E({kind:"error",title:it("scriptLoadingFailed","Error: Script failed to load"),description:it("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:it("resetOverrides","Reset overrides"),onActionButtonClick(){i7(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function si(){return i1()}let ss=Symbol.for("__openmrs_script_loading");function sl(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 su(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&&sl(t))}let sc="openmrs-routes:",sd="openmrs-routes:change",sm=!1,sp=null,sf=null;async function sh(){return sf??(sf=sg().then(({map:e,complete:t})=>(t||(sf=null),e))),sf}async function sg(){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&&su(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:sy(t),complete:r}}function sy(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 sv(){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(sc)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(sc.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(sl(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(sl(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 sb(){let e=await sh();return sm?sy([e,sp??await sv()]):e}async function sw(){return sh()}async function sE(){return sm?sy([await sh(),await sv()]):sh()}function sx(){if(!sm)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sc)){let t=localStorage.getItem(r);t&&(e[r.slice(sc.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function sD(e,t){if(!sm)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(sc+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!sl(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(sc+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(sc+e,JSON.stringify(t.toString()));else{if(!sl(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(sc+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(sd))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function s_(e){if(!sm)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(sc+e),window.dispatchEvent(new CustomEvent(sd))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function sS(){if(!sm)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(sc)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sd))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let sC=null;function sP(){return sC||(sC=(sm="development"===window.spaEnv)?sv().then(e=>{sp=e}):Promise.resolve())}let sk=`${ig}/attachment`;function sT(e,t){return iw(`${sk}/${e}`,{signal:t.signal})}function sR(e,t,r,n){return iw(sO(e,t,n),{signal:r.signal})}function sO(e,t,r){return r?`${sk}?patient=${e}&encounter=${r}`:`${sk}?patient=${e}&includeEncounterless=${t}`}async function sN(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)),iw(`${sk}`,{method:"POST",body:n})}function s$(e,t){return iw(`${sk}/${e}`,{method:"DELETE",signal:t.signal})}async function sj(e,t){return e?(await iw(`${iy}/Patient/${e}`,t)).data:null}function sI(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function sA(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 sM(e){return{uuid:e.uuid,display:e.display}}function sL(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return iw(`${ig}/location${n?"?"+n:""}`).then(e=>e.data.results.map(sM))}function sF(e){return{uuid:e.uuid,display:e.display,name:e.name}}let sB=`${ig}/visittype`;function sU(e=sB){return iw(e).then(e=>e.data.results.map(sF))}var sV=((et={}).NEWVISIT="startVisit",et.EDITVISIT="editVisit",et.LOADING="loadingVisit",et),sW=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let sH="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))",sz=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function sK(){return W("visit",sz)}function sG(e,t){sK().setState({patientUuid:e,manuallySetVisitUuid:t})}function sZ(e,t){return iw(`${ig}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function sY(e,t,r){return iw(`${ig}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function sq(e,t,r){return iw(`${ig}/visit?patient=${e}&v=${r??sH}`,{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 sJ{static get version(){return"1.6.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+sJ.version}static addUnaryOp(e){return sJ.max_unop_len=Math.max(e.length,sJ.max_unop_len),sJ.unary_ops[e]=1,sJ}static addBinaryOp(e,t,r){return sJ.max_binop_len=Math.max(e.length,sJ.max_binop_len),sJ.binary_ops[e]=t,r?sJ.right_associative.add(e):sJ.right_associative.delete(e),sJ}static addIdentifierChar(e){return sJ.additional_identifier_chars.add(e),sJ}static addLiteral(e,t){return sJ.literals[e]=t,sJ}static removeUnaryOp(e){return delete sJ.unary_ops[e],e.length===sJ.max_unop_len&&(sJ.max_unop_len=sJ.getMaxKeyLen(sJ.unary_ops)),sJ}static removeAllUnaryOps(){return sJ.unary_ops={},sJ.max_unop_len=0,sJ}static removeIdentifierChar(e){return sJ.additional_identifier_chars.delete(e),sJ}static removeBinaryOp(e){return delete sJ.binary_ops[e],e.length===sJ.max_binop_len&&(sJ.max_binop_len=sJ.getMaxKeyLen(sJ.binary_ops)),sJ.right_associative.delete(e),sJ}static removeAllBinaryOps(){return sJ.binary_ops={},sJ.max_binop_len=0,sJ}static removeLiteral(e){return delete sJ.literals[e],sJ}static removeAllLiterals(){return sJ.literals={},sJ}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 sJ(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 sJ.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!sJ.binary_ops[String.fromCharCode(e)]||sJ.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return sJ.isIdentifierStart(e)||sJ.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(sJ.hooks[e]){let r={context:this,node:t};return sJ.hooks.run(e,r),r.node}return t}searchHook(e){if(sJ.hooks[e]){let t={context:this};return sJ.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===sJ.SPACE_CODE||e===sJ.TAB_CODE||e===sJ.LF_CODE||e===sJ.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:sJ.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)===sJ.SEMCOL_CODE||r===sJ.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,sJ.max_binop_len),t=e.length;for(;t>0;){if(sJ.binary_ops.hasOwnProperty(e)&&(!sJ.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!sJ.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:sJ.binaryPrecedence(t),right_a:sJ.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=sJ.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:sJ.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:sJ.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:sJ.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,sJ.isDecimalDigit(e)||e===sJ.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===sJ.SQUOTE_CODE||e===sJ.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===sJ.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,sJ.max_unop_len)).length;r>0;){if(sJ.unary_ops.hasOwnProperty(t)&&(!sJ.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!sJ.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:sJ.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}sJ.isIdentifierStart(e)?(n=this.gobbleIdentifier(),sJ.literals.hasOwnProperty(n.name)?n={type:sJ.LITERAL,value:sJ.literals[n.name],raw:n.name}:n.name===sJ.this_str&&(n={type:sJ.THIS_EXP})):e===sJ.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===sJ.PERIOD_CODE||t===sJ.OBRACK_CODE||t===sJ.OPAREN_CODE||t===sJ.QUMARK_CODE;){let r;if(t===sJ.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==sJ.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===sJ.OBRACK_CODE?((e={type:sJ.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==sJ.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===sJ.OPAREN_CODE?e={type:sJ.CALL_EXP,arguments:this.gobbleArguments(sJ.CPAREN_CODE),callee:e}:(t===sJ.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:sJ.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(;sJ.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===sJ.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);sJ.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++));sJ.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);sJ.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,sJ.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===sJ.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===sJ.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:sJ.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:sJ.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(sJ.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,sJ.isIdentifierPart(e))this.index++;else break;return{type:sJ.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===sJ.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===sJ.COMMA_CODE){if(this.index++,++n!==t.length){if(e===sJ.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===sJ.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!==sJ.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(sJ.CPAREN_CODE);if(this.code===sJ.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:sJ.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:sJ.ARRAY_EXP,elements:this.gobbleArguments(sJ.CBRACK_CODE)}}}Object.assign(sJ,{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)})}}(sJ),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"}),sJ.max_unop_len=sJ.getMaxKeyLen(sJ.unary_ops),sJ.max_binop_len=sJ.getMaxKeyLen(sJ.binary_ops);let sX=e=>new sJ(e).parse(),sQ=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(sJ).filter(e=>!sQ.includes(e)&&void 0===sX[e]).forEach(e=>{sX[e]=sJ[e]}),sX.Jsep=sJ,sX.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 s0="ArrowFunctionExpression",s1={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)}},s4={...s1,Promise};function s2(e,t={}){return s7(e,t,lr)}async function s3(e,t={}){return le(e,t,lr)}function s6(e,t={}){return s7(e,t,ln)}function s5(e,t={}){return le(e,t,ln)}function s9(e,t={}){return s7(e,t,la)}function s8(e,t={}){return le(e,t,la)}function s7(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=lu(t,s1),a=lo("string"==typeof e?sX(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 le(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=lu(t,s4);return Promise.resolve(lo("string"==typeof e?sX(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 lt(e){return sX(e)}function lr(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function ln(e){return"boolean"==typeof e}function la(e){return"number"==typeof e}function lo(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h=e,g=t;let y=lo(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 lo(v.left,b)&&lo(v.right,b);case"||":return lo(v.left,b)||lo(v.right,b);case"??":return lo(v.left,b)??lo(v.right,b)}let w=lo(v.left,b),E=lo(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,lo(r.test,n)?lo(r.consequent,n):lo(r.alternate,n);case"CallExpression":return lm(ls(e,t));case"ArrowFunctionExpression":let x;return a=e,o=t,x=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.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 lo(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return lm(ll(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(lp(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(lp(u)))[D.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(lp(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,(lf(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,p=t,C=m.expressions?.map(lp(p))??[],(P=m.quasis?.map(lp(p))??[]).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:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function li(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return li(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function ls(e,t){let r=ld(e.callee,t);if(r===lc||e.optional&&null==r)return lc;let n=e.arguments?.map(lp(t));if(r){if("function"!=typeof r)throw`${ly(e.callee)} is not a function`}else throw`No function named ${ly(e.callee)} is defined in this context`;return r(...n)}function ll(e,t){let r=ld(e.object,t);if(r===lc||e.optional&&null==r)return lc;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${lg(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=li(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${lg(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}(lo(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);lf(n),function(e,t){if(lh.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 lu(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}sX.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:s0,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=s0,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)})}}),sX.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"}})}}),sX.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)})}}),sX.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")}})}}),sX.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 :")}})}}),sX.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})}}),sX.addBinaryOp("in",7),sX.addBinaryOp("??",1);let lc=Symbol("optional chain short-circuited");function ld(e,t){switch(e.type){case"MemberExpression":return ll(e,t);case"CallExpression":return ls(e,t);default:return lo(e,t)}}function lm(e){return e===lc?void 0:e}function lp(e){return function(t){return null===t?null:lo(t,e)}}function lf(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let lh=new Set(["toString","valueOf","hasOwnProperty"]);function lg(e,t){try{return li(e,t)}catch{return"<computed>"}}function ly(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function lv(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:{...s4},boundNames:new Set,variables:new Set};return lb("string"==typeof e?sX(e):e,t),[...t.variables]}function lb(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void lb(r.argument,n);case"BinaryExpression":return a=e,o=t,void(lb(a.left,o),lb(a.right,o));case"ConditionalExpression":return i=e,s=t,void(lb(i.consequent,s),lb(i.test,s),lb(i.alternate,s));case"CallExpression":return l=e,u=t,void(lb(l.callee,u),l.arguments?.map(lw(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b,w,E,x=e,D=t;let _=new Set(D.boundNames);for(let e of x.params??[])e?.type==="Identifier"&&_.add(e.name);lb(x.body,{...D,boundNames:_});return;case"MemberExpression":return c=e,d=t,void(lb(c.object,d),c.computed&&lb(c.property,d));case"ArrayExpression":return m=e,p=t,void m.elements?.map(lw(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(lw(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(lw(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(lw(E)),w.quasis?.map(lw(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function lw(e){return function(t){return null===t?null:lb(t,e)}}let lE=W("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 lx(e,t,r){lE.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function lD(){let e=lE.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 l_(e){return lE.getState().flags[e].enabled}function lS(e,t){lE.subscribe(r=>{t(r.flags[e].enabled)})}function lC(e,t){lE.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}lE.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 lP=tG(function(e,t,r){tF(e,t,r)});let lk=B("extensionsInternal",{slots:{},extensions:{}}),lT=B("extensionRenderings",{renderings:new Map}),lR=()=>W("extensionsInternal",{slots:{},extensions:{}}),lO=()=>W("extensionRenderings",{renderings:new Map});function lN(e){let t=lk.getState(),r=e(t);r!==t&&lk.setState(r)}let l$=null,lj=null;function lI(){let e=lT.getState();return l$&&e===lj||(l$=new Map(e.renderings),lj=e,function(e){for(let t of(lz.clear(),e.values()))lG(t,1);lK=!0}(l$)),l$}function lA(e){lj={renderings:e},lT.setState(lj,!0)}function lM(e){let t=lI();t.has(e.renderingId)||(t.set(e.renderingId,e),lG(e,1),lA(t))}function lL(e){let t=lI(),r=t.get(e);r&&(t.delete(e),lG(r,-1),lA(t))}let lF=()=>W("extensions",{slots:{}}),lB=0,lU=new Set;function lV(e){lB++;try{return e()}finally{if(0==--lB&&lU.size>0){let e=Array.from(lU);for(let t of(lU.clear(),e))lW(t)}}}function lW(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function lH(e){lB>0?lU.add(e):lW(e)}let lz=new Map,lK=!1;function lG(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=lz.get(r);if(!n){if(t<0)return;lz.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&&(lz.delete(r),lK=!0)}function lZ(){var e,t;if(lI(),!lK)return;lK=!1;let r=Array.from(lz.values(),({record:e})=>e);r.sort(lY),e=nw.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===lY(e,t[r]))||nw.setState({mountedExtensions:r})}function lY(e,t){return lq(e.slotName,t.slotName)||lq(e.extensionId,t.extensionId)||lq(e.slotModuleName,t.slotModuleName)||lq(e.extensionModuleName,t.extensionModuleName)}function lq(e,t){return e===t?0:e<t?-1:1}lZ(),lT.subscribe(()=>lH(lZ));let lJ=lR(),lX=lF(),lQ=nx(),l0=nS(),l1=new Set,l4=!1;function l2(e){if(null===e)l1=null;else if(null!==l1)for(let t of e)l1.add(t);lH(l3)}function l3(){if(!l4){l4=!0;try{for(let e=1;;e++){let t=l1;if(null!==t&&0===t.size)return;l1=new Set;try{!function(e,t,r,n,a,o=null){let i=lX.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}=n_(t,c.name),p=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=lJ.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=ua(a),u=ua(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[l9(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}=nC(n,e,l),u=nP(r,e,l),c=u?lP({},i,u):i,d=l9(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||!iO(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&&rk(d.candidateExtensions,p)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&lX.setState({slots:s})}(lJ.getState(),lQ.getState(),l0.getState(),lE.getState(),ix.getState(),t)}catch(e){throw l1=null===t||null===l1?null:new Set([...t,...l1]),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{l4=!1}}}function l6(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 l5(e,t){return{moduleName:t,name:e,attachedIds:[]}}function l9(e){let[t]=e.split("#");return t}function l8(e,t){let r=l9(t);return e.extensions[r]}function l7(e){return l8(lJ.getState(),e)}lJ.subscribe((e,t)=>{l2(e.extensions!==t.extensions?null:l6(e.slots,t.slots))}),lQ.subscribe((e,t)=>{l2(l6(e.slots,t.slots))}),l0.subscribe((e,t)=>{l2(l6(e.configs,t.configs))}),lE.subscribe(()=>l2(null)),ix.subscribe(()=>l2(null)),l2(null);let ue=e=>lN(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function ut(e,t){lN(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...l5(e),attachedIds:[t]}}}})}function ur(e,t){lN(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 un(e){lN(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function ua(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function uo(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!!s6(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(ui(e),t,ix.getState().session,e)}function ui(e){return lX.getState().slots[e]?.candidateExtensions??[]}let us=(e,t)=>lJ.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=l5(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),ul=()=>{l1=null,lN(()=>({slots:{},extensions:{}})),lO().setState({renderings:new Map}),lX.setState({slots:{}})},uu=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function uc({name:e,basePath:t,mode:r,componentContext:n,state:a}){uu.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function ud(e){uu.getState().slotName===e&&uu.setState(uu.getInitialState(),!0)}let um=B("modalRegistry",{modals:{}});function up(e){um.setState(t=>(t.modals[e.name]=e,t))}function uf(e){let t=um.getState().modals[e];if(!t){let r=l7(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.`),up(t))}return t}let uh=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function ug(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=uh.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 uy(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=uh.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 uv(e){let{openedWindows:t}=uh.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function ub(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=uh.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}}uh.setState({registeredGroupsByName:n})}function uw(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=uh.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}uh.setState({registeredWindowsByName:n})}function uE(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=uh.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}uh.setState({registeredWorkspacesByName:n})}let ux=0,uD=null,u_={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(u_).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=u_[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 uC(e,t){var r,n;let a,o,i,s,l,u=await (uD??(uD=new Promise((e,t)=>{ot({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),ot))),uD),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 uP(){return uk}function uk(e,t){let r,n=uC(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 uT(e,t,r,n,a=e=>e,o={}){let i=l9(n),s=l7(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,p=ux++,f=`${t}/${n}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{lL(f)}catch(t){console.error(e,t)}};try{lM({renderingId:f,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 uC(a({...u,name:`${t}/${i}-${p}`}),{...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 uR=r(2491),uO=r.n(uR);let uN=(0,uR.createContext)({moduleName:"",featureName:""});var u$=r(1982);function uj({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,uR.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}`)},[]),(0,u$.jsx)("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),io({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:ir(e,t),...a,children:n})}let uI=({state:e,children:t,...r})=>{let{extension:n}=(0,uR.useContext)(uN),a=(0,uR.useRef)(null),o=(0,uR.useRef)(Promise.resolve()),i=(0,uR.useRef)(!1),s=(0,uR.useRef)(!1),l=(0,uR.useRef)(e),u=(0,uR.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,uR.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,uR.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,uT(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,uR.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,uR.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?(0,u$.jsx)("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function uA(e){let t=(0,uR.useRef)(e);return R(t.current,e)||(t.current=e),t.current}function uM(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 uL=e=>e;function uF(e,t=uL,r){let n=(0,uR.useCallback)(t=>e.subscribe(t),[e]),a=(0,uR.useCallback)(()=>t(e.getState()),[e,t]),o=(0,uR.useSyncExternalStore)(n,a,a),i=(0,uR.useMemo)(()=>r?uM(e,r):null,[e,r]);return(0,uR.useMemo)(()=>i?{...o,...i}:o,[o,i])}function uB(e,t){return uF(e,uL,t)}function uU(e){return function(t){let r=(0,uR.useCallback)(t=>e.subscribe(t),[]),n=(0,uR.useCallback)(()=>e.getState(),[]),a=(0,uR.useSyncExternalStore)(r,n,n),o=(0,uR.useMemo)(()=>t?uM(e,t):null,[t]);return(0,uR.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let uV=[];Object.freeze(uV);let uW={candidateExtensions:uV};Object.freeze(uW);let uH=e=>{let t=(0,uR.useCallback)(t=>t.slots?.[e]??uW,[e]);return uF(lF(),t)},uz=e=>e.session;function uK(e,t){let{candidateExtensions:r}=uH(e),n=uF(ix,uz),a=uA(t);return(0,uR.useMemo)(()=>uo(e,a),[e,a,n,r])}function uG(e,t){let{moduleName:r}=(0,uR.useContext)(uN);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,uR.useEffect)(()=>{us(r,e)},[r,e]),{extensions:uK(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function uZ(e){return e}function uY({name:e,extensionSlotName:t,select:r=uZ,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,uR.useRef)(null),{extensions:u,extensionSlotModuleName:c}=uG(s,a),d=(0,uR.useMemo)(()=>r(u),[r,u]),m=(0,uR.useMemo)(()=>{if("function"==typeof n&&!uO().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return(0,u$.jsx)("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i,children:s&&d?.map((e,t)=>(0,u$.jsx)(uN.Provider,{value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}},children:m?.[t]??("function"!=typeof n?n:null)??(0,u$.jsx)(uI,{state:a})},e.id))})}var uq=r(2870),uJ=r.n(uq);function uX(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 uQ(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?uX(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)):uX(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function u0(e){return(u0="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 u1(e){return(u1="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 u4(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(u1(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(u1(e)));return e}}var u2=null;try{u2=require("react").createContext()}catch(e){}var u3={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 u6(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function u5(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=ce(e,t,function(){r(this)}),i=u4(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:u7(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function u9(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():u7(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function u8(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=ce(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=u4(e,t)();u7(e).render(n,o)}})}function u7(e){return e.ReactDOMClient||e.ReactDOM}function ce(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=u2?e.React.createElement(u2.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,uQ(uQ({},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 ct=r(4011),cr=r(5327),cn=r.n(cr),ca=r(3780);let co={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ci=new Map;(0,ca.initCache)(ci);let cs={errorRetryCount:3,fetcher:iw,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof iE){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>ci};function cl(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},co,e),r={...cs,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=uO().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(0,u$.jsx)("div",{children:"An error has occurred. Please try reloading the page."});{let n=(0,u$.jsx)(uR.Suspense,{fallback:null,children:(0,u$.jsx)(cr.SWRConfig,{value:r,children:(0,u$.jsx)(uN.Provider,{value:this.state.config,children:t.disableTranslations?(0,u$.jsx)(e,{...this.props}):(0,u$.jsx)(ct.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,children:(0,u$.jsx)(e,{...this.props})})})})});return t.strictMode&&uO().StrictMode?(0,u$.jsx)(uO().StrictMode,{children: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 cu(e,t){return function(e){if("object"!==u0(e))throw Error("single-spa-react requires a configuration object");var t,r=uQ(uQ({},u3),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");!u2&&r.React.createContext&&(u2=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:u6.bind(null,r),mount:u5.bind(null,r),unmount:u9.bind(null,r)};return r.parcelCanUpdate&&(n.update=u8.bind(null,r)),n}({React:uO(),ReactDOMClient:uJ(),rootComponent:cl(t)(e)})}function cc(e,t){return()=>e().then(({default:e})=>cu(e,t))}function cd(e,t){return()=>Promise.resolve(cu(e,t))}let cm=cc,cp=j()(()=>({}));V("openmrs-app-context",cp);let cf={};function ch(e,t=e=>e){let r=cp.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function cg(e,t){cp.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function cy(e){return null===e?null:Object.freeze(Object.assign({},e))}let cv=new Map;function cb(e,t){let r=(0,uR.useRef)(t??{}),n=(0,uR.useRef)(t=>cg(e,t)),a=(0,uR.useRef)(Symbol());return(0,uR.useEffect)(()=>{let r=t??{},n=a.current;return null===ch(e)?!function(e,t=cf){cp.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===cf?{}: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.`),cg(e,()=>r)),cv.set(e,n),()=>{cv.get(e)===n&&(cp.setState(t=>(e in t&&delete t[e],t)),cv.delete(e))}},[e]),(0,uR.useEffect)(()=>{let n=t??{};R(r.current,n)||(cg(e,()=>n),r.current=n)},[t]),n.current}function cw({namespace:e,value:t}){return cb(e,t),null}let cE=({children:e,value:t,fallback:r})=>t?(0,u$.jsx)(u$.Fragment,{children:e}):r?(0,u$.jsx)(u$.Fragment,{children:r}):null;function cx(){let e=(0,uR.useRef)(null);return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,uR.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function cD(e,t=e=>e??{}){let[r,n]=(0,uR.useState)(()=>{if(c_(e))return;let r=ch(e);if(null!==r)return t?t(r):r});return(0,uR.useEffect)(()=>{if(c_(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,uR.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>R(e,r)?e:r)})(cy(a=ch(e))),cp.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(cy(n)))})},[e,t]),r}function c_(e){return"string"!=typeof e||0===e.trim().length}function cS(e){let t=uK(e);return(0,uR.useMemo)(()=>t.map(e=>e.id),[t])}function cC(e){return uH(e).candidateExtensions}function cP(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=cn()(e?sO(e,t,r):null,iw);return(0,uR.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function ck(e){(0,uR.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let cT={},cR=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function cO(e,t,r){let n=cT[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 cT[e]=a,a.then(()=>{cT[e]===a&&delete cT[e]}),a}function cN(e){let{moduleName:t,extension:r}=(0,uR.useContext)(uN),n=e?.externalModuleName??t;if(!n&&!r)throw Error(cR);let a=function(e){let t=(0,uR.useMemo)(()=>nE(e),[e]),r=function(e){let[t,r]=(0,uR.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,uR.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw cO(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,uR.useMemo)(nS,[]),r=function(e,t){let[r,n]=(0,uR.useState)(t?()=>{let r=nC(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,uR.useEffect)(()=>{if(t)return e.subscribe(e=>{let a=nC(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!rk(a.config,r)&&n(a.config)})},[e,t,r]),r}(t,e);if(!r&&e)throw cO(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let r=nC(t,e.extensionSlotName,e.extensionId);return r.loaded?r.config:null});return r||{}}(r);return(0,uR.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...a}:{...a,...o},[n,e?.externalModuleName,a,o])}let c$=uK;function cj(e,t=300){let[r,n]=(0,uR.useState)(e);return(0,uR.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var cI=r(9256),cA=r.n(cI);let cM=`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 cL(){let e=`${ig}/emrapi/configuration?v=${cM}`,t=cA()(e,iw);return(0,uR.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function cF(){return(0,uR.useContext)(uN).extension}let cB=uU(lR());function cU(e){let t=uK(e);return(0,uR.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let cV=uU(lF());function cW(e){let{flags:t}=uF(lE);return t[e]?.enabled??!1}function cH(){let[,e]=(0,uR.useState)(0);return(0,uR.useCallback)(()=>{e(e=>e+1)},[])}function cz(e,t,r={}){return cG(e,t,cK,r)}let cK={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(ib(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 cG(e,t,r,n={}){let{getPaginatedUrl:a,getTotalCount:o,getCurrentPageSize:i,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??iw,[d,m]=(0,uR.useState)(1),p=(0,uR.useRef)(NaN),f=(0,uR.useRef)(NaN),h=(0,uR.useRef)(d),g=(0,uR.useRef)(!1),y=(0,uR.useRef)(!1),v=e?.toString()??"",[b,w]=(0,uR.useState)(v);v!==b&&(w(v),m(1),h.current=1,p.current=NaN,f.current=NaN,g.current=!1,y.current=!1);let E=(d-1)*t,x=(0,uR.useMemo)(()=>a(e,t,E),[e,t,E]),{data:D,..._}=(l?cA():cn())(x,c,u);D?.data&&(p.current=o(D?.data),f.current=i(D?.data),g.current=!0);let S=Math.ceil(p.current/t),C=(0,uR.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(p.current/t);!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,uR.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(p.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(p.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,D]);let P=(0,uR.useCallback)(()=>{C(h.current+1)},[C]),k=(0,uR.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(D?.data),totalPages:S,totalCount:p.current,currentPage:d,currentPageSize:f.current,paginated:S>1,showNextButton:d<S,showPreviousButton:d>1,goTo:C,goToNext:P,goToPrevious:k,..._}}function cZ(e,t,r={}){return cG(e,t,cY(),r)}function cY(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(ib(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 cq=r(6038),cJ=r.n(cq);function cX(e,t={}){return cQ(e,cK,t)}function cQ(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??iw,u=(0,uR.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:m,...p}=cJ()(u,l,{...n,...a?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),f=o(c?.[c.length-1].data),h=i(c?.[0]?.data);return{data:c?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=f,loadMore:()=>{m((c?.length??0)+1)},nextUri:f,...p}}function c0(e,t={}){return c1(e,cK,t)}function c1(e,t,r={}){let n=cQ(e,t,r),{hasMore:a,error:o,data:i,loadMore:s,isLoading:l,nextUri:u}=n;return((0,uR.useEffect)(()=>{a&&!o&&s()},[a,u]),r.partialData)?n:{...n,data:a||o?void 0:i,isLoading:l||a}}function c4(e,t={}){return c1(e,cY(),t)}function c2(e,t={}){return cQ(e,cY(),t)}function c3(){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 c6(){let[e,t]=(0,uR.useState)(c3);return(0,uR.useEffect)(()=>{let e=()=>{t(c3())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let c5=e=>"small-desktop"===e||"large-desktop"===e;function c9(e){let t=(0,uR.useContext)(uN);(0,uR.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),uc(e),()=>{ud(e.name)}),[t,e])}function c8(){return uF(uu)}let c7=[];function de(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=c0(`${ig}/location${n?"?"+n:""}`,{immutable:!0});return a??c7}function dt(e,t=!0){let r=(0,uR.useRef)(null);return(0,uR.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 dr(e){let t=(0,uR.useRef)(null);return(0,uR.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 dn(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=cx(),s=(0,uR.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,uR.useCallback)(e=>iw(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 cn()(e,l,o)}function da(e=[],t=10){let[r,n]=(0,uR.useState)(1),a=(0,uR.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,uR.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,uR.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,uR.useCallback)(()=>{n(e=>e+1)},[]),u=(0,uR.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,uR.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 di(e,t,r,n){return{pageSizes:(0,uR.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,uR.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function ds(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function dl(e){let[t,r]=(0,uR.useState)(e??ds()),{data:n,error:a,isValidating:o}=cn()(t?["patient",t]:null,()=>sj(t,{}));return(0,uR.useEffect)(()=>{let e=()=>{let e=ds();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,uR.useMemo)(()=>({isLoading:o&&!a&&!n,patient:n,patientUuid:t,error:a}),[o,a,n,t])}function du(){let e=`${ig}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=cn()(e,iw);return(0,uR.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function dc(e,t,r,n){let a=e?.slotName===t&&e.slotModuleName===r?e.components:null,o=new Map;for(let e of n)o.set(e,a?.get(e)??function(e,t,r){let n=l9(r),a=e=>e.extensions[n]?.meta,o=({state:n})=>{let o=uF(lR(),a),i=(0,uR.useMemo)(()=>({moduleName:t,featureName:"",extension:{extensionId:r,extensionSlotName:e,extensionSlotModuleName:t,extensionMeta:o}}),[o]);return(0,u$.jsx)(uN.Provider,{value:i,children:(0,u$.jsx)(uI,{state:n})})};return o.displayName=`RenderableExtension(${r})`,o}(t,r,e));return{slotName:t,slotModuleName:r,components:o}}function dd(e){let{extensions:t,extensionSlotModuleName:r}=uG(e),n=(0,uR.useMemo)(()=>new Set(e?t.map(e=>e.id):[]),[e,t]),[a,o]=(0,uR.useState)(()=>dc(null,e,r,n)),i=a;return a.slotName===e&&a.slotModuleName===r&&a.components.size===n.size&&[...n].every(e=>a.components.has(e))||o(i=dc(a,e,r,n)),(0,uR.useMemo)(()=>e?t.flatMap(e=>{let t=i.components.get(e.id);return t?[t]:[]}):[],[e,t,i])}function dm(){let e=(0,uR.useRef)(null),[t,r]=(0,uR.useState)(null),n=null;if(!t){if(i){let e=iP().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=null))};r(iP().getState()),n||(e.current=iP().subscribe(r))});if(n)r(n);else throw i}(0,uR.useEffect)(()=>(e.current||(e.current=iP().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=null)}),[]);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 dp=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,uR.useState)(null);return((0,uR.useEffect)(()=>{let e=iP(),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&&iO(e,n))?(0,u$.jsx)(u$.Fragment,{children:r}):t?(0,u$.jsx)(u$.Fragment,{children:t}):null};var df=r(4274),dh=r.n(df),dg=r(5602);let dy=new Map;function dv(){for(let e of Array.from(dy.values()))e()}let db={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function dw(e){let t=(0,uR.useId)();return(0,uR.useEffect)(()=>{if(e)return dy.set(t,e),()=>{dy.delete(t)}},[t,e]),{...uB(sK(),db),mutateVisit:dv}}function dE(e,t=sH){let r=(0,uR.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=dw((0,uR.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}=cn()(e?`${ig}/visit${s}`:null,iw),{data:p,error:f,mutate:h,isValidating:g}=cn()(e&&i?`${ig}/visit${l}`:null,iw),y=(0,uR.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,uR.useMemo)(()=>i&&p?p.data:null,[p,i]),b=(0,uR.useRef)(null);(0,uR.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,uR.useCallback)(()=>{d(),h()},[d,h]);(0,uR.useEffect)(()=>{r.current=w},[w]);let E=!!(!u||i&&!p),x=!!(i?f:c);return{error:c||f,mutate:w,isValidating:m||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:E&&!x}}dh().extend(dg);let dx=[];function dD(){let{data:e}=cA()(sB,sU);return e??dx}let d_=new Map;async function dS(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 sa(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?dP(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`),dC)}let dC={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function dP(e,t){if(e in d_)await d_[e];else{let r=t??await sa(e);await (d_[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let a=r.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{nq(e),t(null)}).catch(n)}nq(e),t(null)}))}}function dk(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