@openmrs/esm-cohort-builder-app 4.0.7-pre.1367 → 4.0.7-pre.1371
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/800.js
CHANGED
|
@@ -9,7 +9,7 @@ If you're the maintainer: the allowed types are ${Object.values(rx).join(", ")}.
|
|
|
9
9
|
If you're the maintainer: all config elements must have a default. Received ${JSON.stringify(a)}`),s&&l&&![rx.Array,rx.Object].includes(l)&&console.error(`${e} has bad config schema definition for key '${i}'. ${r}.
|
|
10
10
|
|
|
11
11
|
If you're the maintainer: the 'elements' key only works with '_type' equal to 'Array' or 'Object'. Received ${JSON.stringify(l)}`)}}function r6(e,t){return r8(t.map(({[e]:t})=>t).filter(e=>!!e))}function r8(e){return e.reduce((e,t)=>rU(e,t),{})}function r7(e,t,n=""){for(let r of Object.keys(t)){let o=t[r],i=n+"."+r,a=e[r];if(!e.hasOwnProperty(r)){("extensionSlots"!==r||""===n)&&oa(i,`Unknown config key '${i}' provided. Ignoring.`);continue}(function e(t,n,r){oe(r,t._type,n),oo(n)?t._type===rx.Object?function(t,n,r){if(t._elements)for(let o of Object.keys(n)){let i=n[o];e(t._elements,i,`${r}.${o}`)}}(t,n,r):t.hasOwnProperty("_default")||t.hasOwnProperty("_type")||r7(t,n,r):t._type===rx.Array&&function(t,n,r){if(oe(r,rx.Array,n)){if(or(t._elements))for(let o=0;o<n.length;o++)e(t._elements,n[o],`${r}[${o}]`);for(let e=0;e<n.length;e++)oe(`${r}[${e}]`,t._elements?._type,n[e])}}(t,n,r)})(a,o,i)}}rK();function r9(e,t,n=""){if(e){if(t!==e._default&&ot(n,e._validators,t),oo(t))for(let r of Object.keys(t)){let o=t[r],i=n+"."+r,a=e[r];e._type===rx.Object&&e._elements?r9(e._elements,o,i):r9(a,o,i)}else if(Array.isArray(t)&&e._elements)for(let r=0;r<t.length;r++)r9(e._elements,t[r],`${n}[${r}]`)}}function oe(e,t,n){return!t||ot(e,[{Array:rE,Boolean:rS,ConceptUuid:rO,Number:rD,Object:rz,String:rM,UUID:rO,PersonAttributeTypeUuid:rO,PatientIdentifierTypeUuid:rO}[t]],n)}function ot(e,t,n){let r=!0;if(t)try{for(let o of t){let t=o(n);if("string"==typeof t){let o="object"==typeof n?`Invalid configuration for ${e}: ${t}`:`Invalid configuration value ${n} for ${e}: ${t}`;oa(e,o),r=!1}}}catch(t){console.error(`Skipping invalid validator at "${e}". Encountered error
|
|
12
|
-
${t}`)}return r}let on=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let r=n[t],o=e[t];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=o._default);let e=o._elements;if(r&&or(e)){if(o._type===rx.Array&&Array.isArray(r)){let o=r.map(t=>on(e,t));n[t]=o}else if(o._type===rx.Object)for(let t of Object.keys(r))r[t]=on(e,r[t])}}else if(oo(o)){let e=r??{};oo(e)&&(n[t]=on(o,e))}}return n};function or(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function oo(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let oi=new Set;function oa(e,t){let n=`${e}:::${t}`;oi||(oi=new Set),oi.has(n)||(console.error(t),oi.add(n))}function os(e){e?oi.forEach(t=>{t.startsWith(e)&&oi.delete(t)}):oi.clear()}function ol(){rq.forEach(e=>e()),rq.length=0,rK()}let oc={"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:rx.Object,_default:{},_validators:[rC(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(", ")}.`})]}},ou={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:rx.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:rx.String,_default:void 0}},...oc},op=(e,t)=>rC(n=>e<=n&&n<=t,`must be between ${e} and ${t}`),od=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return rC(e=>{if(!e||"string"!=typeof e)return!1;let n=/\${(.*?)}/g,r=n.exec(e);for(;r;){if(!t.includes(r[1]))return!1;r=n.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},of=od([]),oh=e=>rC(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),om={inRange:op,isUrl:of,isUrlWithTemplateParameters:od,oneOf:oh};var og=n(8067);let ob=V("breadcrumbs",[]);function oy(e){return o_([e])}function o_(e){let t=[...ov(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,og.pathToRegexp)(e.matcher).regexp:(0,og.pathToRegexp)(e.path).regexp,settings:e}))];ob.setState(t,!0)}function ov(){return ob.getState()}function oA(e,t){if(t)return function(e,t){let[n]=e.filter(e=>e.matcher.test(t));return n}(e,t)||function(e,t){let n=t.split("/");for(;n.length>1;){n.pop();let t=oA(e,n.join("/"));if(t)return t}}(e,t)}function o$(e,t){if(e.length>0){let n=oA(e,t);if(n){let t=[n],r=oA(e,n.settings.parent);for(;void 0!==r;)t.push(r),r=oA(e,r.settings.parent);return t.reverse()}}return[]}function ow(e){return o$(ov(),e)}var ok=Object.freeze({__proto__:null,get start(){return iJ},get ensureJQuerySupport(){return ix},get setBootstrapMaxTime(){return ii},get setMountMaxTime(){return ia},get setUnmountMaxTime(){return is},get setUnloadMaxTime(){return il},get registerApplication(){return ij},get unregisterApplication(){return iN},get getMountedApps(){return iO},get getAppStatus(){return iT},get unloadApplication(){return iR},get checkActivityFunctions(){return iI},get getAppNames(){return iP},get pathToActiveWhen(){return iW},get navigateToUrl(){return ig},get patchHistoryApi(){return i$},get triggerAppChange(){return iq},get addErrorHandler(){return oD},get removeErrorHandler(){return oM},get mountRootParcel(){return o9},get NOT_LOADED(){return oP},get LOADING_SOURCE_CODE(){return oT},get NOT_BOOTSTRAPPED(){return oB},get BOOTSTRAPPING(){return oj},get NOT_MOUNTED(){return oI},get MOUNTING(){return oN},get UPDATING(){return oF},get LOAD_ERROR(){return oG},get MOUNTED(){return oR},get UNLOADING(){return oW},get UNMOUNTING(){return oL},get SKIP_BECAUSE_BROKEN(){return oV}}),ox=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,oC=!function(){try{var e=new ox("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var n=document.createEvent("CustomEvent");return t?n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):n.initCustomEvent(e,!1,!1,void 0),n}:function(e,t){var n=document.createEventObject();return n.type=e,t?(n.bubbles=!!t.bubbles,n.cancelable=!!t.cancelable,n.detail=t.detail):(n.bubbles=!1,n.cancelable=!1,n.detail=void 0),n}:ox;let oE=[];function oS(e,t,n){let r=oO(e,t,n);oE.length?oE.forEach(e=>e(r)):setTimeout(()=>{throw r})}function oD(e){if("function"!=typeof e)throw Error(oz(28,!1));oE.push(e)}function oM(e){if("function"!=typeof e)throw Error(oz(29,!1));let t=!1;return oE=oE.filter(n=>{let r=n===e;return t=t||r,!r}),t}function oz(e,t,...n){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${n.length?`&arg=${n.join("&arg=")}`:""}`}function oO(e,t,n){let r,o=`${oY(t)} '${oH(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(oz(30,!1,t.status,oH(t)));try{r=Error(o+JSON.stringify(e))}catch(t){r=e}}return r.appOrParcelName=oH(t),t.status=n,r}let oP="NOT_LOADED",oT="LOADING_SOURCE_CODE",oB="NOT_BOOTSTRAPPED",oj="BOOTSTRAPPING",oI="NOT_MOUNTED",oN="MOUNTING",oR="MOUNTED",oF="UPDATING",oL="UNMOUNTING",oW="UNLOADING",oG="LOAD_ERROR",oV="SKIP_BECAUSE_BROKEN";function oU(e){return e.status===oR}function oq(e){try{return e.activeWhen(window.location)}catch(t){return oS(t,e,oV),!1}}function oH(e){return e.name}function oK(e){return!!e.unmountThisParcel}function oY(e){return oK(e)?"parcel":"application"}function oJ(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function oZ(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}function oX(e){return e&&("function"==typeof e||Array.isArray(e)&&!oZ(e,e=>"function"!=typeof e))}function oQ(e,t){let n=e[t]||[];0===(n=Array.isArray(n)?n:[n]).length&&(n=[()=>Promise.resolve()]);let r=oY(e),o=oH(e);return function(e){return n.reduce((n,i,a)=>n.then(()=>{let n=i(e);return o0(n)?n:Promise.reject(oz(15,!1,r,o,t,a))}),Promise.resolve())}}function o0(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let o1=[];function o2(e,t){return Promise.resolve().then(()=>e.status!==oB?e:(e.status=oj,e.bootstrap?ic(e,"bootstrap").then(n).catch(n=>{if(t)throw oO(n,e,oV);return oS(n,e,oV),e}):Promise.resolve().then(n)));function n(){return e.status=oI,e}}function o3(e,t){return Promise.resolve().then(()=>{if(e.status!==oR)return e;return e.status=oL,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(n,r=>n().then(()=>{let n=Error(r.message);if(t)throw oO(n,e,oV);oS(n,e,oV)})).then(()=>e);function n(){return ic(e,"unmount").then(()=>{e.status=oI},n=>{if(t)throw oO(n,e,oV);oS(n,e,oV)})}})}let o4=!1,o5=!1;function o6(e,t){return Promise.resolve().then(()=>e.status!==oI?e:(o4||(window.dispatchEvent(new oC("single-spa:before-first-mount")),o4=!0),e.status=oN,ic(e,"mount").then(()=>(e.status=oR,o5||(window.dispatchEvent(new oC("single-spa:first-mount")),o5=!0),e)).catch(n=>{return e.status=oR,o3(e,!0).then(r,r);function r(){if(t)throw oO(n,e,oV);return oS(n,e,oV),e}})))}let o8=0,o7={parcels:{}};function o9(){return ie.apply(o7,arguments)}function ie(e,t){let n,r,o,i=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(oz(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(oz(3,!1,typeof e.name));let a=o8++,s=e.name||`parcel-${a}`;if("object"!=typeof t)throw Error(oz(4,!1,s,typeof t));if(!t.domElement)throw Error(oz(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:a,parcels:{},status:l?oT:oB,customProps:t,parentName:oH(i),unmountThisParcel:()=>f.then(()=>{if(u.status!==oR)throw Error(oz(6,!1,s,u.status));return o3(u,!0)}).then(e=>(u.parentName&&delete i.parcels[u.id],e)).then(e=>(r(e),e)).catch(e=>{throw u.status=oV,o(e),e})};i.parcels[a]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(oz(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(oz(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!oX(e.bootstrap))throw Error(oz(9,!1,s));if(!oX(e.mount))throw Error(oz(10,!1,s));if(!oX(e.unmount))throw Error(oz(11,!1,s));if(e.update&&!oX(e.update))throw Error(oz(12,!1,s));let t=oQ(e,"bootstrap"),r=oQ(e,"mount"),o=oQ(e,"unmount");u.status=oB,u.name=s,u.bootstrap=t,u.mount=r,u.unmount=o,u.timeouts=iu(e.timeouts),e.update&&(u.update=oQ(e,"update"),n.update=function(e){return u.customProps=e,it(Promise.resolve().then(()=>{if(u.status!==oR)throw Error(oz(32,!1,oH(u)));return u.status=oF,ic(u,"update").then(()=>(u.status=oR,u)).catch(e=>{throw oO(e,u,oV)})}))})})).then(()=>o2(u,!0)),f=d.then(()=>o6(u,!0)),h=new Promise((e,t)=>{r=e,o=t});return n={mount:()=>it(Promise.resolve().then(()=>{if(u.status!==oI)throw Error(oz(13,!1,s,u.status));return i.parcels[a]=u,o6(u)})),unmount:()=>it(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:it(p),bootstrapPromise:it(d),mountPromise:it(f),unmountPromise:it(h)}}function it(e){return e.then(()=>null)}function ir(e){let t=oH(e),n="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof n||null===n||Array.isArray(n))&&(n={},console.warn(oz(40,!1),t,n));let r=oJ({},n,{name:t,mountParcel:ie.bind(e),singleSpa:ok});return oK(e)&&(r.unmountSelf=e.unmountThisParcel),r}let io={bootstrap:{millis:4e3,dieOnTimeout:!1,warningMillis:1e3},mount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unmount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unload:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},update:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3}};function ii(e,t,n){if("number"!=typeof e||e<=0)throw Error(oz(16,!1));io.bootstrap={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ia(e,t,n){if("number"!=typeof e||e<=0)throw Error(oz(17,!1));io.mount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function is(e,t,n){if("number"!=typeof e||e<=0)throw Error(oz(18,!1));io.unmount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function il(e,t,n){if("number"!=typeof e||e<=0)throw Error(oz(19,!1));io.unload={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ic(e,t){let n=e.timeouts[t],r=n.warningMillis,o=oY(e);return new Promise((i,a)=>{let s=!1,l=!1;e[t](ir(e)).then(e=>{s=!0,i(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>u(1),r),setTimeout(()=>u(!0),n.millis);let c=oz(31,!1,t,o,oH(e),n.millis);function u(e){s||(!0===e?(l=!0,n.dieOnTimeout?a(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<n.millis&&setTimeout(()=>u(e+1),r)))}})}function iu(e){let t={};for(let n in io)t[n]=oJ({},io[n],e&&e[n]||{});return t}function ip(e){return Promise.resolve().then(()=>{let t,n;return e.loadPromise?e.loadPromise:e.status!==oP&&e.status!==oG?e:(e.status=oT,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(ir(e));if(!o0(r))throw n=!0,Error(oz(33,!1,oH(e)));return r.then(n=>{let r;e.loadErrorTime=null,"object"!=typeof(t=n)&&(r=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!oX(t.bootstrap)&&(r=35),oX(t.mount)||(r=36),oX(t.unmount)||(r=37);let o=oY(t);if(r){let n;try{n=JSON.stringify(t)}catch(e){}return console.error(oz(r,!1,o,oH(e),n),t),oS(void 0,e,oV),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=oJ({},e.devtools.overlays,t.devtools.overlays)),e.status=oB,e.bootstrap=oQ(t,"bootstrap"),e.mount=oQ(t,"mount"),e.unmount=oQ(t,"unmount"),e.unload=oQ(t,"unload"),e.timeouts=iu(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let r;return delete e.loadPromise,n?r=oV:(r=oG,e.loadErrorTime=(new Date).getTime()),oS(t,e,r),e}))})}let id="u">typeof window,ih={hashchange:[],popstate:[]},im=["hashchange","popstate"];function ig(e){let t;if("string"==typeof e)t=e;else if(this&&this.href)t=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(oz(14,!1));t=e.currentTarget.href,e.preventDefault()}let n=iw(window.location.href),r=iw(t);0===t.indexOf("#")?window.location.hash=r.hash:n.host!==r.host&&r.host?window.location.href=t:r.pathname===n.pathname&&r.search===n.search?window.location.hash=r.hash:window.history.pushState(null,null,t)}function ib(e){if(e){let t=e[0].type;im.indexOf(t)>=0&&ih[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function iy(){iH([],arguments)}function i_(e,t){return function(){let n=window.location.href,o=e.apply(this,arguments),i=window.location.href;return r&&n===i||window.dispatchEvent(function(e,t){let n;try{n=new PopStateEvent("popstate",{state:e})}catch(t){(n=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return n.singleSpa=!0,n.singleSpaTrigger=t,n}(window.history.state,t)),o}}let iv=null,iA=!1;function i$(e){if(iA)throw Error(oz(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,iA=!0,iv=window.history.replaceState,window.addEventListener("hashchange",iy),window.addEventListener("popstate",iy);let t=window.addEventListener,n=window.removeEventListener;window.addEventListener=function(e,n){if(!("function"==typeof n&&im.indexOf(e)>=0)||oZ(ih[e],e=>e===n))return t.apply(this,arguments);ih[e].push(n)},window.removeEventListener=function(e,t){return"function"==typeof t&&im.indexOf(e)>=0&&(ih[e]=ih[e].filter(e=>e!==t)),n.apply(this,arguments)},window.history.pushState=i_(window.history.pushState,"pushState"),window.history.replaceState=i_(iv,"replaceState")}function iw(e){let t=document.createElement("a");return t.href=e,t}id&&(window.singleSpaNavigate?console.warn(oz(41,!1)):window.singleSpaNavigate=ig);let ik=!1;function ix(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!ik){let t=e.fn.on,n=e.fn.off;e.fn.on=function(e,n){return iC.call(this,t,window.addEventListener,e,n,arguments)},e.fn.off=function(e,t){return iC.call(this,n,window.removeEventListener,e,t,arguments)},ik=!0}}function iC(e,t,n,r,o){return"string"!=typeof n?e.apply(this,o):(n.split(/\s+/).forEach(e=>{im.indexOf(e)>=0&&(t(e,r),n=n.replace(e,""))}),""===n.trim()?this:e.apply(this,o))}let iE={};function iS(e){return Promise.resolve().then(()=>{let t=iE[oH(e)];if(!t)return e;if(e.status===oP)return iD(e,t),e;if(e.status===oW)return t.promise.then(()=>e);if(e.status!==oI&&e.status!==oG)return e;let n=e.status===oG?Promise.resolve():ic(e,"unload");return e.status=oW,n.then(()=>(iD(e,t),e)).catch(n=>(delete iE[oH(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,oS(n,e,oV),t.reject(n),e))})}function iD(e,t){delete iE[oH(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=oP,t.resolve()}function iM(e,t,n,r){iE[oH(e)]={app:e,resolve:n,reject:r},Object.defineProperty(iE[oH(e)],"promise",{get:t})}let iz=[];function iO(){return iz.filter(oU).map(oH)}function iP(){return iz.map(oH)}function iT(e){let t=oZ(iz,t=>oH(t)===e);return t?t.status:null}let iB=!1;function ij(e,t,n,r){var o,i;let a,s,l=(a={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(oz(39,!1));let t=["name","app","activeWhen","customProps"],n=Object.keys(e).reduce((e,n)=>t.indexOf(n)>=0?e:e.concat(n),[]);if(0!==n.length)throw Error(oz(38,!1,t.join(", "),n.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(oz(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(oz(24,!1));if(!iL(e.customProps))throw Error(oz(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,t,n,r){if("string"!=typeof e||0===e.length)throw Error(oz(20,!1));if(!t)throw Error(oz(23,!1));if("function"!=typeof n)throw Error(oz(24,!1));if(!iL(r))throw Error(oz(22,!1))}(e,t,n,r),a.name=e,a.loadApp=t,a.activeWhen=n,a.customProps=r),a.loadApp="function"!=typeof(o=a.loadApp)?()=>Promise.resolve(o):o,a.customProps=a.customProps||{},s=(s=Array.isArray(i=a.activeWhen)?i:[i]).map(e=>"function"==typeof e?e:iW(e)),a.activeWhen=e=>s.some(t=>t(e)),a);if(iY||iB||(iB=!0,setTimeout(()=>{iY||console.warn(oz(1,!1))},5e3)),-1!==iP().indexOf(l.name))throw Error(oz(21,!1,l.name));iz.push(oJ({loadErrorTime:null,status:oP,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),id&&(ix(),iH())}function iI(e=window.location){return iz.filter(t=>t.activeWhen(e)).map(oH)}function iN(e){if(0===iz.filter(t=>oH(t)===e).length)throw Error(oz(25,!1,e));return(id?iR(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=iz.map(oH).indexOf(e);iz.splice(t,1)})}function iR(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(oz(26,!1));let n=oZ(iz,t=>oH(t)===e);if(!n)throw Error(oz(27,!1,e));let r=iE[oH(n)];if(t&&t.waitForUnmount){if(r)return r.promise;{let e=new Promise((t,r)=>{iM(n,()=>e,t,r)});return e}}{let e;return r?(e=r.promise,iF(n,r.resolve,r.reject)):e=new Promise((t,r)=>{iM(n,()=>e,t,r),iF(n,t,r)}),e}}function iF(e,t,n){Promise.resolve().then(()=>{if(oZ(iI(),t=>t===oH(e)))return iq()}).then(()=>o3(e).then(iS).then(()=>{t(),setTimeout(()=>{iH()})})).catch(n)}function iL(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function iW(e,t){let n=function(e,t){let n=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let n=e[t],o=r&&"/"===n;(!r&&":"===n||o)&&i(t)}return i(e.length),RegExp(o,"i");function i(i){let a=e.slice(n,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":a,i===e.length)if(r)t&&(o+="$");else{let e=t?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,n=i}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let r=e.href.replace(t,"").replace(e.search,"").split("?")[0];return n.test(r)}}let iG=!1,iV=[],iU=id&&window.location.href;function iq(){return iH()}function iH(e=[],t,n=!1){let r,o,i,a,s;if(iG)return new Promise((e,n)=>{iV.push({resolve:e,reject:n,eventArguments:t})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(r=[],o=[],i=[],a=[],s=(new Date).getTime(),iz.forEach(e=>{let t=e.status!==oV&&oq(e);switch(e.status){case oG:t&&s-e.loadErrorTime>=200&&i.push(e);break;case oP:case oT:t&&i.push(e);break;case oB:case oI:!t&&iE[oH(e)]?r.push(e):t&&a.push(e);break;case oR:t||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:i,appsToMount:a}),d,f=[],h=iU,m=iU=window.location.href;return iY?(iG=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>(A(0===d.length?"before-no-app-change":"before-app-change",v(!0)),A("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(n=>{if(n.some(e=>e))return iv.call(window.history,history.state,"",h.substring(location.origin.length)),iU=location.href,iG=!1,iH(e,t,!0);let r=l.map(iS),o=Promise.all(c.map(o3).map(e=>e.then(iS)).concat(r));o.then(()=>{A("before-mount-routing-event",v(!0))},e=>{throw e});let i=u.map(e=>ip(e).then(e=>iK(e,o))),a=p.filter(e=>0>u.indexOf(e)).map(e=>iK(e,o));return o.catch(e=>{throw y(),e}).then(()=>(y(),Promise.all(i.concat(a)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(b).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(ip)).then(y).then(()=>[]).catch(e=>{throw y(),e}).finally(()=>{})));function g(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(t.catch(e=>(console.warn(Error(oz(42,!1))),console.warn(e),!1)))}function b(){let t=iO();e.forEach(e=>e.resolve(t));try{A(0===d.length?"no-app-change":"app-change",v()),A("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(iG=!1,iV.length>0){let e=iV;iV=[],iH(e)}return t}function y(){n||(e.forEach(e=>{ib(e.eventArguments)}),ib(t))}function v(e=!1,n){let r={},o={[oR]:[],[oI]:[],[oP]:[],[oV]:[]};e?(u.concat(p).forEach((e,t)=>{a(e,oR)}),l.forEach(e=>{a(e,oP)}),c.forEach(e=>{a(e,oI)})):d.forEach(e=>{a(e)});let i={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return n&&oJ(i.detail,n),i;function a(e,t){let n=oH(e);t=t||iT(n),r[n]=t,(o[t]=o[t]||[]).push(n)}}function A(e,t){n||window.dispatchEvent(new oC(`single-spa:${e}`,t))}}function iK(e,t){return oq(e)?o2(e).then(e=>t.then(()=>oq(e)?o6(e):e)):t.then(()=>e)}let iY=!1;function iJ(e){iY=!0,id&&(i$(e),iH())}function iZ(e,t){let n=window.getOpenmrsSpaBase().replace(/\/$/,"");return iX(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t}).replace(/^\/\//,"/")}function iX(e,t){return Object.keys(t).reduce((e,n)=>e.split("${"+n+"}").join(t[n]),e)}function iQ({to:e,templateParams:t}){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=iZ(e,t).replace(window.location.origin,"");r.startsWith(n)?ig(r):window.location.assign(r)}id&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...iz]},reroute:iH,NOT_LOADED:oP,toLoadPromise:ip,toBootstrapPromise:o2,unregisterApplication:iN,getProfilerData:function(){return o1}});let i0="openmrs:history";function i1(e){let t=JSON.parse(sessionStorage.getItem(i0)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(i0,JSON.stringify(t))}function i2(){0===JSON.parse(sessionStorage.getItem(i0)??"[]").length&&document.referrer&&i1(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=i3();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(i0,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?i4({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&i1(window.location.href)})}function i3(){return JSON.parse(sessionStorage.getItem(i0)??"[]")}function i4({toUrl:e}){let t=i3(),n=t.lastIndexOf(e);if(-1!=n){let e=t.slice(0,n+1);iQ({to:t[n]}),sessionStorage.setItem(i0,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function i5(){sessionStorage.removeItem(i0)}let i6="${openmrsSpaBase}/login",i8={redirectAuthFailure:{enabled:{_type:rx.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:rx.String,_default:i6,_validators:[om.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:rx.Array,_default:[401],_elements:{_type:rx.Number,_validators:[om.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:rx.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:rx.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function i7(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let i9="/ws/rest/v1",ae="/ws/fhir2/R4",at=`${i9}/session`;function an(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function ar(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 n=an(e);if(t.headers||(t.headers={}),eB(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,e.startsWith(i9)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(ae)){let e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}let r=Error();return window.fetch(n,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:o}=await r1("@openmrs/esm-api");if(e.ok)if(204!==e.status)return e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e});else{if(o&&e.headers.has("location")){let t=e.headers.get("location");t&&iQ({to:t})}return e.data=null,e}return n===an(at)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(i5(),iQ({to:t.url||e.headers.get("location")||i6}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let o=t;try{o=JSON.parse(t)}catch(e){}throw new ai(n,e,o,r)},t=>{throw new ai(n,e,null,r)})})}function ao(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let n=new AbortController;return t.signal=n.signal,new ex(r=>{let o=!1;return ar(e,t).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||n.abort()}})}class ai extends Error{constructor(e,t,n,r){super(),i7(this,"response",void 0),i7(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`,r.message=this.message,this.responseBody=n,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
12
|
+
${t}`)}return r}let on=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let r=n[t],o=e[t];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=o._default);let e=o._elements;if(r&&or(e)){if(o._type===rx.Array&&Array.isArray(r)){let o=r.map(t=>on(e,t));n[t]=o}else if(o._type===rx.Object)for(let t of Object.keys(r))r[t]=on(e,r[t])}}else if(oo(o)){let e=r??{};oo(e)&&(n[t]=on(o,e))}}return n};function or(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function oo(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let oi=new Set;function oa(e,t){let n=`${e}:::${t}`;oi||(oi=new Set),oi.has(n)||(console.error(t),oi.add(n))}function os(e){e?oi.forEach(t=>{t.startsWith(e)&&oi.delete(t)}):oi.clear()}function ol(){rq.forEach(e=>e()),rq.length=0,rK()}let oc={"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:rx.Object,_default:{},_validators:[rC(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(", ")}.`})]}},ou={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:rx.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:rx.String,_default:void 0}},...oc},op=(e,t)=>rC(n=>e<=n&&n<=t,`must be between ${e} and ${t}`),od=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return rC(e=>{if(!e||"string"!=typeof e)return!1;let n=/\${(.*?)}/g,r=n.exec(e);for(;r;){if(!t.includes(r[1]))return!1;r=n.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},of=od([]),oh=e=>rC(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),om={inRange:op,isUrl:of,isUrlWithTemplateParameters:od,oneOf:oh};var og=n(8067);let ob=V("breadcrumbs",[]);function oy(e){return o_([e])}function o_(e){let t=[...ov(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,og.pathToRegexp)(e.matcher).regexp:(0,og.pathToRegexp)(e.path).regexp,settings:e}))];ob.setState(t,!0)}function ov(){return ob.getState()}function oA(e,t){if(t)return function(e,t){let[n]=e.filter(e=>e.matcher.test(t));return n}(e,t)||function(e,t){let n=t.split("/");for(;n.length>1;){n.pop();let t=oA(e,n.join("/"));if(t)return t}}(e,t)}function o$(e,t){if(e.length>0){let n=oA(e,t);if(n){let t=[n],r=oA(e,n.settings.parent);for(;void 0!==r;)t.push(r),r=oA(e,r.settings.parent);return t.reverse()}}return[]}function ow(e){return o$(ov(),e)}var ok=Object.freeze({__proto__:null,get start(){return iJ},get ensureJQuerySupport(){return ix},get setBootstrapMaxTime(){return ii},get setMountMaxTime(){return ia},get setUnmountMaxTime(){return is},get setUnloadMaxTime(){return il},get registerApplication(){return ij},get unregisterApplication(){return iN},get getMountedApps(){return iO},get getAppStatus(){return iT},get unloadApplication(){return iR},get checkActivityFunctions(){return iI},get getAppNames(){return iP},get pathToActiveWhen(){return iW},get navigateToUrl(){return ig},get patchHistoryApi(){return i$},get triggerAppChange(){return iq},get addErrorHandler(){return oD},get removeErrorHandler(){return oM},get mountRootParcel(){return o9},get NOT_LOADED(){return oP},get LOADING_SOURCE_CODE(){return oT},get NOT_BOOTSTRAPPED(){return oB},get BOOTSTRAPPING(){return oj},get NOT_MOUNTED(){return oI},get MOUNTING(){return oN},get UPDATING(){return oF},get LOAD_ERROR(){return oG},get MOUNTED(){return oR},get UNLOADING(){return oW},get UNMOUNTING(){return oL},get SKIP_BECAUSE_BROKEN(){return oV}}),ox=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,oC=!function(){try{var e=new ox("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var n=document.createEvent("CustomEvent");return t?n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):n.initCustomEvent(e,!1,!1,void 0),n}:function(e,t){var n=document.createEventObject();return n.type=e,t?(n.bubbles=!!t.bubbles,n.cancelable=!!t.cancelable,n.detail=t.detail):(n.bubbles=!1,n.cancelable=!1,n.detail=void 0),n}:ox;let oE=[];function oS(e,t,n){let r=oO(e,t,n);oE.length?oE.forEach(e=>e(r)):setTimeout(()=>{throw r})}function oD(e){if("function"!=typeof e)throw Error(oz(28,!1));oE.push(e)}function oM(e){if("function"!=typeof e)throw Error(oz(29,!1));let t=!1;return oE=oE.filter(n=>{let r=n===e;return t=t||r,!r}),t}function oz(e,t,...n){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${n.length?`&arg=${n.join("&arg=")}`:""}`}function oO(e,t,n){let r,o=`${oY(t)} '${oH(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(oz(30,!1,t.status,oH(t)));try{r=Error(o+JSON.stringify(e))}catch(t){r=e}}return r.appOrParcelName=oH(t),t.status=n,r}let oP="NOT_LOADED",oT="LOADING_SOURCE_CODE",oB="NOT_BOOTSTRAPPED",oj="BOOTSTRAPPING",oI="NOT_MOUNTED",oN="MOUNTING",oR="MOUNTED",oF="UPDATING",oL="UNMOUNTING",oW="UNLOADING",oG="LOAD_ERROR",oV="SKIP_BECAUSE_BROKEN";function oU(e){return e.status===oR}function oq(e){try{return e.activeWhen(window.location)}catch(t){return oS(t,e,oV),!1}}function oH(e){return e.name}function oK(e){return!!e.unmountThisParcel}function oY(e){return oK(e)?"parcel":"application"}function oJ(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function oZ(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}function oX(e){return e&&("function"==typeof e||Array.isArray(e)&&!oZ(e,e=>"function"!=typeof e))}function oQ(e,t){let n=e[t]||[];0===(n=Array.isArray(n)?n:[n]).length&&(n=[()=>Promise.resolve()]);let r=oY(e),o=oH(e);return function(e){return n.reduce((n,i,a)=>n.then(()=>{let n=i(e);return o0(n)?n:Promise.reject(oz(15,!1,r,o,t,a))}),Promise.resolve())}}function o0(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let o1=[];function o2(e,t){return Promise.resolve().then(()=>e.status!==oB?e:(e.status=oj,e.bootstrap?ic(e,"bootstrap").then(n).catch(n=>{if(t)throw oO(n,e,oV);return oS(n,e,oV),e}):Promise.resolve().then(n)));function n(){return e.status=oI,e}}function o3(e,t){return Promise.resolve().then(()=>{if(e.status!==oR)return e;return e.status=oL,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(n,r=>n().then(()=>{let n=Error(r.message);if(t)throw oO(n,e,oV);oS(n,e,oV)})).then(()=>e);function n(){return ic(e,"unmount").then(()=>{e.status=oI},n=>{if(t)throw oO(n,e,oV);oS(n,e,oV)})}})}let o4=!1,o5=!1;function o6(e,t){return Promise.resolve().then(()=>e.status!==oI?e:(o4||(window.dispatchEvent(new oC("single-spa:before-first-mount")),o4=!0),e.status=oN,ic(e,"mount").then(()=>(e.status=oR,o5||(window.dispatchEvent(new oC("single-spa:first-mount")),o5=!0),e)).catch(n=>{return e.status=oR,o3(e,!0).then(r,r);function r(){if(t)throw oO(n,e,oV);return oS(n,e,oV),e}})))}let o8=0,o7={parcels:{}};function o9(){return ie.apply(o7,arguments)}function ie(e,t){let n,r,o,i=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(oz(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(oz(3,!1,typeof e.name));let a=o8++,s=e.name||`parcel-${a}`;if("object"!=typeof t)throw Error(oz(4,!1,s,typeof t));if(!t.domElement)throw Error(oz(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:a,parcels:{},status:l?oT:oB,customProps:t,parentName:oH(i),unmountThisParcel:()=>f.then(()=>{if(u.status!==oR)throw Error(oz(6,!1,s,u.status));return o3(u,!0)}).then(e=>(u.parentName&&delete i.parcels[u.id],e)).then(e=>(r(e),e)).catch(e=>{throw u.status=oV,o(e),e})};i.parcels[a]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(oz(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(oz(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!oX(e.bootstrap))throw Error(oz(9,!1,s));if(!oX(e.mount))throw Error(oz(10,!1,s));if(!oX(e.unmount))throw Error(oz(11,!1,s));if(e.update&&!oX(e.update))throw Error(oz(12,!1,s));let t=oQ(e,"bootstrap"),r=oQ(e,"mount"),o=oQ(e,"unmount");u.status=oB,u.name=s,u.bootstrap=t,u.mount=r,u.unmount=o,u.timeouts=iu(e.timeouts),e.update&&(u.update=oQ(e,"update"),n.update=function(e){return u.customProps=e,it(Promise.resolve().then(()=>{if(u.status!==oR)throw Error(oz(32,!1,oH(u)));return u.status=oF,ic(u,"update").then(()=>(u.status=oR,u)).catch(e=>{throw oO(e,u,oV)})}))})})).then(()=>o2(u,!0)),f=d.then(()=>o6(u,!0)),h=new Promise((e,t)=>{r=e,o=t});return n={mount:()=>it(Promise.resolve().then(()=>{if(u.status!==oI)throw Error(oz(13,!1,s,u.status));return i.parcels[a]=u,o6(u)})),unmount:()=>it(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:it(p),bootstrapPromise:it(d),mountPromise:it(f),unmountPromise:it(h)}}function it(e){return e.then(()=>null)}function ir(e){let t=oH(e),n="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof n||null===n||Array.isArray(n))&&(n={},console.warn(oz(40,!1),t,n));let r=oJ({},n,{name:t,mountParcel:ie.bind(e),singleSpa:ok});return oK(e)&&(r.unmountSelf=e.unmountThisParcel),r}let io={bootstrap:{millis:4e3,dieOnTimeout:!1,warningMillis:1e3},mount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unmount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unload:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},update:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3}};function ii(e,t,n){if("number"!=typeof e||e<=0)throw Error(oz(16,!1));io.bootstrap={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ia(e,t,n){if("number"!=typeof e||e<=0)throw Error(oz(17,!1));io.mount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function is(e,t,n){if("number"!=typeof e||e<=0)throw Error(oz(18,!1));io.unmount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function il(e,t,n){if("number"!=typeof e||e<=0)throw Error(oz(19,!1));io.unload={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ic(e,t){let n=e.timeouts[t],r=n.warningMillis,o=oY(e);return new Promise((i,a)=>{let s=!1,l=!1;e[t](ir(e)).then(e=>{s=!0,i(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>u(1),r),setTimeout(()=>u(!0),n.millis);let c=oz(31,!1,t,o,oH(e),n.millis);function u(e){s||(!0===e?(l=!0,n.dieOnTimeout?a(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<n.millis&&setTimeout(()=>u(e+1),r)))}})}function iu(e){let t={};for(let n in io)t[n]=oJ({},io[n],e&&e[n]||{});return t}function ip(e){return Promise.resolve().then(()=>{let t,n;return e.loadPromise?e.loadPromise:e.status!==oP&&e.status!==oG?e:(e.status=oT,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(ir(e));if(!o0(r))throw n=!0,Error(oz(33,!1,oH(e)));return r.then(n=>{let r;e.loadErrorTime=null,"object"!=typeof(t=n)&&(r=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!oX(t.bootstrap)&&(r=35),oX(t.mount)||(r=36),oX(t.unmount)||(r=37);let o=oY(t);if(r){let n;try{n=JSON.stringify(t)}catch(e){}return console.error(oz(r,!1,o,oH(e),n),t),oS(void 0,e,oV),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=oJ({},e.devtools.overlays,t.devtools.overlays)),e.status=oB,e.bootstrap=oQ(t,"bootstrap"),e.mount=oQ(t,"mount"),e.unmount=oQ(t,"unmount"),e.unload=oQ(t,"unload"),e.timeouts=iu(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let r;return delete e.loadPromise,n?r=oV:(r=oG,e.loadErrorTime=(new Date).getTime()),oS(t,e,r),e}))})}let id="u">typeof window,ih={hashchange:[],popstate:[]},im=["hashchange","popstate"];function ig(e){let t;if("string"==typeof e)t=e;else if(this&&this.href)t=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(oz(14,!1));t=e.currentTarget.href,e.preventDefault()}let n=iw(window.location.href),r=iw(t);0===t.indexOf("#")?window.location.hash=r.hash:n.host!==r.host&&r.host?window.location.href=t:r.pathname===n.pathname&&r.search===n.search?window.location.hash=r.hash:window.history.pushState(null,null,t)}function ib(e){if(e){let t=e[0].type;im.indexOf(t)>=0&&ih[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function iy(){iH([],arguments)}function i_(e,t){return function(){let n=window.location.href,o=e.apply(this,arguments),i=window.location.href;return r&&n===i||window.dispatchEvent(function(e,t){let n;try{n=new PopStateEvent("popstate",{state:e})}catch(t){(n=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return n.singleSpa=!0,n.singleSpaTrigger=t,n}(window.history.state,t)),o}}let iv=null,iA=!1;function i$(e){if(iA)throw Error(oz(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,iA=!0,iv=window.history.replaceState,window.addEventListener("hashchange",iy),window.addEventListener("popstate",iy);let t=window.addEventListener,n=window.removeEventListener;window.addEventListener=function(e,n){if(!("function"==typeof n&&im.indexOf(e)>=0)||oZ(ih[e],e=>e===n))return t.apply(this,arguments);ih[e].push(n)},window.removeEventListener=function(e,t){return"function"==typeof t&&im.indexOf(e)>=0&&(ih[e]=ih[e].filter(e=>e!==t)),n.apply(this,arguments)},window.history.pushState=i_(window.history.pushState,"pushState"),window.history.replaceState=i_(iv,"replaceState")}function iw(e){let t=document.createElement("a");return t.href=e,t}id&&(window.singleSpaNavigate?console.warn(oz(41,!1)):window.singleSpaNavigate=ig);let ik=!1;function ix(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!ik){let t=e.fn.on,n=e.fn.off;e.fn.on=function(e,n){return iC.call(this,t,window.addEventListener,e,n,arguments)},e.fn.off=function(e,t){return iC.call(this,n,window.removeEventListener,e,t,arguments)},ik=!0}}function iC(e,t,n,r,o){return"string"!=typeof n?e.apply(this,o):(n.split(/\s+/).forEach(e=>{im.indexOf(e)>=0&&(t(e,r),n=n.replace(e,""))}),""===n.trim()?this:e.apply(this,o))}let iE={};function iS(e){return Promise.resolve().then(()=>{let t=iE[oH(e)];if(!t)return e;if(e.status===oP)return iD(e,t),e;if(e.status===oW)return t.promise.then(()=>e);if(e.status!==oI&&e.status!==oG)return e;let n=e.status===oG?Promise.resolve():ic(e,"unload");return e.status=oW,n.then(()=>(iD(e,t),e)).catch(n=>(delete iE[oH(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,oS(n,e,oV),t.reject(n),e))})}function iD(e,t){delete iE[oH(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=oP,t.resolve()}function iM(e,t,n,r){iE[oH(e)]={app:e,resolve:n,reject:r},Object.defineProperty(iE[oH(e)],"promise",{get:t})}let iz=[];function iO(){return iz.filter(oU).map(oH)}function iP(){return iz.map(oH)}function iT(e){let t=oZ(iz,t=>oH(t)===e);return t?t.status:null}let iB=!1;function ij(e,t,n,r){var o,i;let a,s,l=(a={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(oz(39,!1));let t=["name","app","activeWhen","customProps"],n=Object.keys(e).reduce((e,n)=>t.indexOf(n)>=0?e:e.concat(n),[]);if(0!==n.length)throw Error(oz(38,!1,t.join(", "),n.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(oz(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(oz(24,!1));if(!iL(e.customProps))throw Error(oz(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,t,n,r){if("string"!=typeof e||0===e.length)throw Error(oz(20,!1));if(!t)throw Error(oz(23,!1));if("function"!=typeof n)throw Error(oz(24,!1));if(!iL(r))throw Error(oz(22,!1))}(e,t,n,r),a.name=e,a.loadApp=t,a.activeWhen=n,a.customProps=r),a.loadApp="function"!=typeof(o=a.loadApp)?()=>Promise.resolve(o):o,a.customProps=a.customProps||{},s=(s=Array.isArray(i=a.activeWhen)?i:[i]).map(e=>"function"==typeof e?e:iW(e)),a.activeWhen=e=>s.some(t=>t(e)),a);if(iY||iB||(iB=!0,setTimeout(()=>{iY||console.warn(oz(1,!1))},5e3)),-1!==iP().indexOf(l.name))throw Error(oz(21,!1,l.name));iz.push(oJ({loadErrorTime:null,status:oP,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),id&&(ix(),iH())}function iI(e=window.location){return iz.filter(t=>t.activeWhen(e)).map(oH)}function iN(e){if(0===iz.filter(t=>oH(t)===e).length)throw Error(oz(25,!1,e));return(id?iR(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=iz.map(oH).indexOf(e);iz.splice(t,1)})}function iR(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(oz(26,!1));let n=oZ(iz,t=>oH(t)===e);if(!n)throw Error(oz(27,!1,e));let r=iE[oH(n)];if(t&&t.waitForUnmount){if(r)return r.promise;{let e=new Promise((t,r)=>{iM(n,()=>e,t,r)});return e}}{let e;return r?(e=r.promise,iF(n,r.resolve,r.reject)):e=new Promise((t,r)=>{iM(n,()=>e,t,r),iF(n,t,r)}),e}}function iF(e,t,n){Promise.resolve().then(()=>{if(oZ(iI(),t=>t===oH(e)))return iq()}).then(()=>o3(e).then(iS).then(()=>{t(),setTimeout(()=>{iH()})})).catch(n)}function iL(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function iW(e,t){let n=function(e,t){let n=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let n=e[t],o=r&&"/"===n;(!r&&":"===n||o)&&i(t)}return i(e.length),RegExp(o,"i");function i(i){let a=e.slice(n,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":a,i===e.length)if(r)t&&(o+="$");else{let e=t?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,n=i}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let r=e.href.replace(t,"").replace(e.search,"").split("?")[0];return n.test(r)}}let iG=!1,iV=[],iU=id&&window.location.href;function iq(){return iH()}function iH(e=[],t,n=!1){let r,o,i,a,s;if(iG)return new Promise((e,n)=>{iV.push({resolve:e,reject:n,eventArguments:t})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(r=[],o=[],i=[],a=[],s=(new Date).getTime(),iz.forEach(e=>{let t=e.status!==oV&&oq(e);switch(e.status){case oG:t&&s-e.loadErrorTime>=200&&i.push(e);break;case oP:case oT:t&&i.push(e);break;case oB:case oI:!t&&iE[oH(e)]?r.push(e):t&&a.push(e);break;case oR:t||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:i,appsToMount:a}),d,f=[],h=iU,m=iU=window.location.href;return iY?(iG=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>(A(0===d.length?"before-no-app-change":"before-app-change",v(!0)),A("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(n=>{if(n.some(e=>e))return iv.call(window.history,history.state,"",h.substring(location.origin.length)),iU=location.href,iG=!1,iH(e,t,!0);let r=l.map(iS),o=Promise.all(c.map(o3).map(e=>e.then(iS)).concat(r));o.then(()=>{A("before-mount-routing-event",v(!0))},e=>{throw e});let i=u.map(e=>ip(e).then(e=>iK(e,o))),a=p.filter(e=>0>u.indexOf(e)).map(e=>iK(e,o));return o.catch(e=>{throw y(),e}).then(()=>(y(),Promise.all(i.concat(a)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(b).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(ip)).then(y).then(()=>[]).catch(e=>{throw y(),e}).finally(()=>{})));function g(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(t.catch(e=>(console.warn(Error(oz(42,!1))),console.warn(e),!1)))}function b(){let t=iO();e.forEach(e=>e.resolve(t));try{A(0===d.length?"no-app-change":"app-change",v()),A("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(iG=!1,iV.length>0){let e=iV;iV=[],iH(e)}return t}function y(){n||(e.forEach(e=>{ib(e.eventArguments)}),ib(t))}function v(e=!1,n){let r={},o={[oR]:[],[oI]:[],[oP]:[],[oV]:[]};e?(u.concat(p).forEach((e,t)=>{a(e,oR)}),l.forEach(e=>{a(e,oP)}),c.forEach(e=>{a(e,oI)})):d.forEach(e=>{a(e)});let i={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return n&&oJ(i.detail,n),i;function a(e,t){let n=oH(e);t=t||iT(n),r[n]=t,(o[t]=o[t]||[]).push(n)}}function A(e,t){n||window.dispatchEvent(new oC(`single-spa:${e}`,t))}}function iK(e,t){return oq(e)?o2(e).then(e=>t.then(()=>oq(e)?o6(e):e)):t.then(()=>e)}let iY=!1;function iJ(e){iY=!0,id&&(i$(e),iH())}function iZ(e,t){let n=window.getOpenmrsSpaBase().replace(/\/$/,"");return iX(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t}).replace(/^\/\//,"/")}function iX(e,t){return Object.keys(t).reduce((e,n)=>e.split("${"+n+"}").join(t[n]),e)}function iQ({to:e,templateParams:t}){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=iZ(e,t).replace(window.location.origin,"");r.startsWith(n)?ig(r):window.location.assign(r)}id&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...iz]},reroute:iH,NOT_LOADED:oP,toLoadPromise:ip,toBootstrapPromise:o2,unregisterApplication:iN,getProfilerData:function(){return o1}});let i0="openmrs:history";function i1(e){let t=JSON.parse(sessionStorage.getItem(i0)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(i0,JSON.stringify(t))}function i2(){0===JSON.parse(sessionStorage.getItem(i0)??"[]").length&&document.referrer&&i1(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=i3();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(i0,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?i4({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&i1(window.location.href)})}function i3(){return JSON.parse(sessionStorage.getItem(i0)??"[]")}function i4({toUrl:e}){let t=i3(),n=t.lastIndexOf(e);if(-1!=n){let e=t.slice(0,n+1);iQ({to:t[n]}),sessionStorage.setItem(i0,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function i5(){sessionStorage.removeItem(i0)}let i6="${openmrsSpaBase}/login",i8={redirectAuthFailure:{enabled:{_type:rx.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:rx.String,_default:i6,_validators:[om.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:rx.Array,_default:[401],_elements:{_type:rx.Number,_validators:[om.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:rx.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:rx.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function i7(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let i9="/ws/rest/v1",ae="/ws/fhir2/R4",at=`${i9}/session`;function an(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function ar(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 n=an(e);if(t.headers||(t.headers={}),eB(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,e.startsWith(i9)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(ae)){let e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}let r=Error();return window.fetch(n,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:o}=await r1("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(n===an(at)||204===e.status)&&iQ({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 n===an(at)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(i5(),iQ({to:t.url||e.headers.get("location")||i6}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let o=t;try{o=JSON.parse(t)}catch(e){}throw new ai(n,e,o,r)},t=>{throw new ai(n,e,null,r)})})}function ao(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let n=new AbortController;return t.signal=n.signal,new ex(r=>{let o=!1;return ar(e,t).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||n.abort()}})}class ai extends Error{constructor(e,t,n,r){super(),i7(this,"response",void 0),i7(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`,r.message=this.message,this.responseBody=n,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${r.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
15
|
${this.stack}`}}let aa=V("session",{loaded:!1,session:null}),as=0;function al(e={includeAuthStatus:!0}){return(as<Date.now()-6e4||!aa.getState().loaded)&&ap(),new ex(t=>{let n=n=>{n.loaded&&(e.includeAuthStatus?t.next(n.session):t.next(n.session?.user))};return n(aa.getState()),aa.subscribe(n)})}function ac(){return(as<Date.now()-6e4||!aa.getState().loaded)&&ap(),aa}function au(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 ap(e,t){as=Date.now();let n={};return e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),ay(ar(at,{headers:n}))}function ad(){aa.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function af(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!Y(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!Y(r.privileges.find(t=>e===t.display))):(Y(n)||console.error(`Could not understand privileges "${n}"`),!0))||!Y(t.roles.find(e=>"System Developer"===e.display))}function ah(){let e,t;return new Promise(n=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(aa.getState()),e||(t=aa.subscribe(r))})}function am(){return new Promise((e,t)=>{al().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function ag(e,t){return ay(ar(at,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function ab(e,t,n){return n||(n=new AbortController),await ar(`${i9}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),ap()}function ay(e){return new Promise((t,n)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},aa.setState(r),t(r)):(r={loaded:!1,session:null},aa.setState(r),n(r))}).catch(e=>{T(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};aa.setState(t),n(t)})})}function a_(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}aa.subscribe(e=>{e.loaded&&e.session&&au(e.session)});let av={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function aA(){rY("@openmrs/esm-api",i8),ap()}let a$={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",closeWorkspaces2PromptTitle:"Close workspace(s)",closeWorkspaces2PromptBody:"You are about to close the following workspace(s), which might have unsaved changes:",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",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",male:"Male",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}}",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",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",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var aw=n(2284),ak=n(3029),ax=n(2901);function aC(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function aE(e,t){return(aE=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function aS(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&aE(e,t)}function aD(e,t){if(t&&("object"==(0,aw.A)(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return aC(e)}function aM(e){return(aM=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var az=n(4467),aO=n(6369),aP=n(3612),aT=n(6562);function aB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function aj(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?aB(Object(n),!0).forEach(function(t){(0,az.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aB(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var aI={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},aN=new(function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,ak.A)(this,e),this.init(t,n)}return(0,ax.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||aI,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,r){return r&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,aj(aj({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),aR=function(){function e(){(0,ak.A)(this,e),this.observers={}}return(0,ax.A)(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach(function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)}),this}},{key:"off",value:function(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e]=this.observers[e].filter(function(e){return e!==t})}}},{key:"emit",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.observers[e]&&[].concat(this.observers[e]).forEach(function(e){e.apply(void 0,n)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(t){t.apply(t,[e].concat(n))})}}]),e}();function aF(){var e,t,n=new Promise(function(n,r){e=n,t=r});return n.resolve=e,n.reject=t,n}function aL(e){return null==e?"":""+e}function aW(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function o(){return!e||"string"==typeof e}for(var i="string"!=typeof t?[].concat(t):t.split(".");i.length>1;){if(o())return{};var a=r(i.shift());!e[a]&&n&&(e[a]=new n),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return o()?{}:{obj:e,k:r(i.shift())}}function aG(e,t,n){var r=aW(e,t,Object);r.obj[r.k]=n}function aV(e,t){var n=aW(e,t),r=n.obj,o=n.k;if(r)return r[o]}function aU(e,t,n){var r=aV(e,n);return void 0!==r?r:aV(t,n)}function aq(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var aH={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function aK(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return aH[e]}):e}var aY="u">typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,aJ=[" ",",","?","!",";"];function aZ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function aX(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?aZ(Object(n),!0).forEach(function(t){(0,az.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aZ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var aQ=function(e){aS(r,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aM(r);return e=t?Reflect.construct(n,arguments,aM(this).constructor):n.apply(this,arguments),aD(this,e)});function r(e){var t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return(0,ak.A)(this,r),t=n.call(this),aY&&aR.call(aC(t)),t.data=e||{},t.options=o,void 0===t.options.keySeparator&&(t.options.keySeparator="."),void 0===t.options.ignoreJSONStructure&&(t.options.ignoreJSONStructure=!0),t}return(0,ax.A)(r,[{key:"addNamespaces",value:function(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,i=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure,a=[e,t];n&&"string"!=typeof n&&(a=a.concat(n)),n&&"string"==typeof n&&(a=a.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(a=e.split("."));var s=aV(this.data,a);return s||!i||"string"!=typeof n?s:function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(t){if(t[n])return t[n];for(var o=n.split(r),i=t,a=0;a<o.length;++a){if(!i||"string"==typeof i[o[a]]&&a+1<o.length)return;if(void 0===i[o[a]]){for(var s=2,l=o.slice(a,a+s).join(r),c=i[l];void 0===c&&o.length>a+s;)s++,c=i[l=o.slice(a,a+s).join(r)];if(void 0===c)return;if(null===c)return null;if(n.endsWith(l)){if("string"==typeof c)return c;if(l&&"string"==typeof c[l])return c[l]}var u=o.slice(a+s).join(r);if(u)return e(c,u,r);return}i=i[o[a]]}return i}}(this.data&&this.data[e]&&this.data[e][t],n,o)}},{key:"addResource",value:function(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},i=this.options.keySeparator;void 0===i&&(i=".");var a=[e,t];n&&(a=a.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(a=e.split("."),r=t,t=a[1]),this.addNamespaces(t),aG(this.data,a,r),o.silent||this.emit("added",e,t,n,r)}},{key:"addResources",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var o in n)("string"==typeof n[o]||"[object Array]"===Object.prototype.toString.apply(n[o]))&&this.addResource(e,t,o,n[o],{silent:!0});r.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,r,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),r=n,n=t,t=a[1]),this.addNamespaces(t);var s=aV(this.data,a)||{};r?function e(t,n,r){for(var o in n)"__proto__"!==o&&"constructor"!==o&&(o in t?"string"==typeof t[o]||t[o]instanceof String||"string"==typeof n[o]||n[o]instanceof String?r&&(t[o]=n[o]):e(t[o],n[o],r):t[o]=n[o]);return t}(s,n,o):s=aX(aX({},s),n),aG(this.data,a,s),i.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return(t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI)?aX(aX({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(function(e){return t[e]&&Object.keys(t[e]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),r}(aR),a0={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,r,o){var i=this;return e.forEach(function(e){i.processors[e]&&(t=i.processors[e].process(t,n,r,o))}),t}};function a1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a2(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a1(Object(n),!0).forEach(function(t){(0,az.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a1(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var a3={},a4=function(e){aS(r,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aM(r);return e=t?Reflect.construct(n,arguments,aM(this).constructor):n.apply(this,arguments),aD(this,e)});function r(e){var t,o,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,ak.A)(this,r),i=n.call(this),aY&&aR.call(aC(i)),t=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],o=aC(i),t.forEach(function(t){e[t]&&(o[t]=e[t])}),i.options=a,void 0===i.options.keySeparator&&(i.options.keySeparator="."),i.logger=aN.create("translator"),i}return(0,ax.A)(r,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS||[],i=n&&e.indexOf(n)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!function(e,t,n){t=t||"",n=n||"";var r=aJ.filter(function(e){return 0>t.indexOf(e)&&0>n.indexOf(e)});if(0===r.length)return!0;var o=new RegExp("(".concat(r.map(function(e){return"?"===e?"\\?":e}).join("|"),")")),i=!o.test(e);if(!i){var a=e.indexOf(n);a>0&&!o.test(e.substring(0,a))&&(i=!0)}return i}(e,n,r);if(i&&!a){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:o};var l=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(l[0])>-1)&&(o=l.shift()),e=l.join(r)}return"string"==typeof o&&(o=[o]),{key:e,namespaces:o}}},{key:"translate",value:function(e,t,n){var o=this;if("object"!==(0,aw.A)(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var i=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(e[e.length-1],t),l=s.key,c=s.namespaces,u=c[c.length-1],p=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p&&"cimode"===p.toLowerCase()){if(d){var f=t.nsSeparator||this.options.nsSeparator;return i?(h.res="".concat(u).concat(f).concat(l),h):"".concat(u).concat(f).concat(l)}return i?(h.res=l,h):l}var h=this.resolve(e,t),m=h&&h.res,g=h&&h.usedKey||l,b=h&&h.exactUsedKey||l,y=Object.prototype.toString.apply(m),v=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,A=!this.i18nFormat||this.i18nFormat.handleAsObject,$="string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m;if(A&&m&&$&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(y)&&("string"!=typeof v||"[object Array]"!==y)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var w=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,m,a2(a2({},t),{},{ns:c})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return i?(h.res=w,h):w}if(a){var k="[object Array]"===y,x=k?[]:{},C=k?b:g;for(var E in m)if(Object.prototype.hasOwnProperty.call(m,E)){var S="".concat(C).concat(a).concat(E);x[E]=this.translate(S,a2(a2({},t),{joinArrays:!1,ns:c})),x[E]===S&&(x[E]=m[E])}m=x}}else if(A&&"string"==typeof v&&"[object Array]"===y)(m=m.join(v))&&(m=this.extendTranslation(m,e,t,n));else{var D=!1,M=!1,z=void 0!==t.count&&"string"!=typeof t.count,O=r.hasDefaultValue(t),P=z?this.pluralResolver.getSuffix(p,t.count,t):"",T=t["defaultValue".concat(P)]||t.defaultValue;!this.isValidLookup(m)&&O&&(D=!0,m=T),this.isValidLookup(m)||(M=!0,m=l);var B=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&M?void 0:m,j=O&&T!==m&&this.options.updateMissing;if(M||D||j){if(this.logger.log(j?"updateKey":"missingKey",p,u,l,j?T:m),a){var I=this.resolve(l,a2(a2({},t),{},{keySeparator:!1}));I&&I.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var N=[],R=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&R&&R[0])for(var F=0;F<R.length;F++)N.push(R[F]);else"all"===this.options.saveMissingTo?N=this.languageUtils.toResolveHierarchy(t.lng||this.language):N.push(t.lng||this.language);var L=function(e,n,r){var i=O&&r!==m?r:B;o.options.missingKeyHandler?o.options.missingKeyHandler(e,u,n,i,j,t):o.backendConnector&&o.backendConnector.saveMissing&&o.backendConnector.saveMissing(e,u,n,i,j,t),o.emit("missingKey",e,u,n,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&z?N.forEach(function(e){o.pluralResolver.getSuffixes(e,t).forEach(function(n){L([e],l+n,t["defaultValue".concat(n)]||T)})}):L(N,l,T))}m=this.extendTranslation(m,e,t,h,n),M&&m===l&&this.options.appendNamespaceToMissingKey&&(m="".concat(u,":").concat(l)),(M||D)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(u,":").concat(l):l,D?m:void 0):this.options.parseMissingKeyHandler(m))}return i?(h.res=m,h):m}},{key:"extendTranslation",value:function(e,t,n,r,o){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,a2(a2({},this.options.interpolation.defaultVariables),n),r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(a2(a2({},n),{interpolation:a2(a2({},this.options.interpolation),n.interpolation)}));var a,s="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(s){var l=e.match(this.interpolator.nestingRegexp);a=l&&l.length}var c=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(c=a2(a2({},this.options.interpolation.defaultVariables),c)),e=this.interpolator.interpolate(e,c,n.lng||this.language,n),s){var u=e.match(this.interpolator.nestingRegexp);a<(u&&u.length)&&(n.nest=!1)}!1!==n.nest&&(e=this.interpolator.nest(e,function(){for(var e=arguments.length,r=Array(e),a=0;a<e;a++)r[a]=arguments[a];return o&&o[0]===r[0]&&!n.context?(i.logger.warn("It seems you are nesting recursively key: ".concat(r[0]," in key: ").concat(t[0])),null):i.translate.apply(i,r.concat([t]))},n)),n.interpolation&&this.interpolator.reset()}var p=n.postProcess||this.options.postProcess,d="string"==typeof p?[p]:p;return null!=e&&d&&d.length&&!1!==n.applyPostProcessor&&(e=a0.handle(d,e,t,this.options&&this.options.postProcessPassResolved?a2({i18nResolved:r},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,r,o,i,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!a.isValidLookup(t)){var l=a.extractFromKey(e,s),c=l.key;n=c;var u=l.namespaces;a.options.fallbackNS&&(u=u.concat(a.options.fallbackNS));var p=void 0!==s.count&&"string"!=typeof s.count,d=p&&!s.ordinal&&0===s.count&&a.pluralResolver.shouldUseIntlApi(),f=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,h=s.lngs?s.lngs:a.languageUtils.toResolveHierarchy(s.lng||a.language,s.fallbackLng);u.forEach(function(e){a.isValidLookup(t)||(i=e,!a3["".concat(h[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(i)&&(a3["".concat(h[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(n,'" for languages "').concat(h.join(", "),'" won\'t get resolved as namespace "').concat(i,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),h.forEach(function(n){if(!a.isValidLookup(t)){o=n;var i,l=[c];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(l,c,n,e,s);else{p&&(u=a.pluralResolver.getSuffix(n,s.count,s));var u,h="".concat(a.options.pluralSeparator,"zero");if(p&&(l.push(c+u),d&&l.push(c+h)),f){var m="".concat(c).concat(a.options.contextSeparator).concat(s.context);l.push(m),p&&(l.push(m+u),d&&l.push(m+h))}}for(;i=l.pop();)a.isValidLookup(t)||(r=i,t=a.getResource(n,e,i,s))}}))})}}),{res:t,usedKey:n,exactUsedKey:r,usedLng:o,usedNS:i}}},{key:"isValidLookup",value:function(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&void 0!==e[n])return!0;return!1}}]),r}(aR);function a5(e){return e.charAt(0).toUpperCase()+e.slice(1)}var a6=function(){function e(t){(0,ak.A)(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=aN.create("languageUtils")}return(0,ax.A)(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return null;var t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map(function(e){return e.toLowerCase()}):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=a5(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=a5(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=a5(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach(function(e){if(!t){var r=n.formatLanguageCode(e);(!n.options.supportedLngs||n.isSupportedCode(r))&&(t=r)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var r=n.getLanguagePartFromCode(e);if(n.isSupportedCode(r))return t=r;t=n.options.supportedLngs.find(function(e){if(0===e.indexOf(r))return e})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,r=this.getFallbackCodes(t||this.options.fallbackLng||[],e),o=[],i=function(e){e&&(n.isSupportedCode(e)?o.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&i(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&i(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&i(this.getLanguagePartFromCode(e))):"string"==typeof e&&i(this.formatLanguageCode(e)),r.forEach(function(e){0>o.indexOf(e)&&i(n.formatLanguageCode(e))}),o}}]),e}(),a8=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],a7={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(+(1!=e&&(e%10!=1||e%100==11)))},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:3*(e%100==3||e%100==4))},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},a9=["v1","v2","v3"],se={zero:0,one:1,two:2,few:3,many:4,other:5},st=function(){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,ak.A)(this,e),this.languageUtils=t,this.options=r,this.logger=aN.create("pluralResolver"),(!this.options.compatibilityJSON||"v4"===this.options.compatibilityJSON)&&("u"<typeof Intl||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(n={},a8.forEach(function(e){e.lngs.forEach(function(t){n[t]={numbers:e.nr,plurals:a7[e.fc]}})}),n)}return(0,ax.A)(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map(function(e){return"".concat(t).concat(e)})}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort(function(e,t){return se[e]-se[t]}).map(function(e){return"".concat(t.options.prepend).concat(e)}):r.numbers.map(function(r){return t.getSuffix(e,r,n)}):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(r.select(t)):this.getSuffixRetroCompatible(r,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,r=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),o=e.numbers[r];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===o?o="plural":1===o&&(o=""));var i=function(){return n.options.prepend&&o.toString()?n.options.prepend+o.toString():o.toString()};return"v1"===this.options.compatibilityJSON?1===o?"":"number"==typeof o?"_plural_".concat(o.toString()):i():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?i():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}},{key:"shouldUseIntlApi",value:function(){return!a9.includes(this.options.compatibilityJSON)}}]),e}();function sn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sn(Object(n),!0).forEach(function(t){(0,az.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var so=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,ak.A)(this,e),this.logger=aN.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return(0,ax.A)(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:aK,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?aq(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?aq(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?aq(t.nestingPrefix):t.nestingPrefixEscaped||aq("$t("),this.nestingSuffix=t.nestingSuffix?aq(t.nestingSuffix):t.nestingSuffixEscaped||aq(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,r){var o,i,a,s=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var u=function(e){if(0>e.indexOf(s.formatSeparator)){var o=aU(t,l,e);return s.alwaysFormat?s.format(o,void 0,n,sr(sr(sr({},r),t),{},{interpolationkey:e})):o}var i=e.split(s.formatSeparator),a=i.shift().trim(),c=i.join(s.formatSeparator).trim();return s.format(aU(t,l,a),c,n,sr(sr(sr({},r),t),{},{interpolationkey:a}))};this.resetRegExp();var p=r&&r.missingInterpolationHandler||this.options.missingInterpolationHandler,d=r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return c(e)}},{regex:this.regexp,safeValue:function(e){return s.escapeValue?c(s.escape(e)):c(e)}}].forEach(function(t){for(a=0;o=t.regex.exec(e);){var n=o[1].trim();if(void 0===(i=u(n)))if("function"==typeof p){var l=p(e,o,r);i="string"==typeof l?l:""}else if(r&&r.hasOwnProperty(n))i="";else if(d){i=o[0];continue}else s.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),i="";else"string"==typeof i||s.useRawValueToEscape||(i=aL(i));var c=t.safeValue(i);if(e=e.replace(o[0],c),d?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,++a>=s.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var n,r,o=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=sr({},i);function s(e,t){var n=this.nestingOptionsSeparator;if(0>e.indexOf(n))return e;var r=e.split(new RegExp("".concat(n,"[ ]*{"))),o="{".concat(r[1]);e=r[0];var i=(o=this.interpolate(o,a)).match(/'/g),s=o.match(/"/g);(i&&i.length%2==0&&!s||s.length%2!=0)&&(o=o.replace(/'/g,'"'));try{a=JSON.parse(o),t&&(a=sr(sr({},t),a))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(o)}return delete a.defaultValue,e}for(a.applyPostProcessor=!1,delete a.defaultValue;n=this.nestingRegexp.exec(e);){var l=[],c=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var u=n[1].split(this.formatSeparator).map(function(e){return e.trim()});n[1]=u.shift(),l=u,c=!0}if((r=t(s.call(this,n[1].trim(),a),a))&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=aL(r)),r||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),r=""),c&&(r=l.reduce(function(e,t){return o.format(e,t,i.lng,sr(sr({},i),{},{interpolationkey:n[1].trim()}))},r.trim())),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}]),e}();function si(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?si(Object(n),!0).forEach(function(t){(0,az.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):si(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ss(e){var t={};return function(n,r,o){var i=r+JSON.stringify(o),a=t[i];return a||(a=e(r,o),t[i]=a),a(n)}}var sl=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,ak.A)(this,e),this.logger=aN.create("formatter"),this.options=t,this.formats={number:ss(function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}}),currency:ss(function(e,t){var n=new Intl.NumberFormat(e,sa(sa({},t),{},{style:"currency"}));return function(e){return n.format(e)}}),datetime:ss(function(e,t){var n=new Intl.DateTimeFormat(e,sa({},t));return function(e){return n.format(e)}}),relativetime:ss(function(e,t){var n=new Intl.RelativeTimeFormat(e,sa({},t));return function(e){return n.format(e,t.range||"day")}}),list:ss(function(e,t){var n=new Intl.ListFormat(e,sa({},t));return function(e){return n.format(e)}})},this.init(t)}return(0,ax.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},n=t.interpolation;this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=ss(t)}},{key:"format",value:function(e,t,n,r){var o=this;return t.split(this.formatSeparator).reduce(function(e,t){var i=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var r=e.split("(");t=r[0].toLowerCase().trim();var o=r[1].substring(0,r[1].length-1);"currency"===t&&0>o.indexOf(":")?n.currency||(n.currency=o.trim()):"relativetime"===t&&0>o.indexOf(":")?n.range||(n.range=o.trim()):o.split(";").forEach(function(e){if(e){var t,r=(t=e.split(":"),(0,aO.A)(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||(0,aP.A)(t)||(0,aT.A)()),o=r[0],i=r.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[o.trim()]||(n[o.trim()]=i),"false"===i&&(n[o.trim()]=!1),"true"===i&&(n[o.trim()]=!0),isNaN(i)||(n[o.trim()]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}}(t),a=i.formatName,s=i.formatOptions;if(o.formats[a]){var l=e;try{var c=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{},u=c.locale||c.lng||r.locale||r.lng||n;l=o.formats[a](e,u,sa(sa(sa({},s),r),c))}catch(e){o.logger.warn(e)}return l}return o.logger.warn("there was no format function for ".concat(a)),e},e)}}]),e}();function sc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function su(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sc(Object(n),!0).forEach(function(t){(0,az.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var sp=function(e){aS(r,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aM(r);return e=t?Reflect.construct(n,arguments,aM(this).constructor):n.apply(this,arguments),aD(this,e)});function r(e,t,o){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,ak.A)(this,r),i=n.call(this),aY&&aR.call(aC(i)),i.backend=e,i.store=t,i.services=o,i.languageUtils=o.languageUtils,i.options=a,i.logger=aN.create("backendConnector"),i.waitingReads=[],i.maxParallelReads=a.maxParallelReads||10,i.readingCalls=0,i.maxRetries=a.maxRetries>=0?a.maxRetries:5,i.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,i.state={},i.queue=[],i.backend&&i.backend.init&&i.backend.init(o,a.backend,a),i}return(0,ax.A)(r,[{key:"queueLoad",value:function(e,t,n,r){var o=this,i={},a={},s={},l={};return e.forEach(function(e){var r=!0;t.forEach(function(t){var s="".concat(e,"|").concat(t);!n.reload&&o.store.hasResourceBundle(e,t)?o.state[s]=2:o.state[s]<0||(1===o.state[s]?void 0===a[s]&&(a[s]=!0):(o.state[s]=1,r=!1,void 0===a[s]&&(a[s]=!0),void 0===i[s]&&(i[s]=!0),void 0===l[t]&&(l[t]=!0)))}),r||(s[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,n){var r=e.split("|"),o=r[0],i=r[1];t&&this.emit("failedLoading",o,i,t),n&&this.store.addResourceBundle(o,i,n),this.state[e]=t?-1:2;var a={};this.queue.forEach(function(n){var r,s,l,c;r=n.loaded,(l=(s=aW(r,[o],Object)).obj)[c=s.k]=l[c]||[],l[c].push(i),void 0!==n.pending[e]&&(delete n.pending[e],n.pendingCount--),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach(function(e){a[e]||(a[e]={});var t=n.loaded[e];t.length&&t.forEach(function(t){void 0===a[e][t]&&(a[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,n){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:o,wait:i,callback:a}):(this.readingCalls++,this.backend[n](e,t,function(s,l){if(r.readingCalls--,r.waitingReads.length>0){var c=r.waitingReads.shift();r.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}s&&l&&o<r.maxRetries?setTimeout(function(){r.read.call(r,e,t,n,o+1,2*i,a)},i):a(s,l)})):a(null,{})}},{key:"prepareLoading",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var i=this.queueLoad(e,t,r,o);if(!i.toLoad.length)return i.pending.length||o(),null;i.toLoad.forEach(function(e){n.loadOne(e)})}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split("|"),o=r[0],i=r[1];this.read(o,i,"read",void 0,void 0,function(r,a){r&&t.logger.warn("".concat(n,"loading namespace ").concat(i," for language ").concat(o," failed"),r),!r&&a&&t.logger.log("".concat(n,"loaded namespace ").concat(i," for language ").concat(o),a),t.loaded(e,r,a)})}},{key:"saveMissing",value:function(e,t,n,r,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null==n||""===n||(this.backend&&this.backend.create&&this.backend.create(e,t,n,r,null,su(su({},i),{},{isUpdate:o})),e&&e[0]&&this.store.addResource(e[0],t,n,r))}}]),r}(aR);function sd(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&0>e.supportedLngs.indexOf("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function sf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sh(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sf(Object(n),!0).forEach(function(t){(0,az.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sf(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function sm(){}var sg=function(e){aS(r,e);var t,n=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,n=aM(r);return e=t?Reflect.construct(n,arguments,aM(this).constructor):n.apply(this,arguments),aD(this,e)});function r(){var e,t,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if((0,ak.A)(this,r),t=n.call(this),aY&&aR.call(aC(t)),t.options=sd(o),t.services={},t.logger=aN,t.modules={external:[]},Object.getOwnPropertyNames(Object.getPrototypeOf(e=aC(t))).forEach(function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}),i&&!t.isInitialized&&!o.isClone){if(!t.options.initImmediate)return t.init(o,i),aD(t,aC(t));setTimeout(function(){t.init(o,i)},0)}return t}return(0,ax.A)(r,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:0>t.ns.indexOf("translation")&&(t.defaultNS=t.ns[0]));var r={debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===(0,aw.A)(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===(0,aw.A)(e[2])||"object"===(0,aw.A)(e[3])){var n=e[3]||e[2];Object.keys(n).forEach(function(e){t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:function(e,t,n,r){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}};function o(e){return e?"function"==typeof e?new e:e:null}if(this.options=sh(sh(sh({},r),this.options),sd(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=sh(sh({},r.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){this.modules.logger?aN.init(o(this.modules.logger),this.options):aN.init(null,this.options),this.modules.formatter?i=this.modules.formatter:"u">typeof Intl&&(i=sl);var i,a=new a6(this.options);this.store=new aQ(this.options.resources,this.options);var s=this.services;s.logger=aN,s.resourceStore=this.store,s.languageUtils=a,s.pluralResolver=new st(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),i&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(s.formatter=o(i),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new so(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new sp(o(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];e.emit.apply(e,[t].concat(r))}),this.modules.languageDetector&&(s.languageDetector=o(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=o(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new a4(this.services,this.options),this.translator.on("*",function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];e.emit.apply(e,[t].concat(r))}),this.modules.external.forEach(function(t){t.init&&t.init(e)})}if(this.format=this.options.interpolation.format,n||(n=sm),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&"dev"!==l[0]&&(this.options.lng=l[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}});var c=aF(),u=function(){var t=function(t,r){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),c.resolve(r),n(t,r)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:sm,r=n,o="string"==typeof e?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(o&&"cimode"===o.toLowerCase())return r();var i=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){0>i.indexOf(e)&&i.push(e)})};o?a(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(e){return a(e)}),this.options.preload&&this.options.preload.forEach(function(e){return a(e)}),this.services.backendConnector.load(i,this.options.ns,function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),r(e)})}else r(null)}},{key:"reloadResources",value:function(e,t,n){var r=aF();return e||(e=this.languages),t||(t=this.options.ns),n||(n=sm),this.services.backendConnector.reload(e,t,function(e){r.resolve(),n(e)}),r}},{key:"use",value:function(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&a0.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var r=aF();this.emit("languageChanging",e);var o=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},i=function(e,i){i?(o(i),n.translator.changeLanguage(i),n.isLanguageChangingTo=void 0,n.emit("languageChanged",i),n.logger.log("languageChanged",i)):n.isLanguageChangingTo=void 0,r.resolve(function(){return n.t.apply(n,arguments)}),t&&t(e,function(){return n.t.apply(n,arguments)})},a=function(t){e||t||!n.services.languageDetector||(t=[]);var r="string"==typeof t?t:n.services.languageUtils.getBestMatchFromCodes(t);r&&(n.language||o(r),n.translator.language||n.translator.changeLanguage(r),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(r)),n.loadResources(r,function(e){i(e,r)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),r}},{key:"getFixedT",value:function(e,t,n){var r=this,o=function e(t,o){if("object"!==(0,aw.A)(o)){for(var i,a=arguments.length,s=Array(a>2?a-2:0),l=2;l<a;l++)s[l-2]=arguments[l];i=r.options.overloadTranslationOptionHandler([t,o].concat(s))}else i=sh({},o);i.lng=i.lng||e.lng,i.lngs=i.lngs||e.lngs,i.ns=i.ns||e.ns,i.keyPrefix=i.keyPrefix||n||e.keyPrefix;var c=r.options.keySeparator||".",u=i.keyPrefix?"".concat(i.keyPrefix).concat(c).concat(t):t;return r.t(u,i)};return"string"==typeof e?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=n,o}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var r=this.resolvedLanguage||this.languages[0],o=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;var a=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return -1===r||2===r};if(n.precheck){var s=n.precheck(this,a);if(void 0!==s)return s}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!o||a(i,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,r=aF();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){0>n.options.ns.indexOf(e)&&n.options.ns.push(e)}),this.loadResources(function(e){r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=aF();"string"==typeof e&&(e=[e]);var r=this.options.preload||[],o=e.filter(function(e){return 0>r.indexOf(e)});return o.length?(this.options.preload=r.concat(o),this.loadResources(function(e){n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),e)?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr":"rtl"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:sm,o=sh(sh(sh({},this.options),t),{isClone:!0}),i=new r(o);return(void 0!==t.debug||void 0!==t.prefix)&&(i.logger=i.logger.clone(t)),["store","services","language"].forEach(function(t){i[t]=e[t]}),i.services=sh({},this.services),i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i.translator=new a4(i.services,i.options),i.translator.on("*",function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];i.emit.apply(i,[e].concat(n))}),i.init(o,n),i.translator.options=i.options,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),r}(aR);(0,az.A)(sg,"createInstance",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new sg(e,t)});var sb=sg.createInstance();sb.createInstance=sg.createInstance,sb.createInstance,sb.init,sb.loadResources,sb.reloadResources,sb.use,sb.changeLanguage,sb.getFixedT,sb.t,sb.exists,sb.setDefaultNamespace,sb.hasLoadedNamespace,sb.loadNamespaces,sb.loadLanguages;let sy=sb.default||sb;function s_(e,t,n,r){return sy.t(t,{ns:e,defaultValue:n,...r})}function sv(e,t,n){return a$[e]?s_("core",e,t??a$[e],n):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}sy.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let sA="import-map-override:",s$="import-map-overrides-disabled",sw="import-map-overrides:change",sk=!1,sx=null;async function sC(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[];for(let n=0;n<e.length;n++){let r=e[n];try{if(r.src){let e=await fetch(r.src);t.push(await e.json())}else r.textContent&&t.push(JSON.parse(r.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return sE(t)}function sE(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function sS(){let e={};try{let t=sP();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(sA)){let n=r.slice(sA.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function sD(){let e=await sC();return sk?sE([e,sx??sS()]):e}async function sM(){return sC()}async function sz(){return sk?sE([await sC(),sS()]):sC()}function sO(e){if(!sk)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(sA)){let t=localStorage.getItem(n);t&&(e[n.slice(sA.length)]=t)}}return{imports:e}}return sS()}function sP(){if(!sk)return[];try{let e=localStorage.getItem(s$);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function sT(e){return!!sk&&sP().includes(e)}function sB(e,t){if(!sk)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sA+e,t),window.dispatchEvent(new CustomEvent(sw))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sj(e){if(!sk)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sA+e);let t=sP().filter(t=>t!==e);t.length>0?localStorage.setItem(s$,JSON.stringify(t)):localStorage.removeItem(s$),window.dispatchEvent(new CustomEvent(sw))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sI(){if(!sk)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 n=localStorage.key(t);n?.startsWith(sA)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(s$),window.dispatchEvent(new CustomEvent(sw))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function sN(e){if(!sk)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=sP().filter(t=>t!==e);t.length>0?localStorage.setItem(s$,JSON.stringify(t)):localStorage.removeItem(s$),window.dispatchEvent(new CustomEvent(sw))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let sR=!1;function sF(){!sR&&(sR=!0,(sk="development"===window.spaEnv)&&(sx=sS()))}function sL(e){return e.replace(/[\/\-@]/g,"_")}async function sW(e,t="./start",r){var o;let i,a=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([sG(e,r?.importMap),new Promise((t,n)=>{i=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=a)<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`}.`))},a)})]),i&&clearTimeout(i);let s=sL(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(n.S.default);let c=(await l.get(t))();if("object"!=typeof c||null===c){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return c}async function sG(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 n=sL(e);if(!window[n]){let n=t??await sV();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in sO().imports;try{return await new Promise((e,t)=>{!function(e,t,n){let r=document.head.querySelector(`script[src="${e}"]`),o=window[sU];if(o||(o=window[sU]=new Set([])),r)if(o.has(e)){let e,o,i;i=()=>{e&&r.removeEventListener("load",e),o&&r.removeEventListener("error",o)},e=()=>{i(),t(null)},o=e=>{i(),n(e.message)},r.addEventListener("load",e),r.addEventListener("error",o)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),t(null);else{let r,i,a;o.add(e);let s=document.createElement("script");s.src=e,s.type="text/javascript",s.async=!0;let l=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);a=()=>{clearTimeout(l),o.delete(e),r&&s.removeEventListener("load",r),i&&s.removeEventListener("error",i)},r=()=>{a(),t(null)},i=t=>{a();let r=`Failed to load script from ${e}`;console.error(r,t),n(t.message??r)},s.addEventListener("load",r),s.addEventListener("error",i),document.head.appendChild(s)}}(r,e,t)})}catch(e){return o&&D({kind:"error",title:sv("scriptLoadingFailed","Error: Script failed to load"),description:sv("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:r}),actionButtonLabel:sv("resetOverrides","Reset overrides"),onActionButtonClick(){sI(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function sV(){return sD()}let sU=Symbol("__openmrs_script_loading");function sq(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,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function sH(e){return!!e&&"object"==typeof e&&Object.entries(e).every(([e,t])=>"string"==typeof e&&sq(t))}let sK="openmrs-routes:",sY="openmrs-routes:change",sJ=!1,sZ=null;async function sX(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[];for(let n=0;n<e.length;n++){let r=e[n];try{let e;if(r.src){let t=await fetch(r.src);e=await t.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&sH(e)&&t.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return sQ(t)}function sQ(e){let t={};for(let n of e)n&&"object"==typeof n&&Object.assign(t,n);return t}async function s0(){let e={};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(sK)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(sK.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(sq(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),r=await t.json();if(sq(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function s1(){let e=await sX();return sJ?sQ([e,sZ??await s0()]):e}async function s2(){return sX()}async function s3(){return sJ?sQ([await sX(),await s0()]):sX()}function s4(){if(!sJ)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(sK)){let t=localStorage.getItem(n);t&&(e[n.slice(sK.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function s5(e,t){if(!sJ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(sK+e,JSON.stringify(t));else{let n=JSON.parse(t);if(!sq(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(sK+e,JSON.stringify(n))}else if(t instanceof URL)localStorage.setItem(sK+e,JSON.stringify(t.toString()));else{if(!sq(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(sK+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(sY))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function s6(e){if(!sJ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(sK+e),window.dispatchEvent(new CustomEvent(sY))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function s8(){if(!sJ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(sK)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sY))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let s7=null;function s9(){return s7||(s7=(sJ="development"===window.spaEnv)?s0().then(e=>{sZ=e}):Promise.resolve())}let le=`${i9}/attachment`;function lt(e,t){return ar(`${le}/${e}`,{signal:t.signal})}function ln(e,t,n){return ar(`${le}?patient=${e}&includeEncounterless=${t}`,{signal:n.signal})}async function lr(e,t){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),ar(`${le}`,{method:"POST",body:n})}function lo(e,t){return ar(`${le}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function li(e,t){return new Promise(function(n){var r=new MessageChannel;r.port1.onmessage=function(e){n(e.data)},e.postMessage(t,[r.port2])})}function la(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ls(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var ll=function(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})};function lc(e,t){var n=location.href;return new URL(e,n).href===new URL(t,n).href}var lu=function(e,t){this.type=e,Object.assign(this,t)};function lp(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function ld(){}var lf={type:"SKIP_WAITING"};function lh(e,t){if(!t)return e&&e.then?e.then(ld):Promise.resolve()}var lm=function(e){function t(t,n){var r,o;return void 0===n&&(n={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new ll,r.en=new ll,r.on=new ll,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,t=e.installing;r.tn>0||!lc(t.scriptURL,r.sn.toString())||performance.now()>r.un+6e4?(r.vn=t,e.removeEventListener("updatefound",r.cn)):(r.hn=t,r.an.add(t),r.rn.resolve(t)),++r.tn,t.addEventListener("statechange",r.ln)},r.ln=function(e){var t=r.fn,n=e.target,o=n.state,i=n===r.vn,a={sw:n,isExternal:i,originalEvent:e};!i&&r.mn&&(a.isUpdate=!0),r.dispatchEvent(new lu(o,a)),"installed"===o?r.wn=self.setTimeout(function(){"installed"===o&&t.waiting===n&&r.dispatchEvent(new lu("waiting",a))},200):"activating"===o&&(clearTimeout(r.wn),i||r.en.resolve(n))},r.dn=function(e){var t=r.hn,n=t!==navigator.serviceWorker.controller;r.dispatchEvent(new lu("controlling",{isExternal:n,originalEvent:e,sw:t,isUpdate:r.mn})),n||r.on.resolve(t)},o=function(e){var t=e.data,n=e.ports,o=e.source;return lp(r.getSW(),function(){r.an.has(o)&&r.dispatchEvent(new lu("message",{data:t,originalEvent:e,ports:n,sw:o}))})},r.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},r.sn=t,r.nn=n,navigator.serviceWorker.addEventListener("message",r.gn),r}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var n,r,o=t.prototype;return o.register=function(e){var t=(void 0===e?{}:e).immediate,n=void 0!==t&&t;try{var r,o,i,a=this;return r=function(){if(!n&&"complete"!==document.readyState)return lh(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),lp(a.bn(),function(e){a.fn=e,a.yn&&(a.hn=a.yn,a.en.resolve(a.yn),a.on.resolve(a.yn),a.yn.addEventListener("statechange",a.ln,{once:!0}));var t=a.fn.waiting;return t&&lc(t.scriptURL,a.sn.toString())&&(a.hn=t,Promise.resolve().then(function(){a.dispatchEvent(new lu("waiting",{sw:t,wasWaitingBeforeRegister:!0}))}).then(function(){})),a.hn&&(a.rn.resolve(a.hn),a.an.add(a.hn)),a.fn.addEventListener("updatefound",a.cn),navigator.serviceWorker.addEventListener("controllerchange",a.dn),a.fn})},(i=r())&&i.then?i.then(o):o(i)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?lh(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},o.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},o.messageSW=function(e){try{return lp(this.getSW(),function(t){return li(t,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&li(this.fn.waiting,lf)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&lc(e.scriptURL,this.sn.toString())?e:void 0},o.bn=function(){try{var e=this;return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(function(){return lp(navigator.serviceWorker.register(e.sn,e.nn),function(t){return e.un=performance.now(),t})},function(e){throw e})}catch(e){return Promise.reject(e)}},n=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],la(t.prototype,n),r&&la(t,r),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,n=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return ls(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ls(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=n()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function lg(e,t){if(void 0!==p)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),p;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let n=new lm(e,t);return p=n.register().then(()=>n.controlling.then(()=>n))}function lb(){return p??Promise.resolve(void 0)}let ly="x-omrs-offline-response-body",l_="x-omrs-offline-response-status",lv="x-omrs-offline-caching-strategy";async function lA(e){let t=await lb();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function l$(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function lw(){return!window.indexedDB}async function lk(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function lx(){return await lk()||await lw()||await l$()}let lC="openmrs3:offline-mode",lE="unavailable";function lS(){return{current:lE,notAvailable:"unavailable"===lE,active:"on"===lE}}function lD(e){"unavailable"!==lE&&"unavailable"!==e&&(localStorage.setItem(lC,"on"===e?"active":"disabled"),lE=e)}async function lM(){await lx()||(lE="active"===localStorage.getItem(lC)?"on":"off"),navigator.onLine}let lz="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,lO=Object.keys,lP=Array.isArray;function lT(e,t){return"object"!=typeof t||lO(t).forEach(function(n){e[n]=t[n]}),e}"u"<typeof Promise||lz.Promise||(lz.Promise=Promise);let lB=Object.getPrototypeOf,lj={}.hasOwnProperty;function lI(e,t){return lj.call(e,t)}function lN(e,t){"function"==typeof t&&(t=t(lB(e))),("u"<typeof Reflect?lO:Reflect.ownKeys)(t).forEach(n=>{lF(e,n,t[n])})}let lR=Object.defineProperty;function lF(e,t,n,r){lR(e,t,lT(n&&lI(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function lL(e){return{from:function(t){return e.prototype=Object.create(t.prototype),lF(e.prototype,"constructor",e),{extend:lN.bind(null,e.prototype)}}}}let lW=Object.getOwnPropertyDescriptor;function lG(e,t){let n;return lW(e,t)||(n=lB(e))&&lG(n,t)}let lV=[].slice;function lU(e,t,n){return lV.call(e,t,n)}function lq(e,t){return t(e)}function lH(e){if(!e)throw Error("Assertion Failed")}function lK(e){lz.setImmediate?setImmediate(e):setTimeout(e,0)}function lY(e,t){return e.reduce((e,n,r)=>{var o=t(n,r);return o&&(e[o[0]]=o[1]),e},{})}function lJ(e,t){if(lI(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,o=t.length;r<o;++r){var i=lJ(e,t[r]);n.push(i)}return n}var a=t.indexOf(".");if(-1!==a){var s=e[t.substr(0,a)];return void 0===s?void 0:lJ(s,t.substr(a+1))}}function lZ(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){lH("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)lZ(e,t[r],n[r])}else{var i=t.indexOf(".");if(-1!==i){var a=t.substr(0,i),s=t.substr(i+1);if(""===s)void 0===n?lP(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=n;else{var l=e[a];l&&lI(e,a)||(l=e[a]={}),lZ(l,s,n)}}else void 0===n?lP(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function lX(e){var t={};for(var n in e)lI(e,n)&&(t[n]=e[n]);return t}let lQ=[].concat;function l0(e){return lQ.apply([],e)}let l1="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(l0([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>lz[e]),l2=l1.map(e=>lz[e]);lY(l1,e=>[e,!0]);let l3=null;function l4(e){l3="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let n=l3&&l3.get(t);if(n)return n;if(lP(t)){n=[],l3&&l3.set(t,n);for(var r=0,o=t.length;r<o;++r)n.push(e(t[r]))}else if(l2.indexOf(t.constructor)>=0)n=t;else{let r=lB(t);for(var i in n=r===Object.prototype?{}:Object.create(r),l3&&l3.set(t,n),t)lI(t,i)&&(n[i]=e(t[i]))}return n}(e);return l3=null,t}let{toString:l5}={};function l6(e){return l5.call(e).slice(8,-1)}let l8="u">typeof Symbol?Symbol.iterator:"@@iterator",l7="symbol"==typeof l8?function(e){var t;return null!=e&&(t=e[l8])&&t.apply(e)}:function(){return null},l9={};function ce(e){var t,n,r,o;if(1==arguments.length){if(lP(e))return e.slice();if(this===l9&&"string"==typeof e)return[e];if(o=l7(e)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=Array(t);t--;)n[t]=arguments[t];return n}let ct="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var cn="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),cr=()=>!0;let co=!Error("").stack;function ci(){if(co)try{throw ci.arguments,Error()}catch(e){return e}return Error()}function ca(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(cr).map(e=>"\n"+e).join("")):""}var cs=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],cl=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(cs),cc={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function cu(e,t){this._e=ci(),this.name=e,this.message=t}function cp(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,n)=>n.indexOf(e)===t).join("\n")}function cd(e,t,n,r){this._e=ci(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=cp(e,t)}function cf(e,t){this._e=ci(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=cp(e,t)}lL(cu).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+ca(this._e,2))}},toString:function(){return this.name+": "+this.message}}),lL(cd).from(cu),lL(cf).from(cu);var ch=cl.reduce((e,t)=>(e[t]=t+"Error",e),{}),cm=cl.reduce((e,t)=>{var n=t+"Error";function r(e,r){this._e=ci(),this.name=n,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=cc[t]||n,this.inner=null)}return lL(r).from(cu),e[t]=r,e},{});cm.Syntax=SyntaxError,cm.Type=TypeError,cm.Range=RangeError;var cg=cs.reduce((e,t)=>(e[t+"Error"]=cm[t],e),{}),cb=cl.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=cm[t]),e),{});function cy(){}function c_(e){return e}function cv(e,t){return null==e||e===c_?t:function(n){return t(e(n))}}function cA(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function c$(e,t){return e===cy?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?cA(r,this.onsuccess):r),o&&(this.onerror=this.onerror?cA(o,this.onerror):o),void 0!==i?i:n}}function cw(e,t){return e===cy?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?cA(n,this.onsuccess):n),r&&(this.onerror=this.onerror?cA(r,this.onerror):r)}}function ck(e,t){return e===cy?t:function(n){var r=e.apply(this,arguments);lT(n,r);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?cA(o,this.onsuccess):o),i&&(this.onerror=this.onerror?cA(i,this.onerror):i),void 0===r?void 0===a?void 0:a:lT(r,a)}}function cx(e,t){return e===cy?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function cC(e,t){return e===cy?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,o=arguments.length,i=Array(o);o--;)i[o]=arguments[o];return n.then(function(){return t.apply(r,i)})}return t.apply(this,arguments)}}cb.ModifyError=cd,cb.DexieError=cu,cb.BulkError=cf;var cE={};let[cS,cD,cM]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,lB(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,lB(t),e]})(),cz=cD&&cD.then,cO=cS&&cS.constructor,cP=!!cM;var cT=!1,cB=cM?()=>{cM.then(c2)}:lz.setImmediate?setImmediate.bind(null,c2):lz.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{c2(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(c2,0)},cj=function(e,t){cU.push([e,t]),cN&&(cB(),cN=!1)},cI=!0,cN=!0,cR=[],cF=[],cL=null,cW=c_,cG={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:um,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{um(e[0],e[1])}catch(e){}})}},cV=cG,cU=[],cq=0,cH=[];function cK(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=cy,this._lib=!1;var t=this._PSD=cV;if(cn&&(this._stackHolder=ci(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==cE)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&cZ(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,n){try{n(n=>{if(null===t._state){if(n===t)throw TypeError("A promise cannot be resolved with itself.");var r=t._lib&&c3();n&&"function"==typeof n.then?e(t,(e,t)=>{n instanceof cK?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,cX(t)),r&&c4()}},cZ.bind(null,t))}catch(e){cZ(t,e)}}(this,e)}let cY={get:function(){var e=cV,t=un;function n(n,r){var o=!e.global&&(e!==cV||t!==un);let i=o&&!ua();var a=new cK((t,a)=>{cQ(this,new cJ(uf(n,e,o,i),uf(r,e,o,i),t,a,e))});return cn&&c1(a,this),a}return n.prototype=cE,n},set:function(e){lF(this,"then",e&&e.prototype===cE?cY:{get:function(){return e},set:cY.set})}};function cJ(e,t,n,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=o}function cZ(e,t){if(cF.push(t),null===e._state){var n=e._lib&&c3();t=cW(t),e._state=!1,e._value=t,cn&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var n=lG(t,"stack");t._promise=e,lF(t,"stack",{get:()=>cT?n&&(n.get?n.get.apply(t):n.value):e.stack})}),cR.some(t=>t._value===e._value)||cR.push(e),cX(e),n&&c4()}}function cX(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)cQ(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),0===cq&&(++cq,cj(()=>{0==--cq&&c5()},[]))}function cQ(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++cq,cj(c0,[n,e,t])}else e._listeners.push(t)}function c0(e,t,n){try{cL=t;var r,o=t._value;t._state?r=e(o):(cF.length&&(cF=[]),r=e(o),-1===cF.indexOf(o)&&function(e){for(var t=cR.length;t;)if(cR[--t]._value===e._value)return void cR.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{cL=null,0==--cq&&c5(),--n.psd.ref||n.psd.finalize()}}function c1(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function c2(){c3()&&c4()}function c3(){var e=cI;return cI=!1,cN=!1,e}function c4(){var e,t,n;do for(;cU.length>0;)for(e=cU,cU=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(cU.length>0);cI=!0,cN=!0}function c5(){var e=cR;cR=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=cH.slice(0),n=t.length;n;)t[--n]()}function c6(e){return new cK(cE,!1,e)}function c8(e,t){var n=cV;return function(){var r=c3(),o=cV;try{return uu(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{uu(o,!1),r&&c4()}}}lN(cK.prototype,{then:cY,_then:function(e,t){cQ(this,new cJ(null,null,e,t,cV))},catch:function(e){if(1==arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?n(e):c6(e)):this.then(null,e=>e&&e.name===t?n(e):c6(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),c6(t)))},stack:{get:function(){if(this._stack)return this._stack;try{cT=!0;var e=(function e(t,n,r){if(n.length===r)return n;var o="";if(!1===t._state){var i,a,s=t._value;null!=s?(i=s.name||"Error",a=s.message||s,o=ca(s,0)):(i=s,a=""),n.push(i+(a?": "+a:"")+o)}return cn&&((o=ca(t._stackHolder,2))&&-1===n.indexOf(o)&&n.push(o),t._prev&&e(t._prev,n,r)),n})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{cT=!1}}},timeout:function(e,t){return e<1/0?new cK((n,r)=>{var o=setTimeout(()=>r(new cm.Timeout(t)),e);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&lF(cK.prototype,Symbol.toStringTag,"Dexie.Promise"),cG.env=up(),lN(cK,{all:function(){var e=ce.apply(null,arguments).map(us);return new cK(function(t,n){0===e.length&&t([]);var r=e.length;e.forEach((o,i)=>cK.resolve(o).then(n=>{e[i]=n,--r||t(e)},n))})},resolve:e=>{if(e instanceof cK)return e;if(e&&"function"==typeof e.then)return new cK((t,n)=>{e.then(t,n)});var t=new cK(cE,!0,e);return c1(t,cL),t},reject:c6,race:function(){var e=ce.apply(null,arguments).map(us);return new cK((t,n)=>{e.map(e=>cK.resolve(e).then(t,n))})},PSD:{get:()=>cV,set:e=>cV=e},totalEchoes:{get:()=>un},newPSD:uo,usePSD:ud,scheduler:{get:()=>cj,set:e=>{cj=e}},rejectionMapper:{get:()=>cW,set:e=>{cW=e}},follow:(e,t)=>new cK((n,r)=>uo((t,n)=>{var r=cV;r.unhandleds=[],r.onunhandled=n,r.finalize=cA(function(){var e;e=()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])},cH.push(function t(){e(),cH.splice(cH.indexOf(t),1)}),++cq,cj(()=>{0==--cq&&c5()},[])},r.finalize),e()},t,n,r))}),cO&&(cO.allSettled&&lF(cK,"allSettled",function(){let e=ce.apply(null,arguments).map(us);return new cK(t=>{0===e.length&&t([]);let n=e.length,r=Array(n);e.forEach((e,o)=>cK.resolve(e).then(e=>r[o]={status:"fulfilled",value:e},e=>r[o]={status:"rejected",reason:e}).then(()=>--n||t(r)))})}),cO.any&&"u">typeof AggregateError&&lF(cK,"any",function(){let e=ce.apply(null,arguments).map(us);return new cK((t,n)=>{0===e.length&&n(AggregateError([]));let r=e.length,o=Array(r);e.forEach((e,i)=>cK.resolve(e).then(e=>t(e),e=>{o[i]=e,--r||n(AggregateError(o))}))})}));let c7={awaits:0,echoes:0,id:0};var c9=0,ue=[],ut=0,un=0,ur=0;function uo(e,t,n,r){var o=cV,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++ur;var a=cG.env;i.env=cP?{Promise:cK,PromiseProp:{value:cK,configurable:!0,writable:!0},all:cK.all,race:cK.race,allSettled:cK.allSettled,any:cK.any,resolve:cK.resolve,reject:cK.reject,nthen:uh(a.nthen,i),gthen:uh(a.gthen,i)}:{},t&&lT(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=ud(i,e,n,r);return 0===i.ref&&i.finalize(),s}function ui(){return c7.id||(c7.id=++c9),++c7.awaits,c7.echoes+=100,c7.id}function ua(){return!!c7.awaits&&(0==--c7.awaits&&(c7.id=0),c7.echoes=100*c7.awaits,!0)}function us(e){return c7.echoes&&e&&e.constructor===cO?(ui(),e.then(e=>(ua(),e),e=>(ua(),ug(e)))):e}function ul(e){++un,c7.echoes&&0!=--c7.echoes||(c7.echoes=c7.id=0),ue.push(cV),uu(e,!0)}function uc(){var e=ue[ue.length-1];ue.pop(),uu(e,!1)}function uu(e,t){var n,r=cV;if((t?!c7.echoes||ut++&&e===cV:!ut||--ut&&e===cV)||(n=t?ul.bind(null,e):uc,cz.call(cS,n)),e!==cV&&(cV=e,r===cG&&(cG.env=up()),cP)){var o=cG.env.Promise,i=e.env;cD.then=i.nthen,o.prototype.then=i.gthen,(r.global||e.global)&&(Object.defineProperty(lz,"Promise",i.PromiseProp),o.all=i.all,o.race=i.race,o.resolve=i.resolve,o.reject=i.reject,i.allSettled&&(o.allSettled=i.allSettled),i.any&&(o.any=i.any))}}function up(){var e=lz.Promise;return cP?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(lz,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:cD.then,gthen:e.prototype.then}:{}}function ud(e,t,n,r,o){var i=cV;try{return uu(e,!0),t(n,r,o)}finally{uu(i,!1)}}function uf(e,t,n,r){return"function"!=typeof e?e:function(){var o,i=cV;n&&ui(),uu(t,!0);try{return e.apply(this,arguments)}finally{uu(i,!1),r&&(o=ua,cz.call(cS,o))}}}function uh(e,t){return function(n,r){return e.call(this,uf(n,t),uf(r,t))}}function um(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,o={promise:t,reason:e};if(lz.document&&document.createEvent?((r=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),lT(r,o)):lz.CustomEvent&&lT(r=new CustomEvent("unhandledrejection",{detail:o}),o),r&&lz.dispatchEvent&&(dispatchEvent(r),!lz.PromiseRejectionEvent&&lz.onunhandledrejection))try{lz.onunhandledrejection(r)}catch(e){}cn&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+cz).indexOf("[native code]")&&(ui=ua=cy);var ug=cK.reject;let ub=String.fromCharCode(65535),uy="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",u_=[],uv="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),uA=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function u$(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let uw={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function uk(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=l4(t))[e],t)}class ux{_trans(e,t,n){let r=this._tx||cV.trans,o=this.name;function i(e,n,r){if(!r.schema[o])throw new cm.NotFound("Table "+o+" not part of transaction");return t(r.idbtrans,r)}let a=c3();try{return r&&r.db===this.db?r===cV.trans?r._promise(e,i,n):uo(()=>r._promise(e,i,n),{trans:r,transless:cV.transless||cV}):function e(t,n,r,o){if(t.idbdb&&(t._state.openComplete||cV.letThrough||t._vip)){var i=t._createTransaction(n,r,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===ch.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,r,o))):ug(i)}return i._promise(n,(e,t)=>uo(()=>(cV.trans=i,o(e,t,i)))).then(e=>i._completion.then(()=>e))}if(t._state.openComplete)return ug(new cm.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return ug(new cm.DatabaseClosed);t.open().catch(cy)}return t._state.dbReadyPromise.then(()=>e(t,n,r,o))}(this.db,e,[this.name],i)}finally{a&&c4()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(lP(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=lO(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)&&e.keyPath.every(e=>t.indexOf(e)>=0))[0];if(n&&this.db._maxKey!==ub)return this.where(n.name).equals(n.keyPath.map(t=>e[t]));!n&&cn&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:r}=this.schema,o=this.db._deps.indexedDB;function i(e,t){try{return 0===o.cmp(e,t)}catch(e){return!1}}let[a,s]=t.reduce(([t,n],o)=>{let a=r[o],s=e[o];return[t||a,t||!a?u$(n,a&&a.multi?e=>{let t=lJ(e,o);return lP(t)&&t.some(e=>i(s,e))}:e=>i(s,lJ(e,o))):n]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):n?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,lP(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let n=Object.create(e.prototype);for(var r in t)if(lI(t,r))try{n[r]=t[r]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){lT(this,e)})}add(e,t){let{auto:n,keyPath:r}=this.schema.primKey,o=e;return r&&n&&(o=uk(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[o]})).then(e=>e.numFailures?cK.reject(e.failures[0]):e.lastResult).then(t=>{if(r)try{lZ(e,r,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||lP(e))return this.where(":id").equals(e).modify(t);{let n=lJ(e,this.schema.primKey.keyPath);if(void 0===n)return ug(new cm.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?lO(t).forEach(n=>{lZ(e,n,t[n])}):t(e,{value:e,primKey:n})}catch(e){}return this.where(":id").equals(n).modify(t)}}put(e,t){let{auto:n,keyPath:r}=this.schema.primKey,o=e;return r&&n&&(o=uk(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=t?[t]:null})).then(e=>e.numFailures?cK.reject(e.failures[0]):e.lastResult).then(t=>{if(r)try{lZ(e,r,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?cK.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:uw})).then(e=>e.numFailures?cK.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,n){let r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new cm.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new cm.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&n?e.map(uk(i)):e;return this.core.mutate({trans:t,type:"add",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new cf(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,r)})})}bulkPut(e,t,n){let r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new cm.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new cm.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&n?e.map(uk(i)):e;return this.core.mutate({trans:t,type:"put",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new cf(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,r)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:n,failures:r})=>{if(0===e)return n;throw new cf(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,r)})}}function uC(e){var t={},n=function(n,r){if(r){for(var o=arguments.length,i=Array(o-1);--o;)i[o-1]=arguments[o];return t[n].subscribe.apply(null,i),e}if("string"==typeof n)return t[n]};n.addEventType=i;for(var r=1,o=arguments.length;r<o;++r)i(arguments[r]);return n;function i(e,r,o){if("object"==typeof e){var a;return void lO(a=e).forEach(function(e){var t=a[e];if(lP(t))i(e,a[e][0],a[e][1]);else{if("asap"!==t)throw new cm.InvalidArgument("Invalid event config");var n=i(e,c_,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){lK(function(){e.apply(null,t)})})})}})}r||(r=cx),o||(o=cy);var s={subscribers:[],fire:o,subscribe:function(e){-1===s.subscribers.indexOf(e)&&(s.subscribers.push(e),s.fire=r(s.fire,e))},unsubscribe:function(e){s.subscribers=s.subscribers.filter(function(t){return t!==e}),s.fire=s.subscribers.reduce(r,o)}};return t[e]=n[e]=s,s}}function uE(e,t){return lL(t).from({prototype:e}),t}function uS(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function uD(e,t){e.filter=u$(e.filter,t)}function uM(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>u$(r(),t()):t,e.justLimit=n&&!r}function uz(e,t){if(e.isPrimKey)return t.primaryKey;let n=t.getIndexByKeyPath(e.index);if(!n)throw new cm.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function uO(e,t,n){let r=uz(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function uP(e,t,n,r){let o=e.replayFilter?u$(e.filter,e.replayFilter()):e.filter;if(e.or){let i={},a=(e,n,r)=>{if(!o||o(n,r,e=>n.stop(e),e=>n.fail(e))){var a=n.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),lI(i,s)||(i[s]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(a,n),uT(uO(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return uT(uO(e,r,n),u$(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function uT(e,t,n,r){var o=c8(r?(e,t,o)=>n(r(e),t,o):n);return e.then(e=>{if(e)return e.start(()=>{var n=()=>e.continue();t&&!t(e,e=>n=e,t=>{e.stop(t),n=cy},t=>{e.fail(t),n=cy})||o(e.value,e,e=>n=e),n()})})}function uB(e,t){try{let n=uj(e),r=uj(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let n=e.length,r=t.length,o=n<r?n:r;for(let n=0;n<o;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===r?0:n<r?-1:1}(uI(e),uI(t));case"Array":return function(e,t){let n=e.length,r=t.length,o=n<r?n:r;for(let n=0;n<o;++n){let r=uB(e[n],t[n]);if(0!==r)return r}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function uj(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let n=l6(e);return"ArrayBuffer"===n?"binary":n}function uI(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class uN{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,ug.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,ug.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=u$(t.algorithm,e)}_iterate(e,t){return uP(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&lT(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(n=>uP(t,e,n,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,n=t.table.core;if(uS(t,!0))return n.count({trans:e,query:{index:uz(t,n.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var r=0;return uP(t,()=>(++r,!1),e,n).then(()=>r)}).then(e)}sortBy(e,t){let n=e.split(".").reverse(),r=n[0],o=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function s(e,t){var n=i(e,o),r=i(t,o);return n<r?-a:n>r?a:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&uS(t,!0)&&t.limit>0){let{valueMapper:n}=t,r=uz(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(({result:e})=>n?e.map(n):e)}{let n=[];return uP(t,e=>n.push(e),e,t.table.core).then(()=>n)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,uS(t)?uM(t,()=>{var t=e;return(e,n)=>0===t||(1===t?--t:n(()=>{e.advance(t),t=0}),!1)}):uM(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),uM(this._ctx,()=>{var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}},!0),this}until(e,t){return uD(this._ctx,function(n,r,o){return!e(n.value)||(r(o),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return uD(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=u$(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&uS(t,!0)&&t.limit>0)return this._read(e=>{var n=uz(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return uD(this._ctx,function(e){var t=e.primaryKey.toString(),r=lI(n,t);return n[t]=!0,!r}),this}modify(e){var t=this._ctx;return this._write(n=>{var r;if("function"==typeof e)r=e;else{var o=lO(e),i=o.length;r=function(t){for(var n=!1,r=0;r<i;++r){var a=o[r],s=e[a];lJ(t,a)!==s&&(lZ(t,a,s),n=!0)}return n}}let a=t.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,c=this.db._options.modifyChunkSize||200,u=[],p=0,d=[],f=(e,t)=>{let{failures:n,numFailures:r}=t;for(let t of(p+=e-r,lO(n)))u.push(n[t])};return this.clone().primaryKeys().then(o=>{let i=u=>{let p=Math.min(c,o.length-u);return a.getMany({trans:n,keys:o.slice(u,u+p),cache:"immutable"}).then(d=>{let h=[],m=[],g=s?[]:null,b=[];for(let e=0;e<p;++e){let t=d[e],n={value:l4(t),primKey:o[u+e]};!1!==r.call(n,n.value,n)&&(null==n.value?b.push(o[u+e]):s||0===uB(l(t),l(n.value))?(m.push(n.value),s&&g.push(o[u+e])):(b.push(o[u+e]),h.push(n.value)))}let y=uS(t)&&t.limit===1/0&&("function"!=typeof e||e===uR)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&a.mutate({trans:n,type:"add",values:h}).then(e=>{for(let t in e.failures)b.splice(parseInt(t),1);f(h.length,e)})).then(()=>(m.length>0||y&&"object"==typeof e)&&a.mutate({trans:n,type:"put",keys:g,values:m,criteria:y,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(b.length>0||y&&e===uR)&&a.mutate({trans:n,type:"delete",keys:b,criteria:y}).then(e=>f(b.length,e))).then(()=>o.length>u+p&&i(u+c))})};return i(0).then(()=>{if(u.length>0)throw new cd("Error modifying one or more objects",u,p,d);return o.length})})})}delete(){var e=this._ctx,t=e.range;return uS(e)&&(e.isPrimKey&&!uv||3===t.type)?this._write(n=>{let{primaryKey:r}=e.table.core.schema;return e.table.core.count({trans:n,query:{index:r,range:t}}).then(r=>e.table.core.mutate({trans:n,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:n,numFailures:o})=>{if(o)throw new cd("Could not delete some values",Object.keys(e).map(t=>e[t]),r-o);return r-o}))}):this.modify(uR)}}let uR=(e,t)=>t.value=null;function uF(e,t){return e<t?-1:+(e!==t)}function uL(e,t){return e>t?-1:+(e!==t)}function uW(e,t,n){var r=e instanceof uH?new e.Collection(e):e;return r._ctx.error=n?new n(t):TypeError(t),r}function uG(e){return new e.Collection(e,()=>uq("")).limit(0)}function uV(e,t,n,r){var o,i,a,s,l,c,u,p=n.length;if(!n.every(e=>"string"==typeof e))return uW(e,"String expected.");function d(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),i="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?uF:uL;var t=n.map(function(e){return{lower:i(e),upper:o(e)}}).sort(function(e,t){return a(e.lower,t.lower)});s=t.map(function(e){return e.upper}),l=t.map(function(e){return e.lower}),c=e,u="next"===e?"":r}d("next");var f=new e.Collection(e,()=>uU(s[0],l[p-1]+r));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,n,r){var o=e.key;if("string"!=typeof o)return!1;var d=i(o);if(t(d,l,h))return!0;for(var f=null,m=h;m<p;++m){var g=function(e,t,n,r,o,i){for(var a=Math.min(e.length,r.length),s=-1,l=0;l<a;++l){var c=t[l];if(c!==r[l])return 0>o(e[l],n[l])?e.substr(0,l)+n[l]+n.substr(l+1):0>o(e[l],r[l])?e.substr(0,l)+r[l]+n.substr(l+1):s>=0?e.substr(0,s)+t[s]+n.substr(s+1):null;0>o(e[l],c)&&(s=l)}return a<r.length&&"next"===i?e+n.substr(e.length):a<e.length&&"prev"===i?e.substr(0,n.length):s<0?null:e.substr(0,s)+r[s]+n.substr(s+1)}(o,d,s[m],l[m],a,c);null===g&&null===f?h=m+1:(null===f||a(f,g)>0)&&(f=g)}return n(null!==f?function(){e.continue(f+u)}:r),!1}),f}function uU(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function uq(e){return{type:1,lower:e,upper:e}}class uH{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?uG(this):new this.Collection(this,()=>uU(e,t,!n,!r))}catch(e){return uW(this,uy)}}equals(e){return null==e?uW(this,uy):new this.Collection(this,()=>uq(e))}above(e){return null==e?uW(this,uy):new this.Collection(this,()=>uU(e,void 0,!0))}aboveOrEqual(e){return null==e?uW(this,uy):new this.Collection(this,()=>uU(e,void 0,!1))}below(e){return null==e?uW(this,uy):new this.Collection(this,()=>uU(void 0,e,!1,!0))}belowOrEqual(e){return null==e?uW(this,uy):new this.Collection(this,()=>uU(void 0,e))}startsWith(e){return"string"!=typeof e?uW(this,"String expected."):this.between(e,e+ub,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):uV(this,(e,t)=>0===e.indexOf(t[0]),[e],ub)}equalsIgnoreCase(e){return uV(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=ce.apply(l9,arguments);return 0===e.length?uG(this):uV(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=ce.apply(l9,arguments);return 0===e.length?uG(this):uV(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,ub)}anyOf(){let e=ce.apply(l9,arguments),t=this._cmp;try{e.sort(t)}catch(e){return uW(this,uy)}if(0===e.length)return uG(this);let n=new this.Collection(this,()=>uU(e[0],e[e.length-1]));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let r=0;return n._addAlgorithm((n,o,i)=>{let a=n.key;for(;t(a,e[r])>0;)if(++r===e.length)return o(i),!1;return 0===t(a,e[r])||(o(()=>{n.continue(e[r])}),!1)}),n}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=ce.apply(l9,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return uW(this,uy)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let n=this._cmp,r=this._ascending,o=this._descending,i=this._min,a=this._max;if(0===e.length)return uG(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=r(e[0],e[1])))return uW(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",cm.InvalidArgument);let s=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,c,u=r;function p(e,t){return u(e[0],t[0])}try{(c=e.reduce(function(e,t){let r=0,o=e.length;for(;r<o;++r){let o=e[r];if(0>n(t[0],o[1])&&n(t[1],o[0])>0){o[0]=i(o[0],t[0]),o[1]=a(o[1],t[1]);break}}return r===o&&e.push(t),e},[])).sort(p)}catch(e){return uW(this,uy)}let d=0,f=l?e=>r(e,c[d][1])>0:e=>r(e,c[d][1])>=0,h=s?e=>o(e,c[d][0])>0:e=>o(e,c[d][0])>=0,m=f,g=new this.Collection(this,()=>uU(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,u=r):(m=h,u=o),c.sort(p)},g._addAlgorithm((e,t,n)=>{for(var o=e.key;m(o);)if(++d===c.length)return t(n),!1;return!!(!f(o)&&!h(o))||(0===this._cmp(o,c[d][1])||0===this._cmp(o,c[d][0])||t(()=>{u===r?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=ce.apply(l9,arguments);return e.every(e=>"string"==typeof e)?0===e.length?uG(this):this.inAnyRange(e.map(e=>[e,e+ub])):uW(this,"startsWithAnyOf() only works with strings")}}function uK(e){return c8(function(t){return uY(t),e(t.target.error),!1})}function uY(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let uJ=uC(null,"storagemutated");class uZ{_lock(){return lH(!cV.global),++this._reculock,1!==this._reculock||cV.global||(cV.lockOwnerFor=this),this}_unlock(){if(lH(!cV.global),0==--this._reculock)for(cV.global||(cV.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{ud(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&cV.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,n=this.db._state.dbOpenError;if(lH(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new cm.DatabaseClosed(n);case"MissingAPIError":throw new cm.MissingAPI(n.message,n);default:throw new cm.OpenFailed(n)}if(!this.active)throw new cm.TransactionInactive;return lH(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=c8(t=>{uY(t),this._reject(e.error)}),e.onabort=c8(t=>{uY(t),this.active&&this._reject(new cm.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=c8(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&uJ.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return ug(new cm.ReadOnly("Transaction is readonly"));if(!this.active)return ug(new cm.TransactionInactive);if(this._locked())return new cK((r,o)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(r,o)},cV])});if(n)return uo(()=>{var e=new cK((e,n)=>{this._lock();let r=t(e,n,this);r&&r.then&&r.then(e,n)});return e.finally(()=>this._unlock()),e._lib=!0,e});var r=new cK((e,n)=>{var r=t(e,n,this);r&&r.then&&r.then(e,n)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let n=cK.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>n);else{t._waitingFor=n,t._waitingQueue=[];var r=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var o=t._waitingFor;return new cK((e,r)=>{n.then(n=>t._waitingQueue.push(c8(e.bind(null,n))),e=>t._waitingQueue.push(c8(r.bind(null,e)))).finally(()=>{t._waitingFor===o&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new cm.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(lI(t,e))return t[e];let n=this.schema[e];if(!n)throw new cm.NotFound("Table "+e+" not part of transaction");let r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r}}function uX(e,t,n,r,o,i,a){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+uQ(t)}}function uQ(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function u0(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:lY(n,e=>[e.name,e])}}let u1=e=>{try{return e.only([[]]),u1=()=>[[]],[[]]}catch(e){return u1=()=>ub,ub}};function u2(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>lJ(t,e):t=>lJ(t,e)}function u3(e){return[].slice.call(e)}let u4=0;function u5(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function u6({_novip:e},t){let n=t.db,r=function(e,t,{IDBKeyRange:n,indexedDB:r},o){var i;return{dbcore:(i=function(e,t,n){let r;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:n,upper:r,lowerOpen:o,upperOpen:i}=e;return void 0===n?void 0===r?null:t.upperBound(r,!!i):void 0===r?t.lowerBound(n,!!o):t.bound(n,r,!!o,!!i)}let{schema:i,hasGetAll:a}=(r=u3(e.objectStoreNames),{schema:{name:e.name,tables:r.map(e=>n.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:n}=e,r=lP(t),o=null==t,i={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:u2(t)},indexes:u3(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:n,multiEntry:r,keyPath:o}=e,a={name:t,compound:lP(o),keyPath:o,unique:n,multiEntry:r,extractKey:u2(o)};return i[u5(o)]=a,a}),getIndexByKeyPath:e=>i[u5(e)]};return i[":id"]=a.primaryKey,null!=t&&(i[u5(t)]=a.primaryKey),a})},hasGetAll:r.length>0&&"getAll"in n.objectStore(r[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=i.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:n,keys:r,values:i,range:a}){return new Promise((s,l)=>{let c;s=c8(s);let u=e.objectStore(t),p=null==u.keyPath,d="put"===n||"add"===n;if(!d&&"delete"!==n&&"deleteRange"!==n)throw Error("Invalid operation type: "+n);let{length:f}=r||i||{length:1};if(r&&i&&r.length!==i.length)throw Error("Given keys array must have same length as given values array.");if(0===f)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],g=0,b=e=>{++g,uY(e)};if("deleteRange"===n){if(4===a.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===a.type?h.push(c=u.clear()):h.push(c=u.delete(o(a)))}else{let[e,t]=d?p?[i,r]:[i,null]:[r,null];if(d)for(let r=0;r<f;++r)h.push(c=t&&void 0!==t[r]?u[n](e[r],t[r]):u[n](e[r])),c.onerror=b;else for(let t=0;t<f;++t)h.push(c=u[n](e[t])),c.onerror=b}let y=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:g,failures:m,results:"delete"===n?r:h.map(e=>e.result),lastResult:t})};c.onerror=e=>{b(e),y(e)},c.onsuccess=y})},getMany:({trans:e,keys:n})=>new Promise((r,o)=>{r=c8(r);let i=e.objectStore(t),a=n.length,s=Array(a),l,c=0,u=0,p=e=>{let t=e.target;s[t._pos]=t.result,++u===c&&r(s)},d=uK(o);for(let e=0;e<a;++e)null!=n[e]&&((l=i.get(n[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&r(s)}),get:({trans:e,key:n})=>new Promise((r,o)=>{r=c8(r);let i=e.objectStore(t).get(n);i.onsuccess=e=>r(e.target.result),i.onerror=uK(o)}),query:e=>new Promise((n,r)=>{n=c8(n);let{trans:i,values:s,limit:l,query:c}=e,u=l===1/0?void 0:l,{index:p,range:d}=c,f=i.objectStore(t),h=p.isPrimaryKey?f:f.index(p.name),m=o(d);if(0===l)return n({result:[]});if(a){let e=s?h.getAll(m,u):h.getAllKeys(m,u);e.onsuccess=e=>n({result:e.target.result}),e.onerror=uK(r)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];t.onsuccess=r=>{let i=t.result;return i?(o.push(s?i.value:i.primaryKey),++e===l?n({result:o}):void i.continue()):n({result:o})},t.onerror=uK(r)}}),openCursor:function({trans:e,values:n,query:r,reverse:i,unique:a}){return new Promise((s,l)=>{s=c8(s);let{index:c,range:u}=r,p=e.objectStore(t),d=c.isPrimaryKey?p:p.index(c.name),f=i?a?"prevunique":"prev":a?"nextunique":"next",h=!n&&"openKeyCursor"in d?d.openKeyCursor(o(u),f):d.openCursor(o(u),f);h.onerror=uK(l),h.onsuccess=c8(t=>{let n=h.result;if(!n)return void s(null);n.___id=++u4,n.done=!1;let r=n.continue.bind(n),o=n.continuePrimaryKey;o&&(o=o.bind(n));let i=n.advance.bind(n),a=()=>{throw Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw Error("Cursor not started")},n.fail=c8(l),n.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},n.start=e=>{let t=new Promise((e,t)=>{e=c8(e),h.onerror=uK(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=a,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw Error("Cursor behind last entry")},n.stop()};return h.onsuccess=c8(e=>{h.onsuccess=s,s()}),n.continue=r,n.continuePrimaryKey=o,n.advance=i,s(),t},s(n)},l)})},count({query:e,trans:n}){let{index:r,range:i}=e;return new Promise((e,a)=>{let s=n.objectStore(t),l=r.isPrimaryKey?s:s.index(r.name),c=o(i),u=c?l.count(c):l.count();u.onsuccess=c8(t=>e(t.target.result)),u.onerror=uK(a)})}}}),l={};return s.forEach(e=>l[e.name]=e),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!l[e])throw Error(`Table '${e}' not found`);return l[e]},MIN_KEY:-1/0,MAX_KEY:u1(t),schema:i}}(t,n,o),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),i))}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach(t=>{let n=t.name;e.core.schema.tables.some(e=>e.name===n)&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))})}function u8({_novip:e},t,n,r){n.forEach(n=>{let o=r[n];t.forEach(t=>{let r=lG(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?lF(t,n,{get(){return this.table(n)},set(e){lR(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,o))})})}function u7({_novip:e},t){t.forEach(t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]})}function u9(e,t){return e._cfg.version-t._cfg.version}function pe(e,t){let n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){let o=e[n],i=t[n];if(o){let e={name:n,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(i.primKey.keyPath||"")&&(o.primKey.auto===i.primKey.auto||uv)){let t,n=o.idxByName,a=i.idxByName;for(t in n)a[t]||e.del.push(t);for(t in a){let r=n[t],o=a[t];r?r.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&r.change.push(e)}else e.recreate=!0,r.change.push(e)}else r.add.push([n,i])}return r}function pt(e,t,n,r){let o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(e=>pn(o,e)),o}function pn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function pr(e,t,n){let r={};return lU(t.objectStoreNames,0).forEach(e=>{let t=n.objectStore(e),o=t.keyPath,i=uX(uQ(o),o||"",!1,!1,!!t.autoIncrement,o&&"string"!=typeof o,!0),a=[];for(let e=0;e<t.indexNames.length;++e){let n=t.index(t.indexNames[e]);o=n.keyPath;var s=uX(n.name,o,!!n.unique,!!n.multiEntry,!1,o&&"string"!=typeof o,!1);a.push(s)}r[e]=u0(e,i,a)}),r}function po({_novip:e},t,n){let r=n.db.objectStoreNames;for(let o=0;o<r.length;++o){let i=r[o],a=n.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let n=a.indexNames[e],r=a.index(n).keyPath,o="string"==typeof r?r:"["+lU(r).join("+")+"]";if(t[i]){let e=t[i].idxByName[o];e&&(e.name=n,delete t[i].idxByName[o],t[i].idxByName[n]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&lz.WorkerGlobalScope&&lz instanceof lz.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class pi{_parseStoresSpec(e,t){lO(e).forEach(n=>{if(null!==e[n]){var r=e[n].split(",").map((e,t)=>{let n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return uX(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),lP(r),0===t)}),o=r.shift();if(o.multi)throw new cm.Schema("Primary key cannot be multi-valued");r.forEach(e=>{if(e.auto)throw new cm.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new cm.Schema("Index must have a name and cannot be an empty string")}),t[n]=u0(n,o,r)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?lT(this._cfg.storesSource,e):e;let n=t._versions,r={},o={};return n.forEach(e=>{lT(r,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(r,o)}),t._dbSchema=o,u7(t,[t._allTables,t,t.Transaction.prototype]),u8(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],lO(o),o),t._storeNames=lO(o),this}upgrade(e){return this._cfg.contentUpgrade=cC(this._cfg.contentUpgrade||cy,e),this}}function pa(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new px("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function ps(e){return e&&"function"==typeof e.databases}function pl(e){return uo(function(){return cV.letThrough=!0,e()})}function pc(e){var t=t=>e.next(t),n=o(t),r=o(t=>e.throw(t));function o(e){return t=>{var o=e(t),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(n,r):lP(i)?Promise.all(i).then(n,r):n(i)}}return o(t)()}function pu(e,t,n){var r=arguments.length;if(r<2)throw new cm.InvalidArgument("Too few arguments");for(var o=Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[e,l0(o),n]}function pp(e,t,n){let r=lP(e)?e.slice():[e];for(let e=0;e<n;++e)r.push(t);return r}let pd={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let n=e.table(t),{schema:r}=n,o={},i=[];function a(e,t,n){let r=u5(e),s=o[r]=o[r]||[],l=null==e?0:"string"==typeof e?1:e.length,c=t>0,u={...n,isVirtual:c,keyTail:t,keyLength:l,extractKey:u2(e),unique:!c&&n.unique};return s.push(u),u.isPrimaryKey||i.push(u),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,n),s.sort((e,t)=>e.keyTail-t.keyTail),u}let s=a(r.primaryKey.keyPath,0,r.primaryKey);for(let e of(o[":id"]=[s],r.indexes))a(e.keyPath,0,e);function l(t){var n,r;let o=t.query.index;return o.isVirtual?{...t,query:{index:o,range:(n=t.query.range,r=o.keyTail,{type:1===n.type?2:n.type,lower:pp(n.lower,n.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:pp(n.upper,n.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:t}return{...n,schema:{...r,primaryKey:s,indexes:i,getIndexByKeyPath:function(e){let t=o[u5(e)];return t&&t[0]}},count:e=>n.count(l(e)),query:e=>n.query(l(e)),openCursor(t){let{keyTail:r,isVirtual:o,keyLength:i}=t.query.index;return o?n.openCursor(l(t)).then(n=>n&&Object.create(n,{continue:{value:function(o){null!=o?n.continue(pp(o,t.reverse?e.MAX_KEY:e.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value(t,o){n.continuePrimaryKey(pp(t,e.MAX_KEY,r),o)}},primaryKey:{get:()=>n.primaryKey},key:{get(){let e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>n.value}})):n.openCursor(t)}}}}}};function pf(e,t,n,r){return n=n||{},r=r||"",lO(e).forEach(o=>{if(lI(t,o)){var i=e[o],a=t[o];if("object"==typeof i&&"object"==typeof a&&i&&a){let e=l6(i);e!==l6(a)?n[r+o]=t[o]:"Object"===e?pf(i,a,n,r+o+"."):i!==a&&(n[r+o]=t[o])}else i!==a&&(n[r+o]=t[o])}else n[r+o]=void 0}),lO(t).forEach(o=>{lI(e,o)||(n[r+o]=t[o])}),n}let ph={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let n=e.table(t),{primaryKey:r}=n.schema;return{...n,mutate(e){let o=cV.trans,{deleting:i,creating:a,updating:s}=o.table(t).hook;switch(e.type){case"add":if(a.fire===cy)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===cy&&s.fire===cy)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(i.fire===cy)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(i.fire===cy)break;return o._promise("readwrite",()=>(function e(t,o,i){return n.query({trans:t,values:!1,query:{index:r,range:o},limit:i}).then(({result:n})=>l({type:"delete",keys:n,trans:t}).then(r=>r.numFailures>0?Promise.reject(r.failures[0]):n.length<i?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...o,lower:n[n.length-1],lowerOpen:!0},i)))})(e.trans,e.range,1e4),!0)}return n.mutate(e);function l(e){var t,o;let l=cV.trans,c=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(r.extractKey));if(!c)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:c}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(o=e).type?Promise.resolve([]):n.getMany({trans:o.trans,keys:c,cache:"immutable"})).then(t=>{let o=c.map((n,o)=>{let c=t[o],u={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(u,n,c,l);else if("add"===e.type||void 0===c){let t=a.fire.call(u,n,e.values[o],l);null==n&&null!=t&&(n=t,e.keys[o]=n,r.outbound||lZ(e.values[o],r.keyPath,n))}else{let t=pf(c,e.values[o]),r=s.fire.call(u,t,n,c,l);if(r){let t=e.values[o];Object.keys(r).forEach(e=>{lI(t,e)?t[e]=r[e]:lZ(t,e,r[e])})}}return u});return n.mutate(e).then(({failures:n,results:r,numFailures:i,lastResult:a})=>{for(let i=0;i<c.length;++i){let a=r?r[i]:c[i],s=o[i];null==a?s.onerror&&s.onerror(n[i]):s.onsuccess&&s.onsuccess("put"===e.type&&t[i]?e.values[i]:a)}return{failures:n,results:r,numFailures:i,lastResult:a}}).catch(e=>(o.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function pm(e,t,n){try{if(!t||t.keys.length<e.length)return null;let r=[];for(let o=0,i=0;o<t.keys.length&&i<e.length;++o)0===uB(t.keys[o],e[i])&&(r.push(n?l4(t.values[o]):t.values[o]),++i);return r.length===e.length?r:null}catch(e){return null}}let pg={stack:"dbcore",level:-1,create:e=>({table:t=>{let n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);let t=pm(e.keys,e.trans._cache,"clone"===e.cache);return t?cK.resolve(t):n.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?l4(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function pb(e){return!("from"in e)}let py=function(e,t){if(!this){let t=new py;return e&&"d"in e&&lT(t,e),t}lT(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function p_(e,t,n){let r=uB(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(pb(e))return lT(e,{from:t,to:n,d:1});let o=e.l,i=e.r;if(0>uB(n,e.from))return o?p_(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},p$(e);if(uB(t,e.to)>0)return i?p_(i,t,n):e.r={from:t,to:n,d:1,l:null,r:null},p$(e);0>uB(t,e.from)&&(e.from=t,e.l=null,e.d=i?i.d+1:1),uB(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;o&&!e.l&&pv(e,o),i&&a&&pv(e,i)}function pv(e,t){pb(t)||function e(t,{from:n,to:r,l:o,r:i}){p_(t,n,r),o&&e(t,o),i&&e(t,i)}(e,t)}function pA(e){let t=pb(e)?null:{s:0,n:e};return{next(e){let n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&0>uB(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||0>=uB(e,t.n.to))return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function p$(e){var t,n;let r=((null==(t=e.r)?void 0:t.d)||0)-((null==(n=e.l)?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){let t="r"===o?"l":"r",n={...e},r=e[o];e.from=r.from,e.to=r.to,e[o]=r[o],n[o]=r[t],e[t]=n,n.d=pw(n)}e.d=pw(e)}function pw({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}lN(py.prototype,{add(e){return pv(this,e),this},addKey(e){return p_(this,e,e),this},addKeys(e){return e.forEach(e=>p_(this,e,e)),this},[l8](){return pA(this)}});let pk={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,n=new py(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{let o=e.table(r),{schema:i}=o,{primaryKey:a}=i,{extractKey:s,outbound:l}=a,c={...o,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),l=e=>{let n=`idb://${t}/${r}/${e}`;return s[n]||(s[n]=new py)},c=l(""),u=l(":dels"),{type:p}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return o.mutate(e).then(e=>{if(lP(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let t=pm(d,h);t||"add"===p||u.addKeys(d),(t||f)&&i.indexes.forEach(function(e){let n=l(e.name||"");function r(t){return null!=t?e.extractKey(t):null}let o=t=>e.multiEntry&&lP(t)?t.forEach(e=>n.addKey(e)):n.addKey(t);(t||f).forEach((e,n)=>{let i=t&&r(t[n]),a=f&&r(f[n]);0!==uB(i,a)&&(null!=i&&o(i),null!=a&&o(a))})})}else if(d){let e={from:d.lower,to:d.upper};u.add(e),c.add(e)}else c.add(n),u.add(n),i.indexes.forEach(e=>l(e.name).add(n));return e})}},u=({query:{index:t,range:n}})=>{var r,o;return[t,new py(null!=(r=n.lower)?r:e.MIN_KEY,null!=(o=n.upper)?o:e.MAX_KEY)]},p={get:e=>[a,new py(e.key)],getMany:e=>[a,(new py).addKeys(e.keys)],count:u,query:u,openCursor:u};return lO(p).forEach(e=>{c[e]=function(i){let{subscr:a}=cV;if(a){let c=e=>{let n=`idb://${t}/${r}/${e}`;return a[n]||(a[n]=new py)},u=c(""),d=c(":dels"),[f,h]=p[e](i);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&i.values&&o.query({...i,values:!1});return o[e].apply(this,arguments).then(n=>{if("query"===e){if(l&&i.values)return t.then(({result:e})=>(u.addKeys(e),n));let e=i.values?n.result.map(s):n.result;i.values?u.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=i.values;return n&&Object.create(n,{key:{get:()=>(d.addKey(n.primaryKey),n.key)},primaryKey:{get(){let e=n.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&u.addKey(n.primaryKey),n.value)}})}return n})}d.add(n)}}return o[e].apply(this,arguments)}}),c}}}};class px{constructor(e,t){var n;this._middlewares={},this.verno=0;const r=px.dependencies;this._options=t={addons:px.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:o}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:cy,dbReadyPromise:null,cancelOpen:cy,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};i.dbReadyPromise=new cK(e=>{i.dbReadyResolve=e}),i.openCanceller=new cK((e,t)=>{i.cancelOpen=t}),this._state=i,this.name=e,this.on=uC(this,"populate","blocked","versionchange","close",{ready:[cC,cy]}),this.on.ready.subscribe=lq(this.on.ready.subscribe,e=>(t,n)=>{px.vip(()=>{let r=this._state;if(r.openComplete)r.dbOpenError||cK.resolve().then(t),n&&e(t);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(t),n&&e(t);else{e(t);let r=this;n||e(function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)})}})}),this.Collection=(n=this,uE(uN.prototype,function(e,t){this.db=n;let r=uw,o=null;if(t)try{r=t()}catch(e){o=e}let i=e._ctx,a=i.table,s=a.hook.reading.fire;this._ctx={table:a,index:i.index,isPrimKey:!i.index||a.schema.primKey.keyPath&&i.index===a.schema.primKey.name,range:r,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:i.or,valueMapper:s!==c_?s:null}})),this.Table=function(e){return uE(ux.prototype,function(t,n,r){this.db=e,this._tx=r,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:uC(null,{creating:[c$,cy],reading:[cv,c_],updating:[ck,cy],deleting:[cw,cy]})})}(this),this.Transaction=function(e){return uE(uZ.prototype,function(t,n,r,o,i){this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=uC(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new cK((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),ug(e)})})}(this),this.Version=function(e){return uE(pi.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return uE(uH.prototype,function(t,n,r){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r};let o=e._deps.indexedDB;if(!o)throw new cm.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,t)=>o.cmp(t,e),this._max=(e,t)=>o.cmp(e,t)>0?e:t,this._min=(e,t)=>0>o.cmp(e,t)?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=u1(t.IDBKeyRange),this._createTransaction=(e,t,n,r)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),u_.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(pd),this.use(ph),this.use(pk),this.use(pg),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new cm.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new cm.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let t=this._versions;var n=t.filter(t=>t._cfg.version===e)[0];return n||(n=new this.Version(e),t.push(n),t.sort(u9),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||cV.letThrough||this._vip)?e():new cK((e,t)=>{if(this._state.openComplete)return t(new cm.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new cm.DatabaseClosed);this.open().catch(cy)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:n,name:r}){r&&this.unuse({stack:e,name:r});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:t,level:null==n?10:n,name:r}),o.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>n?e.create!==n:!!t&&e.name!==t)),this}open(){return function(e){var t;let n=e._state,{indexedDB:r}=e._deps;if(n.isBeingOpened||e.idbdb)return n.dbReadyPromise.then(()=>n.dbOpenError?ug(n.dbOpenError):e);cn&&(n.openCanceller._stackHolder=ci()),n.isBeingOpened=!0,n.dbOpenError=null,n.openComplete=!1;let o=n.openCanceller;function i(){if(n.openCanceller!==o)throw new cm.DatabaseClosed("db.open() was cancelled")}let a=n.dbReadyResolve,s=null,l=!1;return cK.race([o,("u"<typeof navigator?cK.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(()=>new cK((t,o)=>{if(i(),!r)throw new cm.MissingAPI;let a=e.name,c=n.autoSchema?r.open(a):r.open(a,Math.round(10*e.verno));if(!c)throw new cm.MissingAPI;c.onerror=uK(o),c.onblocked=c8(e._fireOnBlocked),c.onupgradeneeded=c8(t=>{if(s=c.transaction,n.autoSchema&&!e._options.allowEmptyDB){c.onerror=uY,s.abort(),c.result.close();let e=r.deleteDatabase(a);e.onsuccess=e.onerror=c8(()=>{o(new cm.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let n,r,a,d;s.onerror=uK(o);var i,u,p=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=p<1,e._novip.idbdb=c.result,i=p/10,u=s,n=e._dbSchema,(r=e._createTransaction("readwrite",e._storeNames,n)).create(u),r._completion.catch(o),a=r._reject.bind(r),d=cV.transless||cV,uo(()=>{cV.trans=r,cV.transless=d,0===i?(lO(n).forEach(e=>{pt(u,e,n[e].primKey,n[e].indexes)}),u6(e,u),cK.follow(()=>e.on.populate.fire(r)).catch(a)):(function({_novip:e},t,n,r){let o=[],i=e._versions,a=e._dbSchema=pr(e,e.idbdb,r),s=!1;return i.filter(e=>e._cfg.version>=t).forEach(i=>{o.push(()=>{let o=a,l=i._cfg.dbschema;po(e,o,r),po(e,l,r),a=e._dbSchema=l;let c=pe(o,l);c.add.forEach(e=>{pt(r,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new cm.Upgrade("Not yet support for changing primary key");{let t=r.objectStore(e.name);e.add.forEach(e=>pn(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),pn(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let u=i._cfg.contentUpgrade;if(u&&i._cfg.version>t){let t;u6(e,r),n._memoizedTables={},s=!0;let i=lX(l);c.del.forEach(e=>{i[e]=o[e]}),u7(e,[e.Transaction.prototype]),u8(e,[e.Transaction.prototype],lO(i),i),n.schema=i;let a=ct(u);a&&ui();let p=cK.follow(()=>{if((t=u(n))&&a){var e=ua.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?cK.resolve(t):p.then(()=>t)}}),o.push(t=>{var r;s&&uv||(r=i._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==r[e]&&t.db.deleteObjectStore(e))),u7(e,[e.Transaction.prototype]),u8(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),n.schema=e._dbSchema})}),(function e(){return o.length?cK.resolve(o.shift()(n.idbtrans)).then(e):cK.resolve()})().then(()=>{var e;lO(e=a).forEach(t=>{r.db.objectStoreNames.contains(t)||pt(r,t,e[t].primKey,e[t].indexes)})})})(e,i,r,u).catch(a)})}},o),c.onsuccess=c8(()=>{s=null;let r=e._novip.idbdb=c.result,o=lU(r.objectStoreNames);if(o.length>0)try{let t,i=r.transaction(1===o.length?o[0]:o,"readonly");n.autoSchema?function({_novip:e},t,n){e.verno=t.version/10;let r=e._dbSchema=pr(0,t,n);e._storeNames=lU(t.objectStoreNames,0),u8(e,[e._allTables],lO(r),r)}(e,r,i):(po(e,e._dbSchema,i),((t=pe(pr(0,e.idbdb,i),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),u6(e,i)}catch(e){}u_.push(e),r.onversionchange=c8(t=>{n.vcFired=!0,e.on("versionchange").fire(t)}),r.onclose=c8(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},n){ps(e)||"__dbnames"===n||pa(e,t).put({name:n}).catch(cy)}(e._deps,a),t()},o)}))]).then(()=>(i(),n.onReadyBeingFired=[],cK.resolve(pl(()=>e.on.ready.fire(e.vip))).then(function t(){if(n.onReadyBeingFired.length>0){let r=n.onReadyBeingFired.reduce(cC,cy);return n.onReadyBeingFired=[],cK.resolve(pl(()=>r(e.vip))).then(t)}}))).finally(()=>{n.onReadyBeingFired=null,n.isBeingOpened=!1}).then(()=>e).catch(t=>{n.dbOpenError=t;try{s&&s.abort()}catch(e){}return o===n.openCanceller&&e._close(),ug(t)}).finally(()=>{n.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=u_.indexOf(this);if(t>=0&&u_.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new cK(t=>{e.dbReadyResolve=t}),e.openCanceller=new cK((t,n)=>{e.cancelOpen=n})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new cm.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new cK((n,r)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=c8(()=>{!function({indexedDB:e,IDBKeyRange:t},n){ps(e)||"__dbnames"===n||pa(e,t).delete(n).catch(cy)}(this._deps,this.name),n()}),e.onerror=uK(r),e.onblocked=this._fireOnBlocked};if(e)throw new cm.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){let e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return lO(this._allTables).map(e=>this._allTables[e])}transaction(){let e=pu.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let r,o,i=cV.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||"readonly"===e)r="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new cm.InvalidArgument("Invalid transaction mode: "+e);r="readwrite"}if(i){if("readonly"===i.mode&&"readwrite"===r){if(!a)throw new cm.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&o.forEach(e=>{if(i&&-1===i.storeNames.indexOf(e)){if(!a)throw new cm.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),a&&i&&!i.active&&(i=null)}}catch(e){return i?i._promise(null,(t,n)=>{n(e)}):ug(e)}let s=(function e(t,n,r,o,i){return cK.resolve().then(()=>{let a,s=cV.transless||cV,l=t._createTransaction(n,r,t._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===ch.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,r,null,i))):ug(o)}let c=ct(i);c&&ui();let u=cK.follow(()=>{if(a=i.call(l,l))if(c){var e=ua.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=pc(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?cK.resolve(a).then(e=>l.active?e:ug(new cm.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>a)).then(e=>(o&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),ug(e)))})}).bind(null,this,r,o,i,n);return i?i._promise(r,s,"lock"):cV.trans?ud(cV.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!lI(this._allTables,e))throw new cm.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let pC="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class pE{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[pC](){return this}}function pS(e,t){return lO(t).forEach(n=>{pv(e[n]||(e[n]=new py),t[n])}),e}try{o={indexedDB:lz.indexedDB||lz.mozIndexedDB||lz.webkitIndexedDB||lz.msIndexedDB,IDBKeyRange:lz.IDBKeyRange||lz.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function pD(e){let t=pM;try{pM=!0,uJ.storagemutated.fire(e)}finally{pM=t}}lN(px,{...cb,delete:e=>new px(e,{addons:[]}).delete(),exists:e=>new px(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return ps(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>"__dbnames"!==e)):pa(e,t).toCollection().primaryKeys()})(px.dependencies).then(e)}catch(e){return ug(new cm.MissingAPI)}},defineClass:()=>function(e){lT(this,e)},ignoreTransaction:e=>cV.trans?ud(cV.transless,e):e(),vip:pl,async:function(e){return function(){try{var t=pc(e.apply(this,arguments));return t&&"function"==typeof t.then?t:cK.resolve(t)}catch(e){return ug(e)}}},spawn:function(e,t,n){try{var r=pc(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:cK.resolve(r)}catch(e){return ug(e)}},currentTransaction:{get:()=>cV.trans||null},waitFor:function(e,t){let n=cK.resolve("function"==typeof e?px.ignoreTransaction(e):e).timeout(t||6e4);return cV.trans?cV.trans.waitFor(n):n},Promise:cK,debug:{get:()=>cn,set:e=>{cn=e,cr="dexie"===e?()=>!0:uA}},derive:lL,extend:lT,props:lN,override:lq,Events:uC,on:uJ,liveQuery:function(e){return new pE(t=>{let n=ct(e),r=!1,o={},i={},a={get closed(){return r},unsubscribe:()=>{r=!0,uJ.storagemutated.unsubscribe(u)}};t.start&&t.start(a);let s=!1,l=!1;function c(){return lO(i).some(e=>o[e]&&function(e,t){let n=pA(t),r=n.next();if(r.done)return!1;let o=r.value,i=pA(e),a=i.next(o.from),s=a.value;for(;!r.done&&!a.done;){if(0>=uB(s.from,o.to)&&uB(s.to,o.from)>=0)return!0;0>uB(o.from,s.from)?o=(r=n.next(s.from)).value:s=(a=i.next(o.from)).value}return!1}(o[e],i[e]))}let u=e=>{pS(o,e),c()&&p()},p=()=>{let d,f;if(s||r)return;o={};let h={},m=(n&&ui(),d=()=>uo(e,{subscr:h,trans:null}),f=cV.trans?ud(cV.transless,d):d(),n&&f.then(ua,ua),f);l||(uJ("storagemutated",u),l=!0),s=!0,Promise.resolve(m).then(e=>{s=!1,r||(c()?p():(o={},i=h,t.next&&t.next(e)))},e=>{s=!1,t.error&&t.error(e),a.unsubscribe()})};return p(),a})},extendObservabilitySet:pS,getByKeyPath:lJ,setByKeyPath:lZ,delByKeyPath:function(e,t){"string"==typeof t?lZ(e,t,void 0):"length"in t&&[].map.call(t,function(t){lZ(e,t,void 0)})},shallowClone:lX,deepClone:l4,getObjectDiff:pf,cmp:uB,asap:lK,minKey:-1/0,addons:[],connections:u_,errnames:ch,dependencies:o,semVer:"3.2.2",version:"3.2.2".split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),px.maxKey=u1(px.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(uJ("storagemutated",e=>{if(!pM){let t;uv?(t=document.createEvent("CustomEvent")).initCustomEvent("x-storagemutated-1",!0,!0,e):t=new CustomEvent("x-storagemutated-1",{detail:e}),pM=!0,dispatchEvent(t),pM=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{pM||pD(e)}));let pM=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel("x-storagemutated-1");uJ("storagemutated",t=>{pM||e.postMessage(t)}),e.onmessage=e=>{e.data&&pD(e.data)}}else if("u">typeof self&&"u">typeof navigator){uJ("storagemutated",e=>{try{pM||("u">typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:"x-storagemutated-1",changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if("x-storagemutated-1"===e.key){let t=JSON.parse(e.newValue);t&&pD(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&"x-storagemutated-1"===e.type&&pD(e.changedParts)})}function pz(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}cK.rejectionMapper=function(e,t){if(!e||e instanceof cu||e instanceof TypeError||e instanceof SyntaxError||!e.name||!cg[e.name])return e;var n=new cg[e.name](t||e.message,e);return"stack"in e&&lF(n,"stack",{get:function(){return this.inner.stack}}),n},cr=uA;class pO extends px{constructor(){super("EsmOffline"),pz(this,"syncQueue",void 0),pz(this,"dynamicOfflineData",void 0),this.version(4).stores({syncQueue:"++id,userId,type,[userId+type]",dynamicOfflineData:"++id,type,identifier,*users,&[type+identifier]"}),this.syncQueue=this.table("syncQueue"),this.dynamicOfflineData=this.table("dynamicOfflineData")}}function pP(){return new pO}let pT=new pO,pB={},pj=V("offline-synchronization",{});function pI(){return pj}async function pN(){if(pj.getState().synchronization)return;let e=await pT.syncQueue.count(),t={},n=Object.entries(pB),r=n.length,o={},i=new AbortController,a=()=>{let e=pj.getState().synchronization;pj.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{pj.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<r&&n.length>0;e++)for(let e=n.length;e--;){let[r,s]=n[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(o[r]={},await Promise.all(l),t[r]=pR(s,o,i,a),n.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{pj.setState({synchronization:void 0})}}async function pR({type:e,dependsOn:t,process:n},r,o,i){let a=[],s=[],l=await pF();await pT.syncQueue.where({type:e,userId:l}).each((e,t)=>{a.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<a.length;c++){let[u,p,{id:d,dependencies:f=[]}]=a[c];try{let i=await n(p,{abort:o,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:n})=>t.includes(n)?r[n][e]:void 0)});void 0!==d&&(r[e][d]=i),await pT.syncQueue.delete(u)}catch(e){await pT.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function pF(){let e=await ah();return e?.uuid||"*"}async function pL(e,t,n,r){let o=r&&r.id;return void 0!==o&&await pT.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(px.errnames.DatabaseClosed),await pT.syncQueue.add({type:t,content:n,userId:e,descriptor:r||{},createdOn:new Date}).catch(px.errnames.DatabaseClosed,()=>-1)}async function pW(e,t,n){let r=await pF();return await pL(r,e,t,n)}async function pG(e,t){return(await pV(e,t)).map(e=>e.content)}async function pV(e,t){return await pT.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(px.errnames.DatabaseClosed,()=>[])}async function pU(e){let t=await pF();return await pG(t,e)}async function pq(e){let t=await pF();return await pV(t,e)}async function pH(e){return await pT.syncQueue.get(e).catch(px.errnames.DatabaseClosed,()=>void 0)}function pK(e){return!!pB[e]?.options.onBeginEditSyncItem}async function pY(e){let t=await pH(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let n=pB[t.type]?.options.onBeginEditSyncItem;if(!n)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);n(t)}async function pJ(e){await pT.syncQueue.delete(e).catch(px.errnames.DatabaseClosed)}function pZ(e,t,n,r={}){pB[e]={type:e,dependsOn:t,process:n,options:r}}let pX="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pQ=new Uint8Array(16),p0=[];for(let e=0;e<256;++e)p0.push((e+256).toString(16).slice(1));let p1=function(e,t,n){if(pX&&!t&&!e)return pX();let r=(e=e||{}).random||(e.rng||function(){if(!i&&!(i="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(pQ)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return p0[e[t+0]]+p0[e[t+1]]+p0[e[t+2]]+p0[e[t+3]]+"-"+p0[e[t+4]]+p0[e[t+5]]+"-"+p0[e[t+6]]+p0[e[t+7]]+"-"+p0[e[t+8]]+p0[e[t+9]]+"-"+p0[e[t+10]]+p0[e[t+11]]+p0[e[t+12]]+p0[e[t+13]]+p0[e[t+14]]+p0[e[t+15]]}(r)},p2="OFFLINE+";function p3(){return p2+p1()}function p4(e){return e.startsWith(p2)}let p5={};function p6(){return Object.values(p5)}function p8(e){p5[e.id]&&console.warn(`[setupDynamicOfflineDataHandler] Another second handler with the ID "${e.id}" was registered. This handler will override the previous one. This could be unintended as the previous handler might run different flows than the newly registered one. If this is the case, ensure that you are setting up the handlers with different IDs.`),p5[e.id]=e}async function p7(e){let t=await ds();return await p9(t,e)}async function p9(e,t){let n=new pO;return await n.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(px.errnames.DatabaseClosed,()=>[])}async function de(e,t){let n=await ds();return await dt(n,e,t)}async function dt(e,t,n){let r=new pO,o=await r.dynamicOfflineData.get({type:t,identifier:n}).catch(px.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(px.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:t,identifier:n}).catch(px.errnames.DatabaseClosed)}async function dn(e,t){let n=await ds();return await dr(n,e,t)}async function dr(e,t,n){let r=new pO,o=await r.dynamicOfflineData.get({type:t,identifier:n,users:e}).catch(px.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(px.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(px.errnames.DatabaseClosed))}async function di(e,t){let n=await p7(e);await Promise.all(n.map(async e=>da(e.type,e.identifier,t)))}async function da(e,t,n){await de(e,t);let r=new pO,o=await ds(),i=await r.dynamicOfflineData.get({type:e,identifier:t}).catch(px.errnames.DatabaseClosed,()=>void 0),a=p6().filter(t=>t.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,n),{id:e.id,error:void 0}}catch(n){let t=n.message?.toString()??n.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),p={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:c,errors:u};i.id&&await r.dynamicOfflineData.update(i.id,{syncState:p}).catch(px.errnames.DatabaseClosed)}async function ds(){let e=(await ah()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let dl=V("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function dc(){return dd(),dl}function du(e,t){dd(),p8({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,n)=>t.onOfflinePatientAdded({patientUuid:e,signal:n??new AbortController().signal})})}async function dp(e){dd(),await da("patient",e)}function dd(){console.warn("The offline patient API has been deprecated and will be removed in a future release. To prevent future crashes, the functions remain available for the moment, but any invocations should be migrated ASAP.")}async function df(e,t,n=!0){if(e){let r=null,[o,i]=await Promise.all([ar(`${ae}/Patient/${e}`,t).catch(e=>r=e),n?dh(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(r)throw r}return null}async function dh(e){let t=(await pU("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function dm(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function dg(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}var db=n(6170);function dy(e){return{uuid:e.uuid,display:e.display}}function d_(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString();return ao(`${i9}/location${r?"?"+r:""}`).pipe((0,db.map)(e=>e.data.results.map(dy))).pipe((0,db.take)(1))}function dv(e){return{uuid:e.uuid,display:e.display,name:e.name}}function dA(){return ao(`${i9}/visittype`).pipe((0,db.map)(e=>e.data.results.map(dv))).pipe((0,db.take)(1))}var d$=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),dw=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return ep(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(e_),dk=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return ep(t,e),t}(e$),dx=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return ep(t,e),t.prototype[eA]=function(){return new dk(this)},t.prototype.lift=function(e){var t=new dC(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new d$;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),o=0;o<n;o++)r[o].next(e)},t.prototype.error=function(e){if(this.closed)throw new d$;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),o=0;o<n;o++)r[o].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new d$;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;r++)n[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new d$},t.prototype._subscribe=function(e){if(this.closed)throw new d$;return this.hasError?(e.error(this.thrownError),e_.EMPTY):this.isStopped?(e.complete(),e_.EMPTY):(this.observers.push(e),new dw(this,e))},t.prototype.asObservable=function(){var e=new ex;return e.source=this,e},t.create=function(e,t){return new dC(e,t)},t}(ex),dC=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return ep(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):e_.EMPTY},t}(dx),dE=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return ep(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new d$},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(dx),dS=((eo={}).NEWVISIT="startVisit",eo.EDITVISIT="editVisit",eo.LOADING="loadingVisit",eo),dD=((ei={}).NOTSTARTED="notStarted",ei.ONGOING="ongoing",ei);let dM="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))",dz=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function dO(){return q("visit",dz)}function dP(e,t){dO().setState({patientUuid:e,manuallySetVisitUuid:t})}function dT(e,t){return ar(`${i9}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function dB(e,t,n){return ar(`${i9}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function dj(e,t,n){return ar(`${i9}/visit?patient=${e}&v=${n??dM}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}dO().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let dI=new dE(null);class dN{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+dN.version}static addUnaryOp(e){return dN.max_unop_len=Math.max(e.length,dN.max_unop_len),dN.unary_ops[e]=1,dN}static addBinaryOp(e,t,n){return dN.max_binop_len=Math.max(e.length,dN.max_binop_len),dN.binary_ops[e]=t,n?dN.right_associative.add(e):dN.right_associative.delete(e),dN}static addIdentifierChar(e){return dN.additional_identifier_chars.add(e),dN}static addLiteral(e,t){return dN.literals[e]=t,dN}static removeUnaryOp(e){return delete dN.unary_ops[e],e.length===dN.max_unop_len&&(dN.max_unop_len=dN.getMaxKeyLen(dN.unary_ops)),dN}static removeAllUnaryOps(){return dN.unary_ops={},dN.max_unop_len=0,dN}static removeIdentifierChar(e){return dN.additional_identifier_chars.delete(e),dN}static removeBinaryOp(e){return delete dN.binary_ops[e],e.length===dN.max_binop_len&&(dN.max_binop_len=dN.getMaxKeyLen(dN.binary_ops)),dN.right_associative.delete(e),dN}static removeAllBinaryOps(){return dN.binary_ops={},dN.max_binop_len=0,dN}static removeLiteral(e){return delete dN.literals[e],dN}static removeAllLiterals(){return dN.literals={},dN}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 dN(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 dN.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!dN.binary_ops[String.fromCharCode(e)]||dN.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return dN.isIdentifierStart(e)||dN.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(dN.hooks[e]){let n={context:this,node:t};return dN.hooks.run(e,n),n.node}return t}searchHook(e){if(dN.hooks[e]){let t={context:this};return dN.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===dN.SPACE_CODE||e===dN.TAB_CODE||e===dN.LF_CODE||e===dN.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:dN.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],n,r;for(;this.index<this.expr.length;)if((n=this.code)===dN.SEMCOL_CODE||n===dN.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(n===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,dN.max_binop_len),t=e.length;for(;t>0;){if(dN.binary_ops.hasOwnProperty(e)&&(!dN.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!dN.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,n,r,o,i,a,s,l;if(!(i=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return i;for(o={value:t,prec:dN.binaryPrecedence(t),right_a:dN.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),r=[i,o,a];t=this.gobbleBinaryOp();){if(0===(n=dN.binaryPrecedence(t))){this.index-=t.length;break}o={value:t,prec:n,right_a:dN.right_associative.has(t)},l=t;let s=e=>o.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;r.length>2&&s(r[r.length-2]);)a=r.pop(),t=r.pop().value,i=r.pop(),e={type:dN.BINARY_EXP,operator:t,left:i,right:a},r.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),r.push(o,e)}for(s=r.length-1,e=r[s];s>1;)e={type:dN.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,dN.isDecimalDigit(e)||e===dN.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===dN.SQUOTE_CODE||e===dN.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===dN.OBRACK_CODE)r=this.gobbleArray();else{for(n=(t=this.expr.substr(this.index,dN.max_unop_len)).length;n>0;){if(dN.unary_ops.hasOwnProperty(t)&&(!dN.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!dN.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=n;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:dN.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--n)}dN.isIdentifierStart(e)?(r=this.gobbleIdentifier(),dN.literals.hasOwnProperty(r.name)?r={type:dN.LITERAL,value:dN.literals[r.name],raw:r.name}:r.name===dN.this_str&&(r={type:dN.THIS_EXP})):e===dN.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===dN.PERIOD_CODE||t===dN.OBRACK_CODE||t===dN.OPAREN_CODE||t===dN.QUMARK_CODE;){let n;if(t===dN.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==dN.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===dN.OBRACK_CODE?((e={type:dN.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==dN.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===dN.OPAREN_CODE?e={type:dN.CALL_EXP,arguments:this.gobbleArguments(dN.CPAREN_CODE),callee:e}:(t===dN.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:dN.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,n;for(;dN.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===dN.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);dN.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++));dN.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);dN.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return n=this.code,dN.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(n===dN.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===dN.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:dN.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){r=!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 r||this.throwError('Unclosed quote after "'+e+'"'),{type:dN.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(dN.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,dN.isIdentifierPart(e))this.index++;else break;return{type:dN.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){n=!0,this.index++,e===dN.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===dN.COMMA_CODE){if(this.index++,++r!==t.length){if(e===dN.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===dN.CBRACK_CODE)for(let e=t.length;e<r;e++)t.push(null)}}else if(t.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==dN.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(dN.CPAREN_CODE);if(this.code===dN.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:dN.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:dN.ARRAY_EXP,elements:this.gobbleArguments(dN.CBRACK_CODE)}}}Object.assign(dN,{hooks:new class{add(e,t,n){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][n?"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)})}}(dN),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"}),dN.max_unop_len=dN.getMaxKeyLen(dN.unary_ops),dN.max_binop_len=dN.getMaxKeyLen(dN.binary_ops);let dR=e=>new dN(e).parse(),dF=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(dN).filter(e=>!dF.includes(e)&&void 0===dR[e]).forEach(e=>{dR[e]=dN[e]}),dR.Jsep=dN,dR.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:o},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}});let dL="ArrowFunctionExpression",dW={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)}},dG={...dW,Promise};function dV(e,t={}){return dJ(e,t,dQ)}async function dU(e,t={}){return dZ(e,t,dQ)}function dq(e,t={}){return dJ(e,t,d0)}function dH(e,t={}){return dZ(e,t,d0)}function dK(e,t={}){return dJ(e,t,d1)}function dY(e,t={}){return dZ(e,t,d1)}function dJ(e,t={},n){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 r=d4(t,dW),o=d2("string"==typeof e?dR(e):e,r);if(n(o))return o;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 dZ(e,t={},n){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 r=d4(t,dG);return Promise.resolve(d2("string"==typeof e?dR(e):e,r)).then(t=>{if(n(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 dX(e){return dR(e)}function dQ(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function d0(e){return"boolean"==typeof e}function d1(e){return"number"==typeof e}function d2(e,t){switch(e.type){case"UnaryExpression":var n,r,o,i,a,s,l,c,u,p,d,f,h=e,m=t;let g=d2(h.argument,m);switch(h.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var b=e,y=t;let v=d2(b.left,y),A=d2(b.right,y);switch(b.operator){case"+":return v+A;case"-":return v-A;case"*":return v*A;case"/":return v/A;case"%":return v%A;case"**":return v**A;case"==":return v==A;case"===":return v===A;case"!=":return v!=A;case"!==":return v!==A;case">":return v>A;case">=":return v>=A;case"<":return v<A;case"<=":return v<=A;case"in":return v in A;case"&&":return v&&A;case"||":return v||A;case"??":return v??A;default:throw`Expression evaluator does not support operator '${b.operator}' operator`}case"ConditionalExpression":return n=e,r=t,d2(n.test,r)?d2(n.consequent,r):d2(n.alternate,r);case"CallExpression":var $=e,w=t;let k=$.arguments?.map(d5(w)),x=d2($.callee,w);if(x){if("function"!=typeof x)throw`${d8($.callee)} is not a function`}else throw`No function named ${d8($.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return o=e,i=t,C=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<C.length)throw`Required argument(s) ${C.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(C.reduce((t,n,r)=>{let o=e[r];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 n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(o)&&t.push([n,o]),t},[]));return d2(o.body,i.addVariables(t))}).bind(i.thisObj??null);case"MemberExpression":return function(e,t){let n,r=d2(e.object,t);if(void 0===r)switch(e.object.type){case"Identifier":{let n=d3(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":{let n=d3(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${n}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=r;if("string"==typeof r)o=String.prototype;else if("number"==typeof r)o=Number.prototype;else if("function"==typeof r);else if("object"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":n=d2(e.property,t);break;default:{let o=d2(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};d6(o),n=r[o]}}return"function"==typeof n?n.bind(r):n}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(d5(s));case"SequenceExpression":let E;return l=e,c=t,(E=l.expressions.map(d5(c)))[E.length-1];case"NewExpression":var S=e,D=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(d5(D));switch(S.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${S.callee.name}`}}if(S.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return d6((u=e).value),u.value;case"Identifier":var M=e,z=t;d6(M.name);let O=z.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&M.name in O){let e=O[M.name];return d6(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return d6(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let P,T;return p=e,d=t,P=p.expressions?.map(d5(d))??[],(T=p.quasis?.map(d5(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.join("")+T.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 d3(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return d3(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function d4(e,t){let n={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}function d5(e){return function(t){return null===t?null:d2(t,e)}}function d6(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function d8(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function d7(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:{...dG},isLocalExpression:!1,variables:new Set};return d9("string"==typeof e?dR(e):e,t),[...t.variables]}function d9(e,t){switch(e.type){case"UnaryExpression":return r=e,o=t,d9(r.argument,o);case"BinaryExpression":return i=e,a=t,[d9(i.left,a),d9(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[d9(s.consequent,l),d9(s.test,l),d9(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return c=e,u=t,n=d9(c.callee,u),c.arguments?.map(fe(u)),n;case"ArrowFunctionExpression":var r,o,i,a,s,l,c,u,p,d,f,h,m,g,b,y,v,A,$=e,w=t;let k={...w};k.isLocalExpression=!0;let x=$.params?.map(fe(k))??[],C=d9($.body,k)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||w.variables.add(e);return;case"MemberExpression":let E;return p=e,d=t,d9(p.object,d),void((E={...d}).isLocalExpression=!0,d9(p.property,E));case"ArrayExpression":return f=e,h=t,void f.elements?.map(fe(h));case"SequenceExpression":return m=e,g=t,void m.expressions?.map(fe(g));case"NewExpression":return b=e,y=t,void b.arguments?.map(fe(y));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=t;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,A=t,void(v.expressions?.map(fe(A)),v.quasis?.map(fe(A)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function fe(e){return function(t){return null===t?null:d9(t,e)}}dR.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 n=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let n=this.gobbleBinaryExpression();n||this.throwError("Expected expression after "+e),t.node={type:dL,params:null,body:n};return}}this.index=n}}),e.hooks.add("after-expression",function(t){!function t(n){n&&(Object.values(n).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===n.operator&&(n.type=dL,n.params=n.left?[n.left]:null,n.body=n.right,n.params&&n.params[0].type===e.SEQUENCE_EXP&&(n.params=n.params[0].expressions),delete n.left,delete n.right,delete n.operator))}(t.node)})}}),dR.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let n=t.node;if(n&&"new"===n.operator){n.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(n.argument.type)||this.throwError("Expected new function()"),t.node=n.argument;let r=t.node;for(;r.type===e.MEMBER_EXP||r.type===e.CALL_EXP&&r.callee.type===e.MEMBER_EXP;)r=r.type===e.MEMBER_EXP?r.object:r.callee.object;r.type="NewExpression"}})}}),dR.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 n(t){let n=this.index,r="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:r+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(r+=this.expr.charAt(this.index++),o());let i=this.char;("e"===i||"E"===i)&&(r+=this.expr.charAt(this.index++),("+"===(i=this.char)||"-"===i)&&(r+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+r+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+r+this.char+")");else if(a===e.PERIOD_CODE){r.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:r},null,2)}`),this.index=n;return}t.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(n,this.index)}}e.hooks.add("gobble-token",function(r){if(48===this.code){var o,i,a;let s=this.index,l=this.expr.charAt(this.index+1),c=t.call(this,l);if(!c)return;let u="";for(;o=this.code,i=c,95===o||i.some(([e,t])=>o>=e&&o<=t);)95===this.code?this.index++:u+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,n.call(this,r);return}this.throwError("unexpected char within number")}r.node={type:e.LITERAL,value:parseInt(u,"x"===(a=l)||"X"===a?16:"b"===a||"B"===a?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&n.call(this,r)})}}),dR.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let n=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,o=this.expr.slice(n,this.index),i="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)i+=this.char;else break}try{r=new RegExp(o,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:r,raw:this.expr.slice(n-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?r=!0:r&&this.code===e.CBRACK_CODE&&(r=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),dR.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:o},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}}),dR.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,n=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},r="",o="",i=!1,a=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:o,cooked:r},tail:i});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,i=!0,s(),e.node=t,n&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",r="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(o+=a,a=this.expr.charAt(++this.index),o+=a,a){case"n":r+="\n";break;case"r":r+="\r";break;case"t":r+=" ";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;default:r+=a}else r+=a,o+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(n){if((n.node.type===e.IDENTIFIER||n.node.type===e.MEMBER_EXP)&&96===this.code)return n.node={type:"TaggedTemplateExpression",tag:n.node,quasi:t.bind(this)(n,!1)},n.node=this.gobbleTokenProperty(n.node),n.node})}}),dR.addBinaryOp("in",7),dR.addBinaryOp("??",1);let ft=q("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function fn(e,t,n){ft.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function fr(){let e=ft.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function fo(e){return ft.getState().flags[e].enabled}function fi(e,t){ft.subscribe(n=>{t(n.flags[e].enabled)})}function fa(e,t){ft.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}function fs(e){return!window.offlineEnabled||(e??navigator.onLine)}ft.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});var fl=t6(function(e,t,n){tX(e,t,n)});function fc(e=!0,t=!1){return fu(fs(),e,t)}function fu(e,t=!0,n=!1){return!!(e?t:n)}let fp=V("extensionsInternal",{slots:{},extensions:{}}),fd=()=>q("extensionsInternal",{slots:{},extensions:{}});function ff(e){let t=fp.getState(),n=e(t);n!==t&&fp.setState(n)}let fh=()=>q("extensions",{slots:{}});function fm(e){let t=[];for(let n of Object.values(e.extensions))for(let e of n.instances)t.push({slotModuleName:e.slotModuleName,extensionModuleName:n.moduleName,slotName:e.slotName,extensionId:e.id});nW(rB.getState().mountedExtensions,t)||rB.setState({mountedExtensions:t})}fm(fp.getState()),fp.subscribe(fm);let fg=fd(),fb=fh(),fy=rI(),f_=rF();function fv(e,t,n,r,o){let i={},a=fs(),s=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,l]of Object.entries(e.slots)){let{config:c}=rR(t,l.name),u=fz(r,e,c,n,s,a,o.session);i[r]={moduleName:l.moduleName,assignedExtensions:u}}nW(fb.getState().slots,i)||fb.setState({slots:i})}function fA(){fv(fg.getState(),fy.getState(),f_.getState(),ft.getState(),aa.getState())}function f$(e,t,n){return{moduleName:t,name:e,attachedIds:[],config:null,state:n}}function fw(e){let[t]=e.split("#");return t}function fk(e,t){let n=fw(t);return e.extensions[n]}function fx(e){return fk(fg.getState(),e)}fg.subscribe(e=>{fv(e,fy.getState(),f_.getState(),ft.getState(),aa.getState())}),fy.subscribe(e=>{fv(fg.getState(),e,f_.getState(),ft.getState(),aa.getState())}),f_.subscribe(e=>{fv(fg.getState(),fy.getState(),e,ft.getState(),aa.getState())}),ft.subscribe(e=>{fv(fg.getState(),fy.getState(),f_.getState(),e,aa.getState())}),aa.subscribe(e=>{fv(fg.getState(),fy.getState(),f_.getState(),ft.getState(),e)}),fA(),g(fA);let fC=e=>fg.setState(t=>(t.extensions[e.name]={...e,instances:[]},t));function fE(e,t){ff(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...f$(e),attachedIds:[t]}}}})}function fS(e,t){ff(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function fD(e){ff(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function fM(e,t,n,r){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==n)return 1e3+n;let t=r.indexOf(e);return -1!==t?2e3+t:-1}}function fz(e,t,n,r,o,i,a){let s=function(e,t){let n=e.add||[],r=e.remove||[],o=e.order||[],{extensions:i}=fg.getState();return[...t,...n].filter(e=>!r.includes(e)).sort((e,n)=>{let r=fM(e,o,i[fw(e)]?.order,t),a=fM(n,o,i[fw(n)]?.order,t);return -1===a?-1:-1===r?1:r-a})}(n,t.slots[e].attachedIds),l=[],c=t.slots[e]?.state,u=c&&"object"==typeof c?{session:a,...c}:{session:a};for(let c of s){let{config:s}=rW(r,e,c),p=fl(s,rG(n,e,c)),d=fw(c),f=t.extensions[d];if(f){let t=p?.["Display conditions"]?.privileges??f.privileges??[];if(t&&("string"==typeof t||Array.isArray(t)&&t.length>0)&&(!a?.user||!af(t,a.user)))continue;let n=p?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==n&&"string"==typeof n&&n.trim().length>0)try{if(!dq(n,u))continue}catch(t){console.error(`Error while evaluating expression '${n}' for extension ${d} in slot ${e}`,t);continue}if(f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!fu(i,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:p,featureFlag:f.featureFlag,meta:f.meta,online:p?.["Display conditions"]?.online??f.online??!0,offline:p?.["Display conditions"]?.offline??f.offline??!1})}}return l}function fO(e){let t=fg.getState(),{config:n}=rN(e),r=f_.getState(),o=ft.getState(),i=aa.getState(),a=fs();return fz(e,t,n,r,Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),a,i.session)}let fP=(e,t,n)=>fg.setState(r=>{let o=r.slots[t]?.moduleName;if(o&&o!=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 ${o}.`),r;if(o&&o==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e,state:n}}};let i=f$(t,e,n);return{...r,slots:{...r.slots,[t]:{...i}}}});function fT(e,t,n=!1){fg.setState(r=>{let o=n?fl(r.slots[e].state,t):t;return{...r,slots:{...r.slots,[e]:{...r.slots[e],state:o}}}})}let fB=()=>fb.setState(()=>({slots:{},extensions:{}})),fj=V("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function fI({name:e,basePath:t,mode:n,componentContext:r,state:o}){fj.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:o})}function fN(e){fj.getState().slotName===e&&fj.setState(fj.getInitialState(),!0)}let fR=V("modalRegistry",{modals:{}});function fF(e){fR.setState(t=>(t.modals[e.name]=e,t))}function fL(e){let t=fR.getState().modals[e];if(!t){let n=fx(e);n&&(t={name:e,load:n.load,moduleName:n.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.`),fF(t))}return t}let fW=V("workspaceRegistrations",{workspaces:{}}),fG=V("workspaceGroups",{workspaceGroups:{}});function fV(e){fW.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function fU(e){fG.setState(t=>{let n=t.workspaceGroups[e.name];return n?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...n,members:Array.from(new Set([...n.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let fq=new Set;function fH(e){let t=fW.getState().workspaces;if(t[e])return t[e];{let t=fx(e);if(t){var n;let r;return fq.has(e)||(console.warn(`The workspace '${e}' is registered as an extension. This is deprecated. Please register it in the "workspaces" section of the routes.json file.`),fq.add(e)),{name:t.name,title:(n=t,"string"==typeof(r=n?.meta?.title)?r:r&&"object"==typeof r?s_(n.moduleName,r.key,r.default):n.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function fK(e){let t=fG.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let fY=V("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function fJ(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=fY.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function fZ(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=fY.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function fX(e){let{openedWindows:t}=fY.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function fQ(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=fY.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}fY.setState({registeredGroupsByName:r})}function f0(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=fY.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}fY.setState({registeredWindowsByName:r})}function f1(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=fY.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}fY.setState({registeredWorkspacesByName:r})}let f2=0;async function f3(e,t,n,r,o=e=>e,i={}){let a=fw(r),s=fx(r),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(fc(p,d)){ff(o=>({...o,extensions:{...o.extensions,[a]:{...o.extensions[a],instances:[...o.extensions[a].instances,{domElement:e,id:r,slotName:t,slotModuleName:n}]}}}));let s=await f(),p=f2++;l=o9(o({...s,name:`${t}/${a}-${p}`}),{...i,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:u},domElement:e})}}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var f4=n(4923),f5=n.n(f4);let f6=(0,f4.createContext)({moduleName:"",featureName:""});function f8({to:e,templateParams:t,onBeforeNavigate:n,children:r,...o}){return(0,f4.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),f5().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),iQ({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:iZ(e,t),...o},r)}let f7=({state:e,children:t,...n})=>{let{extension:r}=(0,f4.useContext)(f6),o=(0,f4.useRef)(null),i=(0,f4.useRef)(Promise.resolve()),a=(0,f4.useCallback)(t=>{r?.extensionSlotName&&r.extensionSlotModuleName&&r.extensionSlotModuleName&&!o.current&&f3(t,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(e=>{o.current=e})},[]);return(0,f4.useEffect)(()=>()=>{if(o&&o.current)switch(o.current.getStatus()){case"MOUNTING":o.current.mountPromise.then(()=>{o.current?.getStatus()==="MOUNTED"&&o.current.unmount()});break;case"MOUNTED":o.current.unmount();break;case"UPDATING":i.current&&i.current.then(()=>{o.current?.getStatus()==="MOUNTED"&&o.current.unmount()})}},[]),(0,f4.useEffect)(()=>{o.current&&o.current.update&&"UNMOUNTING"!==o.current.getStatus()&&Promise.all([o.current.mountPromise,i.current]).then(()=>{o?.current?.getStatus()==="MOUNTED"&&o.current.update&&(i.current=o.current.update({...e}).catch(e=>{if(!(e instanceof Error)||!e.message.includes("minified message #32")||o.current?.getStatus()==="MOUNTED")throw e}))})},[e]),r?f5().createElement("div",{ref:a,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function f9(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};n[r]=t}return n}let he=()=>e=>e;function ht(e,t=he(),n){let r=(0,f4.useCallback)(t=>e.subscribe(t),[e]),o=(0,f4.useCallback)(()=>t(e.getState()),[e,t]),i=(0,f4.useSyncExternalStore)(r,o,o),a=(0,f4.useMemo)(()=>n?f9(e,n):{},[e,n]);return{...i,...a}}function hn(e,t){return ht(e,he(),t)}function hr(e){return function(t){let n=(0,f4.useCallback)(t=>e.subscribe(t),[]),r=(0,f4.useCallback)(()=>e.getState(),[]),o=(0,f4.useSyncExternalStore)(n,r,r),i=(0,f4.useMemo)(()=>t?f9(e,t):{},[t]);return{...o,...i}}}let ho=e=>ht(fh(),t=>t.slots?.[e]);function hi(e){let t=ho(e);return t?.assignedExtensions??[]}function ha(e,t){let{moduleName:n}=(0,f4.useContext)(f6),r=(0,f4.useRef)(!0);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,f4.useEffect)(()=>{fP(n,e,t),r.current=!1},[]),(0,f4.useEffect)(()=>{r.current||fT(e,t)},[e,t]),{extensions:hi(e),extensionSlotName:e,extensionSlotModuleName:n}}function hs(e){return e}function hl({name:e,extensionSlotName:t,select:n=hs,children:r,state:o,style:i,...a}){if(r&&o)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,f4.useRef)(null),{extensions:c,extensionSlotModuleName:u}=ha(s,o),p=(0,f4.useMemo)(()=>n(c),[n,c]),d=(0,f4.useMemo)(()=>{if("function"==typeof r&&!f5().isValidElement(r))return p.map(e=>r(e,o))},[r,p]);return f5().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...i,position:"relative"},...a},s&&p?.map((e,t)=>f5().createElement(f6.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[t]??("function"!=typeof r?r:null)??f5().createElement(f7,{state:o}))))}var hc=n(5338);function hu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function hp(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?hu(Object(n),!0).forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function hd(e){return(hd="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 hf(e){return(hf="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 hh(e,t){var n;if("function"!=typeof(n=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 n="single-spa-application:".concat(t);return function(){var e=document.getElementById(n);return e||((e=document.createElement("div")).id=n,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(hf(n)));return function(){var e=n(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(hf(e)));return e}}var hm=null;try{hm=require("react").createContext()}catch(e){}var hg={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 hb(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function hy(e,t){return new Promise(function(n,r){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 o,i=h$(e,t,function(){n(this)}),a=hh(e,t)(),s=function(e){var t=e.reactDom,n=e.renderType,r=e.elementToRender,o=e.domElement,i=t[n];if("function"!=typeof i)throw Error('renderType "'.concat(n,'" did not return a function.'));switch(n){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=i(o);return a.render(r),a;case"hydrateRoot":return i(o,r);default:return i(r,o),null}}({elementToRender:i,domElement:a,reactDom:hA(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function h_(e,t){return new Promise(function(n){e.unmountResolves[t.name]=n;var r=e.renderResults[t.name];r&&r.unmount?r.unmount():hA(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function hv(e,t){return new Promise(function(n){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(n);var r=h$(e,t,null),o=e.renderResults[t.name];if(o&&o.render)o.render(r);else{var i=hh(e,t)();hA(e).render(r,i)}})}function hA(e){return e.ReactDOMClient||e.ReactDOM}function h$(e,t,n){var r=e.React.createElement(e.rootComponent,t),o=hm?e.React.createElement(hm.Provider,{value:t},r):r;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function n(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},n.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},n.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},n}(e,t),o=e.React.createElement(e.errorBoundaryClass,t,o)),o=e.React.createElement(e.SingleSpaRoot,hp(hp({},t),{},{mountFinished:n,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])}}),o)}var hw=n(202),hk=n(9324),hx=n(4993);let hC={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},hE=new Map;(0,hx.r2)(hE);let hS={errorRetryCount:3,fetcher:ar,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof ai){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>hE};function hD(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},hC,e),n={...hS,...t.swrConfig};return function(e){var r,o,i,a,s;return i=o=class extends(r=f5().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return f5().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=f5().createElement(f4.Suspense,{fallback:null},f5().createElement(hk.BE,{value:n},f5().createElement(f6.Provider,{value:this.state.config},t.disableTranslations?f5().createElement(e,this.props):f5().createElement(hw.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},f5().createElement(e,this.props)))));return t.strictMode&&f5().StrictMode?f5().createElement(f5().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}}function hM(e,t){return function(e){if("object"!==hd(e))throw Error("single-spa-react requires a configuration object");var t,n=hp(hp({},hg),e);if(!n.React)throw Error("single-spa-react must be passed opts.React");if(!n.ReactDOM&&!n.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(n.renderType||(null!=(t=n.ReactDOMClient)&&t.createRoot?n.renderType="createRoot":n.renderType="render"),!n.rootComponent&&!n.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(n.errorBoundary&&"function"!=typeof n.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!hm&&n.React.createContext&&(hm=n.React.createContext()),n.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}(n);var r={bootstrap:hb.bind(null,n),mount:hy.bind(null,n),unmount:h_.bind(null,n)};return n.parcelCanUpdate&&(r.update=hv.bind(null,n)),r}({React:f5(),ReactDOMClient:hc,rootComponent:hD(t)(e)})}function hz(e,t){return()=>e().then(({default:e})=>hM(e,t))}function hO(e,t){return()=>Promise.resolve(hM(e,t))}let hP=hz,hT=L()(()=>({}));U("openmrs-app-context",hT);let hB={};function hj(e,t=e=>e){let n=hT.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function hI(e,t){hT.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function hN(e){return null===e?null:Object.freeze(Object.assign({},e))}let hR=new Map;function hF(e,t){let n=(0,f4.useRef)(t??{}),r=(0,f4.useRef)(t=>hI(e,t)),o=(0,f4.useRef)(Symbol());return(0,f4.useEffect)(()=>{let n=t??{},r=o.current;return null===hj(e)?!function(e,t=hB){hT.setState(n=>{if(e in n)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({},n,{[e]:t===hB?{}:t})})}(e,n):(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.`),hI(e,()=>n)),hR.set(e,r),()=>{hR.get(e)===r&&(hT.setState(t=>(e in t&&delete t[e],t)),hR.delete(e))}},[e]),(0,f4.useEffect)(()=>{let r=t??{};I(n.current,r)||(hI(e,()=>r),n.current=r)},[t]),r.current}function hL({namespace:e,value:t}){return hF(e,t),null}let hW=({children:e,value:t,fallback:n})=>t?f5().createElement(f5().Fragment,null,e):n?f5().createElement(f5().Fragment,null,n):null;function hG(){let e=(0,f4.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,f4.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function hV(e,t=e=>e??{}){let[n,r]=(0,f4.useState)(()=>{if(hU(e))return;let n=hj(e);if(null!==n)return t?t(n):n});return(0,f4.useEffect)(()=>{if(hU(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,f4.useEffect)(()=>{var n;let o;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>I(e,n)?e:n)})(hN(o=hj(e))),hT.subscribe(t=>{let r=e in t?t[e]:null;r!==o&&(o=r,n(hN(r)))})},[e,t]),n}function hU(e){return"string"!=typeof e||0===e.trim().length}function hq(e){let[t,n]=(0,f4.useState)([]);return(0,f4.useEffect)(()=>fh().subscribe(r=>{let o=r.slots[e]?.assignedExtensions.map(e=>e.id)??[];nW(o,t)||n(o)}),[]),t}function hH(e,t){let{data:n,error:r,mutate:o,isLoading:i,isValidating:a}=(0,hk.Ay)(`${le}?patient=${e}&includeEncounterless=${t}`,ar);return(0,f4.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:r,mutate:o,isValidating:a}),[n,r,i,a,o])}function hK(e){(0,f4.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let hY={},hJ=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|