@openmrs/esm-openconceptlab-app 4.6.2-pre.1019 → 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.
package/dist/522.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(", ")}.`})]}},ap={"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},am=(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:am,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 o$},get getAppStatus(){return oj},get unloadApplication(){return oF},get checkActivityFunctions(){return oM},get getAppNames(){return oN},get pathToActiveWhen(){return oV},get navigateToUrl(){return og},get patchHistoryApi(){return ox},get triggerAppChange(){return oK},get addErrorHandler(){return aO},get removeErrorHandler(){return a$},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}}),ak=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,aP=!function(){try{var e=new ak("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}:ak;let aR=[];function aT(e,t,r){let n=aj(e,t,r);aR.length?aR.forEach(e=>e(n)):setTimeout(()=>{throw n})}function aO(e){if("function"!=typeof e)throw Error(aN(28,!1));aR.push(e)}function a$(e){if("function"!=typeof e)throw Error(aN(29,!1));let t=!1;return aR=aR.filter(r=>{let n=r===e;return t=t||n,!n}),t}function aN(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(aN(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 aT(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(aN(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 aT(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);aT(r,e,aK)})).then(()=>e);function r(){return oc(e,"unmount").then(()=>{e.status=aF},r=>{if(t)throw aj(r,e,aK);aT(r,e,aK)})}})}let a5=!1,a9=!1;function a8(e,t){return Promise.resolve().then(()=>e.status!==aF?e:(a5||(window.dispatchEvent(new aP("single-spa:before-first-mount")),a5=!0),e.status=aB,oc(e,"mount").then(()=>(e.status=aU,a9||(window.dispatchEvent(new aP("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 aT(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(aN(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(aN(3,!1,typeof e.name));let i=a7++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(aN(4,!1,s,typeof t));if(!t.domElement)throw Error(aN(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:()=>m.then(()=>{if(c.status!==aU)throw Error(aN(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(aN(7,!1));let p=(d=d.then(e=>{if(!e)throw Error(aN(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!a0(e.bootstrap))throw Error(aN(9,!1,s));if(!a0(e.mount))throw Error(aN(10,!1,s));if(!a0(e.unmount))throw Error(aN(11,!1,s));if(e.update&&!a0(e.update))throw Error(aN(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(aN(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)),m=p.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(aN(13,!1,s,c.status));return o.parcels[i]=c,a8(c)})),unmount:()=>on(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:on(d),bootstrapPromise:on(p),mountPromise:on(m),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(aN(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(aN(16,!1));oo.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function os(e,t,r){if("number"!=typeof e||e<=0)throw Error(aN(17,!1));oo.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function ol(e,t,r){if("number"!=typeof e||e<=0)throw Error(aN(18,!1));oo.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function ou(e,t,r){if("number"!=typeof e||e<=0)throw Error(aN(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=aN(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 op(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(aN(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(aN(n,!1,a,aY(e),r),t),aT(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()),aT(t,e,n),e}))})}let om="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(aN(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(aN(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}om&&(window.singleSpaNavigate?console.warn(aN(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 ok={};function oP(e){return Promise.resolve().then(()=>{let t=ok[aY(e)];if(!t)return e;if(e.status===aI)return oR(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(()=>(oR(e,t),e)).catch(r=>(delete ok[aY(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,aT(r,e,aK),t.reject(r),e))})}function oR(e,t){delete ok[aY(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=aI,t.resolve()}function oT(e,t,r,n){ok[aY(e)]={app:e,resolve:r,reject:n},Object.defineProperty(ok[aY(e)],"promise",{get:t})}let oO=[];function o$(){return oO.filter(aG).map(aY)}function oN(){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(aN(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(aN(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(aN(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(aN(24,!1));if(!oU(e.customProps))throw Error(aN(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(aN(20,!1));if(!t)throw Error(aN(23,!1));if("function"!=typeof r)throw Error(aN(24,!1));if(!oU(n))throw Error(aN(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(aN(1,!1))},5e3)),-1!==oN().indexOf(l.name))throw Error(aN(21,!1,l.name));oO.push(aX({loadErrorTime:null,status:aI,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),om&&(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(aN(25,!1,e));return(om?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(aN(26,!1));let r=aQ(oO,t=>aY(t)===e);if(!r)throw Error(aN(27,!1,e));let n=ok[aY(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{oT(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,oB(r,n.resolve,n.reject)):e=new Promise((t,n)=>{oT(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(oP).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=om&&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&&ok[aY(e)]?n.push(e):t&&i.push(e);break;case aU:t||a.push(e)}}),{appsToUnload:n,appsToUnmount:a,appsToLoad:o,appsToMount:i}),p,m=[],f=oz,h=oz=window.location.href;return oY?(oW=!0,p=l.concat(c,u,d),Promise.resolve().then(()=>(w(0===p.length?"before-no-app-change":"before-app-change",b(!0)),w("before-routing-event",b(!0,{cancelNavigation:g})),Promise.all(m).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(oP),a=Promise.all(u.map(a6).map(e=>e.then(oP)).concat(n));a.then(()=>{w("before-mount-routing-event",b(!0))},e=>{throw e});let o=c.map(e=>op(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})))})))):(p=c,Promise.resolve().then(()=>Promise.all(c.map(op)).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);m.push(t.catch(e=>(console.warn(Error(aN(42,!1))),console.warn(e),!1)))}function y(){let t=o$();e.forEach(e=>e.resolve(t));try{w(0===p.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)})):p.forEach(e=>{i(e)});let o={detail:{newAppStatuses:n,appsByNewStatus:a,totalAppChanges:p.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 aP(`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,om&&(ox(e),oG())}om&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...oO]},reroute:oG,NOT_LOADED:aI,toLoadPromise:op,toBootstrapPromise:a3,unregisterApplication:oL,getProfilerData:function(){return a2}});let oJ=e=>"string"==typeof e,oX=()=>{let e,t,r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r},oQ=e=>null==e?"":""+e,o0=/###/g,o1=e=>e&&e.indexOf("###")>-1?e.replace(o0,"."):e,o4=e=>!e||oJ(e),o2=(e,t,r)=>{let n=oJ(t)?t.split("."):t,a=0;for(;a<n.length-1;){if(o4(e))return{};let t=o1(n[a]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++a}return o4(e)?{}:{obj:e,k:o1(n[a])}},o3=(e,t,r)=>{let{obj:n,k:a}=o2(e,t,Object);if(void 0!==n||1===t.length){n[a]=r;return}let o=t[t.length-1],i=t.slice(0,t.length-1),s=o2(e,i,Object);for(;void 0===s.obj&&i.length;)o=`${i[i.length-1]}.${o}`,s=o2(e,i=i.slice(0,i.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${o}`]&&(s.obj=void 0);s.obj[`${s.k}.${o}`]=r},o6=(e,t)=>{let{obj:r,k:n}=o2(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},o5=(e,t,r)=>{for(let n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?oJ(e[n])||e[n]instanceof String||oJ(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):o5(e[n],t[n],r):e[n]=t[n]);return e};var o9={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let o8=e=>oJ(e)?e.replace(/[&<>"'\/]/g,e=>o9[e]):e,o7=[" ",",","?","!",";"],ie=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(void 0!==t)return t;let r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}(20),it=(e,t,r=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let n=t.split(r),a=e;for(let e=0;e<n.length;){let t;if(!a||"object"!=typeof a)return;let o="";for(let i=e;i<n.length;++i)if(i!==e&&(o+=r),o+=n[i],void 0!==(t=a[o])){if(["string","number","boolean"].indexOf(typeof t)>-1&&i<n.length-1)continue;e+=i-e+1;break}a=t}return a},ir=e=>e?.replace("_","-"),ia={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class io{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||ia,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,r,n){return n&&!this.debug?null:(oJ(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new io(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new io(this.logger,e)}}var ii=new io;class is{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let r=this.observers[e].get(t)||0;this.observers[e].set(t,r+1)}),this}off(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,r])=>{for(let n=0;n<r;n++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,n])=>{for(let a=0;a<n;a++)r.apply(r,[e,...t])})}}class il extends is{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,n={}){let a,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,i=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],r&&(Array.isArray(r)?a.push(...r):oJ(r)&&o?a.push(...r.split(o)):a.push(r)));let s=o6(this.data,a);return(!s&&!t&&!r&&e.indexOf(".")>-1&&(e=a[0],t=a[1],r=a.slice(2).join(".")),!s&&i&&oJ(r))?it(this.data?.[e]?.[t],r,o):s}addResource(e,t,r,n,a={silent:!1}){let o=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=[e,t];r&&(i=i.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(i=e.split("."),n=t,t=i[1]),this.addNamespaces(t),o3(this.data,i,n),a.silent||this.emit("added",e,t,r,n)}addResources(e,t,r,n={silent:!1}){for(let n in r)(oJ(r[n])||Array.isArray(r[n]))&&this.addResource(e,t,n,r[n],{silent:!0});n.silent||this.emit("added",e,t,r)}addResourceBundle(e,t,r,n,a,o={silent:!1,skipCopy:!1}){let i=[e,t];e.indexOf(".")>-1&&(i=e.split("."),n=r,r=t,t=i[1]),this.addNamespaces(t);let s=o6(this.data,i)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),n?o5(s,r,a):s={...s,...r},o3(this.data,i,s),o.silent||this.emit("added",e,t,r)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var iu={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,n,a){return e.forEach(e=>{t=this.processors[e]?.process(t,r,n,a)??t}),t}};let ic=Symbol("i18next/PATH_KEY");function id(e,t){let r,n,a,{[ic]:o}=e((n=[],(a=Object.create(null)).get=(e,t)=>(r?.revoke?.(),t===ic)?n:(n.push(t),(r=Proxy.revocable(e,a)).proxy),Proxy.revocable(Object.create(null),a).proxy));return o.join(t?.keySeparator??".")}let ip={},im=e=>!oJ(e)&&"boolean"!=typeof e&&"number"!=typeof e;class ih extends is{constructor(e,t={}){super(),((e,t,r)=>{e.forEach(e=>{t[e]&&(r[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=ii.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let r={...t};if(null==e)return!1;let n=this.resolve(e,r);if(n?.res===void 0)return!1;let a=im(n.res);return!1!==r.returnObjects||!a}extractFromKey(e,t){let r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");let n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,a=t.ns||this.options.defaultNS||[],o=r&&e.indexOf(r)>-1,i=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,r)=>{t=t||"",r=r||"";let n=o7.filter(e=>0>t.indexOf(e)&&0>r.indexOf(e));if(0===n.length)return!0;let a=ie.getRegExp(`(${n.map(e=>"?"===e?"\\?":e).join("|")})`),o=!a.test(e);if(!o){let t=e.indexOf(r);t>0&&!a.test(e.substring(0,t))&&(o=!0)}return o})(e,r,n);if(o&&!i){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:oJ(a)?[a]:a};let o=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(o[0])>-1)&&(a=o.shift()),e=o.join(n)}return{key:e,namespaces:oJ(a)?[a]:a}}translate(e,t,r){let n="object"==typeof t?{...t}:t;if("object"!=typeof n&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof n&&(n={...n}),n||(n={}),null==e)return"";"function"==typeof e&&(e=id(e,{...this.options,...n})),Array.isArray(e)||(e=[String(e)]);let a=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],n),l=s[s.length-1],u=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c?.toLowerCase()==="cimode")return d?a?{res:`${l}${u}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${u}${i}`:a?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:i;let p=this.resolve(e,n),m=p?.res,f=p?.usedKey||i,h=p?.exactUsedKey||i,g=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==n.count&&!oJ(n.count),b=ih.hasDefaultValue(n),w=v?this.pluralResolver.getSuffix(c,n.count,n):"",E=n.ordinal&&v?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",x=v&&!n.ordinal&&0===n.count,D=x&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${w}`]||n[`defaultValue${E}`]||n.defaultValue,_=m;y&&!m&&b&&(_=D);let S=im(_),C=Object.prototype.toString.apply(_);if(y&&_&&S&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(C)&&!(oJ(g)&&Array.isArray(_))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,_,{...n,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return a?(p.res=e,p.usedParams=this.getUsedParamsDetails(n),p):e}if(o){let e=Array.isArray(_),t=e?[]:{},r=e?h:f;for(let e in _)if(Object.prototype.hasOwnProperty.call(_,e)){let a=`${r}${o}${e}`;b&&!m?t[e]=this.translate(a,{...n,defaultValue:im(D)?D[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(a,{...n,joinArrays:!1,ns:s}),t[e]===a&&(t[e]=_[e])}m=t}}else if(y&&oJ(g)&&Array.isArray(m))(m=m.join(g))&&(m=this.extendTranslation(m,e,n,r));else{let t=!1,a=!1;!this.isValidLookup(m)&&b&&(t=!0,m=D),this.isValidLookup(m)||(a=!0,m=i);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:m,d=b&&D!==m&&this.options.updateMissing;if(a||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,i,d?D:m),o){let e=this.resolve(i,{...n,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let r=0;r<t.length;r++)e.push(t[r]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(n.lng||this.language):e.push(n.lng||this.language);let r=(e,t,r)=>{let a=b&&r!==m?r:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,a,d,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,a,d,n),this.emit("missingKey",e,l,t,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,n);x&&n[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{r([e],i+t,n[`defaultValue${t}`]||D)})}):r(e,i,D))}m=this.extendTranslation(m,e,n,p,r),a&&m===i&&this.options.appendNamespaceToMissingKey&&(m=`${l}${u}${i}`),(a||t)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${i}`:i,t?m:void 0,n))}return a?(p.res=m,p.usedParams=this.getUsedParamsDetails(n),p):m}extendTranslation(e,t,r,n,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){let o;r.interpolation&&this.interpolator.init({...r,...{interpolation:{...this.options.interpolation,...r.interpolation}}});let i=oJ(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=r.replace&&!oJ(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,r.lng||this.language||n.usedLng,r),i){let t=e.match(this.interpolator.nestingRegexp);o<(t&&t.length)&&(r.nest=!1)}!r.lng&&n&&n.res&&(r.lng=this.language||n.usedLng),!1!==r.nest&&(e=this.interpolator.nest(e,(...e)=>a?.[0]!==e[0]||r.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),r)),r.interpolation&&this.interpolator.reset()}let o=r.postProcess||this.options.postProcess,i=oJ(o)?[o]:o;return null!=e&&i?.length&&!1!==r.applyPostProcessor&&(e=iu.handle(i,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,n,a,o,i;return oJ(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(r))return;let s=this.extractFromKey(e,t),l=s.key;n=l;let u=s.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let c=void 0!==t.count&&!oJ(t.count),d=c&&!t.ordinal&&0===t.count,p=void 0!==t.context&&(oJ(t.context)||"number"==typeof t.context)&&""!==t.context,m=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(i=e,!ip[`${m[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(ip[`${m[0]}-${e}`]=!0,this.logger.warn(`key "${n}" for languages "${m.join(", ")}" won't get resolved as namespace "${i}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),m.forEach(n=>{let i;if(this.isValidLookup(r))return;o=n;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,n,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(n,t.count,t));let r=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(a)&&s.push(l+e.replace(a,this.options.pluralSeparator)),s.push(l+e),d&&s.push(l+r)),p){let n=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(n),c&&(t.ordinal&&0===e.indexOf(a)&&s.push(n+e.replace(a,this.options.pluralSeparator)),s.push(n+e),d&&s.push(n+r))}}for(;i=s.pop();)this.isValidLookup(r)||(a=i,r=this.getResource(n,e,i,t))}))})}),{res:r,usedKey:n,exactUsedKey:a,usedLng:o,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,r,n={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}getUsedParamsDetails(e={}){let t=e.replace&&!oJ(e.replace),r=t?e.replace:e;if(t&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!t)for(let e of(r={...r},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete r[e];return r}static hasDefaultValue(e){let t="defaultValue";for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}class ig{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ii.create("languageUtils")}getScriptPartFromCode(e){if(!(e=ir(e))||0>e.indexOf("-"))return null;let t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(!(e=ir(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(oJ(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return(t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t)?t:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let t;return e?(e.forEach(e=>{if(t)return;let r=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let r=this.getScriptPartFromCode(e);if(this.isSupportedCode(r))return t=r;let n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(e=>{if(e===n||!(0>e.indexOf("-")&&0>n.indexOf("-"))&&(e.indexOf("-")>0&&0>n.indexOf("-")&&e.substring(0,e.indexOf("-"))===n||0===e.indexOf(n)&&n.length>1))return e})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),oJ(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}toResolveHierarchy(e,t){let r=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),n=[],a=e=>{e&&(this.isSupportedCode(e)?n.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return oJ(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):oJ(e)&&a(this.formatLanguageCode(e)),r.forEach(e=>{0>n.indexOf(e)&&a(this.formatLanguageCode(e))}),n}}let iy={zero:0,one:1,two:2,few:3,many:4,other:5},iv={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class ib{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=ii.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let r,n=ir("dev"===e?"en":e),a=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:n,type:a});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];try{r=new Intl.PluralRules(n,{type:a})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),iv;if(!e.match(/-|_/))return iv;let n=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(n,t)}return this.pluralRulesCache[o]=r,r}needsPlural(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,r={}){return this.getSuffixes(e,r).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let r=this.getRule(e,t);return(r||(r=this.getRule("dev",t)),r)?r.resolvedOptions().pluralCategories.sort((e,t)=>iy[e]-iy[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,r={}){let n=this.getRule(e,r);return n?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${n.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,r))}}let iw=(e,t,r,n=".",a=!0)=>{let o,i=void 0!==(o=o6(e,r))?o:o6(t,r);return!i&&a&&oJ(r)&&void 0===(i=it(e,r,n))&&(i=it(t,r,n)),i};class iE{constructor(e={}){this.logger=ii.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:t,escapeValue:r,useRawValueToEscape:n,prefix:a,prefixEscaped:o,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:p,nestingSuffix:m,nestingSuffixEscaped:f,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==t?t:o8,this.escapeValue=void 0===r||r,this.useRawValueToEscape=void 0!==n&&n,this.prefix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):o||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=d?d.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):p||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=m?m.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):f||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=h||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,r,n){let a,o,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let a=iw(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,r,{...n,...t,interpolationkey:e}):a}let a=e.split(this.formatSeparator),o=a.shift().trim(),i=a.join(this.formatSeparator).trim();return this.format(iw(t,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),i,r,{...n,...t,interpolationkey:o})};this.resetRegExp();let u=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(t=>{for(i=0;a=t.regex.exec(e);){let r=a[1].trim();if(void 0===(o=l(r)))if("function"==typeof u){let t=u(e,a,n);o=oJ(t)?t:""}else if(n&&Object.prototype.hasOwnProperty.call(n,r))o="";else if(c){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${r} for interpolating ${e}`),o="";else oJ(o)||this.useRawValueToEscape||(o=oQ(o));let s=t.safeValue(o);if(e=e.replace(a[0],s),c?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,t,r={}){let n,a,o,i=(e,t)=>{let r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;let n=e.split(RegExp(`${r}[ ]*{`)),a=`{${n[1]}`;e=n[0];let i=(a=this.interpolate(a,o)).match(/'/g),s=a.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(a=a.replace(/'/g,'"'));try{o=JSON.parse(a),t&&(o={...t,...o})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${r}${a}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,e};for(;n=this.nestingRegexp.exec(e);){let s=[];(o=(o={...r}).replace&&!oJ(o.replace)?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;let l=/{.*}/.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==l&&(s=n[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,l)),(a=t(i.call(this,n[1].trim(),o),o))&&n[0]===e&&!oJ(a))return a;oJ(a)||(a=oQ(a)),a||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),a=""),s.length&&(a=s.reduce((e,t)=>this.format(e,t,r.lng,{...r,interpolationkey:n[1].trim()}),a.trim())),e=e.replace(n[0],a),this.regexp.lastIndex=0}return e}}let ix=e=>{let t={};return(r,n,a)=>{let o=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(o={...o,[a.interpolationkey]:void 0});let i=n+JSON.stringify(o),s=t[i];return s||(s=e(ir(n),a),t[i]=s),s(r)}},iD=e=>(t,r,n)=>e(ir(r),n)(t);class i_{constructor(e={}){this.logger=ii.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let r=t.cacheInBuiltFormats?ix:iD;this.formats={number:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t});return e=>r.format(e)}),currency:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>r.format(e)}),datetime:r((e,t)=>{let r=new Intl.DateTimeFormat(e,{...t});return e=>r.format(e)}),relativetime:r((e,t)=>{let r=new Intl.RelativeTimeFormat(e,{...t});return e=>r.format(e,t.range||"day")}),list:r((e,t)=>{let r=new Intl.ListFormat(e,{...t});return e=>r.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ix(t)}format(e,t,r,n={}){let a=t.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&0>a[0].indexOf(")")&&a.find(e=>e.indexOf(")")>-1)){let e=a.findIndex(e=>e.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,e)].join(this.formatSeparator)}return a.reduce((e,t)=>{let{formatName:a,formatOptions:o}=(e=>{let t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){let n=e.split("(");t=n[0].toLowerCase().trim();let a=n[1].substring(0,n[1].length-1);"currency"===t&&0>a.indexOf(":")?r.currency||(r.currency=a.trim()):"relativetime"===t&&0>a.indexOf(":")?r.range||(r.range=a.trim()):a.split(";").forEach(e=>{if(e){let[t,...n]=e.split(":"),a=n.join(":").trim().replace(/^'+|'+$/g,""),o=t.trim();r[o]||(r[o]=a),"false"===a&&(r[o]=!1),"true"===a&&(r[o]=!0),isNaN(a)||(r[o]=parseInt(a,10))}})}return{formatName:t,formatOptions:r}})(t);if(this.formats[a]){let t=e;try{let i=n?.formatParams?.[n.interpolationkey]||{},s=i.locale||i.lng||n.locale||n.lng||r;t=this.formats[a](e,s,{...o,...n,...i})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${a}`),e},e)}}class iS extends is{constructor(e,t,r,n={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=n,this.logger=ii.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,n.backend,n)}queueLoad(e,t,r,n){let a={},o={},i={},s={};return e.forEach(e=>{let n=!0;t.forEach(t=>{let i=`${e}|${t}`;!r.reload&&this.store.hasResourceBundle(e,t)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===o[i]&&(o[i]=!0):(this.state[i]=1,n=!1,void 0===o[i]&&(o[i]=!0),void 0===a[i]&&(a[i]=!0),void 0===s[t]&&(s[t]=!0)))}),n||(i[e]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,t,r){let n=e.split("|"),a=n[0],o=n[1];t&&this.emit("failedLoading",a,o,t),!t&&r&&this.store.addResourceBundle(a,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&r&&(this.state[e]=0);let i={};this.queue.forEach(r=>{((e,t,r,n)=>{let{obj:a,k:o}=o2(e,t,Object);a[o]=a[o]||[],a[o].push(r)})(r.loaded,[a],o),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(e=>{i[e]||(i[e]={});let t=r.loaded[e];t.length&&t.forEach(t=>{void 0===i[e][t]&&(i[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,t,r,n=0,a=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:n,wait:a,callback:o});this.readingCalls++;let i=(i,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}i&&s&&n<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,r,n+1,2*a,o)},a):o(i,s)},s=this.backend[r].bind(this.backend);if(2===s.length){try{let r=s(e,t);r&&"function"==typeof r.then?r.then(e=>i(null,e)).catch(i):i(null,r)}catch(e){i(e)}return}return s(e,t,i)}prepareLoading(e,t,r={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();oJ(e)&&(e=this.languageUtils.toResolveHierarchy(e)),oJ(t)&&(t=[t]);let a=this.queueLoad(e,t,r,n);if(!a.toLoad.length)return a.pending.length||n(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,r){this.prepareLoading(e,t,{},r)}reload(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}loadOne(e,t=""){let r=e.split("|"),n=r[0],a=r[1];this.read(n,a,"read",void 0,void 0,(r,o)=>{r&&this.logger.warn(`${t}loading namespace ${a} for language ${n} failed`,r),!r&&o&&this.logger.log(`${t}loaded namespace ${a} for language ${n}`,o),this.loaded(e,r,o)})}saveMissing(e,t,r,n,a,o={},i=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${r}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=r&&""!==r){if(this.backend?.create){let s={...o,isUpdate:a},l=this.backend.create.bind(this.backend);if(l.length<6)try{let a;(a=5===l.length?l(e,t,r,n,s):l(e,t,r,n))&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(e){i(e)}else l(e,t,r,n,i,s)}e&&e[0]&&this.store.addResource(e[0],t,r,n)}}}let iC=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),oJ(e[1])&&(t.defaultValue=e[1]),oJ(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let r=e[3]||e[2];Object.keys(r).forEach(e=>{t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),ik=e=>(oJ(e.ns)&&(e.ns=[e.ns]),oJ(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),oJ(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),iP=()=>{};class iR extends is{constructor(e={},t){if(super(),this.options=ik(e),this.services={},this.logger=ii,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{"function"==typeof e[t]&&(e[t]=e[t].bind(e))})})(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(oJ(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let r=iC();this.options={...r,...this.options,...ik(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let n=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?ii.init(n(this.modules.logger),this.options):ii.init(null,this.options),e=this.modules.formatter?this.modules.formatter:i_;let t=new ig(this.options);this.store=new il(this.options.resources,this.options);let a=this.services;a.logger=ii,a.resourceStore=this.store,a.languageUtils=t,a.pluralResolver=new ib(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(a.formatter=n(e),a.formatter.init&&a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new iE(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new iS(n(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(a.languageDetector=n(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=n(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new ih(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=iP),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let a=oX(),o=()=>{let e=(e,r)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(r),t(e,r)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),a}loadResources(e,t=iP){let r=t,n=oJ(e)?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(n?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return r();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};n?t(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,t,r){let n=oX();return"function"==typeof e&&(r=e,e=void 0),"function"==typeof t&&(r=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),r||(r=iP),this.services.backendConnector.reload(e,t,e=>{n.resolve(),r(e)}),n}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&iu.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let r=oX();this.emit("languageChanging",e);let n=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(a,o)=>{o?this.isLanguageChangingTo===e&&(n(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,r.resolve((...e)=>this.t(...e)),t&&t(a,(...e)=>this.t(...e))},o=t=>{e||t||!this.services.languageDetector||(t=[]);let r=oJ(t)?t:t&&t[0],o=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(oJ(t)?[t]:t);o&&(this.language||n(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,e=>{a(e,o)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),r}getFixedT(e,t,r){let n=(e,t,...a)=>{let o,i;(o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(a)):{...t}).lng=o.lng||n.lng,o.lngs=o.lngs||n.lngs,o.ns=o.ns||n.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||r||n.keyPrefix);let s=this.options.keySeparator||".";return o.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=id(e,{...this.options,...t})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=id(e,{...this.options,...t})),i=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(i,o)};return oJ(e)?n.lng=e:n.lngs=e,n.ns=t,n.keyPrefix=r,n}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let r=t.lng||this.resolvedLanguage||this.languages[0],n=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;let o=(e,t)=>{let r=this.services.backendConnector.state[`${e}|${t}`];return -1===r||0===r||2===r};if(t.precheck){let e=t.precheck(this,o);if(void 0!==e)return e}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!n||o(a,e)))}loadNamespaces(e,t){let r=oX();return this.options.ns?(oJ(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}loadLanguages(e,t){let r=oX();oJ(e)&&(e=[e]);let n=this.options.preload||[],a=e.filter(e=>0>n.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=n.concat(a),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let t=this.services?.languageUtils||new ig(iC());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new iR(e,t)}cloneInstance(e={},t=iP){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let n={...this.options,...e,isClone:!0},a=new iR(n);return(void 0!==e.debug||void 0!==e.prefix)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new il(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((r,n)=>(r[n]={...e[t][n]},r),e[t]),e),{}),n),a.services.resourceStore=a.store),a.translator=new ih(a.services,n),a.translator.on("*",(e,...t)=>{a.emit(e,...t)}),a.init(n,t),a.translator.options=n,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let iT=iR.createInstance();iT.createInstance=iR.createInstance,iT.createInstance,iT.dir,iT.init,iT.loadResources,iT.reloadResources,iT.use,iT.changeLanguage,iT.getFixedT,iT.t,iT.exists,iT.setDefaultNamespace,iT.hasLoadedNamespace,iT.loadNamespaces,iT.loadLanguages;let iO={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"},i$=iT.default||iT,iN="___",ij=new Map,iI=!1;function iA(){iI=!0,i$.emit("languageChanged",i$.language)}function iM(){iI=!1,ij.clear()}function iL(){return iI}function iF(e){if(!iI)return;let t=ij.get(e.value);if(!t){ij.size>=2e4&&ij.delete(ij.keys().next().value),ij.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}),ij.delete(e.value),ij.set(e.value,t)}function iB(e){return e&&iI?(ij.get(e)??ij.get(e.trim())??[]).map(e=>({...e})):[]}let iU=iT.default||iT;function iV(e,t,r,n){return iU.t(t,{ns:e,defaultValue:r,...n})}function iW(e,t,r){return iO[e]?iV("core",e,t??iO[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function iH(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=iz(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function iz(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function iK({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=iH(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(iW("navigateNonHttp"));n.startsWith(r)?og(n):window.location.assign(n)}iU.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let iG="openmrs:history";function iZ(e){let t=JSON.parse(sessionStorage.getItem(iG)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(iG,JSON.stringify(t))}function iY(){0===JSON.parse(sessionStorage.getItem(iG)??"[]").length&&document.referrer&&iZ(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=iq();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(iG,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?iJ({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&iZ(window.location.href)})}function iq(){return JSON.parse(sessionStorage.getItem(iG)??"[]")}function iJ({toUrl:e}){let t=iq(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);iK({to:t[r]}),sessionStorage.setItem(iG,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function iX(){sessionStorage.removeItem(iG)}let iQ="${openmrsSpaBase}/login",i0={redirectAuthFailure:{enabled:{_type:nc.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nc.String,_default:iQ,_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 i1(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let i4="/ws/rest/v1",i2="/ws/fhir2/R4",i3=`${i4}/session`;function i6(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function i5(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=i6(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(i6(i4),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(i2)){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===i6(i3)||204===e.status)&&iK({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===i6(i3)&&403===e.status||n.enabled&&n.errors.includes(e.status))&&(iX(),iK({to:n.url||e.headers.get("location")||iQ}),!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 i9(r,e,n,a)},()=>{throw new i9(r,e,null,a)})})}class i9 extends Error{constructor(e,t,r,n){super(),i1(this,"response",void 0),i1(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 i8=B("session",{loaded:!1,session:null}),i7=0,se=null;function st(){return se||(i8.getState().loaded&&i7>=Date.now()-6e4?null:so())}function sr(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=st();return n?new Promise(e=>{let t=()=>{let t=i8.getState();t.loaded&&(a(),e(r(t.session)))},a=i8.subscribe(t);n.then(t,t)}):Promise.resolve(r(i8.getState().session))}function sn(){return st(),i8}function sa(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 so(e,t){i7=Date.now(),o??(o=i7);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=sh(i5(i3,{headers:r,rejectAuthFailure:!0})),a=()=>{se===n&&(se=null)};return n.then(a,a),se=n,n}function si(){i8.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function ss(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 sl(){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(i8.getState()),e||(t=i8.subscribe(n))})}async function su(){return(await sr()).sessionLocation}async function sc(e,t){return sh(i5(i3,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function sd(e,t){return await i5(i3,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),so()}async function sp(e,t,r){return r||(r=new AbortController),await i5(`${i4}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),so()}async function sm(e,t=!1){let r=await i5(t?`${i3}?rememberMe=true`:i3,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await so()).session:r.data}async function sf(){try{await i5(i3,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!sg(e))throw e}si(),await so().catch(()=>{})}function sh(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};i8.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(sy(Error("The session endpoint did not respond with a session"))):r(sy(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(sg(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?i8.setState({loaded:!0,session:e.responseBody},!0):si(),t(i8.getState());return}(a=e)instanceof i9&&502===a.response.status&&!i8.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(sy(e,!0)):(k(`Failed to fetch new session information: ${e}`),r(sy(e)))})})}function sg(e){return e instanceof i9&&(401===e.response.status||403===e.response.status)}function sy(e,t=!1){return i8.getState().loaded||i8.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),i8.getState()}function sv(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}i8.subscribe(e=>{e.loaded&&e.session&&sa(e.session)});let sb={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function sw(){nZ("@openmrs/esm-api",i0),so()}let sE="import-map-override:",sx="import-map-overrides-disabled",sD="import-map-overrides:change",s_=!1,sS=null,sC=null;async function sk(){return sC??(sC=sP().then(({map:e,complete:t})=>(t||(sC=null),e))),sC}async function sP(){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:sR(t),complete:r}}function sR(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function sT(){let e={};try{let t=sI();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(sE)){let r=n.slice(sE.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 sO(){let e=await sk();return s_?sR([e,sS??sT()]):e}async function s$(){return sk()}async function sN(){return s_?sR([await sk(),sT()]):sk()}function sj(e){if(!s_)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sE)){let t=localStorage.getItem(r);t&&(e[r.slice(sE.length)]=t)}}return{imports:e}}return sT()}function sI(){if(!s_)return[];try{let e=localStorage.getItem(sx);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function sA(e){return!!s_&&sI().includes(e)}function sM(e,t){if(!s_)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sE+e,t),window.dispatchEvent(new CustomEvent(sD))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sL(e){if(!s_)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sE+e);let t=sI().filter(t=>t!==e);t.length>0?localStorage.setItem(sx,JSON.stringify(t)):localStorage.removeItem(sx),window.dispatchEvent(new CustomEvent(sD))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sF(){if(!s_)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(sE)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(sx),window.dispatchEvent(new CustomEvent(sD))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function sB(e){if(!s_)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=sI().filter(t=>t!==e);t.length>0?localStorage.setItem(sx,JSON.stringify(t)):localStorage.removeItem(sx),window.dispatchEvent(new CustomEvent(sD))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let sU=!1;function sV(){!sU&&(sU=!0,(s_="development"===window.spaEnv)&&(sS=sT()))}function sW(e){return e.replace(/[\/\-@]/g,"_")}async function sH(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([sz(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=sW(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 sz(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=sW(e);if(!window[r]){let r=t??await sK();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 sj().imports;try{return await function(e){var t;let r=(t=window)[sG]??(t[sG]=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:iW("scriptLoadingFailed","Error: Script failed to load"),description:iW("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:iW("resetOverrides","Reset overrides"),onActionButtonClick(){sF(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function sK(){return sO()}let sG=Symbol.for("__openmrs_script_loading");function sZ(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 sY(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&&sZ(t))}let sq="openmrs-routes:",sJ="openmrs-routes:change",sX=!1,sQ=null,s0=null;async function s1(){return s0??(s0=s4().then(({map:e,complete:t})=>(t||(s0=null),e))),s0}async function s4(){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&&sY(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:s2(t),complete:r}}function s2(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 s3(){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(sq)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(sq.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(sZ(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(sZ(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 s6(){let e=await s1();return sX?s2([e,sQ??await s3()]):e}async function s5(){return s1()}async function s9(){return sX?s2([await s1(),await s3()]):s1()}function s8(){if(!sX)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sq)){let t=localStorage.getItem(r);t&&(e[r.slice(sq.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function s7(e,t){if(!sX)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(sq+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!sZ(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(sq+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(sq+e,JSON.stringify(t.toString()));else{if(!sZ(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(sq+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(sJ))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function le(e){if(!sX)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(sq+e),window.dispatchEvent(new CustomEvent(sJ))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function lt(){if(!sX)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(sq)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sJ))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let lr=null;function ln(){return lr||(lr=(sX="development"===window.spaEnv)?s3().then(e=>{sQ=e}):Promise.resolve())}let la=`${i4}/attachment`;function lo(e,t){return i5(`${la}/${e}`,{signal:t.signal})}function li(e,t,r,n){return i5(ls(e,t,n),{signal:r.signal})}function ls(e,t,r){return r?`${la}?patient=${e}&encounter=${r}`:`${la}?patient=${e}&includeEncounterless=${t}`}async function ll(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)),i5(`${la}`,{method:"POST",body:n})}function lu(e,t){return i5(`${la}/${e}`,{method:"DELETE",signal:t.signal})}async function lc(e,t){return e?(await i5(`${i2}/Patient/${e}`,t)).data:null}function ld(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function lp(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 lm(e){return{uuid:e.uuid,display:e.display}}function lf(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return i5(`${i4}/location${n?"?"+n:""}`).then(e=>e.data.results.map(lm))}function lh(e){return{uuid:e.uuid,display:e.display,name:e.name}}let lg=`${i4}/visittype`;function ly(e=lg){return i5(e).then(e=>e.data.results.map(lh))}var lv=((et={}).NEWVISIT="startVisit",et.EDITVISIT="editVisit",et.LOADING="loadingVisit",et),lb=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let lw="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))",lE=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function lx(){return W("visit",lE)}function lD(e,t){lx().setState({patientUuid:e,manuallySetVisitUuid:t})}function l_(e,t){return i5(`${i4}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function lS(e,t,r){return i5(`${i4}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function lC(e,t,r){return i5(`${i4}/visit?patient=${e}&v=${r??lw}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}lx().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class lk{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+lk.version}static addUnaryOp(e){return lk.max_unop_len=Math.max(e.length,lk.max_unop_len),lk.unary_ops[e]=1,lk}static addBinaryOp(e,t,r){return lk.max_binop_len=Math.max(e.length,lk.max_binop_len),lk.binary_ops[e]=t,r?lk.right_associative.add(e):lk.right_associative.delete(e),lk}static addIdentifierChar(e){return lk.additional_identifier_chars.add(e),lk}static addLiteral(e,t){return lk.literals[e]=t,lk}static removeUnaryOp(e){return delete lk.unary_ops[e],e.length===lk.max_unop_len&&(lk.max_unop_len=lk.getMaxKeyLen(lk.unary_ops)),lk}static removeAllUnaryOps(){return lk.unary_ops={},lk.max_unop_len=0,lk}static removeIdentifierChar(e){return lk.additional_identifier_chars.delete(e),lk}static removeBinaryOp(e){return delete lk.binary_ops[e],e.length===lk.max_binop_len&&(lk.max_binop_len=lk.getMaxKeyLen(lk.binary_ops)),lk.right_associative.delete(e),lk}static removeAllBinaryOps(){return lk.binary_ops={},lk.max_binop_len=0,lk}static removeLiteral(e){return delete lk.literals[e],lk}static removeAllLiterals(){return lk.literals={},lk}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 lk(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 lk.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!lk.binary_ops[String.fromCharCode(e)]||lk.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return lk.isIdentifierStart(e)||lk.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(lk.hooks[e]){let r={context:this,node:t};return lk.hooks.run(e,r),r.node}return t}searchHook(e){if(lk.hooks[e]){let t={context:this};return lk.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===lk.SPACE_CODE||e===lk.TAB_CODE||e===lk.LF_CODE||e===lk.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:lk.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)===lk.SEMCOL_CODE||r===lk.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,lk.max_binop_len),t=e.length;for(;t>0;){if(lk.binary_ops.hasOwnProperty(e)&&(!lk.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!lk.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:lk.binaryPrecedence(t),right_a:lk.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=lk.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:lk.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:lk.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:lk.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,lk.isDecimalDigit(e)||e===lk.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===lk.SQUOTE_CODE||e===lk.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===lk.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,lk.max_unop_len)).length;r>0;){if(lk.unary_ops.hasOwnProperty(t)&&(!lk.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!lk.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:lk.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}lk.isIdentifierStart(e)?(n=this.gobbleIdentifier(),lk.literals.hasOwnProperty(n.name)?n={type:lk.LITERAL,value:lk.literals[n.name],raw:n.name}:n.name===lk.this_str&&(n={type:lk.THIS_EXP})):e===lk.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===lk.PERIOD_CODE||t===lk.OBRACK_CODE||t===lk.OPAREN_CODE||t===lk.QUMARK_CODE;){let r;if(t===lk.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==lk.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===lk.OBRACK_CODE?((e={type:lk.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==lk.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===lk.OPAREN_CODE?e={type:lk.CALL_EXP,arguments:this.gobbleArguments(lk.CPAREN_CODE),callee:e}:(t===lk.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:lk.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(;lk.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===lk.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);lk.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++));lk.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);lk.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,lk.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===lk.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===lk.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:lk.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:lk.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(lk.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,lk.isIdentifierPart(e))this.index++;else break;return{type:lk.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===lk.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===lk.COMMA_CODE){if(this.index++,++n!==t.length){if(e===lk.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===lk.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!==lk.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(lk.CPAREN_CODE);if(this.code===lk.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:lk.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:lk.ARRAY_EXP,elements:this.gobbleArguments(lk.CBRACK_CODE)}}}Object.assign(lk,{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)})}}(lk),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"}),lk.max_unop_len=lk.getMaxKeyLen(lk.unary_ops),lk.max_binop_len=lk.getMaxKeyLen(lk.binary_ops);let lP=e=>new lk(e).parse(),lR=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(lk).filter(e=>!lR.includes(e)&&void 0===lP[e]).forEach(e=>{lP[e]=lk[e]}),lP.Jsep=lk,lP.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 lT="ArrowFunctionExpression",lO={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)}},l$={...lO,Promise};function lN(e,t={}){return lF(e,t,lV)}async function lj(e,t={}){return lB(e,t,lV)}function lI(e,t={}){return lF(e,t,lW)}function lA(e,t={}){return lB(e,t,lW)}function lM(e,t={}){return lF(e,t,lH)}function lL(e,t={}){return lB(e,t,lH)}function lF(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=lY(t,lO),a=lz("string"==typeof e?lP(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 lB(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=lY(t,l$);return Promise.resolve(lz("string"==typeof e?lP(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 lU(e){return lP(e)}function lV(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function lW(e){return"boolean"==typeof e}function lH(e){return"number"==typeof e}function lz(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,p,m,f,h=e,g=t;let y=lz(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 lz(v.left,b)&&lz(v.right,b);case"||":return lz(v.left,b)||lz(v.right,b);case"??":return lz(v.left,b)??lz(v.right,b)}let w=lz(v.left,b),E=lz(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,lz(r.test,n)?lz(r.consequent,n):lz(r.alternate,n);case"CallExpression":return lX(lG(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 lz(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return lX(lZ(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(lQ(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(lQ(u)))[D.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(lQ(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,(l0(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,k;return p=e,m=t,C=p.expressions?.map(lQ(m))??[],(k=p.quasis?.map(lQ(m))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+k.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 lK(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return lK(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function lG(e,t){let r=lJ(e.callee,t);if(r===lq||e.optional&&null==r)return lq;let n=e.arguments?.map(lQ(t));if(r){if("function"!=typeof r)throw`${l2(e.callee)} is not a function`}else throw`No function named ${l2(e.callee)} is defined in this context`;return r(...n)}function lZ(e,t){let r=lJ(e.object,t);if(r===lq||e.optional&&null==r)return lq;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${l4(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=lK(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${l4(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}(lz(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);l0(n),function(e,t){if(l1.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 lY(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}lP.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:lT,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=lT,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)})}}),lP.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"}})}}),lP.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)})}}),lP.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")}})}}),lP.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 :")}})}}),lP.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})}}),lP.addBinaryOp("in",7),lP.addBinaryOp("??",1);let lq=Symbol("optional chain short-circuited");function lJ(e,t){switch(e.type){case"MemberExpression":return lZ(e,t);case"CallExpression":return lG(e,t);default:return lz(e,t)}}function lX(e){return e===lq?void 0:e}function lQ(e){return function(t){return null===t?null:lz(t,e)}}function l0(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let l1=new Set(["toString","valueOf","hasOwnProperty"]);function l4(e,t){try{return lK(e,t)}catch{return"<computed>"}}function l2(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function l3(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:{...l$},boundNames:new Set,variables:new Set};return l6("string"==typeof e?lP(e):e,t),[...t.variables]}function l6(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void l6(r.argument,n);case"BinaryExpression":return a=e,o=t,void(l6(a.left,o),l6(a.right,o));case"ConditionalExpression":return i=e,s=t,void(l6(i.consequent,s),l6(i.test,s),l6(i.alternate,s));case"CallExpression":return l=e,u=t,void(l6(l.callee,u),l.arguments?.map(l5(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,p,m,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);l6(x.body,{...D,boundNames:_});return;case"MemberExpression":return c=e,d=t,void(l6(c.object,d),c.computed&&l6(c.property,d));case"ArrayExpression":return p=e,m=t,void p.elements?.map(l5(m));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(l5(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(l5(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(l5(E)),w.quasis?.map(l5(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function l5(e){return function(t){return null===t?null:l6(t,e)}}let l9=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 l8(e,t,r){l9.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function l7(){let e=l9.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 ue(e){return l9.getState().flags[e].enabled}function ut(e,t){l9.subscribe(r=>{t(r.flags[e].enabled)})}function ur(e,t){l9.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}l9.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 un=tG(function(e,t,r){tF(e,t,r)});let ua=B("extensionsInternal",{slots:{},extensions:{}}),uo=B("extensionRenderings",{renderings:new Map}),ui=()=>W("extensionsInternal",{slots:{},extensions:{}}),us=()=>W("extensionRenderings",{renderings:new Map});function ul(e){let t=ua.getState(),r=e(t);r!==t&&ua.setState(r)}let uu=null,uc=null;function ud(){let e=uo.getState();return uu&&e===uc||(uu=new Map(e.renderings),uc=e,function(e){for(let t of(uE.clear(),e.values()))uD(t,1);ux=!0}(uu)),uu}function up(e){uc={renderings:e},uo.setState(uc,!0)}function um(e){let t=ud();t.has(e.renderingId)||(t.set(e.renderingId,e),uD(e,1),up(t))}function uf(e){let t=ud(),r=t.get(e);r&&(t.delete(e),uD(r,-1),up(t))}let uh=()=>W("extensions",{slots:{}}),ug=0,uy=new Set;function uv(e){ug++;try{return e()}finally{if(0==--ug&&uy.size>0){let e=Array.from(uy);for(let t of(uy.clear(),e))ub(t)}}}function ub(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function uw(e){ug>0?uy.add(e):ub(e)}let uE=new Map,ux=!1;function uD(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=uE.get(r);if(!n){if(t<0)return;uE.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),ux=!0;return}n.count+=t,n.count<1&&(uE.delete(r),ux=!0)}function u_(){var e,t;if(ud(),!ux)return;ux=!1;let r=Array.from(uE.values(),({record:e})=>e);r.sort(uS),e=nw.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===uS(e,t[r]))||nw.setState({mountedExtensions:r})}function uS(e,t){return uC(e.slotName,t.slotName)||uC(e.extensionId,t.extensionId)||uC(e.slotModuleName,t.slotModuleName)||uC(e.extensionModuleName,t.extensionModuleName)}function uC(e,t){return e===t?0:e<t?-1:1}u_(),uo.subscribe(()=>uw(u_));let uk=ui(),uP=uh(),uR=nx(),uT=nS(),uO=new Set,u$=!1;function uN(e){if(null===e)uO=null;else if(null!==uO)for(let t of e)uO.add(t);uw(uj)}function uj(){if(!u$){u$=!0;try{for(let e=1;;e++){let t=uO;if(null!==t&&0===t.size)return;uO=new Set;try{!function(e,t,r,n,a,o=null){let i=uP.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:p}=n_(t,c.name),m=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=uk.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=uH(a),u=uH(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[uM(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=nk(r,e,l),c=u?un({},i,u):i,d=uM(l),p=t.extensions[d];if(p){let e=c?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!ss(e,o.user))||p.featureFlag&&!a.includes(p.featureFlag))continue;s.push({id:l,name:d,moduleName:p.moduleName,config:c,featureFlag:p.featureFlag,meta:p.meta,displayConditionExpression:c?.["Display conditions"]?.expression||p.displayExpression})}}return s}(n,e,p,r,u,a.session);d&&d.moduleName===c.moduleName&&rP(d.candidateExtensions,m)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&uP.setState({slots:s})}(uk.getState(),uR.getState(),uT.getState(),l9.getState(),i8.getState(),t)}catch(e){throw uO=null===t||null===uO?null:new Set([...t,...uO]),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{u$=!1}}}function uI(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 uA(e,t){return{moduleName:t,name:e,attachedIds:[]}}function uM(e){let[t]=e.split("#");return t}function uL(e,t){let r=uM(t);return e.extensions[r]}function uF(e){return uL(uk.getState(),e)}uk.subscribe((e,t)=>{uN(e.extensions!==t.extensions?null:uI(e.slots,t.slots))}),uR.subscribe((e,t)=>{uN(uI(e.slots,t.slots))}),uT.subscribe((e,t)=>{uN(uI(e.configs,t.configs))}),l9.subscribe(()=>uN(null)),i8.subscribe(()=>uN(null)),uN(null);let uB=e=>ul(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function uU(e,t){ul(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...uA(e),attachedIds:[t]}}}})}function uV(e,t){ul(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 uW(e){ul(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function uH(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function uz(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!!lI(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(uK(e),t,i8.getState().session,e)}function uK(e){return uP.getState().slots[e]?.candidateExtensions??[]}let uG=(e,t)=>uk.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=uA(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),uZ=()=>{uO=null,ul(()=>({slots:{},extensions:{}})),us().setState({renderings:new Map}),uP.setState({slots:{}})},uY=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function uq({name:e,basePath:t,mode:r,componentContext:n,state:a}){uY.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function uJ(e){uY.getState().slotName===e&&uY.setState(uY.getInitialState(),!0)}let uX=B("modalRegistry",{modals:{}});function uQ(e){uX.setState(t=>(t.modals[e.name]=e,t))}function u0(e){let t=uX.getState().modals[e];if(!t){let r=uF(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.`),uQ(t))}return t}let u1=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function u4(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=u1.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 u2(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=u1.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 u3(e){let{openedWindows:t}=u1.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function u6(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=u1.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}}u1.setState({registeredGroupsByName:n})}function u5(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=u1.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}u1.setState({registeredWindowsByName:n})}function u9(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=u1.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}u1.setState({registeredWorkspacesByName:n})}let u8=0,u7=null,ce={bootstrap:15e3,mount:15e3,unmount:15e3};function ct(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(ce).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=ce[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 cr(e,t){var r,n;let a,o,i,s,l,u=await (u7??(u7=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))),u7),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=>ct(e,r)):ct(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 cn(){return ca}function ca(e,t){let r,n=cr(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 co(e,t,r,n,a=e=>e,o={}){let i=uM(n),s=uF(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:p}=s,m=u8++,f=`${t}/${n}-${m}`;e.dataset.extensionRenderingId=f;let h=e=>{try{uf(f)}catch(t){console.error(e,t)}};try{um({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 p()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await cr(a({...u,name:`${t}/${i}-${m}`}),{...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 ci=r(2491),cs=r.n(ci);let cl=(0,ci.createContext)({moduleName:"",featureName:""});var cu=r(1982);function cc({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,ci.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,cu.jsx)("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),iK({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:iH(e,t),...a,children:n})}let cd=({state:e,children:t,...r})=>{let{extension:n}=(0,ci.useContext)(cl),a=(0,ci.useRef)(null),o=(0,ci.useRef)(Promise.resolve()),i=(0,ci.useRef)(!1),s=(0,ci.useRef)(!1),l=(0,ci.useRef)(e),u=(0,ci.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,ci.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,ci.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,co(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,ci.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,ci.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?(0,cu.jsx)("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function cp(e){let t=(0,ci.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function cm(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 cf=e=>e;function ch(e,t=cf,r){let n=(0,ci.useCallback)(t=>e.subscribe(t),[e]),a=(0,ci.useCallback)(()=>t(e.getState()),[e,t]),o=(0,ci.useSyncExternalStore)(n,a,a),i=(0,ci.useMemo)(()=>r?cm(e,r):null,[e,r]);return(0,ci.useMemo)(()=>i?{...o,...i}:o,[o,i])}function cg(e,t){return ch(e,cf,t)}function cy(e){return function(t){let r=(0,ci.useCallback)(t=>e.subscribe(t),[]),n=(0,ci.useCallback)(()=>e.getState(),[]),a=(0,ci.useSyncExternalStore)(r,n,n),o=(0,ci.useMemo)(()=>t?cm(e,t):null,[t]);return(0,ci.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let cv=[];Object.freeze(cv);let cb={candidateExtensions:cv};Object.freeze(cb);let cw=e=>{let t=(0,ci.useCallback)(t=>t.slots?.[e]??cb,[e]);return ch(uh(),t)},cE=e=>e.session;function cx(e,t){let{candidateExtensions:r}=cw(e),n=ch(i8,cE),a=cp(t);return(0,ci.useMemo)(()=>uz(e,a),[e,a,n,r])}function cD(e,t){let{moduleName:r}=(0,ci.useContext)(cl);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,ci.useEffect)(()=>{uG(r,e)},[r,e]),{extensions:cx(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function c_(e){return e}function cS({name:e,extensionSlotName:t,select:r=c_,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,ci.useRef)(null),{extensions:u,extensionSlotModuleName:c}=cD(s,a),d=(0,ci.useMemo)(()=>r(u),[r,u]),p=(0,ci.useMemo)(()=>{if("function"==typeof n&&!cs().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return(0,cu.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,cu.jsx)(cl.Provider,{value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}},children:p?.[t]??("function"!=typeof n?n:null)??(0,cu.jsx)(cd,{state:a})},e.id))})}var cC=r(2870),ck=r.n(cC);function cP(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 cR(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?cP(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)):cP(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function cT(e){return(cT="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 cO(e){return(cO="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 c$(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(cO(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(cO(e)));return e}}var cN=null;try{cN=require("react").createContext()}catch(e){}var cj={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 cI(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function cA(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=cB(e,t,function(){r(this)}),i=c$(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:cF(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function cM(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():cF(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function cL(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=cB(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=c$(e,t)();cF(e).render(n,o)}})}function cF(e){return e.ReactDOMClient||e.ReactDOM}function cB(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=cN?e.React.createElement(cN.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,cR(cR({},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 cU=r(4011),cV=r(5327),cW=r.n(cV),cH=r(3780);let cz={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},cK=new Map;(0,cH.initCache)(cK);let cG={errorRetryCount:3,fetcher:i5,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof i9){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>cK};function cZ(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},cz,e),r={...cG,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=cs().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,cu.jsx)("div",{children:"An error has occurred. Please try reloading the page."});{let n=(0,cu.jsx)(ci.Suspense,{fallback:null,children:(0,cu.jsx)(cV.SWRConfig,{value:r,children:(0,cu.jsx)(cl.Provider,{value:this.state.config,children:t.disableTranslations?(0,cu.jsx)(e,{...this.props}):(0,cu.jsx)(cU.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,cu.jsx)(e,{...this.props})})})})});return t.strictMode&&cs().StrictMode?(0,cu.jsx)(cs().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 cY(e,t){return function(e){if("object"!==cT(e))throw Error("single-spa-react requires a configuration object");var t,r=cR(cR({},cj),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");!cN&&r.React.createContext&&(cN=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:cI.bind(null,r),mount:cA.bind(null,r),unmount:cM.bind(null,r)};return r.parcelCanUpdate&&(n.update=cL.bind(null,r)),n}({React:cs(),ReactDOMClient:ck(),rootComponent:cZ(t)(e)})}function cq(e,t){return()=>e().then(({default:e})=>cY(e,t))}function cJ(e,t){return()=>Promise.resolve(cY(e,t))}let cX=cq,cQ=j()(()=>({}));V("openmrs-app-context",cQ);let c0={};function c1(e,t=e=>e){let r=cQ.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function c4(e,t){cQ.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function c2(e){return null===e?null:Object.freeze(Object.assign({},e))}let c3=new Map;function c6(e,t){let r=(0,ci.useRef)(t??{}),n=(0,ci.useRef)(t=>c4(e,t)),a=(0,ci.useRef)(Symbol());return(0,ci.useEffect)(()=>{let r=t??{},n=a.current;return null===c1(e)?!function(e,t=c0){cQ.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===c0?{}: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.`),c4(e,()=>r)),c3.set(e,n),()=>{c3.get(e)===n&&(cQ.setState(t=>(e in t&&delete t[e],t)),c3.delete(e))}},[e]),(0,ci.useEffect)(()=>{let n=t??{};T(r.current,n)||(c4(e,()=>n),r.current=n)},[t]),n.current}function c5({namespace:e,value:t}){return c6(e,t),null}let c9=({children:e,value:t,fallback:r})=>t?(0,cu.jsx)(cu.Fragment,{children:e}):r?(0,cu.jsx)(cu.Fragment,{children:r}):null;function c8(){let e=(0,ci.useRef)(null);return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,ci.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function c7(e,t=e=>e??{}){let[r,n]=(0,ci.useState)(()=>{if(de(e))return;let r=c1(e);if(null!==r)return t?t(r):r});return(0,ci.useEffect)(()=>{if(de(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,ci.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>T(e,r)?e:r)})(c2(a=c1(e))),cQ.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(c2(n)))})},[e,t]),r}function de(e){return"string"!=typeof e||0===e.trim().length}function dt(e){let t=cx(e);return(0,ci.useMemo)(()=>t.map(e=>e.id),[t])}function dr(e){return cw(e).candidateExtensions}function dn(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=cW()(e?ls(e,t,r):null,i5);return(0,ci.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function da(e){(0,ci.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let di={},ds=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let i8=B("session",{loaded:!1,session:null}),i7=0,se=null;function st(){return se||(i8.getState().loaded&&i7>=Date.now()-6e4?null:so())}function sr(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=st();return n?new Promise(e=>{let t=()=>{let t=i8.getState();t.loaded&&(a(),e(r(t.session)))},a=i8.subscribe(t);n.then(t,t)}):Promise.resolve(r(i8.getState().session))}function sn(){return st(),i8}function sa(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 so(e,t){i7=Date.now(),o??(o=i7);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=sh(i5(i3,{headers:r,rejectAuthFailure:!0})),a=()=>{se===n&&(se=null)};return n.then(a,a),se=n,n}function si(){i8.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function ss(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 sl(){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(i8.getState()),e||(t=i8.subscribe(n))})}async function su(){return(await sr()).sessionLocation}async function sc(e,t){return sh(i5(i3,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function sd(e,t){return await i5(i3,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),so()}async function sp(e,t,r){return r||(r=new AbortController),await i5(`${i4}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),so()}async function sm(e,t=!1){let r=await i5(t?`${i3}?rememberMe=true`:i3,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await so()).session:r.data}async function sf(){try{await i5(i3,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!sg(e))throw e}si(),await so().catch(()=>{})}function sh(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};i8.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(sy(Error("The session endpoint did not respond with a session"))):r(sy(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(sg(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?i8.setState({loaded:!0,session:e.responseBody},!0):si(),t(i8.getState());return}(a=e)instanceof i9&&502===a.response.status&&!i8.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(sy(e,!0)):(k(`Failed to fetch new session information: ${e}`),r(sy(e)))})})}function sg(e){return e instanceof i9&&(401===e.response.status||403===e.response.status)}function sy(e,t=!1){return i8.getState().loaded||i8.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),i8.getState()}function sv(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}i8.subscribe(e=>{e.loaded&&e.session&&sa(e.session)});let sb={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function sw(){nZ("@openmrs/esm-api",i0),so()}let sE="import-map-override:",sx="import-map-overrides-disabled",sD="import-map-overrides:change",s_=!1,sS=null,sC=null;async function sk(){return sC??(sC=sP().then(({map:e,complete:t})=>(t||(sC=null),e))),sC}async function sP(){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:sR(t),complete:r}}function sR(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function sT(){let e={};try{let t=sI();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(sE)){let r=n.slice(sE.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 sO(){let e=await sk();return s_?sR([e,sS??sT()]):e}async function s$(){return sk()}async function sN(){return s_?sR([await sk(),sT()]):sk()}function sj(e){if(!s_)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sE)){let t=localStorage.getItem(r);t&&(e[r.slice(sE.length)]=t)}}return{imports:e}}return sT()}function sI(){if(!s_)return[];try{let e=localStorage.getItem(sx);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function sA(e){return!!s_&&sI().includes(e)}function sM(e,t){if(!s_)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sE+e,t),window.dispatchEvent(new CustomEvent(sD))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sL(e){if(!s_)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sE+e);let t=sI().filter(t=>t!==e);t.length>0?localStorage.setItem(sx,JSON.stringify(t)):localStorage.removeItem(sx),window.dispatchEvent(new CustomEvent(sD))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sF(){if(!s_)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(sE)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(sx),window.dispatchEvent(new CustomEvent(sD))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function sB(e){if(!s_)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=sI().filter(t=>t!==e);t.length>0?localStorage.setItem(sx,JSON.stringify(t)):localStorage.removeItem(sx),window.dispatchEvent(new CustomEvent(sD))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let sU=!1;function sV(){!sU&&(sU=!0,(s_="development"===window.spaEnv)&&(sS=sT()))}function sW(e){return e.replace(/[\/\-@]/g,"_")}async function sH(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([sz(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=sW(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 sz(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=sW(e);if(!window[r]){let r=t??await sK();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 sj().imports;try{return await function(e){var t;let r=(t=window)[sG]??(t[sG]=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:iW("scriptLoadingFailed","Error: Script failed to load"),description:iW("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:iW("resetOverrides","Reset overrides"),onActionButtonClick(){sF(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function sK(){return sO()}let sG=Symbol.for("__openmrs_script_loading");function sZ(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 sY(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&&sZ(t))}let sq="openmrs-routes:",sJ="openmrs-routes:change",sX=!1,sQ=null,s0=null;async function s1(){return s0??(s0=s4().then(({map:e,complete:t})=>(t||(s0=null),e))),s0}async function s4(){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&&sY(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:s2(t),complete:r}}function s2(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 s3(){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(sq)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(sq.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(sZ(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(sZ(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 s6(){let e=await s1();return sX?s2([e,sQ??await s3()]):e}async function s5(){return s1()}async function s9(){return sX?s2([await s1(),await s3()]):s1()}function s8(){if(!sX)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sq)){let t=localStorage.getItem(r);t&&(e[r.slice(sq.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function s7(e,t){if(!sX)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(sq+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!sZ(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(sq+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(sq+e,JSON.stringify(t.toString()));else{if(!sZ(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(sq+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(sJ))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function le(e){if(!sX)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(sq+e),window.dispatchEvent(new CustomEvent(sJ))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function lt(){if(!sX)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(sq)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sJ))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let lr=null;function ln(){return lr||(lr=(sX="development"===window.spaEnv)?s3().then(e=>{sQ=e}):Promise.resolve())}let la=`${i4}/attachment`;function lo(e,t){return i5(`${la}/${e}`,{signal:t.signal})}function li(e,t,r,n){return i5(ls(e,t,n),{signal:r.signal})}function ls(e,t,r){return r?`${la}?patient=${e}&encounter=${r}`:`${la}?patient=${e}&includeEncounterless=${t}`}async function ll(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)),i5(`${la}`,{method:"POST",body:n})}function lu(e,t){return i5(`${la}/${e}`,{method:"DELETE",signal:t.signal})}async function lc(e,t){return e?(await i5(`${i2}/Patient/${e}`,t)).data:null}function ld(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function lp(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 lm(e){return{uuid:e.uuid,display:e.display}}function lf(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return i5(`${i4}/location${n?"?"+n:""}`).then(e=>e.data.results.map(lm))}function lh(e){return{uuid:e.uuid,display:e.display,name:e.name}}let lg=`${i4}/visittype`;function ly(e=lg){return i5(e).then(e=>e.data.results.map(lh))}var lv=((et={}).NEWVISIT="startVisit",et.EDITVISIT="editVisit",et.LOADING="loadingVisit",et),lb=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let lw="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))",lE=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function lx(){return W("visit",lE)}function lD(e,t){lx().setState({patientUuid:e,manuallySetVisitUuid:t})}function l_(e,t){return i5(`${i4}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function lS(e,t,r){return i5(`${i4}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function lC(e,t,r){return i5(`${i4}/visit?patient=${e}&v=${r??lw}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}lx().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class lk{static get version(){return"1.6.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+lk.version}static addUnaryOp(e){return lk.max_unop_len=Math.max(e.length,lk.max_unop_len),lk.unary_ops[e]=1,lk}static addBinaryOp(e,t,r){return lk.max_binop_len=Math.max(e.length,lk.max_binop_len),lk.binary_ops[e]=t,r?lk.right_associative.add(e):lk.right_associative.delete(e),lk}static addIdentifierChar(e){return lk.additional_identifier_chars.add(e),lk}static addLiteral(e,t){return lk.literals[e]=t,lk}static removeUnaryOp(e){return delete lk.unary_ops[e],e.length===lk.max_unop_len&&(lk.max_unop_len=lk.getMaxKeyLen(lk.unary_ops)),lk}static removeAllUnaryOps(){return lk.unary_ops={},lk.max_unop_len=0,lk}static removeIdentifierChar(e){return lk.additional_identifier_chars.delete(e),lk}static removeBinaryOp(e){return delete lk.binary_ops[e],e.length===lk.max_binop_len&&(lk.max_binop_len=lk.getMaxKeyLen(lk.binary_ops)),lk.right_associative.delete(e),lk}static removeAllBinaryOps(){return lk.binary_ops={},lk.max_binop_len=0,lk}static removeLiteral(e){return delete lk.literals[e],lk}static removeAllLiterals(){return lk.literals={},lk}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 lk(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 lk.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!lk.binary_ops[String.fromCharCode(e)]||lk.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return lk.isIdentifierStart(e)||lk.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(lk.hooks[e]){let r={context:this,node:t};return lk.hooks.run(e,r),r.node}return t}searchHook(e){if(lk.hooks[e]){let t={context:this};return lk.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===lk.SPACE_CODE||e===lk.TAB_CODE||e===lk.LF_CODE||e===lk.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:lk.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)===lk.SEMCOL_CODE||r===lk.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,lk.max_binop_len),t=e.length;for(;t>0;){if(lk.binary_ops.hasOwnProperty(e)&&(!lk.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!lk.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:lk.binaryPrecedence(t),right_a:lk.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=lk.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:lk.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:lk.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:lk.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,lk.isDecimalDigit(e)||e===lk.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===lk.SQUOTE_CODE||e===lk.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===lk.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,lk.max_unop_len)).length;r>0;){if(lk.unary_ops.hasOwnProperty(t)&&(!lk.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!lk.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:lk.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}lk.isIdentifierStart(e)?(n=this.gobbleIdentifier(),lk.literals.hasOwnProperty(n.name)?n={type:lk.LITERAL,value:lk.literals[n.name],raw:n.name}:n.name===lk.this_str&&(n={type:lk.THIS_EXP})):e===lk.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===lk.PERIOD_CODE||t===lk.OBRACK_CODE||t===lk.OPAREN_CODE||t===lk.QUMARK_CODE;){let r;if(t===lk.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==lk.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===lk.OBRACK_CODE?((e={type:lk.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==lk.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===lk.OPAREN_CODE?e={type:lk.CALL_EXP,arguments:this.gobbleArguments(lk.CPAREN_CODE),callee:e}:(t===lk.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:lk.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(;lk.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===lk.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);lk.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++));lk.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);lk.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,lk.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===lk.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===lk.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:lk.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:lk.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(lk.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,lk.isIdentifierPart(e))this.index++;else break;return{type:lk.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===lk.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===lk.COMMA_CODE){if(this.index++,++n!==t.length){if(e===lk.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===lk.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!==lk.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(lk.CPAREN_CODE);if(this.code===lk.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:lk.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:lk.ARRAY_EXP,elements:this.gobbleArguments(lk.CBRACK_CODE)}}}Object.assign(lk,{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)})}}(lk),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"}),lk.max_unop_len=lk.getMaxKeyLen(lk.unary_ops),lk.max_binop_len=lk.getMaxKeyLen(lk.binary_ops);let lP=e=>new lk(e).parse(),lR=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(lk).filter(e=>!lR.includes(e)&&void 0===lP[e]).forEach(e=>{lP[e]=lk[e]}),lP.Jsep=lk,lP.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 lT="ArrowFunctionExpression",lO={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)}},l$={...lO,Promise};function lN(e,t={}){return lF(e,t,lV)}async function lj(e,t={}){return lB(e,t,lV)}function lI(e,t={}){return lF(e,t,lW)}function lA(e,t={}){return lB(e,t,lW)}function lM(e,t={}){return lF(e,t,lH)}function lL(e,t={}){return lB(e,t,lH)}function lF(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=lY(t,lO),a=lz("string"==typeof e?lP(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 lB(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=lY(t,l$);return Promise.resolve(lz("string"==typeof e?lP(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 lU(e){return lP(e)}function lV(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function lW(e){return"boolean"==typeof e}function lH(e){return"number"==typeof e}function lz(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,p,m,f,h=e,g=t;let y=lz(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 lz(v.left,b)&&lz(v.right,b);case"||":return lz(v.left,b)||lz(v.right,b);case"??":return lz(v.left,b)??lz(v.right,b)}let w=lz(v.left,b),E=lz(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,lz(r.test,n)?lz(r.consequent,n):lz(r.alternate,n);case"CallExpression":return lX(lG(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 lz(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return lX(lZ(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(lQ(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(lQ(u)))[D.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(lQ(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,(l0(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,k;return p=e,m=t,C=p.expressions?.map(lQ(m))??[],(k=p.quasis?.map(lQ(m))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+k.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 lK(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return lK(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function lG(e,t){let r=lJ(e.callee,t);if(r===lq||e.optional&&null==r)return lq;let n=e.arguments?.map(lQ(t));if(r){if("function"!=typeof r)throw`${l2(e.callee)} is not a function`}else throw`No function named ${l2(e.callee)} is defined in this context`;return r(...n)}function lZ(e,t){let r=lJ(e.object,t);if(r===lq||e.optional&&null==r)return lq;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${l4(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=lK(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${l4(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}(lz(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);l0(n),function(e,t){if(l1.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 lY(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}lP.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:lT,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=lT,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)})}}),lP.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"}})}}),lP.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)})}}),lP.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")}})}}),lP.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 :")}})}}),lP.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})}}),lP.addBinaryOp("in",7),lP.addBinaryOp("??",1);let lq=Symbol("optional chain short-circuited");function lJ(e,t){switch(e.type){case"MemberExpression":return lZ(e,t);case"CallExpression":return lG(e,t);default:return lz(e,t)}}function lX(e){return e===lq?void 0:e}function lQ(e){return function(t){return null===t?null:lz(t,e)}}function l0(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let l1=new Set(["toString","valueOf","hasOwnProperty"]);function l4(e,t){try{return lK(e,t)}catch{return"<computed>"}}function l2(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function l3(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:{...l$},boundNames:new Set,variables:new Set};return l6("string"==typeof e?lP(e):e,t),[...t.variables]}function l6(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void l6(r.argument,n);case"BinaryExpression":return a=e,o=t,void(l6(a.left,o),l6(a.right,o));case"ConditionalExpression":return i=e,s=t,void(l6(i.consequent,s),l6(i.test,s),l6(i.alternate,s));case"CallExpression":return l=e,u=t,void(l6(l.callee,u),l.arguments?.map(l5(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,p,m,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);l6(x.body,{...D,boundNames:_});return;case"MemberExpression":return c=e,d=t,void(l6(c.object,d),c.computed&&l6(c.property,d));case"ArrayExpression":return p=e,m=t,void p.elements?.map(l5(m));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(l5(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(l5(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(l5(E)),w.quasis?.map(l5(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function l5(e){return function(t){return null===t?null:l6(t,e)}}let l9=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 l8(e,t,r){l9.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function l7(){let e=l9.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 ue(e){return l9.getState().flags[e].enabled}function ut(e,t){l9.subscribe(r=>{t(r.flags[e].enabled)})}function ur(e,t){l9.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}l9.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 un=tG(function(e,t,r){tF(e,t,r)});let ua=B("extensionsInternal",{slots:{},extensions:{}}),uo=B("extensionRenderings",{renderings:new Map}),ui=()=>W("extensionsInternal",{slots:{},extensions:{}}),us=()=>W("extensionRenderings",{renderings:new Map});function ul(e){let t=ua.getState(),r=e(t);r!==t&&ua.setState(r)}let uu=null,uc=null;function ud(){let e=uo.getState();return uu&&e===uc||(uu=new Map(e.renderings),uc=e,function(e){for(let t of(uE.clear(),e.values()))uD(t,1);ux=!0}(uu)),uu}function up(e){uc={renderings:e},uo.setState(uc,!0)}function um(e){let t=ud();t.has(e.renderingId)||(t.set(e.renderingId,e),uD(e,1),up(t))}function uf(e){let t=ud(),r=t.get(e);r&&(t.delete(e),uD(r,-1),up(t))}let uh=()=>W("extensions",{slots:{}}),ug=0,uy=new Set;function uv(e){ug++;try{return e()}finally{if(0==--ug&&uy.size>0){let e=Array.from(uy);for(let t of(uy.clear(),e))ub(t)}}}function ub(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function uw(e){ug>0?uy.add(e):ub(e)}let uE=new Map,ux=!1;function uD(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=uE.get(r);if(!n){if(t<0)return;uE.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),ux=!0;return}n.count+=t,n.count<1&&(uE.delete(r),ux=!0)}function u_(){var e,t;if(ud(),!ux)return;ux=!1;let r=Array.from(uE.values(),({record:e})=>e);r.sort(uS),e=nw.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===uS(e,t[r]))||nw.setState({mountedExtensions:r})}function uS(e,t){return uC(e.slotName,t.slotName)||uC(e.extensionId,t.extensionId)||uC(e.slotModuleName,t.slotModuleName)||uC(e.extensionModuleName,t.extensionModuleName)}function uC(e,t){return e===t?0:e<t?-1:1}u_(),uo.subscribe(()=>uw(u_));let uk=ui(),uP=uh(),uR=nx(),uT=nS(),uO=new Set,u$=!1;function uN(e){if(null===e)uO=null;else if(null!==uO)for(let t of e)uO.add(t);uw(uj)}function uj(){if(!u$){u$=!0;try{for(let e=1;;e++){let t=uO;if(null!==t&&0===t.size)return;uO=new Set;try{!function(e,t,r,n,a,o=null){let i=uP.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:p}=n_(t,c.name),m=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=uk.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=uH(a),u=uH(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[uM(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=nk(r,e,l),c=u?un({},i,u):i,d=uM(l),p=t.extensions[d];if(p){let e=c?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!ss(e,o.user))||p.featureFlag&&!a.includes(p.featureFlag))continue;s.push({id:l,name:d,moduleName:p.moduleName,config:c,featureFlag:p.featureFlag,meta:p.meta,displayConditionExpression:c?.["Display conditions"]?.expression||p.displayExpression})}}return s}(n,e,p,r,u,a.session);d&&d.moduleName===c.moduleName&&rP(d.candidateExtensions,m)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&uP.setState({slots:s})}(uk.getState(),uR.getState(),uT.getState(),l9.getState(),i8.getState(),t)}catch(e){throw uO=null===t||null===uO?null:new Set([...t,...uO]),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{u$=!1}}}function uI(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 uA(e,t){return{moduleName:t,name:e,attachedIds:[]}}function uM(e){let[t]=e.split("#");return t}function uL(e,t){let r=uM(t);return e.extensions[r]}function uF(e){return uL(uk.getState(),e)}uk.subscribe((e,t)=>{uN(e.extensions!==t.extensions?null:uI(e.slots,t.slots))}),uR.subscribe((e,t)=>{uN(uI(e.slots,t.slots))}),uT.subscribe((e,t)=>{uN(uI(e.configs,t.configs))}),l9.subscribe(()=>uN(null)),i8.subscribe(()=>uN(null)),uN(null);let uB=e=>ul(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function uU(e,t){ul(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...uA(e),attachedIds:[t]}}}})}function uV(e,t){ul(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 uW(e){ul(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function uH(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function uz(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!!lI(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(uK(e),t,i8.getState().session,e)}function uK(e){return uP.getState().slots[e]?.candidateExtensions??[]}let uG=(e,t)=>uk.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=uA(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),uZ=()=>{uO=null,ul(()=>({slots:{},extensions:{}})),us().setState({renderings:new Map}),uP.setState({slots:{}})},uY=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function uq({name:e,basePath:t,mode:r,componentContext:n,state:a}){uY.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function uJ(e){uY.getState().slotName===e&&uY.setState(uY.getInitialState(),!0)}let uX=B("modalRegistry",{modals:{}});function uQ(e){uX.setState(t=>(t.modals[e.name]=e,t))}function u0(e){let t=uX.getState().modals[e];if(!t){let r=uF(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.`),uQ(t))}return t}let u1=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function u4(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=u1.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 u2(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=u1.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 u3(e){let{openedWindows:t}=u1.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function u6(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=u1.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}}u1.setState({registeredGroupsByName:n})}function u5(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=u1.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}u1.setState({registeredWindowsByName:n})}function u9(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=u1.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}u1.setState({registeredWorkspacesByName:n})}let u8=0,u7=null,ce={bootstrap:15e3,mount:15e3,unmount:15e3};function ct(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(ce).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=ce[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 cr(e,t){var r,n;let a,o,i,s,l,u=await (u7??(u7=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))),u7),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=>ct(e,r)):ct(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 cn(){return ca}function ca(e,t){let r,n=cr(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 co(e,t,r,n,a=e=>e,o={}){let i=uM(n),s=uF(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:p}=s,m=u8++,f=`${t}/${n}-${m}`;e.dataset.extensionRenderingId=f;let h=e=>{try{uf(f)}catch(t){console.error(e,t)}};try{um({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 p()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await cr(a({...u,name:`${t}/${i}-${m}`}),{...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 ci=r(2491),cs=r.n(ci);let cl=(0,ci.createContext)({moduleName:"",featureName:""});var cu=r(1982);function cc({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,ci.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,cu.jsx)("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),iK({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:iH(e,t),...a,children:n})}let cd=({state:e,children:t,...r})=>{let{extension:n}=(0,ci.useContext)(cl),a=(0,ci.useRef)(null),o=(0,ci.useRef)(Promise.resolve()),i=(0,ci.useRef)(!1),s=(0,ci.useRef)(!1),l=(0,ci.useRef)(e),u=(0,ci.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,ci.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,ci.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,co(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,ci.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,ci.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?(0,cu.jsx)("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function cp(e){let t=(0,ci.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function cm(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 cf=e=>e;function ch(e,t=cf,r){let n=(0,ci.useCallback)(t=>e.subscribe(t),[e]),a=(0,ci.useCallback)(()=>t(e.getState()),[e,t]),o=(0,ci.useSyncExternalStore)(n,a,a),i=(0,ci.useMemo)(()=>r?cm(e,r):null,[e,r]);return(0,ci.useMemo)(()=>i?{...o,...i}:o,[o,i])}function cg(e,t){return ch(e,cf,t)}function cy(e){return function(t){let r=(0,ci.useCallback)(t=>e.subscribe(t),[]),n=(0,ci.useCallback)(()=>e.getState(),[]),a=(0,ci.useSyncExternalStore)(r,n,n),o=(0,ci.useMemo)(()=>t?cm(e,t):null,[t]);return(0,ci.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let cv=[];Object.freeze(cv);let cb={candidateExtensions:cv};Object.freeze(cb);let cw=e=>{let t=(0,ci.useCallback)(t=>t.slots?.[e]??cb,[e]);return ch(uh(),t)},cE=e=>e.session;function cx(e,t){let{candidateExtensions:r}=cw(e),n=ch(i8,cE),a=cp(t);return(0,ci.useMemo)(()=>uz(e,a),[e,a,n,r])}function cD(e,t){let{moduleName:r}=(0,ci.useContext)(cl);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,ci.useEffect)(()=>{uG(r,e)},[r,e]),{extensions:cx(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function c_(e){return e}function cS({name:e,extensionSlotName:t,select:r=c_,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,ci.useRef)(null),{extensions:u,extensionSlotModuleName:c}=cD(s,a),d=(0,ci.useMemo)(()=>r(u),[r,u]),p=(0,ci.useMemo)(()=>{if("function"==typeof n&&!cs().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return(0,cu.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,cu.jsx)(cl.Provider,{value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}},children:p?.[t]??("function"!=typeof n?n:null)??(0,cu.jsx)(cd,{state:a})},e.id))})}var cC=r(2870),ck=r.n(cC);function cP(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 cR(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?cP(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)):cP(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function cT(e){return(cT="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 cO(e){return(cO="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 c$(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(cO(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(cO(e)));return e}}var cN=null;try{cN=require("react").createContext()}catch(e){}var cj={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 cI(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function cA(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=cB(e,t,function(){r(this)}),i=c$(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:cF(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function cM(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():cF(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function cL(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=cB(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=c$(e,t)();cF(e).render(n,o)}})}function cF(e){return e.ReactDOMClient||e.ReactDOM}function cB(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=cN?e.React.createElement(cN.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,cR(cR({},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 cU=r(4011),cV=r(5327),cW=r.n(cV),cH=r(3780);let cz={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},cK=new Map;(0,cH.initCache)(cK);let cG={errorRetryCount:3,fetcher:i5,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof i9){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>cK};function cZ(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},cz,e),r={...cG,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=cs().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,cu.jsx)("div",{children:"An error has occurred. Please try reloading the page."});{let n=(0,cu.jsx)(ci.Suspense,{fallback:null,children:(0,cu.jsx)(cV.SWRConfig,{value:r,children:(0,cu.jsx)(cl.Provider,{value:this.state.config,children:t.disableTranslations?(0,cu.jsx)(e,{...this.props}):(0,cu.jsx)(cU.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,cu.jsx)(e,{...this.props})})})})});return t.strictMode&&cs().StrictMode?(0,cu.jsx)(cs().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 cY(e,t){return function(e){if("object"!==cT(e))throw Error("single-spa-react requires a configuration object");var t,r=cR(cR({},cj),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");!cN&&r.React.createContext&&(cN=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:cI.bind(null,r),mount:cA.bind(null,r),unmount:cM.bind(null,r)};return r.parcelCanUpdate&&(n.update=cL.bind(null,r)),n}({React:cs(),ReactDOMClient:ck(),rootComponent:cZ(t)(e)})}function cq(e,t){return()=>e().then(({default:e})=>cY(e,t))}function cJ(e,t){return()=>Promise.resolve(cY(e,t))}let cX=cq,cQ=j()(()=>({}));V("openmrs-app-context",cQ);let c0={};function c1(e,t=e=>e){let r=cQ.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function c4(e,t){cQ.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function c2(e){return null===e?null:Object.freeze(Object.assign({},e))}let c3=new Map;function c6(e,t){let r=(0,ci.useRef)(t??{}),n=(0,ci.useRef)(t=>c4(e,t)),a=(0,ci.useRef)(Symbol());return(0,ci.useEffect)(()=>{let r=t??{},n=a.current;return null===c1(e)?!function(e,t=c0){cQ.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===c0?{}: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.`),c4(e,()=>r)),c3.set(e,n),()=>{c3.get(e)===n&&(cQ.setState(t=>(e in t&&delete t[e],t)),c3.delete(e))}},[e]),(0,ci.useEffect)(()=>{let n=t??{};T(r.current,n)||(c4(e,()=>n),r.current=n)},[t]),n.current}function c5({namespace:e,value:t}){return c6(e,t),null}let c9=({children:e,value:t,fallback:r})=>t?(0,cu.jsx)(cu.Fragment,{children:e}):r?(0,cu.jsx)(cu.Fragment,{children:r}):null;function c8(){let e=(0,ci.useRef)(null);return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,ci.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function c7(e,t=e=>e??{}){let[r,n]=(0,ci.useState)(()=>{if(de(e))return;let r=c1(e);if(null!==r)return t?t(r):r});return(0,ci.useEffect)(()=>{if(de(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,ci.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>T(e,r)?e:r)})(c2(a=c1(e))),cQ.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(c2(n)))})},[e,t]),r}function de(e){return"string"!=typeof e||0===e.trim().length}function dt(e){let t=cx(e);return(0,ci.useMemo)(()=>t.map(e=>e.id),[t])}function dr(e){return cw(e).candidateExtensions}function dn(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=cW()(e?ls(e,t,r):null,i5);return(0,ci.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function da(e){(0,ci.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let di={},ds=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function dl(e,t,r){let n=di[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 di[e]=a,a.then(()=>{di[e]===a&&delete di[e]}),a}function du(e){let{moduleName:t,extension:r}=(0,ci.useContext)(cl),n=e?.externalModuleName??t;if(!n&&!r)throw Error(ds);let a=function(e){let t=(0,ci.useMemo)(()=>nE(e),[e]),r=function(e){let[t,r]=(0,ci.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,ci.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw dl(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,ci.useMemo)(nS,[]),r=function(e,t){let[r,n]=(0,ci.useState)(t?()=>{let r=nC(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,ci.useEffect)(()=>{if(t)return e.subscribe(e=>{let a=nC(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!rP(a.config,r)&&n(a.config)})},[e,t,r]),r}(t,e);if(!r&&e)throw dl(`${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,ci.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...a}:{...a,...o},[n,e?.externalModuleName,a,o])}let dc=cx;function dd(e,t=300){let[r,n]=(0,ci.useState)(e);return(0,ci.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var dp=r(9256),dm=r.n(dp);let df=`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 dh(){let e=`${i4}/emrapi/configuration?v=${df}`,t=dm()(e,i5);return(0,ci.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function dg(){return(0,ci.useContext)(cl).extension}let dy=cy(ui());function dv(e){let t=cx(e);return(0,ci.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let db=cy(uh());function dw(e){let{flags:t}=ch(l9);return t[e]?.enabled??!1}function dE(){let[,e]=(0,ci.useState)(0);return(0,ci.useCallback)(()=>{e(e=>e+1)},[])}function dx(e,t,r={}){return d_(e,t,dD,r)}let dD={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(i6(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 d_(e,t,r,n={}){let{getPaginatedUrl:a,getTotalCount:o,getCurrentPageSize:i,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??i5,[d,p]=(0,ci.useState)(1),m=(0,ci.useRef)(NaN),f=(0,ci.useRef)(NaN),h=(0,ci.useRef)(d),g=(0,ci.useRef)(!1),y=(0,ci.useRef)(!1),v=e?.toString()??"",[b,w]=(0,ci.useState)(v);v!==b&&(w(v),p(1),h.current=1,m.current=NaN,f.current=NaN,g.current=!1,y.current=!1);let E=(d-1)*t,x=(0,ci.useMemo)(()=>a(e,t,E),[e,t,E]),{data:D,..._}=(l?dm():cW())(x,c,u);D?.data&&(m.current=o(D?.data),f.current=i(D?.data),g.current=!0);let S=Math.ceil(m.current/t),C=(0,ci.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(m.current/t);!g.current||Number.isNaN(r)||e<=r?(h.current=e,p(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,ci.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(m.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(m.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),h.current=e,p(e))},[d,t,v,D]);let k=(0,ci.useCallback)(()=>{C(h.current+1)},[C]),P=(0,ci.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(D?.data),totalPages:S,totalCount:m.current,currentPage:d,currentPageSize:f.current,paginated:S>1,showNextButton:d<S,showPreviousButton:d>1,goTo:C,goToNext:k,goToPrevious:P,..._}}function dS(e,t,r={}){return d_(e,t,dC(),r)}function dC(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(i6(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 dk=r(6038),dP=r.n(dk);function dR(e,t={}){return dT(e,dD,t)}function dT(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??i5,u=(0,ci.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:p,...m}=dP()(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:()=>{p((c?.length??0)+1)},nextUri:f,...m}}function dO(e,t={}){return d$(e,dD,t)}function d$(e,t,r={}){let n=dT(e,t,r),{hasMore:a,error:o,data:i,loadMore:s,isLoading:l,nextUri:u}=n;return((0,ci.useEffect)(()=>{a&&!o&&s()},[a,u]),r.partialData)?n:{...n,data:a||o?void 0:i,isLoading:l||a}}function dN(e,t={}){return d$(e,dC(),t)}function dj(e,t={}){return dT(e,dC(),t)}function dI(){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 dA(){let[e,t]=(0,ci.useState)(dI);return(0,ci.useEffect)(()=>{let e=()=>{t(dI())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let dM=e=>"small-desktop"===e||"large-desktop"===e;function dL(e){let t=(0,ci.useContext)(cl);(0,ci.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),uq(e),()=>{uJ(e.name)}),[t,e])}function dF(){return ch(uY)}let dB=[];function dU(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=dO(`${i4}/location${n?"?"+n:""}`,{immutable:!0});return a??dB}function dV(e,t=!0){let r=(0,ci.useRef)(null);return(0,ci.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 dW(e){let t=(0,ci.useRef)(null);return(0,ci.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 dH(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=c8(),s=(0,ci.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,ci.useCallback)(e=>i5(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 cW()(e,l,o)}function dz(e=[],t=10){let[r,n]=(0,ci.useState)(1),a=(0,ci.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,ci.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,ci.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,ci.useCallback)(()=>{n(e=>e+1)},[]),u=(0,ci.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,ci.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 dK(e,t,r,n){return{pageSizes:(0,ci.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,ci.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function dG(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function dZ(e){let[t,r]=(0,ci.useState)(e??dG()),{data:n,error:a,isValidating:o}=cW()(t?["patient",t]:null,()=>lc(t,{}));return(0,ci.useEffect)(()=>{let e=()=>{let e=dG();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,ci.useMemo)(()=>({isLoading:o&&!a&&!n,patient:n,patientUuid:t,error:a}),[o,a,n,t])}function dY(){let e=`${i4}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=cW()(e,i5);return(0,ci.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function dq(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=uM(r),a=e=>e.extensions[n]?.meta,o=({state:n})=>{let o=ch(ui(),a),i=(0,ci.useMemo)(()=>({moduleName:t,featureName:"",extension:{extensionId:r,extensionSlotName:e,extensionSlotModuleName:t,extensionMeta:o}}),[o]);return(0,cu.jsx)(cl.Provider,{value:i,children:(0,cu.jsx)(cd,{state:n})})};return o.displayName=`RenderableExtension(${r})`,o}(t,r,e));return{slotName:t,slotModuleName:r,components:o}}function dJ(e){let{extensions:t,extensionSlotModuleName:r}=cD(e),n=(0,ci.useMemo)(()=>new Set(e?t.map(e=>e.id):[]),[e,t]),[a,o]=(0,ci.useState)(()=>dq(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=dq(a,e,r,n)),(0,ci.useMemo)(()=>e?t.flatMap(e=>{let t=i.components.get(e.id);return t?[t]:[]}):[],[e,t,i])}function dX(){let e=(0,ci.useRef)(null),[t,r]=(0,ci.useState)(null),n=null;if(!t){if(i){let e=sn().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(sn().getState()),n||(e.current=sn().subscribe(r))});if(n)r(n);else throw i}(0,ci.useEffect)(()=>(e.current||(e.current=sn().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 dQ=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,ci.useState)(null);return((0,ci.useEffect)(()=>{let e=sn(),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&&ss(e,n))?(0,cu.jsx)(cu.Fragment,{children:r}):t?(0,cu.jsx)(cu.Fragment,{children:t}):null};var d0=r(4274),d1=r.n(d0),d4=r(5602);let d2=new Map;function d3(){for(let e of Array.from(d2.values()))e()}let d6={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function d5(e){let t=(0,ci.useId)();return(0,ci.useEffect)(()=>{if(e)return d2.set(t,e),()=>{d2.delete(t)}},[t,e]),{...cg(lx(),d6),mutateVisit:d3}}function d9(e,t=lw){let r=(0,ci.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=d5((0,ci.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:p}=cW()(e?`${i4}/visit${s}`:null,i5),{data:m,error:f,mutate:h,isValidating:g}=cW()(e&&i?`${i4}/visit${l}`:null,i5),y=(0,ci.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,ci.useMemo)(()=>i&&m?m.data:null,[m,i]),b=(0,ci.useRef)(null);(0,ci.useEffect)(()=>{!p&&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,p,g,n]);let w=(0,ci.useCallback)(()=>{d(),h()},[d,h]);(0,ci.useEffect)(()=>{r.current=w},[w]);let E=!!(!u||i&&!m),x=!!(i?f:c);return{error:c||f,mutate:w,isValidating:p||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:E&&!x}}d1().extend(d4);let d8=[];function d7(){let{data:e}=dm()(lg,ly);return e??d8}let pe=new Map;async function pt(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 sH(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?pn(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`),pr)}let pr={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function pn(e,t){if(e in pe)await pe[e];else{let r=t??await sH(e);await (pe[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 pa(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