@openmrs/esm-implementer-tools-app 11.0.1-pre.5993 → 11.0.1-pre.6006

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.
@@ -5,4 +5,4 @@
5
5
  │ 4698.js (414.009 KiB)
6
6
  
7
7
 
8
- Rspack compiled with 1 warning in 23.66 s
8
+ Rspack compiled with 1 warning in 21.71 s
@@ -1,3 +1,3 @@
1
- var _openmrs_esm_implementer_tools_app;!function(){var e="u">typeof globalThis?globalThis:self;if(void 0===e._FEDERATION_RUNTIME_CORE||void 0===e._OPENMRS_FEDERATION_SDK||void 0===e._OPENMRS_FEDERATION_ERROR_CODES)throw Error("@openmrs/esm-implementer-tools-app cannot start: the OpenMRS app shell serving this page does not provide the Module Federation runtime. This app was built with newer OpenMRS tooling than the app shell, so either upgrade @openmrs/esm-app-shell, or rebuild this app with tooling matching the app shell.");var t=e._FEDERATION_RUNTIME_CORE_FROM;t&&t.version&&"2.8"!==String(t.version).split(".").slice(0,2).join(".")&&console.warn("@openmrs/esm-implementer-tools-app was built against Module Federation 2.8.x but the app shell provides "+t.version+". Shared dependencies may not de-duplicate correctly.")}(),(()=>{var e,t,r,n,o,i={3242(e,t,r){"use strict";var n,o,i,a,s,l,u,p,c,d,f,h,m=r(8516),g=r.n(m);let b=[].filter(({plugin:e})=>e).map(({plugin:e,params:t})=>e(t)),y={};if((r.initializeSharingData||r.initializeExposesData)&&r.federation){let e=(e,t,r)=>{e&&e[t]&&(e[t]=r)},t=(e,t,r)=>{let n=r();Array.isArray(n)?(null!=e[t]||(e[t]=[]),e[t].push(...n)):"object"==typeof n&&null!==n&&(null!=e[t]||(e[t]={}),Object.assign(e[t],n))},m=(e,t,r)=>{null!=e[t]||(e[t]=r())},S=null!=(n=null==(l=r.remotesLoadingData)?void 0:l.chunkMapping)?n:{},_=null!=(o=null==(u=r.remotesLoadingData)?void 0:u.moduleIdToRemoteDataMapping)?o:{},E=null!=(i=null==(p=r.initializeSharingData)?void 0:p.scopeToSharingDataMapping)?i:{},O=null!=(a=null==(c=r.consumesLoadingData)?void 0:c.chunkMapping)?a:{},M=null!=(s=null==(d=r.consumesLoadingData)?void 0:d.moduleIdToConsumeDataMapping)?s:{},v={},R=[],w={},T=null==(f=r.initializeExposesData)?void 0:f.shareScope;for(let e in g())r.federation[e]=g()[e];m(r.federation,"consumesLoadingModuleToHandlerMapping",()=>{let e={};for(let[t,r]of Object.entries(M))e[t]={getter:r.fallback,shareInfo:{shareConfig:{fixedDependencies:!1,requiredVersion:r.requiredVersion,strictVersion:r.strictVersion,singleton:r.singleton,eager:r.eager},scope:[r.shareScope]},shareKey:r.shareKey};return e}),m(r.federation,"initOptions",()=>({})),m(r.federation.initOptions,"name",()=>"@openmrs/esm-implementer-tools-app"),m(r.federation.initOptions,"shareStrategy",()=>"version-first"),m(r.federation.initOptions,"shared",()=>{let e={};for(let[t,r]of Object.entries(E))for(let n of r)if("object"==typeof n&&null!==n){let{name:r,version:o,factory:i,eager:a,singleton:s,requiredVersion:l,strictVersion:u}=n,p={},c=function(e){return void 0!==e};c(s)&&(p.singleton=s),c(l)&&(p.requiredVersion=l),c(a)&&(p.eager=a),c(u)&&(p.strictVersion=u);let d={version:o,scope:[t],shareConfig:p,get:i};e[r]?e[r].push(d):e[r]=[d]}return e}),t(r.federation.initOptions,"remotes",()=>Object.values(y).flat().filter(e=>"script"===e.externalType)),t(r.federation.initOptions,"plugins",()=>b),m(r.federation,"bundlerRuntimeOptions",()=>({})),m(r.federation.bundlerRuntimeOptions,"remotes",()=>({})),m(r.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>S),m(r.federation.bundlerRuntimeOptions.remotes,"remoteInfos",()=>y),m(r.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{let e={};for(let[t,r]of Object.entries(_))e[t]=[r.shareScope,r.name,r.externalModuleId,r.remoteName];return e}),m(r.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>r),t(r.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{let e={};for(let[t,r]of Object.entries(_)){let n=y[r.remoteName];n&&(e[t]=n)}return e}),e(r,"S",r.federation.bundlerRuntime.S),r.federation.attachShareScopeMap&&r.federation.attachShareScopeMap(r),e(r.f,"remotes",(e,t)=>r.federation.bundlerRuntime.remotes({chunkId:e,promises:t,chunkMapping:S,idToExternalAndNameMapping:r.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:r.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:r})),e(r.f,"consumes",(e,t)=>r.federation.bundlerRuntime.consumes({chunkId:e,promises:t,chunkMapping:O,moduleToHandlerMapping:r.federation.consumesLoadingModuleToHandlerMapping,installedModules:v,webpackRequire:r})),e(r,"I",(e,t)=>r.federation.bundlerRuntime.I({shareScopeName:e,initScope:t,initPromises:R,initTokens:w,webpackRequire:r})),e(r,"initContainer",(e,t,n)=>r.federation.bundlerRuntime.initContainerEntry({shareScope:e,initScope:t,remoteEntryInitOptions:n,shareScopeKey:T,webpackRequire:r})),e(r,"getContainer",(e,t)=>{var n=r.initializeExposesData.moduleMap;return r.R=t,t=Object.prototype.hasOwnProperty.call(n,e)?n[e]():Promise.resolve().then(()=>{throw Error('Module "'+e+'" does not exist in container.')}),r.R=void 0,t}),r.federation.instance=r.federation.runtime.init(r.federation.initOptions),(null==(h=r.consumesLoadingData)?void 0:h.initialConsumes)&&r.federation.bundlerRuntime.installInitialConsumes({webpackRequire:r,installedModules:v,initialConsumes:r.consumesLoadingData.initialConsumes,moduleToHandlerMapping:r.federation.consumesLoadingModuleToHandlerMapping})}},7240(e,t,r){"use strict";r.d(t,{get:()=>r.getContainer,init:()=>r.initContainer})},3054(e){"use strict";e.exports=globalThis._FEDERATION_RUNTIME_CORE},9170(e){"use strict";e.exports=globalThis._OPENMRS_FEDERATION_ERROR_CODES},1853(e){"use strict";e.exports=globalThis._OPENMRS_FEDERATION_SDK},7416(e,t){var r=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;t.__toESM=(e,t,l)=>(l=null!=e?r(a(e)):{},((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var a,l=i(t),u=0,p=l.length;u<p;u++)a=l[u],s.call(e,a)||void 0===a||n(e,a,{get:(e=>t[e]).bind(null,a),enumerable:!(r=o(t,a))||r.enumerable});return e})(!t&&e&&e.__esModule?l:n(l,"default",{value:e,enumerable:!0}),e))},5734(e,t,r){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),r(7416);let n=r(1001),o=r(3054),i=r(9170);function a(e){let t=new((0,o.getGlobalFederationConstructor)()||o.ModuleFederation)({id:`${e.name}@${e.version||Date.now()}`,...e});return(0,o.setGlobalFederationInstance)(t),t}let s=null;(0,o.setGlobalFederationConstructor)(o.ModuleFederation),Object.defineProperty(t,"Module",{enumerable:!0,get:function(){return o.Module}}),t.ModuleFederation=o.ModuleFederation,t.createInstance=a,t.getInstance=function(e){return e?o.CurrentGlobal.__FEDERATION__.__INSTANCES__.find(e)||null:s},Object.defineProperty(t,"getRemoteEntry",{enumerable:!0,get:function(){return o.getRemoteEntry}}),Object.defineProperty(t,"getRemoteInfo",{enumerable:!0,get:function(){return o.getRemoteInfo}}),t.init=function(e){let t=n.getGlobalFederationInstance(e.name,e.version),r={...e,id:e.id||""};return t?(t.initOptions(r),s||(s=t),t):s=a(r)},t.loadRemote=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.loadRemote.apply(s,e)},Object.defineProperty(t,"loadScript",{enumerable:!0,get:function(){return o.loadScript}}),Object.defineProperty(t,"loadScriptNode",{enumerable:!0,get:function(){return o.loadScriptNode}}),t.loadShare=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.loadShare.apply(s,e)},t.loadShareSync=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.loadShareSync.apply(s,e)},t.preloadRemote=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.preloadRemote.apply(s,e)},Object.defineProperty(t,"registerGlobalPlugins",{enumerable:!0,get:function(){return o.registerGlobalPlugins}}),t.registerPlugins=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.registerPlugins.apply(s,e)},t.registerRemotes=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.registerRemotes.apply(s,e)},t.registerShared=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.registerShared.apply(s,e)}},1001(e,t,r){r(7416);let n=r(3054);t.getGlobalFederationInstance=function(e,t){let r="@openmrs/esm-implementer-tools-app:11.0.1-pre.5993";return n.CurrentGlobal.__FEDERATION__.__INSTANCES__.find(n=>!!r&&n.options.id===r||n.options.name===e&&!n.options.version&&!t||n.options.name===e&&!!t&&n.options.version===t)}},3162(e,t){var r=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;t.__toESM=(e,t,l)=>(l=null!=e?r(a(e)):{},((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var a,l=i(t),u=0,p=l.length;u<p;u++)a=l[u],s.call(e,a)||void 0===a||n(e,a,{get:(e=>t[e]).bind(null,a),enumerable:!(r=o(t,a))||r.enumerable});return e})(!t&&e&&e.__esModule?l:n(l,"default",{value:e,enumerable:!0}),e))},8262(e,t){t.attachShareScopeMap=function(e){e.S&&!e.federation.hasAttachShareScopeMap&&e.federation.instance&&e.federation.instance.shareScopeMap&&(e.S=e.federation.instance.shareScopeMap,e.federation.hasAttachShareScopeMap=!0)}},1148(e,t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t.FEDERATION_SUPPORTED_TYPES=["script"]},1229(e,t,r){let n=r(8262),o=r(1163),i=r(4476),a=r(1532),s=r(3602);t.consumes=function(e){o.updateConsumeOptions(e);let{chunkId:t,promises:r,installedModules:l,webpackRequire:u,chunkMapping:p,moduleToHandlerMapping:c}=e;n.attachShareScopeMap(u),u.o(p,t)&&p[t].forEach(e=>{if(u.o(l,e))return r.push(l[e]);let t=t=>{l[e]=0,u.m[e]=r=>{delete u.c[e];let n=t(),{shareInfo:o}=c[e];if(o?.shareConfig?.layer&&n&&"object"==typeof n)try{n.hasOwnProperty("layer")&&void 0!==n.layer||(n.layer=o.shareConfig.layer)}catch(e){}r.exports=n}},n=t=>{delete l[e],u.m[e]=r=>{throw delete u.c[e],t}};try{let o=u.federation.instance;if(!o)throw Error("Federation instance not found!");let{shareKey:p,getter:d,shareInfo:f,treeShakingGetter:h}=c[e],m=i.getUsedExports(u,p),g={...f};Array.isArray(g.scope)&&Array.isArray(g.scope[0])&&(g.scope=g.scope[0]),m&&(g.treeShaking={usedExports:m,useIn:[o.options.name]});let b=o.loadShare(p,{customShareInfo:g}).then(e=>{if(!1===e){if("function"!=typeof d)throw Error(s.getShortErrorMsg(a.RUNTIME_012,{[a.RUNTIME_012]:'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.'},{shareKey:p}));return h?.()||d()}return e});b.then?r.push(l[e]=b.then(t).catch(n)):t(b)}catch(e){n(e)}})}},1532(e,t){t.RUNTIME_012="RUNTIME-012"},3602(e,t){t.getShortErrorMsg=(e,t,r,n)=>{let o=[`${[t[e]]} #${e}`];return r&&o.push(`args: ${JSON.stringify(r)}`),o.push(`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${e.split("-")[0].toLowerCase()}#${e.toLowerCase()}`),n&&o.push(`Original Error Message:
1
+ var _openmrs_esm_implementer_tools_app;!function(){var e="u">typeof globalThis?globalThis:self;if(void 0===e._FEDERATION_RUNTIME_CORE||void 0===e._OPENMRS_FEDERATION_SDK||void 0===e._OPENMRS_FEDERATION_ERROR_CODES)throw Error("@openmrs/esm-implementer-tools-app cannot start: the OpenMRS app shell serving this page does not provide the Module Federation runtime. This app was built with newer OpenMRS tooling than the app shell, so either upgrade @openmrs/esm-app-shell, or rebuild this app with tooling matching the app shell.");var t=e._FEDERATION_RUNTIME_CORE_FROM;t&&t.version&&"2.8"!==String(t.version).split(".").slice(0,2).join(".")&&console.warn("@openmrs/esm-implementer-tools-app was built against Module Federation 2.8.x but the app shell provides "+t.version+". Shared dependencies may not de-duplicate correctly.")}(),(()=>{var e,t,r,n,o,i={3242(e,t,r){"use strict";var n,o,i,a,s,l,u,p,c,d,f,h,m=r(8516),g=r.n(m);let b=[].filter(({plugin:e})=>e).map(({plugin:e,params:t})=>e(t)),y={};if((r.initializeSharingData||r.initializeExposesData)&&r.federation){let e=(e,t,r)=>{e&&e[t]&&(e[t]=r)},t=(e,t,r)=>{let n=r();Array.isArray(n)?(null!=e[t]||(e[t]=[]),e[t].push(...n)):"object"==typeof n&&null!==n&&(null!=e[t]||(e[t]={}),Object.assign(e[t],n))},m=(e,t,r)=>{null!=e[t]||(e[t]=r())},S=null!=(n=null==(l=r.remotesLoadingData)?void 0:l.chunkMapping)?n:{},_=null!=(o=null==(u=r.remotesLoadingData)?void 0:u.moduleIdToRemoteDataMapping)?o:{},E=null!=(i=null==(p=r.initializeSharingData)?void 0:p.scopeToSharingDataMapping)?i:{},O=null!=(a=null==(c=r.consumesLoadingData)?void 0:c.chunkMapping)?a:{},M=null!=(s=null==(d=r.consumesLoadingData)?void 0:d.moduleIdToConsumeDataMapping)?s:{},v={},R=[],w={},T=null==(f=r.initializeExposesData)?void 0:f.shareScope;for(let e in g())r.federation[e]=g()[e];m(r.federation,"consumesLoadingModuleToHandlerMapping",()=>{let e={};for(let[t,r]of Object.entries(M))e[t]={getter:r.fallback,shareInfo:{shareConfig:{fixedDependencies:!1,requiredVersion:r.requiredVersion,strictVersion:r.strictVersion,singleton:r.singleton,eager:r.eager},scope:[r.shareScope]},shareKey:r.shareKey};return e}),m(r.federation,"initOptions",()=>({})),m(r.federation.initOptions,"name",()=>"@openmrs/esm-implementer-tools-app"),m(r.federation.initOptions,"shareStrategy",()=>"version-first"),m(r.federation.initOptions,"shared",()=>{let e={};for(let[t,r]of Object.entries(E))for(let n of r)if("object"==typeof n&&null!==n){let{name:r,version:o,factory:i,eager:a,singleton:s,requiredVersion:l,strictVersion:u}=n,p={},c=function(e){return void 0!==e};c(s)&&(p.singleton=s),c(l)&&(p.requiredVersion=l),c(a)&&(p.eager=a),c(u)&&(p.strictVersion=u);let d={version:o,scope:[t],shareConfig:p,get:i};e[r]?e[r].push(d):e[r]=[d]}return e}),t(r.federation.initOptions,"remotes",()=>Object.values(y).flat().filter(e=>"script"===e.externalType)),t(r.federation.initOptions,"plugins",()=>b),m(r.federation,"bundlerRuntimeOptions",()=>({})),m(r.federation.bundlerRuntimeOptions,"remotes",()=>({})),m(r.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>S),m(r.federation.bundlerRuntimeOptions.remotes,"remoteInfos",()=>y),m(r.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{let e={};for(let[t,r]of Object.entries(_))e[t]=[r.shareScope,r.name,r.externalModuleId,r.remoteName];return e}),m(r.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>r),t(r.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{let e={};for(let[t,r]of Object.entries(_)){let n=y[r.remoteName];n&&(e[t]=n)}return e}),e(r,"S",r.federation.bundlerRuntime.S),r.federation.attachShareScopeMap&&r.federation.attachShareScopeMap(r),e(r.f,"remotes",(e,t)=>r.federation.bundlerRuntime.remotes({chunkId:e,promises:t,chunkMapping:S,idToExternalAndNameMapping:r.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:r.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:r})),e(r.f,"consumes",(e,t)=>r.federation.bundlerRuntime.consumes({chunkId:e,promises:t,chunkMapping:O,moduleToHandlerMapping:r.federation.consumesLoadingModuleToHandlerMapping,installedModules:v,webpackRequire:r})),e(r,"I",(e,t)=>r.federation.bundlerRuntime.I({shareScopeName:e,initScope:t,initPromises:R,initTokens:w,webpackRequire:r})),e(r,"initContainer",(e,t,n)=>r.federation.bundlerRuntime.initContainerEntry({shareScope:e,initScope:t,remoteEntryInitOptions:n,shareScopeKey:T,webpackRequire:r})),e(r,"getContainer",(e,t)=>{var n=r.initializeExposesData.moduleMap;return r.R=t,t=Object.prototype.hasOwnProperty.call(n,e)?n[e]():Promise.resolve().then(()=>{throw Error('Module "'+e+'" does not exist in container.')}),r.R=void 0,t}),r.federation.instance=r.federation.runtime.init(r.federation.initOptions),(null==(h=r.consumesLoadingData)?void 0:h.initialConsumes)&&r.federation.bundlerRuntime.installInitialConsumes({webpackRequire:r,installedModules:v,initialConsumes:r.consumesLoadingData.initialConsumes,moduleToHandlerMapping:r.federation.consumesLoadingModuleToHandlerMapping})}},7240(e,t,r){"use strict";r.d(t,{get:()=>r.getContainer,init:()=>r.initContainer})},3054(e){"use strict";e.exports=globalThis._FEDERATION_RUNTIME_CORE},9170(e){"use strict";e.exports=globalThis._OPENMRS_FEDERATION_ERROR_CODES},1853(e){"use strict";e.exports=globalThis._OPENMRS_FEDERATION_SDK},7416(e,t){var r=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;t.__toESM=(e,t,l)=>(l=null!=e?r(a(e)):{},((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var a,l=i(t),u=0,p=l.length;u<p;u++)a=l[u],s.call(e,a)||void 0===a||n(e,a,{get:(e=>t[e]).bind(null,a),enumerable:!(r=o(t,a))||r.enumerable});return e})(!t&&e&&e.__esModule?l:n(l,"default",{value:e,enumerable:!0}),e))},5734(e,t,r){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),r(7416);let n=r(1001),o=r(3054),i=r(9170);function a(e){let t=new((0,o.getGlobalFederationConstructor)()||o.ModuleFederation)({id:`${e.name}@${e.version||Date.now()}`,...e});return(0,o.setGlobalFederationInstance)(t),t}let s=null;(0,o.setGlobalFederationConstructor)(o.ModuleFederation),Object.defineProperty(t,"Module",{enumerable:!0,get:function(){return o.Module}}),t.ModuleFederation=o.ModuleFederation,t.createInstance=a,t.getInstance=function(e){return e?o.CurrentGlobal.__FEDERATION__.__INSTANCES__.find(e)||null:s},Object.defineProperty(t,"getRemoteEntry",{enumerable:!0,get:function(){return o.getRemoteEntry}}),Object.defineProperty(t,"getRemoteInfo",{enumerable:!0,get:function(){return o.getRemoteInfo}}),t.init=function(e){let t=n.getGlobalFederationInstance(e.name,e.version),r={...e,id:e.id||""};return t?(t.initOptions(r),s||(s=t),t):s=a(r)},t.loadRemote=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.loadRemote.apply(s,e)},Object.defineProperty(t,"loadScript",{enumerable:!0,get:function(){return o.loadScript}}),Object.defineProperty(t,"loadScriptNode",{enumerable:!0,get:function(){return o.loadScriptNode}}),t.loadShare=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.loadShare.apply(s,e)},t.loadShareSync=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.loadShareSync.apply(s,e)},t.preloadRemote=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.preloadRemote.apply(s,e)},Object.defineProperty(t,"registerGlobalPlugins",{enumerable:!0,get:function(){return o.registerGlobalPlugins}}),t.registerPlugins=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.registerPlugins.apply(s,e)},t.registerRemotes=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.registerRemotes.apply(s,e)},t.registerShared=function(...e){return(0,o.assert)(s,i.RUNTIME_009,i.runtimeDescMap),s.registerShared.apply(s,e)}},1001(e,t,r){r(7416);let n=r(3054);t.getGlobalFederationInstance=function(e,t){let r="@openmrs/esm-implementer-tools-app:11.0.1-pre.6006";return n.CurrentGlobal.__FEDERATION__.__INSTANCES__.find(n=>!!r&&n.options.id===r||n.options.name===e&&!n.options.version&&!t||n.options.name===e&&!!t&&n.options.version===t)}},3162(e,t){var r=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;t.__toESM=(e,t,l)=>(l=null!=e?r(a(e)):{},((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var a,l=i(t),u=0,p=l.length;u<p;u++)a=l[u],s.call(e,a)||void 0===a||n(e,a,{get:(e=>t[e]).bind(null,a),enumerable:!(r=o(t,a))||r.enumerable});return e})(!t&&e&&e.__esModule?l:n(l,"default",{value:e,enumerable:!0}),e))},8262(e,t){t.attachShareScopeMap=function(e){e.S&&!e.federation.hasAttachShareScopeMap&&e.federation.instance&&e.federation.instance.shareScopeMap&&(e.S=e.federation.instance.shareScopeMap,e.federation.hasAttachShareScopeMap=!0)}},1148(e,t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t.FEDERATION_SUPPORTED_TYPES=["script"]},1229(e,t,r){let n=r(8262),o=r(1163),i=r(4476),a=r(1532),s=r(3602);t.consumes=function(e){o.updateConsumeOptions(e);let{chunkId:t,promises:r,installedModules:l,webpackRequire:u,chunkMapping:p,moduleToHandlerMapping:c}=e;n.attachShareScopeMap(u),u.o(p,t)&&p[t].forEach(e=>{if(u.o(l,e))return r.push(l[e]);let t=t=>{l[e]=0,u.m[e]=r=>{delete u.c[e];let n=t(),{shareInfo:o}=c[e];if(o?.shareConfig?.layer&&n&&"object"==typeof n)try{n.hasOwnProperty("layer")&&void 0!==n.layer||(n.layer=o.shareConfig.layer)}catch(e){}r.exports=n}},n=t=>{delete l[e],u.m[e]=r=>{throw delete u.c[e],t}};try{let o=u.federation.instance;if(!o)throw Error("Federation instance not found!");let{shareKey:p,getter:d,shareInfo:f,treeShakingGetter:h}=c[e],m=i.getUsedExports(u,p),g={...f};Array.isArray(g.scope)&&Array.isArray(g.scope[0])&&(g.scope=g.scope[0]),m&&(g.treeShaking={usedExports:m,useIn:[o.options.name]});let b=o.loadShare(p,{customShareInfo:g}).then(e=>{if(!1===e){if("function"!=typeof d)throw Error(s.getShortErrorMsg(a.RUNTIME_012,{[a.RUNTIME_012]:'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.'},{shareKey:p}));return h?.()||d()}return e});b.then?r.push(l[e]=b.then(t).catch(n)):t(b)}catch(e){n(e)}})}},1532(e,t){t.RUNTIME_012="RUNTIME-012"},3602(e,t){t.getShortErrorMsg=(e,t,r,n)=>{let o=[`${[t[e]]} #${e}`];return r&&o.push(`args: ${JSON.stringify(r)}`),o.push(`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${e.split("-")[0].toLowerCase()}#${e.toLowerCase()}`),n&&o.push(`Original Error Message:
2
2
  ${n}`),o.join("\n")}},252(e,t){t.getSharedFallbackGetter=({shareKey:e,factory:t,version:r,webpackRequire:n,libraryType:o="global"})=>{let{runtime:i,instance:a,bundlerRuntime:s,sharedFallback:l}=n.federation;if(!l)return t;let u=l[e];if(!u)return t;let p=r?u.find(e=>e[1]===r):u[0];if(!p)throw Error(`No fallback item found for shareKey: ${e} and version: ${r}`);return()=>i.getRemoteEntry({origin:n.federation.instance,remoteInfo:{name:p[2],entry:`${n.p}${p[0]}`,type:o,entryGlobalName:p[2],shareScope:"default"}}).then(t=>{if(!t)throw Error(`Failed to load fallback entry for shareKey: ${e} and version: ${r}`);return t.init(n.federation.instance,s).then(()=>t.get())})}},4476(e,t){t.getUsedExports=function(e,t){let r=e.federation.usedExports;if(r)return r[t]}},8516(e,t,r){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let n=r(3162),o=r(8262),i=r(7245),a=r(1229),s=r(7706),l=r(9982),u=r(6605),p=r(6582),c=r(252),d=r(5734);d=n.__toESM(d);let f={remotes:i.remotes,consumes:a.consumes,I:s.initializeSharing,S:{},installInitialConsumes:l.installInitialConsumes,initContainerEntry:u.initContainerEntry,init:p.init,getSharedFallbackGetter:c.getSharedFallbackGetter},h={runtime:d,instance:void 0,initOptions:void 0,bundlerRuntime:f,attachShareScopeMap:o.attachShareScopeMap,bundlerRuntimeOptions:{}},m=h.instance,g=h.initOptions,b=h.bundlerRuntimeOptions;t.attachShareScopeMap=o.attachShareScopeMap,t.bundlerRuntime=f,t.bundlerRuntimeOptions=b,t.default=h,t.initOptions=g,t.instance=m,Object.defineProperty(t,"runtime",{enumerable:!0,get:function(){return d}})},6582(e,t,r){let n=r(3162),o=r(5734),i=r(3926);i=n.__toESM(i),t.init=function({webpackRequire:e}){let{initOptions:t,runtime:n,sharedFallback:a,bundlerRuntime:s,libraryType:l}=e.federation;if(!t)throw Error("initOptions is required!");return t.plugins||=[],t.plugins.push({name:"tree-shake-plugin",beforeInit(t){let{userOptions:n,origin:u,options:p}=t,c=n.version||p.version;if(!a)return t;let d=n.shared||{},f=[];Object.keys(d).forEach(t=>{(Array.isArray(d[t])?d[t]:[d[t]]).forEach(r=>{f.push([t,r]),"get"in r&&(r.treeShaking||={},r.treeShaking.get=r.get,r.get=s.getSharedFallbackGetter({shareKey:t,factory:r.get,webpackRequire:e,libraryType:l,version:r.version}))})});let h=i.default.global.getGlobalSnapshotInfoByModuleInfo({name:u.name,version:c});return h&&"shared"in h&&(Object.keys(p.shared||{}).forEach(e=>{p.shared[e].forEach(t=>{f.push([e,t])})}),f.forEach(([e,t])=>{((e,t)=>{let n=h.shared.find(t=>t.sharedName===e);if(!n)return;let{treeShaking:i}=t;if(!i)return;let{secondarySharedTreeShakingName:a,secondarySharedTreeShakingEntry:s,treeShakingStatus:p}=n;i.status!==p&&(i.status=p,s&&l&&a&&(i.get=async()=>{let e=await (0,o.getRemoteEntry)({origin:u,remoteInfo:{name:a,entry:s,type:l,entryGlobalName:a,shareScope:"default"}});return await e.init(u,r.federation.bundlerRuntime),e.get()}))})(e,t)})),t}}),n.init(t)}},6605(e,t){t.initContainerEntry=function(e){let{webpackRequire:t,shareScope:r,initScope:n,shareScopeKey:o,remoteEntryInitOptions:i}=e;if(!t.S||!t.federation||!t.federation.instance||!t.federation.initOptions)return;let a=t.federation.instance;a.initOptions({name:t.federation.initOptions.name,remotes:[],...i});let s=i?.shareScopeKeys,l=i?.shareScopeMap;if(o&&"string"!=typeof o)o.forEach(e=>{if(!s||!l)return void a.initShareScopeMap(e,r,{hostShareScopeMap:i?.shareScopeMap||{}});l[e]||(l[e]={});let t=l[e];a.initShareScopeMap(e,t,{hostShareScopeMap:i?.shareScopeMap||{}})});else{let e=o||"default";Array.isArray(s)?s.forEach(e=>{l[e]||(l[e]={});let t=l[e];a.initShareScopeMap(e,t,{hostShareScopeMap:i?.shareScopeMap||{}})}):a.initShareScopeMap(e,r,{hostShareScopeMap:i?.shareScopeMap||{}})}return(t.federation.attachShareScopeMap&&t.federation.attachShareScopeMap(t),Array.isArray(o))?t.federation.initOptions.shared?t.I(o,n):Promise.all(o.map(e=>t.I(e,n))).then(()=>!0):t.I(o||"default",n)}},7706(e,t,r){let n=r(8262),o=r(1148);t.initializeSharing=function({shareScopeName:e,webpackRequire:t,initPromises:r,initTokens:i,initScope:a}){let s=Array.isArray(e)?e:[e];var l=[],u=function(s){a||(a=[]);let l=t.federation.instance;var u=i[s];if(u||(u=i[s]={from:l.name}),a.indexOf(u)>=0)return;a.push(u);let p=r[s];if(p)return p;var c=r=>{var n=e=>{let t;return t="Initialization of sharing external failed: "+e,"u">typeof console&&console.warn&&console.warn(t)};try{var o=t(r);if(!o)return;var i=r=>r&&r.init&&r.init(t.S[s],a,{shareScopeMap:t.S||{},shareScopeKeys:e});if(o.then)return d.push(o.then(i,n));var l=i(o);if(l&&"boolean"!=typeof l&&l.then)return d.push(l.catch(n))}catch(e){n(e)}};let d=l.initializeSharing(s,{strategy:l.options.shareStrategy,initScope:a,from:"build"});n.attachShareScopeMap(t);let f=t.federation.bundlerRuntimeOptions.remotes;return(f&&Object.keys(f.idToRemoteMap).forEach(e=>{let t=f.idToRemoteMap[e],r=f.idToExternalAndNameMapping[e][2];if(t.length>1)c(r);else if(1===t.length){let e=t[0];o.FEDERATION_SUPPORTED_TYPES.includes(e.externalType)||c(r)}}),d.length)?r[s]=Promise.all(d).then(()=>r[s]=!0):r[s]=!0};return s.forEach(e=>{l.push(u(e))}),Promise.all(l).then(()=>!0)}},9982(e,t,r){let n=r(1163),o=r(4476);t.installInitialConsumes=function(e){n.updateConsumeOptions(e);let{moduleToHandlerMapping:t,webpackRequire:r,installedModules:i,initialConsumes:a,asyncLoad:s}=e,l=[];a.forEach(e=>{l.push([e,()=>(function(e){let{moduleId:t,moduleToHandlerMapping:r,webpackRequire:n,asyncLoad:i}=e,a=n.federation.instance;if(!a)throw Error("Federation instance not found!");let{shareKey:s,shareInfo:l}=r[t];try{let e=o.getUsedExports(n,s),t={...l};if(e&&(t.treeShaking={usedExports:e,useIn:[a.options.name]}),i)return a.loadShare(s,{customShareInfo:t});return a.loadShareSync(s,{customShareInfo:t})}catch(e){throw console.error('loadShareSync failed! The function should not be called unless you set "eager:true". If you do not set it, and encounter this issue, you can check whether an async boundary is implemented.'),console.error("The original error message is as follows: "),e}})({moduleId:e,moduleToHandlerMapping:t,webpackRequire:r,asyncLoad:s})])});let u=(e,n)=>{r.m[e]=o=>{i[e]=0,delete r.c[e];let a=n();if("function"!=typeof a)throw Error(`Shared module is not available for eager consumption: ${e}`);let s=a(),{shareInfo:l}=t[e];if(l?.shareConfig?.layer&&s&&"object"==typeof s)try{s.hasOwnProperty("layer")&&void 0!==s.layer||(s.layer=l.shareConfig.layer)}catch(e){}o.exports=s}};if(s)return Promise.all(l.map(async([e,t])=>{let r=await t();u(e,()=>r)}));l.forEach(([e,t])=>{u(e,t)})}},7245(e,t,r){r(3162);let n=r(8262),o=r(1148),i=r(1163),a=r(1853);t.remotes=function(e){i.updateRemoteOptions(e);let{chunkId:t,promises:r,webpackRequire:s,chunkMapping:l,idToExternalAndNameMapping:u,idToRemoteMap:p}=e;n.attachShareScopeMap(s),s.o(l,t)&&l[t].forEach(e=>{let t=s.R;t||(t=[]);let n=u[e],i=p[e]||[];if(t.indexOf(n)>=0)return;if(t.push(n),n.p)return r.push(n.p);let l=t=>{t||(t=Error("Container missing")),"string"==typeof t.message&&(t.message+=`
3
- while loading "${n[1]}" from ${n[2]}`),s.m[e]=()=>{throw t},n.p=0},c=(e,t,o,i,a,s)=>{try{let u=e(t,o);if(!u||!u.then)return a(u,i,s);{let e=u.then(e=>a(e,i),l);if(!s)return e;r.push(n.p=e)}}catch(e){l(e)}};var d=(e,r,o)=>c(r.get,n[1],t,0,f,o),f=t=>{n.p=1,s.m[e]=e=>{e.exports=t()}};1===i.length&&o.FEDERATION_SUPPORTED_TYPES.includes(i[0].externalType)&&i[0].name?c(()=>{try{let e=(0,a.decodeName)(i[0].name,a.ENCODE_NAME_PREFIX)+n[1].slice(1),t=s.federation.instance,r=()=>s.federation.instance.loadRemote(e,{loadFactory:!1,from:"build"});if("version-first"===t.options.shareStrategy){let e=Array.isArray(n[0])?n[0]:[n[0]];return Promise.all(e.map(e=>t.sharedHandler.initializeSharing(e))).then(()=>r())}return r()}catch(e){l(e)}},n[2],0,0,f,1):c(s,n[2],0,0,(e,t,r)=>e?c(s.I,n[0],0,e,d,r):l(),1)})}},1163(e,t){t.updateConsumeOptions=function(e){let{webpackRequire:t,moduleToHandlerMapping:r}=e,{consumesLoadingData:n,initializeSharingData:o}=t,{sharedFallback:i,bundlerRuntime:a,libraryType:s}=t.federation;if(n&&!n._updated){let{moduleIdToConsumeDataMapping:o={},initialConsumes:l=[],chunkMapping:u={}}=n;if(Object.entries(o).forEach(([e,n])=>{r[e]||(r[e]={getter:i?a?.getSharedFallbackGetter({shareKey:n.shareKey,factory:n.fallback,webpackRequire:t,libraryType:s}):n.fallback,treeShakingGetter:i?n.fallback:void 0,shareInfo:{shareConfig:{requiredVersion:n.requiredVersion,strictVersion:n.strictVersion,singleton:n.singleton,eager:n.eager,layer:n.layer},scope:Array.isArray(n.shareScope)?n.shareScope:[n.shareScope||"default"],treeShaking:i?{get:n.fallback,mode:n.treeShakingMode}:void 0},shareKey:n.shareKey})}),"initialConsumes"in e){let{initialConsumes:t=[]}=e;l.forEach(e=>{t.includes(e)||t.push(e)})}if("chunkMapping"in e){let{chunkMapping:t={}}=e;Object.entries(u).forEach(([e,r])=>{t[e]||(t[e]=[]),r.forEach(r=>{t[e].includes(r)||t[e].push(r)})})}n._updated=1}if(o&&!o._updated){let{federation:e}=t;if(!e.instance||!o.scopeToSharingDataMapping)return;let r={};for(let[e,t]of Object.entries(o.scopeToSharingDataMapping))for(let n of t)if("object"==typeof n&&null!==n){let{name:t,version:o,factory:i,eager:a,singleton:s,requiredVersion:l,strictVersion:u}=n,p={requiredVersion:`^${o}`},c=function(e){return void 0!==e};c(s)&&(p.singleton=s),c(l)&&(p.requiredVersion=l),c(a)&&(p.eager=a),c(u)&&(p.strictVersion=u);let d={version:o,scope:[e],shareConfig:p,get:i};r[t]?r[t].push(d):r[t]=[d]}e.instance.registerShared(r),o._updated=1}},t.updateRemoteOptions=function(e){let{webpackRequire:t,idToExternalAndNameMapping:r={},idToRemoteMap:n={},chunkMapping:o={}}=e,{remotesLoadingData:i}=t,a=t.federation?.bundlerRuntimeOptions?.remotes?.remoteInfos;if(!i||i._updated||!a)return;let{chunkMapping:s,moduleIdToRemoteDataMapping:l}=i;if(s&&l){for(let[e,t]of Object.entries(l))if(r[e]||(r[e]=[t.shareScope,t.name,t.externalModuleId]),!n[e]&&a[t.remoteName]){let r=a[t.remoteName];n[e]||=[],r.forEach(t=>{n[e].includes(t)||n[e].push(t)})}o&&Object.entries(s).forEach(([e,t])=>{o[e]||(o[e]=[]),t.forEach(t=>{o[e].includes(t)||o[e].push(t)})}),i._updated=1}}},7913(e,t){var r=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;t.__toESM=(e,t,l)=>(l=null!=e?r(a(e)):{},((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var a,l=i(t),u=0,p=l.length;u<p;u++)a=l[u],s.call(e,a)||void 0===a||n(e,a,{get:(e=>t[e]).bind(null,a),enumerable:!(r=o(t,a))||r.enumerable});return e})(!t&&e&&e.__esModule?l:n(l,"default",{value:e,enumerable:!0}),e))},3926(e,t,r){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),r(7913);let n=r(1050),o=r(3054),i={...o.helpers.global,getGlobalFederationInstance:n.getGlobalFederationInstance},a=o.helpers.share,s=o.helpers.utils;t.default={global:i,share:a,utils:s},t.global=i,t.share=a,t.utils=s},1050(e,t,r){r(7913);let n=r(3054);t.getGlobalFederationInstance=function(e,t){let r="@openmrs/esm-implementer-tools-app:11.0.1-pre.5993";return n.CurrentGlobal.__FEDERATION__.__INSTANCES__.find(n=>!!r&&n.options.id===r||n.options.name===e&&!n.options.version&&!t||n.options.name===e&&!!t&&n.options.version===t)}}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={id:e,loaded:!1,exports:{}};return i[e].call(r.exports,r,r.exports,s),r.loaded=!0,r.exports}s.m=i,s.c=a,s.x=()=>s(7240),s.federation||(s.federation={chunkMatcher:function(e){return!/^(1541|2366|3230|3611|4234|7143)$/.test(e)},rootOutputDir:""}),s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,r)=>(s.f[r](e,t),t),[])),s.u=e=>""+e+".js",s.miniCssF=e=>""+e+".css",s.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},s.l=function(e,t,r,n){if(l[e])return void l[e].push(t);if(void 0!==r)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var p=a[u];if(p.getAttribute("src")==e||p.getAttribute("data-rspack")=="@openmrs/esm-implementer-tools-app:"+r){o=p;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-rspack","@openmrs/esm-implementer-tools-app:"+r),o.src=e),l[e]=[t];var c=function(t,r){o.onerror=o.onload=null,clearTimeout(d);var n=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),n&&n.forEach(function(e){return e(r)}),t)return t(r)},d=setTimeout(c.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=c.bind(null,o.onerror),o.onload=c.bind(null,o.onload),i&&document.head.appendChild(o)},s.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),s.rv=()=>"1.7.9",s.S={},s.initializeSharingData={scopeToSharingDataMapping:{default:[{name:"@carbon/react",version:"1.92.1",factory:()=>Promise.all([s.e("2536"),s.e("195"),s.e("2366"),s.e("4234"),s.e("1541")]).then(()=>()=>s(350)),eager:0,singleton:1,requiredVersion:"1.x",strictVersion:0},{name:"@openmrs/esm-framework",version:"11.0.1-pre.5993",factory:()=>Promise.all([s.e("2536"),s.e("4012"),s.e("4698"),s.e("8855"),s.e("2366"),s.e("4234"),s.e("3230"),s.e("1541"),s.e("4823"),s.e("3611")]).then(()=>()=>s(7562)),eager:0,singleton:1,requiredVersion:"11.x",strictVersion:0},{name:"react-dom/client",version:"18.3.1",factory:()=>Promise.all([s.e("4234"),s.e("5449")]).then(()=>()=>s(3776)),eager:0,singleton:1,requiredVersion:"18.x",strictVersion:0},{name:"react-dom",version:"18.3.1",factory:()=>Promise.all([s.e("9116"),s.e("2366")]).then(()=>()=>s(5623)),eager:0,singleton:1,requiredVersion:"18.x",strictVersion:0},{name:"react-i18next",version:"16.0.0",factory:()=>Promise.all([s.e("651"),s.e("2366")]).then(()=>()=>s(2454)),eager:0,singleton:1,requiredVersion:"16.x",strictVersion:0},{name:"react/jsx-runtime",version:"18.3.1",factory:()=>Promise.all([s.e("2366"),s.e("4011")]).then(()=>()=>s(6870)),eager:0,singleton:1,requiredVersion:"18.x",strictVersion:0},{name:"react",version:"18.3.1",factory:()=>s.e("5819").then(()=>()=>s(6326)),eager:0,singleton:1,requiredVersion:"18.x",strictVersion:0},{name:"swr/_internal",version:"2.5.1",factory:()=>Promise.all([s.e("8574"),s.e("2366")]).then(()=>()=>s(1405)),eager:0,singleton:1,requiredVersion:"2.x",strictVersion:0},{name:"swr/immutable",version:"2.5.1",factory:()=>Promise.all([s.e("8574"),s.e("149"),s.e("2366"),s.e("7918")]).then(()=>()=>s(6269)),eager:0,singleton:1,requiredVersion:"2.x",strictVersion:0},{name:"swr/infinite",version:"2.5.1",factory:()=>Promise.all([s.e("8574"),s.e("149"),s.e("2366"),s.e("1582")]).then(()=>()=>s(3709)),eager:0,singleton:1,requiredVersion:"2.x",strictVersion:0},{name:"swr",version:"2.5.1",factory:()=>Promise.all([s.e("8574"),s.e("149"),s.e("2366"),s.e("4070")]).then(()=>()=>s(1237)),eager:0,singleton:1,requiredVersion:"2.x",strictVersion:0}]},uniqueName:"@openmrs/esm-implementer-tools-app"},s.I=s.I||function(){throw Error("should have __webpack_require__.I")},s.g.importScripts&&(u=s.g.location+"");var l,u,p=s.g.document;if(!u&&p&&(p.currentScript&&"SCRIPT"===p.currentScript.tagName.toUpperCase()&&(u=p.currentScript.src),!u)){var c=p.getElementsByTagName("script");if(c.length)for(var d=c.length-1;d>-1&&(!u||!/^http(s?):/.test(u));)u=c[d--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");if(s.p=u=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.consumesLoadingData={chunkMapping:{1541:["5140"],3038:["5607"],7143:["3658"],3611:["8326","9737"],4823:["5254","8086","2852","2216"],2366:["6925"],3230:["749"],4234:["2065"]},moduleIdToConsumeDataMapping:{5140:{shareScope:"default",shareKey:"react/jsx-runtime",import:"react/jsx-runtime",requiredVersion:"18.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("6392").then(()=>()=>s(6870))},5254:{shareScope:"default",shareKey:"swr/_internal",import:"swr/_internal",requiredVersion:"2.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("8574").then(()=>()=>s(1405))},8326:{shareScope:"default",shareKey:"@carbon/react",import:"@carbon/react",requiredVersion:"1.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("2536"),s.e("195"),s.e("4234")]).then(()=>()=>s(350))},6925:{shareScope:"default",shareKey:"react",import:"react",requiredVersion:"18.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("5819").then(()=>()=>s(6326))},9737:{shareScope:"default",shareKey:"react-i18next",import:"react-i18next",requiredVersion:"16.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("651").then(()=>()=>s(2454))},2216:{shareScope:"default",shareKey:"swr/infinite",import:"swr/infinite",requiredVersion:"2.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("8574"),s.e("149"),s.e("9201")]).then(()=>()=>s(3709))},5607:{shareScope:"default",shareKey:"@openmrs/esm-framework",import:"@openmrs/esm-framework",requiredVersion:"11.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("2536"),s.e("4012"),s.e("4698"),s.e("4234"),s.e("3230"),s.e("4823")]).then(()=>()=>s(7562))},2852:{shareScope:"default",shareKey:"react-dom/client",import:"react-dom/client",requiredVersion:"18.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("7830").then(()=>()=>s(3776))},3658:{shareScope:"default",shareKey:"@openmrs/esm-framework/src/internal",import:"@openmrs/esm-framework/src/internal",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("2536"),s.e("4012"),s.e("4698"),s.e("4234"),s.e("3230"),s.e("4823")]).then(()=>()=>s(7562))},8086:{shareScope:"default",shareKey:"swr/immutable",import:"swr/immutable",requiredVersion:"2.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("8574"),s.e("149"),s.e("5537")]).then(()=>()=>s(6269))},749:{shareScope:"default",shareKey:"swr",import:"swr",requiredVersion:"2.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("8574"),s.e("149"),s.e("1689")]).then(()=>()=>s(1237))},2065:{shareScope:"default",shareKey:"react-dom",import:"react-dom",requiredVersion:"18.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("9116"),s.e("2366")]).then(()=>()=>s(5623))}},initialConsumes:[]},s.f.consumes=s.f.consumes||function(){throw Error("should have __webpack_require__.f.consumes")},"u">typeof document){var f=function(e,t,r,n,o){var i=document.createElement("link");return i.rel="stylesheet",i.type="text/css",s.nc&&(i.nonce=s.nc),i.href=t,i.onerror=i.onload=function(r){if(i.onerror=i.onload=null,"load"===r.type)n();else{var a=r&&("load"===r.type?"missing":r.type),s=r&&r.target&&r.target.href||t,l=Error("Loading CSS chunk "+e+" failed.\\n("+s+")");l.code="CSS_CHUNK_LOAD_FAILED",l.type=a,l.request=s,i.parentNode&&i.parentNode.removeChild(i),o(l)}},r?r.parentNode.insertBefore(i,r.nextSibling):document.head.appendChild(i),i},h=function(e,t){for(var r=document.getElementsByTagName("link"),n=0;n<r.length;n++){var o=r[n],i=o.getAttribute("data-href")||o.getAttribute("href");if(i&&(i=i.split("?")[0]),"stylesheet"===o.rel&&(i===e||i===t))return o}for(var a=document.getElementsByTagName("style"),n=0;n<a.length;n++){var o=a[n],i=o.getAttribute("data-href");if(i===e||i===t)return o}},m={1887:0};s.f.miniCss=function(e,t){if(m[e])t.push(m[e]);else 0!==m[e]&&({1389:1,2920:1,3038:1,4823:1,8088:1})[e]&&t.push(m[e]=new Promise(function(t,r){var n=s.miniCssF(e),o=s.p+n;if(h(n,o))return t();f(e,o,null,t,r)}).then(function(){m[e]=0},function(t){throw delete m[e],t}))}}s.initializeExposesData={moduleMap:{"./start":()=>Promise.all([s.e("8855"),s.e("2366"),s.e("1541"),s.e("3611"),s.e("3038")]).then(()=>()=>s(5917))},shareScope:"default"},s.getContainer=s.getContainer||function(){throw Error("should have __webpack_require__.getContainer")},s.initContainer=s.initContainer||function(){throw Error("should have __webpack_require__.initContainer")},s.b=document.baseURI||self.location.href,e={1887:0},s.f.j=function(t,r){var n=s.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else if(/^(1541|2366|3230|3611|4234|7143)$/.test(t))e[t]=0;else{var o=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=o);var i=s.p+s.u(t),a=Error();s.l(i,function(r){if(s.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var o=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;a.message="Loading chunk "+t+" failed.\n("+o+": "+i+")",a.name="ChunkLoadError",a.type=o,a.request=i,n[1](a)}},"chunk-"+t,t)}},t=(t,r)=>{var n,o,[i,a,l]=r,u=0;if(i.some(t=>0!==e[t])){for(n in a)s.o(a,n)&&(s.m[n]=a[n]);l&&l(s)}for(t&&t(r);u<i.length;u++)o=i[u],s.o(e,o)&&e[o]&&e[o][0](),e[o]=0},(r=globalThis.webpackChunk_openmrs_esm_implementer_tools_app=globalThis.webpackChunk_openmrs_esm_implementer_tools_app||[]).forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r)),s.ruid="bundler=rspack@1.7.9",n=s.x,o=!1,s.x=function(){if(o||(o=!0,s(3242)),"function"==typeof n)return n();console.warn("[MF] Invalid prevStartup")},_openmrs_esm_implementer_tools_app=s.x()})();
3
+ while loading "${n[1]}" from ${n[2]}`),s.m[e]=()=>{throw t},n.p=0},c=(e,t,o,i,a,s)=>{try{let u=e(t,o);if(!u||!u.then)return a(u,i,s);{let e=u.then(e=>a(e,i),l);if(!s)return e;r.push(n.p=e)}}catch(e){l(e)}};var d=(e,r,o)=>c(r.get,n[1],t,0,f,o),f=t=>{n.p=1,s.m[e]=e=>{e.exports=t()}};1===i.length&&o.FEDERATION_SUPPORTED_TYPES.includes(i[0].externalType)&&i[0].name?c(()=>{try{let e=(0,a.decodeName)(i[0].name,a.ENCODE_NAME_PREFIX)+n[1].slice(1),t=s.federation.instance,r=()=>s.federation.instance.loadRemote(e,{loadFactory:!1,from:"build"});if("version-first"===t.options.shareStrategy){let e=Array.isArray(n[0])?n[0]:[n[0]];return Promise.all(e.map(e=>t.sharedHandler.initializeSharing(e))).then(()=>r())}return r()}catch(e){l(e)}},n[2],0,0,f,1):c(s,n[2],0,0,(e,t,r)=>e?c(s.I,n[0],0,e,d,r):l(),1)})}},1163(e,t){t.updateConsumeOptions=function(e){let{webpackRequire:t,moduleToHandlerMapping:r}=e,{consumesLoadingData:n,initializeSharingData:o}=t,{sharedFallback:i,bundlerRuntime:a,libraryType:s}=t.federation;if(n&&!n._updated){let{moduleIdToConsumeDataMapping:o={},initialConsumes:l=[],chunkMapping:u={}}=n;if(Object.entries(o).forEach(([e,n])=>{r[e]||(r[e]={getter:i?a?.getSharedFallbackGetter({shareKey:n.shareKey,factory:n.fallback,webpackRequire:t,libraryType:s}):n.fallback,treeShakingGetter:i?n.fallback:void 0,shareInfo:{shareConfig:{requiredVersion:n.requiredVersion,strictVersion:n.strictVersion,singleton:n.singleton,eager:n.eager,layer:n.layer},scope:Array.isArray(n.shareScope)?n.shareScope:[n.shareScope||"default"],treeShaking:i?{get:n.fallback,mode:n.treeShakingMode}:void 0},shareKey:n.shareKey})}),"initialConsumes"in e){let{initialConsumes:t=[]}=e;l.forEach(e=>{t.includes(e)||t.push(e)})}if("chunkMapping"in e){let{chunkMapping:t={}}=e;Object.entries(u).forEach(([e,r])=>{t[e]||(t[e]=[]),r.forEach(r=>{t[e].includes(r)||t[e].push(r)})})}n._updated=1}if(o&&!o._updated){let{federation:e}=t;if(!e.instance||!o.scopeToSharingDataMapping)return;let r={};for(let[e,t]of Object.entries(o.scopeToSharingDataMapping))for(let n of t)if("object"==typeof n&&null!==n){let{name:t,version:o,factory:i,eager:a,singleton:s,requiredVersion:l,strictVersion:u}=n,p={requiredVersion:`^${o}`},c=function(e){return void 0!==e};c(s)&&(p.singleton=s),c(l)&&(p.requiredVersion=l),c(a)&&(p.eager=a),c(u)&&(p.strictVersion=u);let d={version:o,scope:[e],shareConfig:p,get:i};r[t]?r[t].push(d):r[t]=[d]}e.instance.registerShared(r),o._updated=1}},t.updateRemoteOptions=function(e){let{webpackRequire:t,idToExternalAndNameMapping:r={},idToRemoteMap:n={},chunkMapping:o={}}=e,{remotesLoadingData:i}=t,a=t.federation?.bundlerRuntimeOptions?.remotes?.remoteInfos;if(!i||i._updated||!a)return;let{chunkMapping:s,moduleIdToRemoteDataMapping:l}=i;if(s&&l){for(let[e,t]of Object.entries(l))if(r[e]||(r[e]=[t.shareScope,t.name,t.externalModuleId]),!n[e]&&a[t.remoteName]){let r=a[t.remoteName];n[e]||=[],r.forEach(t=>{n[e].includes(t)||n[e].push(t)})}o&&Object.entries(s).forEach(([e,t])=>{o[e]||(o[e]=[]),t.forEach(t=>{o[e].includes(t)||o[e].push(t)})}),i._updated=1}}},7913(e,t){var r=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;t.__toESM=(e,t,l)=>(l=null!=e?r(a(e)):{},((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var a,l=i(t),u=0,p=l.length;u<p;u++)a=l[u],s.call(e,a)||void 0===a||n(e,a,{get:(e=>t[e]).bind(null,a),enumerable:!(r=o(t,a))||r.enumerable});return e})(!t&&e&&e.__esModule?l:n(l,"default",{value:e,enumerable:!0}),e))},3926(e,t,r){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),r(7913);let n=r(1050),o=r(3054),i={...o.helpers.global,getGlobalFederationInstance:n.getGlobalFederationInstance},a=o.helpers.share,s=o.helpers.utils;t.default={global:i,share:a,utils:s},t.global=i,t.share=a,t.utils=s},1050(e,t,r){r(7913);let n=r(3054);t.getGlobalFederationInstance=function(e,t){let r="@openmrs/esm-implementer-tools-app:11.0.1-pre.6006";return n.CurrentGlobal.__FEDERATION__.__INSTANCES__.find(n=>!!r&&n.options.id===r||n.options.name===e&&!n.options.version&&!t||n.options.name===e&&!!t&&n.options.version===t)}}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={id:e,loaded:!1,exports:{}};return i[e].call(r.exports,r,r.exports,s),r.loaded=!0,r.exports}s.m=i,s.c=a,s.x=()=>s(7240),s.federation||(s.federation={chunkMatcher:function(e){return!/^(1541|2366|3230|3611|4234|7143)$/.test(e)},rootOutputDir:""}),s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,r)=>(s.f[r](e,t),t),[])),s.u=e=>""+e+".js",s.miniCssF=e=>""+e+".css",s.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},s.l=function(e,t,r,n){if(l[e])return void l[e].push(t);if(void 0!==r)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var p=a[u];if(p.getAttribute("src")==e||p.getAttribute("data-rspack")=="@openmrs/esm-implementer-tools-app:"+r){o=p;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-rspack","@openmrs/esm-implementer-tools-app:"+r),o.src=e),l[e]=[t];var c=function(t,r){o.onerror=o.onload=null,clearTimeout(d);var n=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),n&&n.forEach(function(e){return e(r)}),t)return t(r)},d=setTimeout(c.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=c.bind(null,o.onerror),o.onload=c.bind(null,o.onload),i&&document.head.appendChild(o)},s.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),s.rv=()=>"1.7.9",s.S={},s.initializeSharingData={scopeToSharingDataMapping:{default:[{name:"@carbon/react",version:"1.92.1",factory:()=>Promise.all([s.e("2536"),s.e("195"),s.e("2366"),s.e("4234"),s.e("1541")]).then(()=>()=>s(350)),eager:0,singleton:1,requiredVersion:"1.x",strictVersion:0},{name:"@openmrs/esm-framework",version:"11.0.1-pre.6006",factory:()=>Promise.all([s.e("2536"),s.e("4012"),s.e("4698"),s.e("8855"),s.e("2366"),s.e("4234"),s.e("3230"),s.e("1541"),s.e("4823"),s.e("3611")]).then(()=>()=>s(7562)),eager:0,singleton:1,requiredVersion:"11.x",strictVersion:0},{name:"react-dom/client",version:"18.3.1",factory:()=>Promise.all([s.e("4234"),s.e("5449")]).then(()=>()=>s(3776)),eager:0,singleton:1,requiredVersion:"18.x",strictVersion:0},{name:"react-dom",version:"18.3.1",factory:()=>Promise.all([s.e("9116"),s.e("2366")]).then(()=>()=>s(5623)),eager:0,singleton:1,requiredVersion:"18.x",strictVersion:0},{name:"react-i18next",version:"16.0.0",factory:()=>Promise.all([s.e("651"),s.e("2366")]).then(()=>()=>s(2454)),eager:0,singleton:1,requiredVersion:"16.x",strictVersion:0},{name:"react/jsx-runtime",version:"18.3.1",factory:()=>Promise.all([s.e("2366"),s.e("4011")]).then(()=>()=>s(6870)),eager:0,singleton:1,requiredVersion:"18.x",strictVersion:0},{name:"react",version:"18.3.1",factory:()=>s.e("5819").then(()=>()=>s(6326)),eager:0,singleton:1,requiredVersion:"18.x",strictVersion:0},{name:"swr/_internal",version:"2.5.1",factory:()=>Promise.all([s.e("8574"),s.e("2366")]).then(()=>()=>s(1405)),eager:0,singleton:1,requiredVersion:"2.x",strictVersion:0},{name:"swr/immutable",version:"2.5.1",factory:()=>Promise.all([s.e("8574"),s.e("149"),s.e("2366"),s.e("7918")]).then(()=>()=>s(6269)),eager:0,singleton:1,requiredVersion:"2.x",strictVersion:0},{name:"swr/infinite",version:"2.5.1",factory:()=>Promise.all([s.e("8574"),s.e("149"),s.e("2366"),s.e("1582")]).then(()=>()=>s(3709)),eager:0,singleton:1,requiredVersion:"2.x",strictVersion:0},{name:"swr",version:"2.5.1",factory:()=>Promise.all([s.e("8574"),s.e("149"),s.e("2366"),s.e("4070")]).then(()=>()=>s(1237)),eager:0,singleton:1,requiredVersion:"2.x",strictVersion:0}]},uniqueName:"@openmrs/esm-implementer-tools-app"},s.I=s.I||function(){throw Error("should have __webpack_require__.I")},s.g.importScripts&&(u=s.g.location+"");var l,u,p=s.g.document;if(!u&&p&&(p.currentScript&&"SCRIPT"===p.currentScript.tagName.toUpperCase()&&(u=p.currentScript.src),!u)){var c=p.getElementsByTagName("script");if(c.length)for(var d=c.length-1;d>-1&&(!u||!/^http(s?):/.test(u));)u=c[d--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");if(s.p=u=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.consumesLoadingData={chunkMapping:{1541:["5140"],3038:["5607"],7143:["3658"],3611:["8326","9737"],4823:["5254","8086","2852","2216"],2366:["6925"],3230:["749"],4234:["2065"]},moduleIdToConsumeDataMapping:{5140:{shareScope:"default",shareKey:"react/jsx-runtime",import:"react/jsx-runtime",requiredVersion:"18.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("6392").then(()=>()=>s(6870))},5254:{shareScope:"default",shareKey:"swr/_internal",import:"swr/_internal",requiredVersion:"2.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("8574").then(()=>()=>s(1405))},8326:{shareScope:"default",shareKey:"@carbon/react",import:"@carbon/react",requiredVersion:"1.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("2536"),s.e("195"),s.e("4234")]).then(()=>()=>s(350))},6925:{shareScope:"default",shareKey:"react",import:"react",requiredVersion:"18.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("5819").then(()=>()=>s(6326))},9737:{shareScope:"default",shareKey:"react-i18next",import:"react-i18next",requiredVersion:"16.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("651").then(()=>()=>s(2454))},2216:{shareScope:"default",shareKey:"swr/infinite",import:"swr/infinite",requiredVersion:"2.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("8574"),s.e("149"),s.e("9201")]).then(()=>()=>s(3709))},5607:{shareScope:"default",shareKey:"@openmrs/esm-framework",import:"@openmrs/esm-framework",requiredVersion:"11.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("2536"),s.e("4012"),s.e("4698"),s.e("4234"),s.e("3230"),s.e("4823")]).then(()=>()=>s(7562))},2852:{shareScope:"default",shareKey:"react-dom/client",import:"react-dom/client",requiredVersion:"18.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>s.e("7830").then(()=>()=>s(3776))},3658:{shareScope:"default",shareKey:"@openmrs/esm-framework/src/internal",import:"@openmrs/esm-framework/src/internal",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("2536"),s.e("4012"),s.e("4698"),s.e("4234"),s.e("3230"),s.e("4823")]).then(()=>()=>s(7562))},8086:{shareScope:"default",shareKey:"swr/immutable",import:"swr/immutable",requiredVersion:"2.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("8574"),s.e("149"),s.e("5537")]).then(()=>()=>s(6269))},749:{shareScope:"default",shareKey:"swr",import:"swr",requiredVersion:"2.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("8574"),s.e("149"),s.e("1689")]).then(()=>()=>s(1237))},2065:{shareScope:"default",shareKey:"react-dom",import:"react-dom",requiredVersion:"18.x",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([s.e("9116"),s.e("2366")]).then(()=>()=>s(5623))}},initialConsumes:[]},s.f.consumes=s.f.consumes||function(){throw Error("should have __webpack_require__.f.consumes")},"u">typeof document){var f=function(e,t,r,n,o){var i=document.createElement("link");return i.rel="stylesheet",i.type="text/css",s.nc&&(i.nonce=s.nc),i.href=t,i.onerror=i.onload=function(r){if(i.onerror=i.onload=null,"load"===r.type)n();else{var a=r&&("load"===r.type?"missing":r.type),s=r&&r.target&&r.target.href||t,l=Error("Loading CSS chunk "+e+" failed.\\n("+s+")");l.code="CSS_CHUNK_LOAD_FAILED",l.type=a,l.request=s,i.parentNode&&i.parentNode.removeChild(i),o(l)}},r?r.parentNode.insertBefore(i,r.nextSibling):document.head.appendChild(i),i},h=function(e,t){for(var r=document.getElementsByTagName("link"),n=0;n<r.length;n++){var o=r[n],i=o.getAttribute("data-href")||o.getAttribute("href");if(i&&(i=i.split("?")[0]),"stylesheet"===o.rel&&(i===e||i===t))return o}for(var a=document.getElementsByTagName("style"),n=0;n<a.length;n++){var o=a[n],i=o.getAttribute("data-href");if(i===e||i===t)return o}},m={1887:0};s.f.miniCss=function(e,t){if(m[e])t.push(m[e]);else 0!==m[e]&&({1389:1,2920:1,3038:1,4823:1,8088:1})[e]&&t.push(m[e]=new Promise(function(t,r){var n=s.miniCssF(e),o=s.p+n;if(h(n,o))return t();f(e,o,null,t,r)}).then(function(){m[e]=0},function(t){throw delete m[e],t}))}}s.initializeExposesData={moduleMap:{"./start":()=>Promise.all([s.e("8855"),s.e("2366"),s.e("1541"),s.e("3611"),s.e("3038")]).then(()=>()=>s(5917))},shareScope:"default"},s.getContainer=s.getContainer||function(){throw Error("should have __webpack_require__.getContainer")},s.initContainer=s.initContainer||function(){throw Error("should have __webpack_require__.initContainer")},s.b=document.baseURI||self.location.href,e={1887:0},s.f.j=function(t,r){var n=s.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else if(/^(1541|2366|3230|3611|4234|7143)$/.test(t))e[t]=0;else{var o=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=o);var i=s.p+s.u(t),a=Error();s.l(i,function(r){if(s.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var o=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;a.message="Loading chunk "+t+" failed.\n("+o+": "+i+")",a.name="ChunkLoadError",a.type=o,a.request=i,n[1](a)}},"chunk-"+t,t)}},t=(t,r)=>{var n,o,[i,a,l]=r,u=0;if(i.some(t=>0!==e[t])){for(n in a)s.o(a,n)&&(s.m[n]=a[n]);l&&l(s)}for(t&&t(r);u<i.length;u++)o=i[u],s.o(e,o)&&e[o]&&e[o][0](),e[o]=0},(r=globalThis.webpackChunk_openmrs_esm_implementer_tools_app=globalThis.webpackChunk_openmrs_esm_implementer_tools_app||[]).forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r)),s.ruid="bundler=rspack@1.7.9",n=s.x,o=!1,s.x=function(){if(o||(o=!0,s(3242)),"function"==typeof n)return n();console.warn("[MF] Invalid prevStartup")},_openmrs_esm_implementer_tools_app=s.x()})();
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","pages":[{"component":"implementerTools","route":true},{"component":"globalImplementerTools","route":true}],"extensions":[{"name":"implementer-tools-button","slot":"top-nav-actions-slot","component":"implementerToolsButton","order":20}],"version":"11.0.1-pre.5993"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","pages":[{"component":"implementerTools","route":true},{"component":"globalImplementerTools","route":true}],"extensions":[{"name":"implementer-tools-button","slot":"top-nav-actions-slot","component":"implementerToolsButton","order":20}],"version":"11.0.1-pre.6006"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-implementer-tools-app",
3
- "version": "11.0.1-pre.5993",
3
+ "version": "11.0.1-pre.6006",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The admin interface for OpenMRS Frontend",
6
6
  "browser": "dist/openmrs-esm-implementer-tools-app.js",
