@openmrs/esm-report-builder 0.1.1-pre.181 → 0.1.1-pre.185
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/5584.js +1 -1
- package/dist/5584.js.map +1 -1
- package/dist/openmrs-esm-report-builder.js +2 -2
- package/dist/routes.json +1 -1
- package/package.json +1 -1
package/dist/5584.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 ai=(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&&as(e)){if(a._type===nd.Array&&Array.isArray(n)){let a=n.map(t=>ai(e,t));r[t]=a}else if(a._type===nd.Object)for(let t of Object.keys(n))n[t]=ai(e,n[t])}}else if(al(a)){let e=n??{};al(e)&&(r[t]=ai(a,e))}}return r};function as(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function al(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function au(e,t){let r=`${e}:::${t}`;nU.has(r)||(console.error(t),nU.add(r))}function ac(e){e?nU.forEach(t=>{t.startsWith(e)&&nU.delete(t)}):nU.clear()}function ad(){nV.forEach(e=>e()),nV.length=0,nG.clear(),n6.clear(),n9.clear(),n5.clear(),nW=null,nH=new WeakMap,nz()}let am={"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:nd.Object,_default:{},_validators:[nm(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:nd.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nd.String,_default:void 0}},...am},af=(e,t)=>nm(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),ah=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return nm(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(", "))},ag=ah([]),ay=e=>nm(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),av={inRange:af,isUrl:ag,isUrlWithTemplateParameters:ah,oneOf:ay};var ab=r(8067);let aw=B("breadcrumbs",[]);function aE(e){return aD([e])}function aD(e){let t=[...ax(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ab.pathToRegexp)(e.matcher).regexp:(0,ab.pathToRegexp)(e.path).regexp,settings:e}))];aw.setState(t,!0)}function ax(){return aw.getState()}function a_(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=a_(e,r.join("/"));if(t)return t}}(e,t)}function aS(e,t){if(e.length>0){let r=a_(e,t);if(r){let t=[r],n=a_(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=a_(e,n.settings.parent);return t.reverse()}}return[]}function aC(e){return aS(ax(),e)}var ak=r(366);let aP={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",applicationError:"Application Error",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",clearDevOverrides:"Clear dev overrides",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",copied:"Copied!",copyToClipboard:"Copy to clipboard",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",navigateNonHttp:"Could not navigate to the requested page as it is not a safe URL",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",provisional:"Provisional",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",reload:"Reload",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",serverStartingUp:"The server is starting",serverStartingUpExplainer:"This can take a few minutes. OpenMRS will open automatically when the server is ready.",serverStartingUpSlowExplainer:"This is taking longer than usual. First startup after an upgrade can take 10 minutes or more. You can leave this page open.",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",somethingWentWrongTryReloading:"Something went wrong. Please try reloading.",toggleDevTools:"Toggle dev tools",unknown:"Unknown",viewSetupProgress:"View setup progress",waitingForServer:"Waiting for the server",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var aR=r(2635);let aT=aR.Ay.default||aR.Ay;function aO(e,t,r,n){return aT.t(t,{ns:e,defaultValue:r,...n})}function a$(e,t,r){return aP[e]?aO("core",e,t??aP[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function aN(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=aI(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function aI(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function aM({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=aN(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(a$("navigateNonHttp"));n.startsWith(r)?(0,ak.navigateToUrl)(n):window.location.assign(n)}aT.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let aj="openmrs:history";function aA(e){let t=JSON.parse(sessionStorage.getItem(aj)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(aj,JSON.stringify(t))}function aL(){0===JSON.parse(sessionStorage.getItem(aj)??"[]").length&&document.referrer&&aA(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=aF();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(aj,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?aB({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&aA(window.location.href)})}function aF(){return JSON.parse(sessionStorage.getItem(aj)??"[]")}function aB({toUrl:e}){let t=aF(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);aM({to:t[r]}),sessionStorage.setItem(aj,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function aV(){sessionStorage.removeItem(aj)}let aU="${openmrsSpaBase}/login",aW={redirectAuthFailure:{enabled:{_type:nd.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nd.String,_default:aU,_validators:[av.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:nd.Array,_default:[401],_elements:{_type:nd.Number,_validators:[av.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nd.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:nd.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function aH(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let az="/ws/rest/v1",aK="/ws/fhir2/R4",aG=`${az}/session`;function aZ(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function aY(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=aZ(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(aZ(az),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(aK)){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 n4("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(r===aZ(aG)||204===e.status)&&aM({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===aZ(aG)&&403===e.status||n.enabled&&n.errors.includes(e.status))&&(aV(),aM({to:n.url||e.headers.get("location")||aU}),!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 aq(r,e,n,a)},()=>{throw new aq(r,e,null,a)})})}class aq extends Error{constructor(e,t,r,n){super(),aH(this,"response",void 0),aH(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 aJ=B("session",{loaded:!1,session:null}),aX=0,aQ=null;function a0(){return aQ||(aJ.getState().loaded&&aX>=Date.now()-6e4?null:a3())}function a1(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=a0();return n?new Promise(e=>{let t=()=>{let t=aJ.getState();t.loaded&&(a(),e(r(t.session)))},a=aJ.subscribe(t);n.then(t,t)}):Promise.resolve(r(aJ.getState().session))}function a4(){return a0(),aJ}function a2(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 a3(e,t){aX=Date.now(),a??(a=aX);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=oa(aY(aG,{headers:r,rejectAuthFailure:!0})),o=()=>{aQ===n&&(aQ=null)};return n.then(o,o),aQ=n,n}function a6(){aJ.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function a5(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 a9(){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(aJ.getState()),e||(t=aJ.subscribe(n))})}async function a8(){return(await a1()).sessionLocation}async function a7(e,t){return oa(aY(aG,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function oe(e,t){return await aY(aG,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),a3()}async function ot(e,t,r){return r||(r=new AbortController),await aY(`${az}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),a3()}async function or(e,t=!1){let r=await aY(t?`${aG}?rememberMe=true`:aG,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await a3()).session:r.data}async function on(){try{await aY(aG,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!oo(e))throw e}a6(),await a3().catch(()=>{})}function oa(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};aJ.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(oi(Error("The session endpoint did not respond with a session"))):r(oi(Error("The server is still starting up"),!0))}).catch(e=>{var n,o;if(oo(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?aJ.setState({loaded:!0,session:e.responseBody},!0):a6(),t(aJ.getState());return}(o=e)instanceof aq&&502===o.response.status&&!aJ.getState().loaded&&void 0!==a&&Date.now()-a<18e4?r(oi(e,!0)):(k(`Failed to fetch new session information: ${e}`),r(oi(e)))})})}function oo(e){return e instanceof aq&&(401===e.response.status||403===e.response.status)}function oi(e,t=!1){return aJ.getState().loaded||aJ.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),aJ.getState()}function os(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}aJ.subscribe(e=>{e.loaded&&e.session&&a2(e.session)});let ol={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ou(){nY("@openmrs/esm-api",aW),a3()}let oc="import-map-override:",od="import-map-overrides-disabled",om="import-map-overrides:change",op=!1,of=null,oh=null;async function og(){return oh??(oh=oy().then(({map:e,complete:t})=>(t||(oh=null),e))),oh}async function oy(){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:ov(t),complete:r}}function ov(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function ob(){let e={};try{let t=o_();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(oc)){let r=n.slice(oc.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 ow(){let e=await og();return op?ov([e,of??ob()]):e}async function oE(){return og()}async function oD(){return op?ov([await og(),ob()]):og()}function ox(e){if(!op)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(oc)){let t=localStorage.getItem(r);t&&(e[r.slice(oc.length)]=t)}}return{imports:e}}return ob()}function o_(){if(!op)return[];try{let e=localStorage.getItem(od);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function oS(e){return!!op&&o_().includes(e)}function oC(e,t){if(!op)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(oc+e,t),window.dispatchEvent(new CustomEvent(om))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function ok(e){if(!op)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(oc+e);let t=o_().filter(t=>t!==e);t.length>0?localStorage.setItem(od,JSON.stringify(t)):localStorage.removeItem(od),window.dispatchEvent(new CustomEvent(om))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function oP(){if(!op)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(oc)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(od),window.dispatchEvent(new CustomEvent(om))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function oR(e){if(!op)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=o_().filter(t=>t!==e);t.length>0?localStorage.setItem(od,JSON.stringify(t)):localStorage.removeItem(od),window.dispatchEvent(new CustomEvent(om))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let oT=!1;function oO(){!oT&&(oT=!0,(op="development"===window.spaEnv)&&(of=ob()))}function o$(e){return e.replace(/[\/\-@]/g,"_")}async function oN(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([oI(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=o$(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 oI(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=o$(e);if(!window[r]){let r=t??await oM();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 ox().imports;try{return await function(e){var t;let r=(t=window)[oj]??(t[oj]=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:a$("scriptLoadingFailed","Error: Script failed to load"),description:a$("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:a$("resetOverrides","Reset overrides"),onActionButtonClick(){oP(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function oM(){return ow()}let oj=Symbol.for("__openmrs_script_loading");function oA(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 oL(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&&oA(t))}let oF="openmrs-routes:",oB="openmrs-routes:change",oV=!1,oU=null,oW=null;async function oH(){return oW??(oW=oz().then(({map:e,complete:t})=>(t||(oW=null),e))),oW}async function oz(){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&&oL(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:oK(t),complete:r}}function oK(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 oG(){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(oF)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(oF.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(oA(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(oA(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 oZ(){let e=await oH();return oV?oK([e,oU??await oG()]):e}async function oY(){return oH()}async function oq(){return oV?oK([await oH(),await oG()]):oH()}function oJ(){if(!oV)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(oF)){let t=localStorage.getItem(r);t&&(e[r.slice(oF.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function oX(e,t){if(!oV)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(oF+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!oA(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(oF+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(oF+e,JSON.stringify(t.toString()));else{if(!oA(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(oF+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(oB))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function oQ(e){if(!oV)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(oF+e),window.dispatchEvent(new CustomEvent(oB))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function o0(){if(!oV)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(oF)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(oB))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let o1=null;function o4(){return o1||(o1=(oV="development"===window.spaEnv)?oG().then(e=>{oU=e}):Promise.resolve())}let o2=`${az}/attachment`;function o3(e,t){return aY(`${o2}/${e}`,{signal:t.signal})}function o6(e,t,r,n){return aY(o5(e,t,n),{signal:r.signal})}function o5(e,t,r){return r?`${o2}?patient=${e}&encounter=${r}`:`${o2}?patient=${e}&includeEncounterless=${t}`}async function o9(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)),aY(`${o2}`,{method:"POST",body:n})}function o8(e,t){return aY(`${o2}/${e}`,{method:"DELETE",signal:t.signal})}async function o7(e,t){return e?(await aY(`${aK}/Patient/${e}`,t)).data:null}function ie(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function it(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 ir(e){return{uuid:e.uuid,display:e.display}}function ia(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return aY(`${az}/location${n?"?"+n:""}`).then(e=>e.data.results.map(ir))}function io(e){return{uuid:e.uuid,display:e.display,name:e.name}}let ii=`${az}/visittype`;function is(e=ii){return aY(e).then(e=>e.data.results.map(io))}var il=((et={}).NEWVISIT="startVisit",et.EDITVISIT="editVisit",et.LOADING="loadingVisit",et),iu=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let ic="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))",id=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function im(){return W("visit",id)}function ip(e,t){im().setState({patientUuid:e,manuallySetVisitUuid:t})}function ih(e,t){return aY(`${az}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function ig(e,t,r){return aY(`${az}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function iy(e,t,r){return aY(`${az}/visit?patient=${e}&v=${r??ic}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}im().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class iv{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+iv.version}static addUnaryOp(e){return iv.max_unop_len=Math.max(e.length,iv.max_unop_len),iv.unary_ops[e]=1,iv}static addBinaryOp(e,t,r){return iv.max_binop_len=Math.max(e.length,iv.max_binop_len),iv.binary_ops[e]=t,r?iv.right_associative.add(e):iv.right_associative.delete(e),iv}static addIdentifierChar(e){return iv.additional_identifier_chars.add(e),iv}static addLiteral(e,t){return iv.literals[e]=t,iv}static removeUnaryOp(e){return delete iv.unary_ops[e],e.length===iv.max_unop_len&&(iv.max_unop_len=iv.getMaxKeyLen(iv.unary_ops)),iv}static removeAllUnaryOps(){return iv.unary_ops={},iv.max_unop_len=0,iv}static removeIdentifierChar(e){return iv.additional_identifier_chars.delete(e),iv}static removeBinaryOp(e){return delete iv.binary_ops[e],e.length===iv.max_binop_len&&(iv.max_binop_len=iv.getMaxKeyLen(iv.binary_ops)),iv.right_associative.delete(e),iv}static removeAllBinaryOps(){return iv.binary_ops={},iv.max_binop_len=0,iv}static removeLiteral(e){return delete iv.literals[e],iv}static removeAllLiterals(){return iv.literals={},iv}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 iv(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 iv.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!iv.binary_ops[String.fromCharCode(e)]||iv.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return iv.isIdentifierStart(e)||iv.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(iv.hooks[e]){let r={context:this,node:t};return iv.hooks.run(e,r),r.node}return t}searchHook(e){if(iv.hooks[e]){let t={context:this};return iv.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===iv.SPACE_CODE||e===iv.TAB_CODE||e===iv.LF_CODE||e===iv.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:iv.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)===iv.SEMCOL_CODE||r===iv.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,iv.max_binop_len),t=e.length;for(;t>0;){if(iv.binary_ops.hasOwnProperty(e)&&(!iv.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!iv.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:iv.binaryPrecedence(t),right_a:iv.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=iv.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:iv.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:iv.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:iv.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,iv.isDecimalDigit(e)||e===iv.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===iv.SQUOTE_CODE||e===iv.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===iv.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,iv.max_unop_len)).length;r>0;){if(iv.unary_ops.hasOwnProperty(t)&&(!iv.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!iv.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:iv.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}iv.isIdentifierStart(e)?(n=this.gobbleIdentifier(),iv.literals.hasOwnProperty(n.name)?n={type:iv.LITERAL,value:iv.literals[n.name],raw:n.name}:n.name===iv.this_str&&(n={type:iv.THIS_EXP})):e===iv.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===iv.PERIOD_CODE||t===iv.OBRACK_CODE||t===iv.OPAREN_CODE||t===iv.QUMARK_CODE;){let r;if(t===iv.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==iv.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===iv.OBRACK_CODE?((e={type:iv.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==iv.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===iv.OPAREN_CODE?e={type:iv.CALL_EXP,arguments:this.gobbleArguments(iv.CPAREN_CODE),callee:e}:(t===iv.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:iv.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(;iv.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===iv.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);iv.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++));iv.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);iv.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,iv.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===iv.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===iv.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:iv.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:iv.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(iv.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,iv.isIdentifierPart(e))this.index++;else break;return{type:iv.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===iv.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===iv.COMMA_CODE){if(this.index++,++n!==t.length){if(e===iv.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===iv.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!==iv.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(iv.CPAREN_CODE);if(this.code===iv.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:iv.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:iv.ARRAY_EXP,elements:this.gobbleArguments(iv.CBRACK_CODE)}}}Object.assign(iv,{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)})}}(iv),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"}),iv.max_unop_len=iv.getMaxKeyLen(iv.unary_ops),iv.max_binop_len=iv.getMaxKeyLen(iv.binary_ops);let ib=e=>new iv(e).parse(),iw=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(iv).filter(e=>!iw.includes(e)&&void 0===ib[e]).forEach(e=>{ib[e]=iv[e]}),ib.Jsep=iv,ib.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 iE="ArrowFunctionExpression",iD={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)}},ix={...iD,Promise};function i_(e,t={}){return iT(e,t,iN)}async function iS(e,t={}){return iO(e,t,iN)}function iC(e,t={}){return iT(e,t,iI)}function ik(e,t={}){return iO(e,t,iI)}function iP(e,t={}){return iT(e,t,iM)}function iR(e,t={}){return iO(e,t,iM)}function iT(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=iB(t,iD),a=ij("string"==typeof e?ib(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 iO(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=iB(t,ix);return Promise.resolve(ij("string"==typeof e?ib(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 i$(e){return ib(e)}function iN(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function iI(e){return"boolean"==typeof e}function iM(e){return"number"==typeof e}function ij(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h=e,g=t;let y=ij(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 ij(v.left,b)&&ij(v.right,b);case"||":return ij(v.left,b)||ij(v.right,b);case"??":return ij(v.left,b)??ij(v.right,b)}let w=ij(v.left,b),E=ij(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,ij(r.test,n)?ij(r.consequent,n):ij(r.alternate,n);case"CallExpression":return iW(iL(e,t));case"ArrowFunctionExpression":let D;return a=e,o=t,D=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<D.length)throw`Required argument(s) ${D.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(D.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return ij(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return iW(iF(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(iH(s));case"SequenceExpression":let x;return l=e,u=t,(x=l.expressions.map(iH(u)))[x.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(iH(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,(iz(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 m=e,p=t,C=m.expressions?.map(iH(p))??[],(k=m.quasis?.map(iH(p))??[]).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 iA(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return iA(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function iL(e,t){let r=iU(e.callee,t);if(r===iV||e.optional&&null==r)return iV;let n=e.arguments?.map(iH(t));if(r){if("function"!=typeof r)throw`${iZ(e.callee)} is not a function`}else throw`No function named ${iZ(e.callee)} is defined in this context`;return r(...n)}function iF(e,t){let r=iU(e.object,t);if(r===iV||e.optional&&null==r)return iV;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${iG(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=iA(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${iG(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}(ij(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);iz(n),function(e,t){if(iK.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 iB(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}ib.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:iE,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=iE,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)})}}),ib.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"}})}}),ib.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)})}}),ib.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")}})}}),ib.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 :")}})}}),ib.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})}}),ib.addBinaryOp("in",7),ib.addBinaryOp("??",1);let iV=Symbol("optional chain short-circuited");function iU(e,t){switch(e.type){case"MemberExpression":return iF(e,t);case"CallExpression":return iL(e,t);default:return ij(e,t)}}function iW(e){return e===iV?void 0:e}function iH(e){return function(t){return null===t?null:ij(t,e)}}function iz(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let iK=new Set(["toString","valueOf","hasOwnProperty"]);function iG(e,t){try{return iA(e,t)}catch{return"<computed>"}}function iZ(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function iY(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:{...ix},isLocalExpression:!1,variables:new Set};return iq("string"==typeof e?ib(e):e,t),[...t.variables]}function iq(e,t){switch(e.type){case"UnaryExpression":return n=e,a=t,iq(n.argument,a);case"BinaryExpression":return o=e,i=t,[iq(o.left,i),iq(o.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[iq(s.consequent,l),iq(s.test,l),iq(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=iq(u.callee,c),u.arguments?.map(iJ(c)),r;case"ArrowFunctionExpression":var n,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b=e,w=t;let E={...w};E.isLocalExpression=!0;let D=b.params?.map(iJ(E))??[],x=iq(b.body,E)??[];if(x&&Array.isArray(x))for(let e of x)D.includes(e)||w.variables.add(e);return;case"MemberExpression":var _=e,S=t;if(iq(_.object,S),_.computed)return void iq(_.property,S);let C={...S};C.isLocalExpression=!0,iq(_.property,C);return;case"ArrayExpression":return d=e,m=t,void d.elements?.map(iJ(m));case"SequenceExpression":return p=e,f=t,void p.expressions?.map(iJ(f));case"NewExpression":return h=e,g=t,void h.arguments?.map(iJ(g));case"Literal":case"TemplateElement":return;case"Identifier":var k=e,P=t;if(!(k.name in P.globals))if(P.isLocalExpression)return k.name;else P.variables.add(k.name);return;case"TemplateLiteral":return y=e,v=t,void(y.expressions?.map(iJ(v)),y.quasis?.map(iJ(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function iJ(e){return function(t){return null===t?null:iq(t,e)}}let iX=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 iQ(e,t,r){iX.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function i0(){let e=iX.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 i1(e){return iX.getState().flags[e].enabled}function i4(e,t){iX.subscribe(r=>{t(r.flags[e].enabled)})}function i2(e,t){iX.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}iX.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 i3=tG(function(e,t,r){tF(e,t,r)});let i6=B("extensionsInternal",{slots:{},extensions:{}}),i5=B("extensionRenderings",{renderings:new Map}),i9=()=>W("extensionsInternal",{slots:{},extensions:{}}),i8=()=>W("extensionRenderings",{renderings:new Map});function i7(e){let t=i6.getState(),r=e(t);r!==t&&i6.setState(r)}let se=null,st=null;function sr(){let e=i5.getState();return se&&e===st||(se=new Map(e.renderings),st=e,function(e){for(let t of(sm.clear(),e.values()))sf(t,1);sp=!0}(se)),se}function sn(e){st={renderings:e},i5.setState(st,!0)}function sa(e){let t=sr();t.has(e.renderingId)||(t.set(e.renderingId,e),sf(e,1),sn(t))}function so(e){let t=sr(),r=t.get(e);r&&(t.delete(e),sf(r,-1),sn(t))}let si=()=>W("extensions",{slots:{}}),ss=0,sl=new Set;function su(e){ss++;try{return e()}finally{if(0==--ss&&sl.size>0){let e=Array.from(sl);for(let t of(sl.clear(),e))sc(t)}}}function sc(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function sd(e){ss>0?sl.add(e):sc(e)}let sm=new Map,sp=!1;function sf(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=sm.get(r);if(!n){if(t<0)return;sm.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),sp=!0;return}n.count+=t,n.count<1&&(sm.delete(r),sp=!0)}function sh(){var e,t;if(sr(),!sp)return;sp=!1;let r=Array.from(sm.values(),({record:e})=>e);r.sort(sg),e=nE.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===sg(e,t[r]))||nE.setState({mountedExtensions:r})}function sg(e,t){return sy(e.slotName,t.slotName)||sy(e.extensionId,t.extensionId)||sy(e.slotModuleName,t.slotModuleName)||sy(e.extensionModuleName,t.extensionModuleName)}function sy(e,t){return e===t?0:e<t?-1:1}sh(),i5.subscribe(()=>sd(sh));let sv=i9(),sb=si(),sw=nx(),sE=nC(),sD=new Set,sx=!1;function s_(e){if(null===e)sD=null;else if(null!==sD)for(let t of e)sD.add(t);sd(sS)}function sS(){if(!sx){sx=!0;try{for(let e=1;;e++){let t=sD;if(null!==t&&0===t.size)return;sD=new Set;try{!function(e,t,r,n,a,o=null){let i=sb.getState().slots,s={},l=!1,u=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,c]of Object.entries(e.slots)){let d=i[n];if(d&&o&&!o.has(n)){s[n]=d;continue}let{config:m}=nS(t,c.name),p=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=sv.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=sM(a),u=sM(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[sP(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}=nk(n,e,l),u=nP(r,e,l),c=u?i3({},i,u):i,d=sP(l),m=t.extensions[d];if(m){let e=c?.["Display conditions"]?.privileges??m.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!a5(e,o.user))||m.featureFlag&&!a.includes(m.featureFlag))continue;s.push({id:l,name:d,moduleName:m.moduleName,config:c,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:c?.["Display conditions"]?.expression||m.displayExpression})}}return s}(n,e,m,r,u,a.session);d&&d.moduleName===c.moduleName&&rP(d.candidateExtensions,p)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&sb.setState({slots:s})}(sv.getState(),sw.getState(),sE.getState(),iX.getState(),aJ.getState(),t)}catch(e){throw sD=null===t||null===sD?null:new Set([...t,...sD]),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{sx=!1}}}function sC(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 sk(e,t){return{moduleName:t,name:e,attachedIds:[]}}function sP(e){let[t]=e.split("#");return t}function sR(e,t){let r=sP(t);return e.extensions[r]}function sT(e){return sR(sv.getState(),e)}sv.subscribe((e,t)=>{s_(e.extensions!==t.extensions?null:sC(e.slots,t.slots))}),sw.subscribe((e,t)=>{s_(sC(e.slots,t.slots))}),sE.subscribe((e,t)=>{s_(sC(e.configs,t.configs))}),iX.subscribe(()=>s_(null)),aJ.subscribe(()=>s_(null)),s_(null);let sO=e=>i7(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function s$(e,t){i7(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...sk(e),attachedIds:[t]}}}})}function sN(e,t){i7(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 sI(e){i7(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function sM(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function sj(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!!iC(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(sA(e),t,aJ.getState().session,e)}function sA(e){return sb.getState().slots[e]?.candidateExtensions??[]}let sL=(e,t)=>sv.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=sk(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),sF=()=>{sD=null,i7(()=>({slots:{},extensions:{}})),i8().setState({renderings:new Map}),sb.setState({slots:{}})},sB=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function sV({name:e,basePath:t,mode:r,componentContext:n,state:a}){sB.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function sU(e){sB.getState().slotName===e&&sB.setState(sB.getInitialState(),!0)}let sW=B("modalRegistry",{modals:{}});function sH(e){sW.setState(t=>(t.modals[e.name]=e,t))}function sz(e){let t=sW.getState().modals[e];if(!t){let r=sT(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.`),sH(t))}return t}let sK=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function sG(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=sK.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 sZ(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=sK.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 sY(e){let{openedWindows:t}=sK.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function sq(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=sK.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}}sK.setState({registeredGroupsByName:n})}function sJ(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=sK.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}sK.setState({registeredWindowsByName:n})}function sX(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=sK.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}sK.setState({registeredWorkspacesByName:n})}let sQ=0,s0=null,s1={bootstrap:15e3,mount:15e3,unmount:15e3};function s4(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(s1).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=s1[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 s2(e,t){var r,n;let a,o,i,s,l,u=await (s0??(s0=new Promise((e,t)=>{(0,ak.mountRootParcel)({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),ak.mountRootParcel))),s0),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=>s4(e,r)):s4(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 s3(){return s6}function s6(e,t){let r,n=s2(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 s5(e,t,r,n,a=e=>e,o={}){let i=sP(n),s=sT(n),l=null;if(e){let u;if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:d,load:m}=s,p=sQ++,f=`${t}/${n}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{so(f)}catch(t){console.error(e,t)}};try{sa({renderingId:f,extensionName:i,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{u=await m()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await s2(a({...u,name:`${t}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var s9=r(4587),s8=r.n(s9);let s7=(0,s9.createContext)({moduleName:"",featureName:""});function le({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,s9.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}`)},[]),s8().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),aM({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:aN(e,t),...a},n)}let lt=({state:e,children:t,...r})=>{let{extension:n}=(0,s9.useContext)(s7),a=(0,s9.useRef)(null),o=(0,s9.useRef)(Promise.resolve()),i=(0,s9.useRef)(!1),s=(0,s9.useRef)(!1),l=(0,s9.useRef)(e),u=(0,s9.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,s9.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,s9.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,s5(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,s9.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,s9.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?s8().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function lr(e){let t=(0,s9.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function ln(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 la=e=>e;function lo(e,t=la,r){let n=(0,s9.useCallback)(t=>e.subscribe(t),[e]),a=(0,s9.useCallback)(()=>t(e.getState()),[e,t]),o=(0,s9.useSyncExternalStore)(n,a,a),i=(0,s9.useMemo)(()=>r?ln(e,r):null,[e,r]);return(0,s9.useMemo)(()=>i?{...o,...i}:o,[o,i])}function li(e,t){return lo(e,la,t)}function ls(e){return function(t){let r=(0,s9.useCallback)(t=>e.subscribe(t),[]),n=(0,s9.useCallback)(()=>e.getState(),[]),a=(0,s9.useSyncExternalStore)(r,n,n),o=(0,s9.useMemo)(()=>t?ln(e,t):null,[t]);return(0,s9.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let ll=[];Object.freeze(ll);let lu={candidateExtensions:ll};Object.freeze(lu);let lc=e=>{let t=(0,s9.useCallback)(t=>t.slots?.[e]??lu,[e]);return lo(si(),t)},ld=e=>e.session;function lm(e,t){let{candidateExtensions:r}=lc(e),n=lo(aJ,ld),a=lr(t);return(0,s9.useMemo)(()=>sj(e,a),[e,a,n,r])}function lp(e,t){let{moduleName:r}=(0,s9.useContext)(s7);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,s9.useEffect)(()=>{sL(r,e)},[r,e]),{extensions:lm(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function lf(e){return e}function lh({name:e,extensionSlotName:t,select:r=lf,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,s9.useRef)(null),{extensions:u,extensionSlotModuleName:c}=lp(s,a),d=(0,s9.useMemo)(()=>r(u),[r,u]),m=(0,s9.useMemo)(()=>{if("function"==typeof n&&!s8().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return s8().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i},s&&d?.map((e,t)=>s8().createElement(s7.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof n?n:null)??s8().createElement(lt,{state:a}))))}var lg=r(5338);function ly(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 lv(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ly(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)):ly(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function lb(e){return(lb="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 lw(e){return(lw="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 lE(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(lw(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(lw(e)));return e}}var lD=null;try{lD=require("react").createContext()}catch(e){}var lx={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 l_(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function lS(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=lR(e,t,function(){r(this)}),i=lE(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:lP(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function lC(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():lP(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function lk(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=lR(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=lE(e,t)();lP(e).render(n,o)}})}function lP(e){return e.ReactDOMClient||e.ReactDOM}function lR(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=lD?e.React.createElement(lD.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,lv(lv({},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 lT=r(587),lO=r(2272),l$=r(8444);let lN={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},lI=new Map;(0,l$.y)(lI);let lM={errorRetryCount:3,fetcher:aY,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof aq){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>lI};function lj(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},lN,e),r={...lM,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=s8().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 s8().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=s8().createElement(s9.Suspense,{fallback:null},s8().createElement(lO.S,{value:r},s8().createElement(s7.Provider,{value:this.state.config},t.disableTranslations?s8().createElement(e,this.props):s8().createElement(lT.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},s8().createElement(e,this.props)))));return t.strictMode&&s8().StrictMode?s8().createElement(s8().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function lA(e,t){return function(e){if("object"!==lb(e))throw Error("single-spa-react requires a configuration object");var t,r=lv(lv({},lx),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");!lD&&r.React.createContext&&(lD=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:l_.bind(null,r),mount:lS.bind(null,r),unmount:lC.bind(null,r)};return r.parcelCanUpdate&&(n.update=lk.bind(null,r)),n}({React:s8(),ReactDOMClient:lg,rootComponent:lj(t)(e)})}function lL(e,t){return()=>e().then(({default:e})=>lA(e,t))}function lF(e,t){return()=>Promise.resolve(lA(e,t))}let lB=lL,lV=I()(()=>({}));U("openmrs-app-context",lV);let lU={};function lW(e,t=e=>e){let r=lV.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function lH(e,t){lV.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function lz(e){return null===e?null:Object.freeze(Object.assign({},e))}let lK=new Map;function lG(e,t){let r=(0,s9.useRef)(t??{}),n=(0,s9.useRef)(t=>lH(e,t)),a=(0,s9.useRef)(Symbol());return(0,s9.useEffect)(()=>{let r=t??{},n=a.current;return null===lW(e)?!function(e,t=lU){lV.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===lU?{}: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.`),lH(e,()=>r)),lK.set(e,n),()=>{lK.get(e)===n&&(lV.setState(t=>(e in t&&delete t[e],t)),lK.delete(e))}},[e]),(0,s9.useEffect)(()=>{let n=t??{};T(r.current,n)||(lH(e,()=>n),r.current=n)},[t]),n.current}function lZ({namespace:e,value:t}){return lG(e,t),null}let lY=({children:e,value:t,fallback:r})=>t?s8().createElement(s8().Fragment,null,e):r?s8().createElement(s8().Fragment,null,r):null;function lq(){let e=(0,s9.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,s9.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function lJ(e,t=e=>e??{}){let[r,n]=(0,s9.useState)(()=>{if(lX(e))return;let r=lW(e);if(null!==r)return t?t(r):r});return(0,s9.useEffect)(()=>{if(lX(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,s9.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)})(lz(a=lW(e))),lV.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(lz(n)))})},[e,t]),r}function lX(e){return"string"!=typeof e||0===e.trim().length}function lQ(e){let t=lm(e);return(0,s9.useMemo)(()=>t.map(e=>e.id),[t])}function l0(e){return lc(e).candidateExtensions}function l1(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=(0,lO.u)(e?o5(e,t,r):null,aY);return(0,s9.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function l4(e){(0,s9.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let l2={},l3=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let aJ=B("session",{loaded:!1,session:null}),aX=0,aQ=null;function a0(){return aQ||(aJ.getState().loaded&&aX>=Date.now()-6e4?null:a3())}function a1(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=a0();return n?new Promise(e=>{let t=()=>{let t=aJ.getState();t.loaded&&(a(),e(r(t.session)))},a=aJ.subscribe(t);n.then(t,t)}):Promise.resolve(r(aJ.getState().session))}function a4(){return a0(),aJ}function a2(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 a3(e,t){aX=Date.now(),a??(a=aX);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=oa(aY(aG,{headers:r,rejectAuthFailure:!0})),o=()=>{aQ===n&&(aQ=null)};return n.then(o,o),aQ=n,n}function a6(){aJ.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function a5(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 a9(){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(aJ.getState()),e||(t=aJ.subscribe(n))})}async function a8(){return(await a1()).sessionLocation}async function a7(e,t){return oa(aY(aG,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function oe(e,t){return await aY(aG,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),a3()}async function ot(e,t,r){return r||(r=new AbortController),await aY(`${az}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),a3()}async function or(e,t=!1){let r=await aY(t?`${aG}?rememberMe=true`:aG,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await a3()).session:r.data}async function on(){try{await aY(aG,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!oo(e))throw e}a6(),await a3().catch(()=>{})}function oa(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};aJ.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(oi(Error("The session endpoint did not respond with a session"))):r(oi(Error("The server is still starting up"),!0))}).catch(e=>{var n,o;if(oo(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?aJ.setState({loaded:!0,session:e.responseBody},!0):a6(),t(aJ.getState());return}(o=e)instanceof aq&&502===o.response.status&&!aJ.getState().loaded&&void 0!==a&&Date.now()-a<18e4?r(oi(e,!0)):(k(`Failed to fetch new session information: ${e}`),r(oi(e)))})})}function oo(e){return e instanceof aq&&(401===e.response.status||403===e.response.status)}function oi(e,t=!1){return aJ.getState().loaded||aJ.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),aJ.getState()}function os(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}aJ.subscribe(e=>{e.loaded&&e.session&&a2(e.session)});let ol={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ou(){nY("@openmrs/esm-api",aW),a3()}let oc="import-map-override:",od="import-map-overrides-disabled",om="import-map-overrides:change",op=!1,of=null,oh=null;async function og(){return oh??(oh=oy().then(({map:e,complete:t})=>(t||(oh=null),e))),oh}async function oy(){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:ov(t),complete:r}}function ov(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function ob(){let e={};try{let t=o_();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(oc)){let r=n.slice(oc.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 ow(){let e=await og();return op?ov([e,of??ob()]):e}async function oE(){return og()}async function oD(){return op?ov([await og(),ob()]):og()}function ox(e){if(!op)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(oc)){let t=localStorage.getItem(r);t&&(e[r.slice(oc.length)]=t)}}return{imports:e}}return ob()}function o_(){if(!op)return[];try{let e=localStorage.getItem(od);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function oS(e){return!!op&&o_().includes(e)}function oC(e,t){if(!op)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(oc+e,t),window.dispatchEvent(new CustomEvent(om))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function ok(e){if(!op)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(oc+e);let t=o_().filter(t=>t!==e);t.length>0?localStorage.setItem(od,JSON.stringify(t)):localStorage.removeItem(od),window.dispatchEvent(new CustomEvent(om))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function oP(){if(!op)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(oc)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(od),window.dispatchEvent(new CustomEvent(om))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function oR(e){if(!op)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=o_().filter(t=>t!==e);t.length>0?localStorage.setItem(od,JSON.stringify(t)):localStorage.removeItem(od),window.dispatchEvent(new CustomEvent(om))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let oT=!1;function oO(){!oT&&(oT=!0,(op="development"===window.spaEnv)&&(of=ob()))}function o$(e){return e.replace(/[\/\-@]/g,"_")}async function oN(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([oI(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=o$(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 oI(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=o$(e);if(!window[r]){let r=t??await oM();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 ox().imports;try{return await function(e){var t;let r=(t=window)[oj]??(t[oj]=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:a$("scriptLoadingFailed","Error: Script failed to load"),description:a$("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:a$("resetOverrides","Reset overrides"),onActionButtonClick(){oP(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function oM(){return ow()}let oj=Symbol.for("__openmrs_script_loading");function oA(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 oL(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&&oA(t))}let oF="openmrs-routes:",oB="openmrs-routes:change",oV=!1,oU=null,oW=null;async function oH(){return oW??(oW=oz().then(({map:e,complete:t})=>(t||(oW=null),e))),oW}async function oz(){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&&oL(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:oK(t),complete:r}}function oK(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 oG(){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(oF)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(oF.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(oA(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(oA(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 oZ(){let e=await oH();return oV?oK([e,oU??await oG()]):e}async function oY(){return oH()}async function oq(){return oV?oK([await oH(),await oG()]):oH()}function oJ(){if(!oV)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(oF)){let t=localStorage.getItem(r);t&&(e[r.slice(oF.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function oX(e,t){if(!oV)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(oF+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!oA(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(oF+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(oF+e,JSON.stringify(t.toString()));else{if(!oA(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(oF+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(oB))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function oQ(e){if(!oV)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(oF+e),window.dispatchEvent(new CustomEvent(oB))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function o0(){if(!oV)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(oF)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(oB))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let o1=null;function o4(){return o1||(o1=(oV="development"===window.spaEnv)?oG().then(e=>{oU=e}):Promise.resolve())}let o2=`${az}/attachment`;function o3(e,t){return aY(`${o2}/${e}`,{signal:t.signal})}function o6(e,t,r,n){return aY(o5(e,t,n),{signal:r.signal})}function o5(e,t,r){return r?`${o2}?patient=${e}&encounter=${r}`:`${o2}?patient=${e}&includeEncounterless=${t}`}async function o9(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)),aY(`${o2}`,{method:"POST",body:n})}function o8(e,t){return aY(`${o2}/${e}`,{method:"DELETE",signal:t.signal})}async function o7(e,t){return e?(await aY(`${aK}/Patient/${e}`,t)).data:null}function ie(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function it(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 ir(e){return{uuid:e.uuid,display:e.display}}function ia(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return aY(`${az}/location${n?"?"+n:""}`).then(e=>e.data.results.map(ir))}function io(e){return{uuid:e.uuid,display:e.display,name:e.name}}let ii=`${az}/visittype`;function is(e=ii){return aY(e).then(e=>e.data.results.map(io))}var il=((et={}).NEWVISIT="startVisit",et.EDITVISIT="editVisit",et.LOADING="loadingVisit",et),iu=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let ic="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))",id=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function im(){return W("visit",id)}function ip(e,t){im().setState({patientUuid:e,manuallySetVisitUuid:t})}function ih(e,t){return aY(`${az}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function ig(e,t,r){return aY(`${az}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function iy(e,t,r){return aY(`${az}/visit?patient=${e}&v=${r??ic}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}im().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class iv{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+iv.version}static addUnaryOp(e){return iv.max_unop_len=Math.max(e.length,iv.max_unop_len),iv.unary_ops[e]=1,iv}static addBinaryOp(e,t,r){return iv.max_binop_len=Math.max(e.length,iv.max_binop_len),iv.binary_ops[e]=t,r?iv.right_associative.add(e):iv.right_associative.delete(e),iv}static addIdentifierChar(e){return iv.additional_identifier_chars.add(e),iv}static addLiteral(e,t){return iv.literals[e]=t,iv}static removeUnaryOp(e){return delete iv.unary_ops[e],e.length===iv.max_unop_len&&(iv.max_unop_len=iv.getMaxKeyLen(iv.unary_ops)),iv}static removeAllUnaryOps(){return iv.unary_ops={},iv.max_unop_len=0,iv}static removeIdentifierChar(e){return iv.additional_identifier_chars.delete(e),iv}static removeBinaryOp(e){return delete iv.binary_ops[e],e.length===iv.max_binop_len&&(iv.max_binop_len=iv.getMaxKeyLen(iv.binary_ops)),iv.right_associative.delete(e),iv}static removeAllBinaryOps(){return iv.binary_ops={},iv.max_binop_len=0,iv}static removeLiteral(e){return delete iv.literals[e],iv}static removeAllLiterals(){return iv.literals={},iv}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 iv(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 iv.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!iv.binary_ops[String.fromCharCode(e)]||iv.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return iv.isIdentifierStart(e)||iv.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(iv.hooks[e]){let r={context:this,node:t};return iv.hooks.run(e,r),r.node}return t}searchHook(e){if(iv.hooks[e]){let t={context:this};return iv.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===iv.SPACE_CODE||e===iv.TAB_CODE||e===iv.LF_CODE||e===iv.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:iv.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)===iv.SEMCOL_CODE||r===iv.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,iv.max_binop_len),t=e.length;for(;t>0;){if(iv.binary_ops.hasOwnProperty(e)&&(!iv.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!iv.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:iv.binaryPrecedence(t),right_a:iv.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=iv.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:iv.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:iv.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:iv.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,iv.isDecimalDigit(e)||e===iv.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===iv.SQUOTE_CODE||e===iv.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===iv.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,iv.max_unop_len)).length;r>0;){if(iv.unary_ops.hasOwnProperty(t)&&(!iv.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!iv.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:iv.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}iv.isIdentifierStart(e)?(n=this.gobbleIdentifier(),iv.literals.hasOwnProperty(n.name)?n={type:iv.LITERAL,value:iv.literals[n.name],raw:n.name}:n.name===iv.this_str&&(n={type:iv.THIS_EXP})):e===iv.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===iv.PERIOD_CODE||t===iv.OBRACK_CODE||t===iv.OPAREN_CODE||t===iv.QUMARK_CODE;){let r;if(t===iv.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==iv.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===iv.OBRACK_CODE?((e={type:iv.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==iv.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===iv.OPAREN_CODE?e={type:iv.CALL_EXP,arguments:this.gobbleArguments(iv.CPAREN_CODE),callee:e}:(t===iv.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:iv.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(;iv.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===iv.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);iv.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++));iv.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);iv.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,iv.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===iv.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===iv.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:iv.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:iv.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(iv.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,iv.isIdentifierPart(e))this.index++;else break;return{type:iv.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===iv.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===iv.COMMA_CODE){if(this.index++,++n!==t.length){if(e===iv.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===iv.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!==iv.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(iv.CPAREN_CODE);if(this.code===iv.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:iv.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:iv.ARRAY_EXP,elements:this.gobbleArguments(iv.CBRACK_CODE)}}}Object.assign(iv,{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)})}}(iv),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"}),iv.max_unop_len=iv.getMaxKeyLen(iv.unary_ops),iv.max_binop_len=iv.getMaxKeyLen(iv.binary_ops);let ib=e=>new iv(e).parse(),iw=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(iv).filter(e=>!iw.includes(e)&&void 0===ib[e]).forEach(e=>{ib[e]=iv[e]}),ib.Jsep=iv,ib.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 iE="ArrowFunctionExpression",iD={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)}},ix={...iD,Promise};function i_(e,t={}){return iT(e,t,iN)}async function iS(e,t={}){return iO(e,t,iN)}function iC(e,t={}){return iT(e,t,iI)}function ik(e,t={}){return iO(e,t,iI)}function iP(e,t={}){return iT(e,t,iM)}function iR(e,t={}){return iO(e,t,iM)}function iT(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=iB(t,iD),a=ij("string"==typeof e?ib(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 iO(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=iB(t,ix);return Promise.resolve(ij("string"==typeof e?ib(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 i$(e){return ib(e)}function iN(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function iI(e){return"boolean"==typeof e}function iM(e){return"number"==typeof e}function ij(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h=e,g=t;let y=ij(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 ij(v.left,b)&&ij(v.right,b);case"||":return ij(v.left,b)||ij(v.right,b);case"??":return ij(v.left,b)??ij(v.right,b)}let w=ij(v.left,b),E=ij(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,ij(r.test,n)?ij(r.consequent,n):ij(r.alternate,n);case"CallExpression":return iW(iL(e,t));case"ArrowFunctionExpression":let D;return a=e,o=t,D=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<D.length)throw`Required argument(s) ${D.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(D.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return ij(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return iW(iF(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(iH(s));case"SequenceExpression":let x;return l=e,u=t,(x=l.expressions.map(iH(u)))[x.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(iH(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,(iz(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 m=e,p=t,C=m.expressions?.map(iH(p))??[],(k=m.quasis?.map(iH(p))??[]).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 iA(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return iA(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function iL(e,t){let r=iU(e.callee,t);if(r===iV||e.optional&&null==r)return iV;let n=e.arguments?.map(iH(t));if(r){if("function"!=typeof r)throw`${iZ(e.callee)} is not a function`}else throw`No function named ${iZ(e.callee)} is defined in this context`;return r(...n)}function iF(e,t){let r=iU(e.object,t);if(r===iV||e.optional&&null==r)return iV;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${iG(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=iA(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${iG(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}(ij(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);iz(n),function(e,t){if(iK.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 iB(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}ib.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:iE,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=iE,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)})}}),ib.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"}})}}),ib.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)})}}),ib.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")}})}}),ib.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 :")}})}}),ib.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})}}),ib.addBinaryOp("in",7),ib.addBinaryOp("??",1);let iV=Symbol("optional chain short-circuited");function iU(e,t){switch(e.type){case"MemberExpression":return iF(e,t);case"CallExpression":return iL(e,t);default:return ij(e,t)}}function iW(e){return e===iV?void 0:e}function iH(e){return function(t){return null===t?null:ij(t,e)}}function iz(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let iK=new Set(["toString","valueOf","hasOwnProperty"]);function iG(e,t){try{return iA(e,t)}catch{return"<computed>"}}function iZ(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function iY(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:{...ix},boundNames:new Set,variables:new Set};return iq("string"==typeof e?ib(e):e,t),[...t.variables]}function iq(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void iq(r.argument,n);case"BinaryExpression":return a=e,o=t,void(iq(a.left,o),iq(a.right,o));case"ConditionalExpression":return i=e,s=t,void(iq(i.consequent,s),iq(i.test,s),iq(i.alternate,s));case"CallExpression":return l=e,u=t,void(iq(l.callee,u),l.arguments?.map(iJ(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b,w,E,D=e,x=t;let _=new Set(x.boundNames);for(let e of D.params??[])e?.type==="Identifier"&&_.add(e.name);iq(D.body,{...x,boundNames:_});return;case"MemberExpression":return c=e,d=t,void(iq(c.object,d),c.computed&&iq(c.property,d));case"ArrayExpression":return m=e,p=t,void m.elements?.map(iJ(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(iJ(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(iJ(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(iJ(E)),w.quasis?.map(iJ(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function iJ(e){return function(t){return null===t?null:iq(t,e)}}let iX=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 iQ(e,t,r){iX.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function i0(){let e=iX.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 i1(e){return iX.getState().flags[e].enabled}function i4(e,t){iX.subscribe(r=>{t(r.flags[e].enabled)})}function i2(e,t){iX.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}iX.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 i3=tG(function(e,t,r){tF(e,t,r)});let i6=B("extensionsInternal",{slots:{},extensions:{}}),i5=B("extensionRenderings",{renderings:new Map}),i9=()=>W("extensionsInternal",{slots:{},extensions:{}}),i8=()=>W("extensionRenderings",{renderings:new Map});function i7(e){let t=i6.getState(),r=e(t);r!==t&&i6.setState(r)}let se=null,st=null;function sr(){let e=i5.getState();return se&&e===st||(se=new Map(e.renderings),st=e,function(e){for(let t of(sm.clear(),e.values()))sf(t,1);sp=!0}(se)),se}function sn(e){st={renderings:e},i5.setState(st,!0)}function sa(e){let t=sr();t.has(e.renderingId)||(t.set(e.renderingId,e),sf(e,1),sn(t))}function so(e){let t=sr(),r=t.get(e);r&&(t.delete(e),sf(r,-1),sn(t))}let si=()=>W("extensions",{slots:{}}),ss=0,sl=new Set;function su(e){ss++;try{return e()}finally{if(0==--ss&&sl.size>0){let e=Array.from(sl);for(let t of(sl.clear(),e))sc(t)}}}function sc(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function sd(e){ss>0?sl.add(e):sc(e)}let sm=new Map,sp=!1;function sf(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=sm.get(r);if(!n){if(t<0)return;sm.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),sp=!0;return}n.count+=t,n.count<1&&(sm.delete(r),sp=!0)}function sh(){var e,t;if(sr(),!sp)return;sp=!1;let r=Array.from(sm.values(),({record:e})=>e);r.sort(sg),e=nE.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===sg(e,t[r]))||nE.setState({mountedExtensions:r})}function sg(e,t){return sy(e.slotName,t.slotName)||sy(e.extensionId,t.extensionId)||sy(e.slotModuleName,t.slotModuleName)||sy(e.extensionModuleName,t.extensionModuleName)}function sy(e,t){return e===t?0:e<t?-1:1}sh(),i5.subscribe(()=>sd(sh));let sv=i9(),sb=si(),sw=nx(),sE=nC(),sD=new Set,sx=!1;function s_(e){if(null===e)sD=null;else if(null!==sD)for(let t of e)sD.add(t);sd(sS)}function sS(){if(!sx){sx=!0;try{for(let e=1;;e++){let t=sD;if(null!==t&&0===t.size)return;sD=new Set;try{!function(e,t,r,n,a,o=null){let i=sb.getState().slots,s={},l=!1,u=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,c]of Object.entries(e.slots)){let d=i[n];if(d&&o&&!o.has(n)){s[n]=d;continue}let{config:m}=nS(t,c.name),p=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=sv.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=sM(a),u=sM(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[sP(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}=nk(n,e,l),u=nP(r,e,l),c=u?i3({},i,u):i,d=sP(l),m=t.extensions[d];if(m){let e=c?.["Display conditions"]?.privileges??m.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!a5(e,o.user))||m.featureFlag&&!a.includes(m.featureFlag))continue;s.push({id:l,name:d,moduleName:m.moduleName,config:c,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:c?.["Display conditions"]?.expression||m.displayExpression})}}return s}(n,e,m,r,u,a.session);d&&d.moduleName===c.moduleName&&rP(d.candidateExtensions,p)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&sb.setState({slots:s})}(sv.getState(),sw.getState(),sE.getState(),iX.getState(),aJ.getState(),t)}catch(e){throw sD=null===t||null===sD?null:new Set([...t,...sD]),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{sx=!1}}}function sC(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 sk(e,t){return{moduleName:t,name:e,attachedIds:[]}}function sP(e){let[t]=e.split("#");return t}function sR(e,t){let r=sP(t);return e.extensions[r]}function sT(e){return sR(sv.getState(),e)}sv.subscribe((e,t)=>{s_(e.extensions!==t.extensions?null:sC(e.slots,t.slots))}),sw.subscribe((e,t)=>{s_(sC(e.slots,t.slots))}),sE.subscribe((e,t)=>{s_(sC(e.configs,t.configs))}),iX.subscribe(()=>s_(null)),aJ.subscribe(()=>s_(null)),s_(null);let sO=e=>i7(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function s$(e,t){i7(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...sk(e),attachedIds:[t]}}}})}function sN(e,t){i7(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 sI(e){i7(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function sM(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function sj(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!!iC(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(sA(e),t,aJ.getState().session,e)}function sA(e){return sb.getState().slots[e]?.candidateExtensions??[]}let sL=(e,t)=>sv.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=sk(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),sF=()=>{sD=null,i7(()=>({slots:{},extensions:{}})),i8().setState({renderings:new Map}),sb.setState({slots:{}})},sB=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function sV({name:e,basePath:t,mode:r,componentContext:n,state:a}){sB.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function sU(e){sB.getState().slotName===e&&sB.setState(sB.getInitialState(),!0)}let sW=B("modalRegistry",{modals:{}});function sH(e){sW.setState(t=>(t.modals[e.name]=e,t))}function sz(e){let t=sW.getState().modals[e];if(!t){let r=sT(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.`),sH(t))}return t}let sK=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function sG(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=sK.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 sZ(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=sK.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 sY(e){let{openedWindows:t}=sK.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function sq(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=sK.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}}sK.setState({registeredGroupsByName:n})}function sJ(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=sK.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}sK.setState({registeredWindowsByName:n})}function sX(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=sK.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}sK.setState({registeredWorkspacesByName:n})}let sQ=0,s0=null,s1={bootstrap:15e3,mount:15e3,unmount:15e3};function s4(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(s1).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=s1[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 s2(e,t){var r,n;let a,o,i,s,l,u=await (s0??(s0=new Promise((e,t)=>{(0,ak.mountRootParcel)({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),ak.mountRootParcel))),s0),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=>s4(e,r)):s4(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 s3(){return s6}function s6(e,t){let r,n=s2(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 s5(e,t,r,n,a=e=>e,o={}){let i=sP(n),s=sT(n),l=null;if(e){let u;if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:d,load:m}=s,p=sQ++,f=`${t}/${n}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{so(f)}catch(t){console.error(e,t)}};try{sa({renderingId:f,extensionName:i,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{u=await m()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await s2(a({...u,name:`${t}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var s9=r(4587),s8=r.n(s9);let s7=(0,s9.createContext)({moduleName:"",featureName:""});function le({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,s9.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}`)},[]),s8().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),aM({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:aN(e,t),...a},n)}let lt=({state:e,children:t,...r})=>{let{extension:n}=(0,s9.useContext)(s7),a=(0,s9.useRef)(null),o=(0,s9.useRef)(Promise.resolve()),i=(0,s9.useRef)(!1),s=(0,s9.useRef)(!1),l=(0,s9.useRef)(e),u=(0,s9.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,s9.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,s9.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,s5(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,s9.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,s9.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?s8().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function lr(e){let t=(0,s9.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function ln(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 la=e=>e;function lo(e,t=la,r){let n=(0,s9.useCallback)(t=>e.subscribe(t),[e]),a=(0,s9.useCallback)(()=>t(e.getState()),[e,t]),o=(0,s9.useSyncExternalStore)(n,a,a),i=(0,s9.useMemo)(()=>r?ln(e,r):null,[e,r]);return(0,s9.useMemo)(()=>i?{...o,...i}:o,[o,i])}function li(e,t){return lo(e,la,t)}function ls(e){return function(t){let r=(0,s9.useCallback)(t=>e.subscribe(t),[]),n=(0,s9.useCallback)(()=>e.getState(),[]),a=(0,s9.useSyncExternalStore)(r,n,n),o=(0,s9.useMemo)(()=>t?ln(e,t):null,[t]);return(0,s9.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let ll=[];Object.freeze(ll);let lu={candidateExtensions:ll};Object.freeze(lu);let lc=e=>{let t=(0,s9.useCallback)(t=>t.slots?.[e]??lu,[e]);return lo(si(),t)},ld=e=>e.session;function lm(e,t){let{candidateExtensions:r}=lc(e),n=lo(aJ,ld),a=lr(t);return(0,s9.useMemo)(()=>sj(e,a),[e,a,n,r])}function lp(e,t){let{moduleName:r}=(0,s9.useContext)(s7);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,s9.useEffect)(()=>{sL(r,e)},[r,e]),{extensions:lm(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function lf(e){return e}function lh({name:e,extensionSlotName:t,select:r=lf,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,s9.useRef)(null),{extensions:u,extensionSlotModuleName:c}=lp(s,a),d=(0,s9.useMemo)(()=>r(u),[r,u]),m=(0,s9.useMemo)(()=>{if("function"==typeof n&&!s8().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return s8().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i},s&&d?.map((e,t)=>s8().createElement(s7.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof n?n:null)??s8().createElement(lt,{state:a}))))}var lg=r(5338);function ly(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 lv(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ly(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)):ly(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function lb(e){return(lb="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 lw(e){return(lw="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 lE(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(lw(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(lw(e)));return e}}var lD=null;try{lD=require("react").createContext()}catch(e){}var lx={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 l_(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function lS(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=lR(e,t,function(){r(this)}),i=lE(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:lP(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function lC(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():lP(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function lk(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=lR(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=lE(e,t)();lP(e).render(n,o)}})}function lP(e){return e.ReactDOMClient||e.ReactDOM}function lR(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=lD?e.React.createElement(lD.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,lv(lv({},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 lT=r(587),lO=r(2272),l$=r(8444);let lN={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},lI=new Map;(0,l$.y)(lI);let lM={errorRetryCount:3,fetcher:aY,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof aq){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>lI};function lj(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},lN,e),r={...lM,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=s8().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 s8().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=s8().createElement(s9.Suspense,{fallback:null},s8().createElement(lO.S,{value:r},s8().createElement(s7.Provider,{value:this.state.config},t.disableTranslations?s8().createElement(e,this.props):s8().createElement(lT.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},s8().createElement(e,this.props)))));return t.strictMode&&s8().StrictMode?s8().createElement(s8().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function lA(e,t){return function(e){if("object"!==lb(e))throw Error("single-spa-react requires a configuration object");var t,r=lv(lv({},lx),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");!lD&&r.React.createContext&&(lD=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:l_.bind(null,r),mount:lS.bind(null,r),unmount:lC.bind(null,r)};return r.parcelCanUpdate&&(n.update=lk.bind(null,r)),n}({React:s8(),ReactDOMClient:lg,rootComponent:lj(t)(e)})}function lL(e,t){return()=>e().then(({default:e})=>lA(e,t))}function lF(e,t){return()=>Promise.resolve(lA(e,t))}let lB=lL,lV=I()(()=>({}));U("openmrs-app-context",lV);let lU={};function lW(e,t=e=>e){let r=lV.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function lH(e,t){lV.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function lz(e){return null===e?null:Object.freeze(Object.assign({},e))}let lK=new Map;function lG(e,t){let r=(0,s9.useRef)(t??{}),n=(0,s9.useRef)(t=>lH(e,t)),a=(0,s9.useRef)(Symbol());return(0,s9.useEffect)(()=>{let r=t??{},n=a.current;return null===lW(e)?!function(e,t=lU){lV.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===lU?{}: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.`),lH(e,()=>r)),lK.set(e,n),()=>{lK.get(e)===n&&(lV.setState(t=>(e in t&&delete t[e],t)),lK.delete(e))}},[e]),(0,s9.useEffect)(()=>{let n=t??{};T(r.current,n)||(lH(e,()=>n),r.current=n)},[t]),n.current}function lZ({namespace:e,value:t}){return lG(e,t),null}let lY=({children:e,value:t,fallback:r})=>t?s8().createElement(s8().Fragment,null,e):r?s8().createElement(s8().Fragment,null,r):null;function lq(){let e=(0,s9.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,s9.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function lJ(e,t=e=>e??{}){let[r,n]=(0,s9.useState)(()=>{if(lX(e))return;let r=lW(e);if(null!==r)return t?t(r):r});return(0,s9.useEffect)(()=>{if(lX(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,s9.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)})(lz(a=lW(e))),lV.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(lz(n)))})},[e,t]),r}function lX(e){return"string"!=typeof e||0===e.trim().length}function lQ(e){let t=lm(e);return(0,s9.useMemo)(()=>t.map(e=>e.id),[t])}function l0(e){return lc(e).candidateExtensions}function l1(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=(0,lO.u)(e?o5(e,t,r):null,aY);return(0,s9.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function l4(e){(0,s9.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let l2={},l3=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function l6(e,t,r){let n=l2[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 l2[e]=a,a.then(()=>{l2[e]===a&&delete l2[e]}),a}function l5(e){let{moduleName:t,extension:r}=(0,s9.useContext)(s7),n=e?.externalModuleName??t;if(!n&&!r)throw Error(l3);let a=function(e){let t=(0,s9.useMemo)(()=>nD(e),[e]),r=function(e){let[t,r]=(0,s9.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,s9.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw l6(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,s9.useMemo)(nC,[]),r=function(e,t){let[r,n]=(0,s9.useState)(t?()=>{let r=nk(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,s9.useEffect)(()=>{if(t)return e.subscribe(e=>{let a=nk(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 l6(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let r=nk(t,e.extensionSlotName,e.extensionId);return r.loaded?r.config:null});return r||{}}(r);return(0,s9.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...a}:{...a,...o},[n,e?.externalModuleName,a,o])}let l9=lm;function l8(e,t=300){let[r,n]=(0,s9.useState)(e);return(0,s9.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var l7=r(4993);let ue=(0,l7.Ht)(lO.u,e=>(t,r,n)=>(n.revalidateOnFocus=!1,n.revalidateIfStale=!1,n.revalidateOnReconnect=!1,n.refreshInterval=0,e(t,r,n))),ut=`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 ur(){let e=ue(`${az}/emrapi/configuration?v=${ut}`,aY);return(0,s9.useMemo)(()=>({emrConfiguration:e.data?.data,isLoadingEmrConfiguration:e.isLoading,mutateEmrConfiguration:e.mutate,errorFetchingEmrConfiguration:e.error}),[e])}function un(){return(0,s9.useContext)(s7).extension}let ua=ls(i9());function uo(e){let t=lm(e);return(0,s9.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let ui=ls(si());function us(e){let{flags:t}=lo(iX);return t[e]?.enabled??!1}function ul(){let[,e]=(0,s9.useState)(0);return(0,s9.useCallback)(()=>{e(e=>e+1)},[])}function uu(e,t,r={}){return ud(e,t,uc,r)}let uc={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(aZ(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 ud(e,t,r,n={}){let{getPaginatedUrl:a,getTotalCount:o,getCurrentPageSize:i,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??aY,[d,m]=(0,s9.useState)(1),p=(0,s9.useRef)(NaN),f=(0,s9.useRef)(NaN),h=(0,s9.useRef)(d),g=(0,s9.useRef)(!1),y=(0,s9.useRef)(!1),v=e?.toString()??"",[b,w]=(0,s9.useState)(v);v!==b&&(w(v),m(1),h.current=1,p.current=NaN,f.current=NaN,g.current=!1,y.current=!1);let E=(d-1)*t,D=(0,s9.useMemo)(()=>a(e,t,E),[e,t,E]),{data:x,..._}=(l?ue:lO.u)(D,c,u);x?.data&&(p.current=o(x?.data),f.current=i(x?.data),g.current=!0);let S=Math.ceil(p.current/t),C=(0,s9.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(p.current/t);!g.current||Number.isNaN(r)||e<=r?(h.current=e,m(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,s9.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(p.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${v} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(p.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),h.current=e,m(e))},[d,t,v,x]);let k=(0,s9.useCallback)(()=>{C(h.current+1)},[C]),P=(0,s9.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(x?.data),totalPages:S,totalCount:p.current,currentPage:d,currentPageSize:f.current,paginated:S>1,showNextButton:d<S,showPreviousButton:d>1,goTo:C,goToNext:k,goToPrevious:P,..._}}function um(e,t,r={}){return ud(e,t,up(),r)}function up(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(aZ(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 uf=r(9888);let uh=Promise.resolve(),ug=(0,l7.Ht)(lO.u,e=>(t,r,n)=>{let a,o=(0,s9.useRef)(!1),{cache:i,initialSize:s=1,revalidateAll:l=!1,persistSize:u=!1,revalidateFirstPage:c=!0,revalidateOnMount:d=!1,parallel:m=!1}=n,[,,,p]=l$.a.get(l$.o);try{(a=(0,l$.s)(t?t(0,null):null)[0])&&(a="$inf$"+a)}catch(e){}let[f,h,g]=(0,l$.c)(i,a),y=(0,s9.useCallback)(()=>(0,l$.i)(f()._l)?s:f()._l,[i,a,s]);(0,uf.useSyncExternalStore)((0,s9.useCallback)(e=>a?g(a,()=>{e()}):()=>{},[i,a]),y,y);let v=(0,s9.useCallback)(()=>{let e=f()._l;return(0,l$.i)(e)?s:e},[a,s]),b=(0,s9.useRef)(v());(0,l$.u)(()=>{if(!o.current){o.current=!0;return}a&&h({_l:u?b.current:v()})},[a,i]);let w=d&&!o.current,E=e(a,async e=>{let a=f()._i,o=f()._r,s=l$.a.get(i),u=s[8],d=()=>s[8]!==u;h({_r:l$.U});let g=[],y=v(),[b]=(0,l$.c)(i,e),E=b().data,D=[],x=null;for(let e=0;e<y;++e){let[s,u]=(0,l$.s)(t(e,m?null:x));if(!s)break;let[f,h]=(0,l$.c)(i,s),y=f().data,v=l||a||(0,l$.i)(y)||c&&!e&&!(0,l$.i)(E)||w||E&&!(0,l$.i)(E[e])&&!n.compare(E[e],y);if(r&&("function"==typeof o?o(y,u):v)){let t=async()=>{if(s in p){let e=p[s];delete p[s],y=await e}else y=await r(u);d()||h({data:y,_k:u}),g[e]=y};m?D.push(t):await t()}else g[e]=y;m||(x=y)}return m&&await Promise.all(D.map(e=>e())),d()||h({_i:l$.U}),g},n),D=(0,s9.useCallback)(function(e,t){let r="boolean"==typeof t?{revalidate:t}:t||{},n=!1!==r.revalidate;return a?(n&&((0,l$.i)(e)?h({_i:!0,_r:r.revalidate}):h({_i:!1,_r:r.revalidate})),arguments.length?E.mutate(e,{...r,revalidate:n}):E.mutate()):uh},[a,i]),x=(0,s9.useCallback)(e=>{let r;if(!a)return uh;let[,n]=(0,l$.c)(i,a);if((0,l$.e)(e)?r=e(v()):"number"==typeof e&&(r=e),"number"!=typeof r)return uh;n({_l:r}),b.current=r;let o=[],[s]=(0,l$.c)(i,a),l=null;for(let e=0;e<r;++e){let[r]=(0,l$.s)(t(e,l)),[n]=(0,l$.c)(i,r),a=r?n().data:l$.U;if((0,l$.i)(a))return D(s().data);o.push(a),l=a}return D(o)},[a,i,D,v]);return{size:v(),setSize:x,mutate:D,get data(){return E.data},get error(){return E.error},get isValidating(){return E.isValidating},get isLoading(){return E.isLoading}}});function uy(e,t={}){return uv(e,uc,t)}function uv(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??aY,{data:u,size:c,setSize:d,...m}=ug((0,s9.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),l,{...n,...a?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),p=o(u?.[u.length-1].data),f=i(u?.[0]?.data);return{data:u?.flatMap(e=>s(e.data)),totalCount:f,hasMore:null!=p,loadMore:()=>{d((u?.length??0)+1)},nextUri:p,...m}}function ub(e,t={}){return uw(e,uc,t)}function uw(e,t,r={}){let n=uv(e,t,r),{hasMore:a,error:o,data:i,loadMore:s,isLoading:l,nextUri:u}=n;return((0,s9.useEffect)(()=>{a&&!o&&s()},[a,u]),r.partialData)?n:{...n,data:a||o?void 0:i,isLoading:l||a}}function uE(e,t={}){return uw(e,up(),t)}function uD(e,t={}){return uv(e,up(),t)}function ux(){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 u_(){let[e,t]=(0,s9.useState)(ux);return(0,s9.useEffect)(()=>{let e=()=>{t(ux())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let uS=e=>"small-desktop"===e||"large-desktop"===e;function uC(e){let t=(0,s9.useContext)(s7);(0,s9.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),sV(e),()=>{sU(e.name)}),[t,e])}function uk(){return lo(sB)}let uP=[];function uR(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=ub(`${az}/location${n?"?"+n:""}`,{immutable:!0});return a??uP}function uT(e,t=!0){let r=(0,s9.useRef)(null);return(0,s9.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 uO(e){let t=(0,s9.useRef)();return(0,s9.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 u$(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=lq(),s=(0,s9.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,s9.useCallback)(e=>aY(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(0,lO.u)(e,l,o)}function uN(e=[],t=10){let[r,n]=(0,s9.useState)(1),a=(0,s9.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,s9.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,s9.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,s9.useCallback)(()=>{n(e=>e+1)},[]),u=(0,s9.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,s9.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 uI(e,t,r,n){return{pageSizes:(0,s9.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,s9.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function uM(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function uj(e){let[t,r]=(0,s9.useState)(e??uM()),{data:n,error:a,isValidating:o}=(0,lO.u)(t?["patient",t]:null,()=>o7(t,{}));return(0,s9.useEffect)(()=>{let e=()=>{let e=uM();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,s9.useMemo)(()=>({isLoading:o&&!a&&!n,patient:n,patientUuid:t,error:a}),[o,a,n,t])}function uA(){let e=`${az}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=(0,lO.u)(e,aY);return(0,s9.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function uL(e){let{extensions:t,extensionSlotModuleName:r}=lp(e);return e?t.map(t=>({state:n})=>s8().createElement(s7.Provider,{value:{moduleName:r,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:r,extensionMeta:t.meta}}},s8().createElement(lt,{state:n}))):[]}function uF(){let e=(0,s9.useRef)(),[t,r]=(0,s9.useState)(null),n=null;if(!t){if(o){let e=a4().getState();e.loaded&&(n=e.session)}else o=new Promise(t=>{let r=({loaded:r,session:a})=>{r&&(t(a),n=a,e.current&&(e.current(),e.current=void 0))};r(a4().getState()),n||(e.current=a4().subscribe(r))});if(n)r(n);else throw o}(0,s9.useEffect)(()=>(e.current||(e.current=a4().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let a=t||n;if(!a)if(o)throw console.warn("useSession is in an unexpected state. Attempting to recover."),o;else throw Error("useSession is in an invalid state.");return a}let uB=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,s9.useState)(null);return((0,s9.useEffect)(()=>{let e=a4(),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&&a5(e,n))?s8().createElement(s8().Fragment,null,r):t?s8().createElement(s8().Fragment,null,t):null};var uV=r(4353),uU=r.n(uV),uW=r(7581);let uH=new Map;function uz(){for(let e of Array.from(uH.values()))e()}let uK={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function uG(e){let t=(0,s9.useId)();return(0,s9.useEffect)(()=>{if(e)return uH.set(t,e),()=>{uH.delete(t)}},[t,e]),{...li(im(),uK),mutateVisit:uz}}function uZ(e,t=ic){let r=(0,s9.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=uG((0,s9.useCallback)(()=>r.current?.(),[])),i=e&&n==e?a:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${i}?v=${t}`,{data:u,error:c,mutate:d,isValidating:m}=(0,lO.u)(e?`${az}/visit${s}`:null,aY),{data:p,error:f,mutate:h,isValidating:g}=(0,lO.u)(e&&i?`${az}/visit${l}`:null,aY),y=(0,s9.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,s9.useMemo)(()=>i&&p?p.data:null,[p,i]),b=(0,s9.useRef)(null);(0,s9.useEffect)(()=>{!m&&y&&n===e&&null===a&&o(y),g||(b.current&&v&&b.current.uuid===v.uuid&&!b.current.stopDatetime&&v.stopDatetime&&o(null),b.current=v)},[v,a,y,m,g,n]);let w=(0,s9.useCallback)(()=>{d(),h()},[d,h]);(0,s9.useEffect)(()=>{r.current=w},[w]);let E=!!(!u||i&&!p),D=!!(i?f:c);return{error:c||f,mutate:w,isValidating:m||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:E&&!D}}uV.extend(uW);let uY=[];function uq(){let{data:e}=ue(ii,is);return e??uY}let uJ=new Map;async function uX(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 oN(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?u0(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`),uQ)}let uQ={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function u0(e,t){if(e in uJ)await uJ[e];else{let r=t??await oN(e);await (uJ[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let a=r.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{nJ(e),t(null)}).catch(n)}nJ(e),t(null)}))}}function u1(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
|