@@ -52,12 +52,12 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@carbon/react": "^1.92.1",
55
- "@openmrs/esm-framework": "11.0.1-pre.5993",
55
+ "@openmrs/esm-framework": "11.0.1-pre.6006",
56
56
  "@vitest/coverage-v8": "^4.1.2",
57
57
  "ace-builds": "^1.43.3",
58
58
  "cross-env": "^10.1.0",
59
59
  "happy-dom": "^20.6.0",
60
- "openmrs": "11.0.1-pre.5993",
60
+ "openmrs": "11.0.1-pre.6006",
61
61
  "react": "^18.3.1",
62
62
  "react-ace": "^14.0.1",
63
63
  "react-dom": "^18.3.1",
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Helpers for reading the outcome of an i18next load. i18next's own reports can't be taken at face
3
+ * value: it resolves its promises and calls back as a success for a language/namespace pair it
4
+ * skipped because an earlier load of it failed, and it hands every waiting request every load error,
5
+ * whichever pair that error came from. What it records per pair in its backend connector is reliable.
6
+ */
7
+
8
+ const notLoadedState = 0;
9
+ const loadingState = 1;
10
+
11
+ interface BackendConnector {
12
+ /** i18next's record of each `language|namespace` pair: 1 while loading, 2 once loaded, below 0 once failed. */
13
+ state?: Record<string, number>;
14
+ on?(event: 'loaded', listener: () => void): void;
15
+ off?(event: 'loaded', listener: () => void): void;
16
+ }
17
+
18
+ function getConnector(): BackendConnector | undefined {
19
+ return window.i18next?.services?.backendConnector as BackendConnector | undefined;
20
+ }
21
+
22
+ function getConnectorState(): Record<string, number> | undefined {
23
+ return getConnector()?.state;
24
+ }
25
+
26
+ function getPairs(languages: Array<string>, namespaces: Array<string>) {
27
+ return languages.flatMap((language) => namespaces.map((namespace) => ({ language, namespace })));
28
+ }
29
+
30
+ /**
31
+ * Clears i18next's failed mark from the pairs. Without this it skips them on the next attempt, while
32
+ * still reporting that attempt as a success.
33
+ */
34
+ export function clearFailedLoads(languages: Array<string>, namespaces: Array<string>) {
35
+ const state = getConnectorState();
36
+
37
+ for (const { language, namespace } of getPairs(languages, namespaces)) {
38
+ if (state && state[`${language}|${namespace}`] < 0) {
39
+ state[`${language}|${namespace}`] = notLoadedState;
40
+ }
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Clears the mark i18next leaves on a pair whose read never finished. i18next attaches any later
46
+ * request for a pair it believes is loading to that read, so without this one hung read would make
47
+ * every later request for the pair hang with it.
48
+ */
49
+ export function releaseStalledLoads(languages: Array<string>, namespaces: Array<string>) {
50
+ const state = getConnectorState();
51
+
52
+ for (const { language, namespace } of getPairs(languages, namespaces)) {
53
+ if (state?.[`${language}|${namespace}`] === loadingState) {
54
+ delete state[`${language}|${namespace}`];
55
+ }
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Settles once none of the pairs is being read. i18next attaches a request for a pair it is already
61
+ * reading to that read, so a request that needs a fresh read has to wait for it first.
62
+ *
63
+ * @param signal Aborting it stops the wait and rejects, so that a caller that gave up on a stalled
64
+ * read doesn't carry on whenever some later load finishes.
65
+ */
66
+ export function waitForLoadsInFlight(
67
+ languages: Array<string>,
68
+ namespaces: Array<string>,
69
+ signal?: AbortSignal,
70
+ ): Promise<void> {
71
+ const connector = getConnector();
72
+ const pairs = getPairs(languages, namespaces);
73
+ const isLoading = () =>
74
+ pairs.some(({ language, namespace }) => connector?.state?.[`${language}|${namespace}`] === loadingState);
75
+
76
+ if (!connector?.on || !connector.off || !isLoading()) {
77
+ return Promise.resolve();
78
+ }
79
+
80
+ const { on, off } = connector;
81
+
82
+ return new Promise((resolve, reject) => {
83
+ const stop = () => {
84
+ off.call(connector, 'loaded', check);
85
+ signal?.removeEventListener('abort', abort);
86
+ };
87
+ const check = () => {
88
+ if (!isLoading()) {
89
+ stop();
90
+ resolve();
91
+ }
92
+ };
93
+ const abort = () => {
94
+ stop();
95
+ reject(signal?.reason);
96
+ };
97
+
98
+ on.call(connector, 'loaded', check);
99
+ signal?.addEventListener('abort', abort, { once: true });
100
+ });
101
+ }
102
+
103
+ /**
104
+ * Works out whether a load of the given pairs failed, given the error i18next called back with.
105
+ *
106
+ * @returns The failure to report, or `undefined` if every pair loaded.
107
+ */
108
+ export function findLoadFailure(
109
+ languages: Array<string>,
110
+ namespaces: Array<string>,
111
+ callbackError: unknown,
112
+ ): Error | undefined {
113
+ const state = getConnectorState();
114
+ const pairs = getPairs(languages, namespaces);
115
+
116
+ // Without the connector's record there is nothing better to go on than the callback.
117
+ if (!state && callbackError) {
118
+ return asError(callbackError);
119
+ }
120
+
121
+ const failed = pairs.find(({ language, namespace }) => state && state[`${language}|${namespace}`] < 0);
122
+
123
+ if (failed) {
124
+ return callbackError
125
+ ? asError(callbackError)
126
+ : new Error(`Loading ${failed.namespace} for ${failed.language} failed; try again`);
127
+ }
128
+
129
+ const missing = pairs.find(({ language, namespace }) => !window.i18next.hasResourceBundle(language, namespace));
130
+
131
+ return missing ? new Error(`i18next holds no ${missing.namespace} resources for ${missing.language}`) : undefined;
132
+ }
133
+
134
+ /** i18next hands a load failure to its callback as an array of errors rather than as an `Error`. */
135
+ export function asError(error: unknown): Error {
136
+ if (error instanceof Error) {
137
+ return error;
138
+ }
139
+
140
+ return new Error(Array.isArray(error) ? error.map(String).join('; ') : String(error));
141
+ }
142
+
143
+ /**
144
+ * i18next puts no timeout on its backend, so a read that never settles, such as one awaiting a
145
+ * module's config that never loads, would otherwise leave whatever waits on it waiting forever. Pair
146
+ * it with `releaseStalledLoads`, so that the next attempt starts a read of its own.
147
+ */
148
+ export function withTimeout<T>(promise: Promise<T>, message: string): Promise<T> {
149
+ let timer: ReturnType<typeof setTimeout>;
150
+
151
+ return Promise.race([
152
+ promise,
153
+ new Promise<never>((_, reject) => {
154
+ timer = setTimeout(() => reject(new Error(message)), loadTimeoutMs);
155
+ }),
156
+ ]).finally(() => clearTimeout(timer)) as Promise<T>;
157
+ }
158
+
159
+ const loadTimeoutMs = 15_000;
@@ -0,0 +1,306 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import { act, renderHook } from '@testing-library/react';
3
+ import i18next from 'i18next';
4
+ import { useSession } from '@openmrs/esm-framework';
5
+ import { implementerToolsConfigStore } from '@openmrs/esm-framework/src/internal';
6
+ import {
7
+ findOverrideSource,
8
+ flattenBundle,
9
+ getLoadedNamespaces,
10
+ loadTranslationLanguage,
11
+ loadTranslationNamespace,
12
+ useTranslationEntries,
13
+ useTranslationLanguages,
14
+ } from './translation-catalog';
15
+
16
+ vi.mock('../hooks', () => ({ useFrontendModules: () => [] }));
17
+
18
+ describe('flattenBundle', () => {
19
+ it('keeps the top-level string entries', () => {
20
+ expect(flattenBundle({ loginButton: 'Log in', locationsHeader: 'Locations' })).toEqual({
21
+ loginButton: 'Log in',
22
+ locationsHeader: 'Locations',
23
+ });
24
+ });
25
+
26
+ it('leaves out a nested entry, which could be listed but never overridden', () => {
27
+ // An override is written at the literal path given, while i18next resolves `errors.required` by
28
+ // walking `errors` then `required`, so editing one here could never take effect.
29
+ expect(flattenBundle({ loginButton: 'Log in', errors: { required: 'Required' } })).toEqual({
30
+ loginButton: 'Log in',
31
+ });
32
+ });
33
+
34
+ it('drops leaves that an override could not represent', () => {
35
+ expect(flattenBundle({ ok: 'Fine', list: ['a', 'b'], count: 3 })).toEqual({ ok: 'Fine' });
36
+ });
37
+
38
+ it('tolerates a missing bundle', () => {
39
+ expect(flattenBundle(undefined)).toEqual({});
40
+ });
41
+ });
42
+
43
+ describe('getLoadedNamespaces', () => {
44
+ it('lists the loaded namespaces, hiding extension-scoped ones', () => {
45
+ window.i18next = {
46
+ ...window.i18next,
47
+ store: {
48
+ data: {
49
+ en: {
50
+ core: {},
51
+ '@openmrs/esm-login-app': {},
52
+ '@openmrs/esm-login-app___some-slot___some-extension': {},
53
+ },
54
+ },
55
+ },
56
+ } as unknown as typeof window.i18next;
57
+
58
+ expect(getLoadedNamespaces('en')).toEqual(['core', '@openmrs/esm-login-app']);
59
+ });
60
+
61
+ it('returns nothing for a language with no resources', () => {
62
+ expect(getLoadedNamespaces('km')).toEqual([]);
63
+ });
64
+ });
65
+
66
+ describe('findOverrideSource', () => {
67
+ const overrides = {
68
+ en: {
69
+ loginButton: { _value: 'Sign in', _source: 'temporary config' },
70
+ },
71
+ };
72
+
73
+ it('reports the config an override came from', () => {
74
+ expect(findOverrideSource(overrides, 'en', 'loginButton')).toBe('temporary config');
75
+ });
76
+
77
+ it('reports nothing for a key, language, or namespace that is not overridden', () => {
78
+ expect(findOverrideSource(overrides, 'en', 'locationsHeader')).toBeUndefined();
79
+ expect(findOverrideSource(overrides, 'km', 'loginButton')).toBeUndefined();
80
+ expect(findOverrideSource(undefined, 'en', 'loginButton')).toBeUndefined();
81
+ });
82
+
83
+ it('ignores the schema’s own default, which is not a per-key leaf', () => {
84
+ expect(findOverrideSource({ _value: {}, _source: 'default' }, 'en', 'loginButton')).toBeUndefined();
85
+ });
86
+ });
87
+
88
+ describe('loadTranslationNamespace', () => {
89
+ it('also loads the fallback languages the namespace is missing, which the table lists keys from', async () => {
90
+ const loaded = new Set(['en']);
91
+ const reloadResources = vi.fn((lngs: Array<string>, _ns: Array<string>, done: () => void) => {
92
+ lngs.forEach((lng) => loaded.add(lng));
93
+ done();
94
+ });
95
+ window.i18next = {
96
+ ...window.i18next,
97
+ reloadResources,
98
+ hasResourceBundle: (lng: string) => loaded.has(lng),
99
+ services: { languageUtils: { toResolveHierarchy: () => ['fr-CA', 'fr', 'en'] } },
100
+ } as unknown as typeof window.i18next;
101
+
102
+ await loadTranslationNamespace('@openmrs/esm-login-app', 'fr-CA');
103
+
104
+ // `en` is already loaded; `fr-CA` is always fetched, since it is the language being browsed.
105
+ expect(reloadResources).toHaveBeenCalledWith(['fr-CA', 'fr'], ['@openmrs/esm-login-app'], expect.any(Function));
106
+ });
107
+
108
+ describe('with i18next’s record of each load', () => {
109
+ const namespace = '@openmrs/esm-login-app';
110
+ let state: Record<string, number>;
111
+ let loaded: Set<string>;
112
+
113
+ beforeEach(() => {
114
+ state = {};
115
+ loaded = new Set();
116
+ window.i18next = {
117
+ ...window.i18next,
118
+ hasResourceBundle: (lng: string, ns: string) => loaded.has(`${lng}|${ns}`),
119
+ services: { backendConnector: { state }, languageUtils: { toResolveHierarchy: () => ['en'] } },
120
+ } as unknown as typeof window.i18next;
121
+ });
122
+
123
+ it('retries a namespace that failed before, which i18next would otherwise skip', async () => {
124
+ state[`en|${namespace}`] = -1;
125
+ window.i18next.reloadResources = vi.fn((_lngs, _ns, done) => {
126
+ // i18next skips a pair still marked failed, so the load only happens if the mark was cleared.
127
+ if (state[`en|${namespace}`] >= 0) {
128
+ state[`en|${namespace}`] = 2;
129
+ loaded.add(`en|${namespace}`);
130
+ }
131
+ done?.();
132
+ }) as unknown as typeof window.i18next.reloadResources;
133
+
134
+ await expect(loadTranslationNamespace(namespace, 'en')).resolves.toBeUndefined();
135
+ });
136
+
137
+ it('reports a load that failed even though i18next called back without an error', async () => {
138
+ window.i18next.reloadResources = vi.fn((_lngs, _ns, done) => {
139
+ state[`en|${namespace}`] = -1;
140
+ done?.();
141
+ }) as unknown as typeof window.i18next.reloadResources;
142
+
143
+ await expect(loadTranslationNamespace(namespace, 'en')).rejects.toThrow(/failed; try again/);
144
+ });
145
+
146
+ it('ignores an error from another namespace’s load', async () => {
147
+ window.i18next.reloadResources = vi.fn((_lngs, _ns, done) => {
148
+ state[`en|${namespace}`] = 2;
149
+ loaded.add(`en|${namespace}`);
150
+ done?.([new Error('core failed')]);
151
+ }) as unknown as typeof window.i18next.reloadResources;
152
+
153
+ await expect(loadTranslationNamespace(namespace, 'en')).resolves.toBeUndefined();
154
+ });
155
+
156
+ describe('when a read never finishes', () => {
157
+ beforeEach(() => vi.useFakeTimers());
158
+ afterEach(() => vi.useRealTimers());
159
+
160
+ it('gives up, and lets the next attempt start a read of its own', async () => {
161
+ window.i18next.reloadResources = vi.fn(() => {
162
+ state[`en|${namespace}`] = 1;
163
+ }) as unknown as typeof window.i18next.reloadResources;
164
+
165
+ const hung = loadTranslationNamespace(namespace, 'en');
166
+ const assertion = expect(hung).rejects.toThrow(/did not finish/);
167
+ await vi.advanceTimersByTimeAsync(15_000);
168
+ await assertion;
169
+
170
+ // Left marked as loading, i18next would attach the next attempt to the read that never ended.
171
+ expect(state[`en|${namespace}`]).toBeUndefined();
172
+ });
173
+
174
+ it('gives up on loading a language whose namespace read hangs', async () => {
175
+ loaded.add(`fr|${namespace}`);
176
+ window.i18next.languages = ['fr'];
177
+ window.i18next.store = { data: { fr: { [namespace]: {} } } } as unknown as typeof window.i18next.store;
178
+ window.i18next.reloadResources = vi.fn(() => {
179
+ state[`de|${namespace}`] = 1;
180
+ }) as unknown as typeof window.i18next.reloadResources;
181
+
182
+ const hung = loadTranslationLanguage('de');
183
+ const assertion = expect(hung).rejects.toThrow(/did not finish/);
184
+ await vi.advanceTimersByTimeAsync(15_000);
185
+ await assertion;
186
+ });
187
+ });
188
+ });
189
+ });
190
+
191
+ describe('useTranslationEntries', () => {
192
+ async function setUpI18next(lng: string, resources: Record<string, Record<string, Record<string, string>>>) {
193
+ const i18n = i18next.createInstance();
194
+ await i18n.init({ lng, fallbackLng: 'en', nsSeparator: false, resources });
195
+ window.i18next = i18n as unknown as typeof window.i18next;
196
+ implementerToolsConfigStore.setState({ config: {} });
197
+ return i18n;
198
+ }
199
+
200
+ it('lists every plural form the selected language renders through, even ones no bundle has', async () => {
201
+ const i18n = await setUpI18next('ar', {
202
+ en: { mod: { items_one: '{{count}} item', items_other: '{{count}} items' } },
203
+ ar: { mod: {} },
204
+ });
205
+
206
+ const { result } = renderHook(() => useTranslationEntries(['mod'], 'ar'));
207
+ const listed = result.current.filter((entry) => entry.key.startsWith('items_')).map((entry) => entry.key);
208
+
209
+ // Overriding every listed form must change what Arabic renders for any count.
210
+ i18n.addResourceBundle('ar', 'mod', Object.fromEntries(listed.map((key) => [key, 'AR'])), true, true);
211
+
212
+ for (const count of [0, 1, 2, 3, 11, 100]) {
213
+ expect(i18n.t('items', { ns: 'mod', lng: 'ar', count })).toBe('AR');
214
+ }
215
+ });
216
+
217
+ it('recomputes for bundles it lists, but not for other namespaces or languages', async () => {
218
+ const i18n = await setUpI18next('fr', { en: { mod: { save: 'Save' } }, fr: { mod: {} } });
219
+
220
+ const { result } = renderHook(() => useTranslationEntries(['mod'], 'fr'));
221
+ const initial = result.current;
222
+
223
+ act(() => {
224
+ i18n.addResourceBundle('fr', 'mod___slot___extension', { save: 'Ext' });
225
+ i18n.addResourceBundle('de', 'mod', { save: 'Speichern' });
226
+ i18n.addResourceBundle('fr', 'other', { save: 'Autre' });
227
+ });
228
+ expect(result.current).toBe(initial);
229
+
230
+ act(() => i18n.addResourceBundle('en', 'mod', { cancel: 'Cancel' }, true));
231
+ expect(result.current.map((entry) => entry.key)).toEqual(['cancel', 'save']);
232
+ });
233
+
234
+ it('points a base key at the plural forms of the selected language', async () => {
235
+ await setUpI18next('ar', {
236
+ en: { mod: { items: 'Items', items_one: '{{count}} item', items_other: '{{count}} items' } },
237
+ });
238
+
239
+ const { result } = renderHook(() => useTranslationEntries(['mod'], 'ar'));
240
+
241
+ expect(result.current.find((entry) => entry.key === 'items')?.pluralForms).toEqual([
242
+ 'items_zero',
243
+ 'items_one',
244
+ 'items_two',
245
+ 'items_few',
246
+ 'items_many',
247
+ 'items_other',
248
+ ]);
249
+ });
250
+
251
+ it('reads a key named like a built-in object property from the bundle that has it', async () => {
252
+ await setUpI18next('fr', {
253
+ fr: { mod: { save: 'Enregistrer' } },
254
+ en: { mod: { save: 'Save', toString: 'Convert to text' } },
255
+ });
256
+
257
+ const { result } = renderHook(() => useTranslationEntries(['mod'], 'fr'));
258
+ const entry = result.current.find((candidate) => candidate.key === 'toString');
259
+
260
+ expect(entry?.value).toBe('Convert to text');
261
+ expect(entry?.sourceLanguage).toBe('en');
262
+ });
263
+
264
+ it('attributes a value shown from a fallback language to the override that supplies it', async () => {
265
+ // The backend merges the en override into the en bundle; fr has no value for the key.
266
+ await setUpI18next('fr', { en: { mod: { greeting: 'Overridden hello' } }, fr: { mod: {} } });
267
+ implementerToolsConfigStore.setState({
268
+ config: {
269
+ mod: {
270
+ 'Translation overrides': {
271
+ en: { greeting: { _value: 'Overridden hello', _source: 'temporary config' } },
272
+ },
273
+ },
274
+ },
275
+ });
276
+
277
+ const { result } = renderHook(() => useTranslationEntries(['mod'], 'fr'));
278
+
279
+ expect(result.current).toEqual([
280
+ expect.objectContaining({
281
+ key: 'greeting',
282
+ value: 'Overridden hello',
283
+ sourceLanguage: 'en',
284
+ overrideSource: 'temporary config',
285
+ }),
286
+ ]);
287
+ });
288
+ });
289
+
290
+ describe('useTranslationLanguages', () => {
291
+ it('offers each server locale as the language i18next runs it as', async () => {
292
+ const i18n = i18next.createInstance();
293
+ await i18n.init({ lng: 'en', fallbackLng: 'en', resources: { en: { mod: {} } } });
294
+ window.i18next = i18n as unknown as typeof window.i18next;
295
+ vi.mocked(useSession).mockReturnValue({
296
+ authenticated: true,
297
+ sessionId: '',
298
+ allowedLocales: ['en', 'en_us', 'sw_KE', 'uz@Latn'],
299
+ } as ReturnType<typeof useSession>);
300
+
301
+ const { result } = renderHook(() => useTranslationLanguages('en'));
302
+
303
+ // `uz@Latn` keeps its modifier: overrides keyed `uz-Latn` would never be read.
304
+ expect(result.current).toEqual(['en', 'en-US', 'sw-KE', 'uz@Latn']);
305
+ });
306
+ });
@@ -0,0 +1,302 @@
1
+ import { useEffect, useMemo, useRef, useState } from 'react';
2
+ import { useSession } from '@openmrs/esm-framework';
3
+ import {
4
+ extensionNamespaceSeparator,
5
+ implementerToolsConfigStore,
6
+ useStore,
7
+ } from '@openmrs/esm-framework/src/internal';
8
+ import { useFrontendModules } from '../hooks';
9
+ import { clearFailedLoads, findLoadFailure, releaseStalledLoads, withTimeout } from './i18next-loads';
10
+
11
+ /** The namespace holding the framework's own translations. It belongs to no frontend module. */
12
+ export const coreNamespace = 'core';
13
+
14
+ /** The reserved config property through which translations are overridden. */
15
+ export const translationOverridesKey = 'Translation overrides';
16
+
17
+ /**
18
+ * The `_source` the config system attributes to values set through the implementer tools. Only those
19
+ * can be reset from here; anything else comes from a config the distribution supplies.
20
+ */
21
+ export const temporaryConfigSource = 'temporary config';
22
+
23
+ export interface TranslationNamespace {
24
+ name: string;
25
+ /** Whether i18next holds resources for this namespace, in which case its keys are browsable. */
26
+ isLoaded: boolean;
27
+ }
28
+
29
+ export interface TranslationEntry {
30
+ namespace: string;
31
+ key: string;
32
+ /** The value i18next holds for the key, before interpolation. An override, where one applies. */
33
+ value: string;
34
+ /**
35
+ * The name of the config that supplies an override for this key in `sourceLanguage`, if any.
36
+ * `undefined` means the value comes from the namespace's translation file.
37
+ */
38
+ overrideSource?: string;
39
+ /**
40
+ * The language the value was actually read from. It differs from the selected one when the key is
41
+ * missing from that language's bundle and i18next would fall back, which an implementer needs to
42
+ * see before treating the value as the text they are overriding.
43
+ */
44
+ sourceLanguage: string;
45
+ /**
46
+ * The plural forms the selected language renders this key through, when the key has any. i18next
47
+ * prefers a suffixed form over the base key, so overriding the base alone leaves these untouched.
48
+ */
49
+ pluralForms: Array<string>;
50
+ }
51
+
52
+ /**
53
+ * The plural categories i18next suffixes a key with. Context variants (`_male` and the like) are not
54
+ * guessed at: the suffix is arbitrary application data, so detecting one would report unrelated keys
55
+ * as variants of each other.
56
+ */
57
+ const pluralSuffixes = ['zero', 'one', 'two', 'few', 'many', 'other'];
58
+
59
+ const pluralFormPattern = new RegExp(`^(.+)_(${pluralSuffixes.join('|')})$`);
60
+
61
+ /** The key a plural form belongs to, such as `items` for `items_few`. */
62
+ function getPluralBase(key: string): string | undefined {
63
+ return pluralFormPattern.exec(key)?.[1];
64
+ }
65
+
66
+ /**
67
+ * Lists the namespaces whose translations can be browsed: everything i18next has loaded, plus every
68
+ * installed frontend module, so that a module the user has not visited yet can still be loaded on
69
+ * demand via `loadTranslationNamespace`.
70
+ */
71
+ export function useTranslationNamespaces(language: string): Array<TranslationNamespace> {
72
+ const frontendModules = useFrontendModules();
73
+ const revision = useI18nextRevision(
74
+ (lng, namespace) => lng === language && !namespace.includes(extensionNamespaceSeparator),
75
+ );
76
+
77
+ return useMemo(() => {
78
+ const loaded = getLoadedNamespaces(language);
79
+ const names = new Set([coreNamespace, ...frontendModules.map((module) => module.name), ...loaded]);
80
+
81
+ return Array.from(names)
82
+ .sort((a, b) => a.localeCompare(b))
83
+ .map((name) => ({ name, isLoaded: loaded.includes(name) }));
84
+ }, [frontendModules, language, revision]);
85
+ }
86
+
87
+ /**
88
+ * Builds the browsable list of translations for the given namespaces and language.
89
+ *
90
+ * Keys are collected across i18next's whole language resolution hierarchy rather than from the
91
+ * selected language alone: a key that only exists in the fallback language still renders in the UI,
92
+ * and is still something an implementer needs to be able to override for their own language. For
93
+ * the same reason, every plural form the selected language needs is listed, even one no bundle has.
94
+ */
95
+ export function useTranslationEntries(namespaces: Array<string>, language: string): Array<TranslationEntry> {
96
+ const { config } = useStore(implementerToolsConfigStore);
97
+ const revision = useI18nextRevision(
98
+ (lng, namespace) => namespaces.includes(namespace) && getResolutionHierarchy(language).includes(lng),
99
+ );
100
+
101
+ return useMemo(() => {
102
+ const languages = getResolutionHierarchy(language);
103
+ const pluralFormSuffixes = window.i18next?.services?.pluralResolver?.getSuffixes?.(language) ?? [];
104
+
105
+ return namespaces.flatMap((namespace) => {
106
+ const bundles = languages.map((lng) => flattenBundle(window.i18next?.store?.data?.[lng]?.[namespace]));
107
+ const bundleKeys = new Set(bundles.flatMap((bundle) => Object.keys(bundle)));
108
+ const pluralKeys = new Set(Array.from(bundleKeys, getPluralBase).filter((base) => base !== undefined));
109
+ const getPluralForms = (key: string) =>
110
+ pluralKeys.has(key) ? pluralFormSuffixes.map((suffix) => `${key}${suffix}`) : [];
111
+ const keys = Array.from(new Set([...bundleKeys, ...Array.from(pluralKeys).flatMap(getPluralForms)])).sort(
112
+ (a, b) => a.localeCompare(b),
113
+ );
114
+ const overrides = config?.[namespace]?.[translationOverridesKey];
115
+
116
+ return keys.map((key) => {
117
+ const source = bundles.findIndex((bundle) => Object.hasOwn(bundle, key));
118
+ const sourceLanguage = languages[source === -1 ? 0 : source];
119
+
120
+ return {
121
+ namespace,
122
+ key,
123
+ value: source === -1 ? '' : bundles[source][key],
124
+ sourceLanguage,
125
+ overrideSource: findOverrideSource(overrides, sourceLanguage, key),
126
+ pluralForms: getPluralForms(key),
127
+ };
128
+ });
129
+ });
130
+ }, [config, namespaces, language, revision]);
131
+ }
132
+
133
+ /**
134
+ * Loads a namespace's resources for the language being browsed, and for any of its fallback
135
+ * languages not loaded yet, since the table also lists the keys only a fallback language has.
136
+ *
137
+ * `reloadResources` rather than `loadNamespaces` because the latter fetches for i18next's active
138
+ * language, which is not necessarily the one selected here.
139
+ */
140
+ export function loadTranslationNamespace(namespace: string, language: string): Promise<void> {
141
+ const languages = getResolutionHierarchy(language).filter(
142
+ (candidate) => candidate === language || !window.i18next.hasResourceBundle(candidate, namespace),
143
+ );
144
+
145
+ clearFailedLoads(languages, [namespace]);
146
+
147
+ return withTimeout(
148
+ new Promise<void>((resolve, reject) => {
149
+ const done = (error?: unknown) => {
150
+ const failure = findLoadFailure(languages, [namespace], error);
151
+ return failure ? reject(failure) : resolve();
152
+ };
153
+
154
+ // i18next declares this callback as taking no arguments but calls it with the load error.
155
+ // It expands a language into its fallbacks only when given a single string, so they are listed.
156
+ window.i18next.reloadResources(languages, [namespace], done as () => void);
157
+ }),
158
+ `Loading ${namespace} for ${language} did not finish`,
159
+ ).catch((error) => {
160
+ releaseStalledLoads(languages, [namespace]);
161
+ throw error;
162
+ });
163
+ }
164
+
165
+ /**
166
+ * The languages an implementer can author overrides for: every locale the server permits, plus
167
+ * anything i18next has already loaded, plus whatever is currently selected.
168
+ *
169
+ * The server's list is the authoritative one, and it is what makes a locale the user is not running
170
+ * in reachable at all. Each locale is listed as the language i18next runs it as, which is the key its
171
+ * `Translation overrides` are read under.
172
+ */
173
+ export function useTranslationLanguages(selectedLanguage: string): Array<string> {
174
+ const session = useSession();
175
+ const revision = useI18nextRevision();
176
+
177
+ return useMemo(() => {
178
+ // As `setUserLanguage` does, then normalised as i18next normalises the language it runs in.
179
+ const allowed = (session?.allowedLocales ?? []).map((locale) => {
180
+ const language = locale.replaceAll('_', '-');
181
+ return window.i18next?.services?.languageUtils?.formatLanguageCode?.(language) ?? language;
182
+ });
183
+
184
+ return Array.from(new Set([...allowed, ...getLoadedLanguages(), selectedLanguage])).sort((a, b) =>
185
+ a.localeCompare(b),
186
+ );
187
+ }, [revision, selectedLanguage, session]);
188
+ }
189
+
190
+ /** The languages i18next currently holds resources for. */
191
+ export function getLoadedLanguages(): Array<string> {
192
+ return Object.keys(window.i18next?.store?.data ?? {});
193
+ }
194
+
195
+ /**
196
+ * Fetches, for a language the application is not running in, the namespaces the application has
197
+ * loaded, which is what lets an implementer browse and override a locale other than their own.
198
+ *
199
+ * Not `loadLanguages`: it also requests i18next's default `translation` namespace, which the app
200
+ * shell refuses, so it always reports a failure; and it adds the language to `preload`, so every
201
+ * namespace the application loads afterwards is fetched in that language too.
202
+ */
203
+ export async function loadTranslationLanguage(language: string): Promise<void> {
204
+ const namespaces = new Set((window.i18next.languages ?? []).flatMap((running) => getLoadedNamespaces(running)));
205
+
206
+ await Promise.all(Array.from(namespaces, (namespace) => loadTranslationNamespace(namespace, language)));
207
+ }
208
+
209
+ export function getLoadedNamespaces(language: string): Array<string> {
210
+ return Object.keys(window.i18next?.store?.data?.[language] ?? {}).filter(
211
+ (namespace) => !namespace.includes(extensionNamespaceSeparator),
212
+ );
213
+ }
214
+
215
+ /**
216
+ * The top-level string entries of a resource bundle.
217
+ *
218
+ * Nested entries are left out rather than flattened to `a.b`. An override is written at the literal
219
+ * path it is given, and i18next resolves `a.b` by walking `a` then `b` before ever looking for a
220
+ * flat key of that name, so a nested key could be listed and edited here but never actually
221
+ * overridden — offering an action that silently does nothing is worse than not listing it. O3's
222
+ * translation files are flat, so nothing is hidden in practice.
223
+ */
224
+ export function flattenBundle(bundle: unknown): Record<string, string> {
225
+ if (!bundle || typeof bundle !== 'object') {
226
+ return {};
227
+ }
228
+
229
+ return Object.entries(bundle).reduce<Record<string, string>>((result, [key, value]) => {
230
+ if (typeof value === 'string') {
231
+ result[key] = value;
232
+ }
233
+
234
+ return result;
235
+ }, {});
236
+ }
237
+
238
+ /**
239
+ * Reports which config supplies an override for a key, or `undefined` if none does.
240
+ *
241
+ * The implementer tools config is a tree of `_value`/`_source` leaves. The config system builds
242
+ * that tree by recursing through every provided config, so an override always appears as a leaf at
243
+ * `[language][key]`, whether it came from a distribution's config file or from an edit made here.
244
+ */
245
+ export function findOverrideSource(overrides: unknown, language: string, key: string): string | undefined {
246
+ const languageNode = isRecord(overrides) ? overrides[language] : undefined;
247
+ const leaf = isRecord(languageNode) ? languageNode[key] : undefined;
248
+ const source = isRecord(leaf) && '_value' in leaf ? leaf._source : undefined;
249
+
250
+ return typeof source === 'string' ? source : undefined;
251
+ }
252
+
253
+ function isRecord(value: unknown): value is Record<string, unknown> {
254
+ return Boolean(value) && typeof value === 'object';
255
+ }
256
+
257
+ /**
258
+ * The languages i18next would consult for the one being browsed, so a key it would resolve from a
259
+ * fallback is listed with the value it would actually render. `i18next.languages` is not that: it is
260
+ * the chain for whichever language the application is running in, so browsing `es` from a French app
261
+ * would otherwise attribute French values to Spanish.
262
+ */
263
+ function getResolutionHierarchy(language: string): Array<string> {
264
+ const resolved = window.i18next?.services?.languageUtils?.toResolveHierarchy?.(language) ?? [];
265
+ return Array.from(new Set([language, ...resolved]));
266
+ }
267
+
268
+ /**
269
+ * Bumps a counter whenever i18next's resources change, giving the catalog a dependency it can
270
+ * recompute on. i18next's resource store is not a zustand store, so it can't be read with
271
+ * `useStore`.
272
+ *
273
+ * @param isRelevant Limits the bumps to the bundles a caller shows, so that loads elsewhere, such as
274
+ * an extension's namespace or another language, don't make it recompute. Reads the latest one
275
+ * passed, so it need not be memoised.
276
+ */
277
+ function useI18nextRevision(isRelevant: (language: string, namespace: string) => boolean = () => true): number {
278
+ const [revision, setRevision] = useState(0);
279
+ const isRelevantRef = useRef(isRelevant);
280
+ isRelevantRef.current = isRelevant;
281
+
282
+ useEffect(() => {
283
+ const store = window.i18next?.store;
284
+ if (typeof store?.on !== 'function') {
285
+ return;
286
+ }
287
+
288
+ const bump = (language: string, namespace: string) => {
289
+ if (isRelevantRef.current(language, namespace)) {
290
+ setRevision((current) => current + 1);
291
+ }
292
+ };
293
+ // Only `added`: nothing in this feature removes a bundle, so `removed` would never fire anyway.
294
+ store.on('added', bump);
295
+
296
+ return () => {
297
+ store.off('added', bump);
298
+ };
299
+ }, []);
300
+
301
+ return revision;
302
+ }