@openmrs/esm-form-builder-app 3.5.2-pre.3574 → 3.5.2-pre.3578
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/4538.js
CHANGED
|
@@ -9,7 +9,7 @@ If you're the maintainer: the allowed types are ${Object.values(nx).join(", ")}.
|
|
|
9
9
|
If you're the maintainer: all config elements must have a default. Received ${JSON.stringify(a)}`),s&&l&&![nx.Array,nx.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 nZ(e,n){return nX(n.map(({[e]:n})=>n).filter(e=>!!e))}function nX(e){return e.reduce((e,n)=>nW(e,n),{})}function nQ(e,n,t=""){for(let r of Object.keys(n)){let o=n[r],i=t+"."+r,a=e[r];if(!e.hasOwnProperty(r)){("extensionSlots"!==r||""===t)&&n8(i,`Unknown config key '${i}' provided. Ignoring.`);continue}(function e(n,t,r){n1(r,n._type,t),n4(t)?n._type===nx.Object?function(n,t,r){if(n._elements)for(let o of Object.keys(t)){let i=t[o];e(n._elements,i,`${r}.${o}`)}}(n,t,r):n.hasOwnProperty("_default")||n.hasOwnProperty("_type")||nQ(n,t,r):n._type===nx.Array&&function(n,t,r){if(n1(r,nx.Array,t)){if(n5(n._elements))for(let o=0;o<t.length;o++)e(n._elements,t[o],`${r}[${o}]`);for(let e=0;e<t.length;e++)n1(`${r}[${e}]`,n._elements?._type,t[e])}}(n,t,r)})(a,o,i)}}nG(),nV.push(nO.subscribe(nG)),nV.push(nT.subscribe(nG)),nV.push(nB.subscribe(nG));function n0(e,n,t=""){if(e){if(n!==e._default&&n2(t,e._validators,n),n4(n))for(let r of Object.keys(n)){let o=n[r],i=t+"."+r,a=e[r];e._type===nx.Object&&e._elements?n0(e._elements,o,i):n0(a,o,i)}else if(Array.isArray(n)&&e._elements)for(let r=0;r<n.length;r++)n0(e._elements,n[r],`${t}[${r}]`)}}function n1(e,n,t){return!n||n2(e,[{Array:nE,Boolean:nD,ConceptUuid:nP,Number:nS,Object:nz,String:nM,UUID:nP,PersonAttributeTypeUuid:nP,PatientIdentifierTypeUuid:nP}[n]],t)}function n2(e,n,t){let r=!0;if(n)try{for(let o of n){let n=o(t);if("string"==typeof n){let o="object"==typeof t?`Invalid configuration for ${e}: ${n}`:`Invalid configuration value ${t} for ${e}: ${n}`;n8(e,o),r=!1}}}catch(n){console.error(`Skipping invalid validator at "${e}". Encountered error
|
|
12
|
-
${n}`)}return r}let n3=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let r=t[n],o=e[n];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=o._default);let e=o._elements;if(r&&n5(e)){if(o._type===nx.Array&&Array.isArray(r)){let o=r.map(n=>n3(e,n));t[n]=o}else if(o._type===nx.Object)for(let n of Object.keys(r))r[n]=n3(e,r[n])}}else if(n4(o)){let e=r??{};n4(e)&&(t[n]=n3(o,e))}}return t};function n5(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function n4(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let n6=new Set;function n8(e,n){let t=`${e}:::${n}`;n6||(n6=new Set),n6.has(t)||(console.error(n),n6.add(t))}let n7={"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:nx.Object,_default:{},_validators:[nC(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=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: ${n.join(", ")}.`})]}},n9={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nx.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nx.String,_default:void 0}},...n7},te=(e,n)=>nC(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),tn=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return nC(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,r=t.exec(e);for(;r;){if(!n.includes(r[1]))return!1;r=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},tt=tn([]),tr=e=>nC(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),to={inRange:te,isUrl:tt,isUrlWithTemplateParameters:tn,oneOf:tr};var ti=t(48067);let ta=L("breadcrumbs",[]);function ts(e){return tl([e])}function tl(e){let n=[...tc(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ti.pathToRegexp)(e.matcher).regexp:(0,ti.pathToRegexp)(e.path).regexp,settings:e}))];ta.setState(n,!0)}function tc(){return ta.getState()}function tu(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=tu(e,t.join("/"));if(n)return n}}(e,n)}function tp(e,n){if(e.length>0){let t=tu(e,n);if(t){let n=[t],r=tu(e,t.settings.parent);for(;void 0!==r;)n.push(r),r=tu(e,r.settings.parent);return n.reverse()}}return[]}function td(e){return tp(tc(),e)}var tf=Object.freeze({__proto__:null,get start(){return rN},get ensureJQuerySupport(){return rd},get setBootstrapMaxTime(){return t3},get setMountMaxTime(){return t5},get setUnmountMaxTime(){return t4},get setUnloadMaxTime(){return t6},get registerApplication(){return rw},get unregisterApplication(){return rx},get getMountedApps(){return r_},get getAppStatus(){return r$},get unloadApplication(){return rC},get checkActivityFunctions(){return rk},get getAppNames(){return rv},get pathToActiveWhen(){return rS},get navigateToUrl(){return rr},get patchHistoryApi(){return rc},get triggerAppChange(){return rO},get addErrorHandler(){return ty},get removeErrorHandler(){return t_},get mountRootParcel(){return tX},get NOT_LOADED(){return tA},get LOADING_SOURCE_CODE(){return tw},get NOT_BOOTSTRAPPED(){return tk},get BOOTSTRAPPING(){return tx},get NOT_MOUNTED(){return tC},get MOUNTING(){return tE},get UPDATING(){return tS},get LOAD_ERROR(){return tP},get MOUNTED(){return tD},get UNLOADING(){return tz},get UNMOUNTING(){return tM},get SKIP_BECAUSE_BROKEN(){return tO}}),th=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,tm=!function(){try{var e=new th("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,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:th;let tg=[];function tb(e,n,t){let r=t$(e,n,t);tg.length?tg.forEach(e=>e(r)):setTimeout(()=>{throw r})}function ty(e){if("function"!=typeof e)throw Error(tv(28,!1));tg.push(e)}function t_(e){if("function"!=typeof e)throw Error(tv(29,!1));let n=!1;return tg=tg.filter(t=>{let r=t===e;return n=n||r,!r}),n}function tv(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function t$(e,n,t){let r,o=`${tj(n)} '${tI(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(tv(30,!1,n.status,tI(n)));try{r=Error(o+JSON.stringify(e))}catch(n){r=e}}return r.appOrParcelName=tI(n),n.status=t,r}let tA="NOT_LOADED",tw="LOADING_SOURCE_CODE",tk="NOT_BOOTSTRAPPED",tx="BOOTSTRAPPING",tC="NOT_MOUNTED",tE="MOUNTING",tD="MOUNTED",tS="UPDATING",tM="UNMOUNTING",tz="UNLOADING",tP="LOAD_ERROR",tO="SKIP_BECAUSE_BROKEN";function tT(e){return e.status===tD}function tB(e){try{return e.activeWhen(window.location)}catch(n){return tb(n,e,tO),!1}}function tI(e){return e.name}function tN(e){return!!e.unmountThisParcel}function tj(e){return tN(e)?"parcel":"application"}function tR(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function tF(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function tL(e){return e&&("function"==typeof e||Array.isArray(e)&&!tF(e,e=>"function"!=typeof e))}function tW(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let r=tj(e),o=tI(e);return function(e){return t.reduce((t,i,a)=>t.then(()=>{let t=i(e);return tV(t)?t:Promise.reject(tv(15,!1,r,o,n,a))}),Promise.resolve())}}function tV(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let tG=[];function tU(e,n){return Promise.resolve().then(()=>e.status!==tk?e:(e.status=tx,e.bootstrap?t8(e,"bootstrap").then(t).catch(t=>{if(n)throw t$(t,e,tO);return tb(t,e,tO),e}):Promise.resolve().then(t)));function t(){return e.status=tC,e}}function tq(e,n){return Promise.resolve().then(()=>{if(e.status!==tD)return e;return e.status=tM,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,r=>t().then(()=>{let t=Error(r.message);if(n)throw t$(t,e,tO);tb(t,e,tO)})).then(()=>e);function t(){return t8(e,"unmount").then(()=>{e.status=tC},t=>{if(n)throw t$(t,e,tO);tb(t,e,tO)})}})}let tH=!1,tK=!1;function tY(e,n){return Promise.resolve().then(()=>e.status!==tC?e:(tH||(window.dispatchEvent(new tm("single-spa:before-first-mount")),tH=!0),e.status=tE,t8(e,"mount").then(()=>(e.status=tD,tK||(window.dispatchEvent(new tm("single-spa:first-mount")),tK=!0),e)).catch(t=>{return e.status=tD,tq(e,!0).then(r,r);function r(){if(n)throw t$(t,e,tO);return tb(t,e,tO),e}})))}let tJ=0,tZ={parcels:{}};function tX(){return tQ.apply(tZ,arguments)}function tQ(e,n){let t,r,o,i=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(tv(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(tv(3,!1,typeof e.name));let a=tJ++,s=e.name||`parcel-${a}`;if("object"!=typeof n)throw Error(tv(4,!1,s,typeof n));if(!n.domElement)throw Error(tv(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:a,parcels:{},status:l?tw:tk,customProps:n,parentName:tI(i),unmountThisParcel:()=>f.then(()=>{if(u.status!==tD)throw Error(tv(6,!1,s,u.status));return tq(u,!0)}).then(e=>(u.parentName&&delete i.parcels[u.id],e)).then(e=>(r(e),e)).catch(e=>{throw u.status=tO,o(e),e})};i.parcels[a]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(tv(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(tv(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!tL(e.bootstrap))throw Error(tv(9,!1,s));if(!tL(e.mount))throw Error(tv(10,!1,s));if(!tL(e.unmount))throw Error(tv(11,!1,s));if(e.update&&!tL(e.update))throw Error(tv(12,!1,s));let n=tW(e,"bootstrap"),r=tW(e,"mount"),o=tW(e,"unmount");u.status=tk,u.name=s,u.bootstrap=n,u.mount=r,u.unmount=o,u.timeouts=t7(e.timeouts),e.update&&(u.update=tW(e,"update"),t.update=function(e){return u.customProps=e,t0(Promise.resolve().then(()=>{if(u.status!==tD)throw Error(tv(32,!1,tI(u)));return u.status=tS,t8(u,"update").then(()=>(u.status=tD,u)).catch(e=>{throw t$(e,u,tO)})}))})})).then(()=>tU(u,!0)),f=d.then(()=>tY(u,!0)),h=new Promise((e,n)=>{r=e,o=n});return t={mount:()=>t0(Promise.resolve().then(()=>{if(u.status!==tC)throw Error(tv(13,!1,s,u.status));return i.parcels[a]=u,tY(u)})),unmount:()=>t0(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:t0(p),bootstrapPromise:t0(d),mountPromise:t0(f),unmountPromise:t0(h)}}function t0(e){return e.then(()=>null)}function t1(e){let n=tI(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(tv(40,!1),n,t));let r=tR({},t,{name:n,mountParcel:tQ.bind(e),singleSpa:tf});return tN(e)&&(r.unmountSelf=e.unmountThisParcel),r}let t2={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 t3(e,n,t){if("number"!=typeof e||e<=0)throw Error(tv(16,!1));t2.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function t5(e,n,t){if("number"!=typeof e||e<=0)throw Error(tv(17,!1));t2.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function t4(e,n,t){if("number"!=typeof e||e<=0)throw Error(tv(18,!1));t2.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function t6(e,n,t){if("number"!=typeof e||e<=0)throw Error(tv(19,!1));t2.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function t8(e,n){let t=e.timeouts[n],r=t.warningMillis,o=tj(e);return new Promise((i,a)=>{let s=!1,l=!1;e[n](t1(e)).then(e=>{s=!0,i(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>u(1),r),setTimeout(()=>u(!0),t.millis);let c=tv(31,!1,n,o,tI(e),t.millis);function u(e){s||(!0===e?(l=!0,t.dieOnTimeout?a(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<t.millis&&setTimeout(()=>u(e+1),r)))}})}function t7(e){let n={};for(let t in t2)n[t]=tR({},t2[t],e&&e[t]||{});return n}function t9(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==tA&&e.status!==tP?e:(e.status=tw,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(t1(e));if(!tV(r))throw t=!0,Error(tv(33,!1,tI(e)));return r.then(t=>{let r;e.loadErrorTime=null,"object"!=typeof(n=t)&&(r=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!tL(n.bootstrap)&&(r=35),tL(n.mount)||(r=36),tL(n.unmount)||(r=37);let o=tj(n);if(r){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(tv(r,!1,o,tI(e),t),n),tb(void 0,e,tO),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=tR({},e.devtools.overlays,n.devtools.overlays)),e.status=tk,e.bootstrap=tW(n,"bootstrap"),e.mount=tW(n,"mount"),e.unmount=tW(n,"unmount"),e.unload=tW(n,"unload"),e.timeouts=t7(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let r;return delete e.loadPromise,t?r=tO:(r=tP,e.loadErrorTime=(new Date).getTime()),tb(n,e,r),e}))})}let re="u">typeof window,rn={hashchange:[],popstate:[]},rt=["hashchange","popstate"];function rr(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(tv(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=ru(window.location.href),r=ru(n);0===n.indexOf("#")?window.location.hash=r.hash:t.host!==r.host&&r.host?window.location.href=n:r.pathname===t.pathname&&r.search===t.search?window.location.hash=r.hash:window.history.pushState(null,null,n)}function ro(e){if(e){let n=e[0].type;rt.indexOf(n)>=0&&rn[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function ri(){rT([],arguments)}function ra(e,n){return function(){let t=window.location.href,o=e.apply(this,arguments),i=window.location.href;return r&&t===i||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),o}}let rs=null,rl=!1;function rc(e){if(rl)throw Error(tv(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,rl=!0,rs=window.history.replaceState,window.addEventListener("hashchange",ri),window.addEventListener("popstate",ri);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&rt.indexOf(e)>=0)||tF(rn[e],e=>e===t))return n.apply(this,arguments);rn[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&rt.indexOf(e)>=0&&(rn[e]=rn[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=ra(window.history.pushState,"pushState"),window.history.replaceState=ra(rs,"replaceState")}function ru(e){let n=document.createElement("a");return n.href=e,n}re&&(window.singleSpaNavigate?console.warn(tv(41,!1)):window.singleSpaNavigate=rr);let rp=!1;function rd(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!rp){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return rf.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return rf.call(this,t,window.removeEventListener,e,n,arguments)},rp=!0}}function rf(e,n,t,r,o){return"string"!=typeof t?e.apply(this,o):(t.split(/\s+/).forEach(e=>{rt.indexOf(e)>=0&&(n(e,r),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,o))}let rh={};function rm(e){return Promise.resolve().then(()=>{let n=rh[tI(e)];if(!n)return e;if(e.status===tA)return rg(e,n),e;if(e.status===tz)return n.promise.then(()=>e);if(e.status!==tC&&e.status!==tP)return e;let t=e.status===tP?Promise.resolve():t8(e,"unload");return e.status=tz,t.then(()=>(rg(e,n),e)).catch(t=>(delete rh[tI(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,tb(t,e,tO),n.reject(t),e))})}function rg(e,n){delete rh[tI(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=tA,n.resolve()}function rb(e,n,t,r){rh[tI(e)]={app:e,resolve:t,reject:r},Object.defineProperty(rh[tI(e)],"promise",{get:n})}let ry=[];function r_(){return ry.filter(tT).map(tI)}function rv(){return ry.map(tI)}function r$(e){let n=tF(ry,n=>tI(n)===e);return n?n.status:null}let rA=!1;function rw(e,n,t,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(tv(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(tv(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(tv(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(tv(24,!1));if(!rD(e.customProps))throw Error(tv(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,n,t,r){if("string"!=typeof e||0===e.length)throw Error(tv(20,!1));if(!n)throw Error(tv(23,!1));if("function"!=typeof t)throw Error(tv(24,!1));if(!rD(r))throw Error(tv(22,!1))}(e,n,t,r),a.name=e,a.loadApp=n,a.activeWhen=t,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:rS(e)),a.activeWhen=e=>s.some(n=>n(e)),a);if(rI||rA||(rA=!0,setTimeout(()=>{rI||console.warn(tv(1,!1))},5e3)),-1!==rv().indexOf(l.name))throw Error(tv(21,!1,l.name));ry.push(tR({loadErrorTime:null,status:tA,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),re&&(rd(),rT())}function rk(e=window.location){return ry.filter(n=>n.activeWhen(e)).map(tI)}function rx(e){if(0===ry.filter(n=>tI(n)===e).length)throw Error(tv(25,!1,e));return(re?rC(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=ry.map(tI).indexOf(e);ry.splice(n,1)})}function rC(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(tv(26,!1));let t=tF(ry,n=>tI(n)===e);if(!t)throw Error(tv(27,!1,e));let r=rh[tI(t)];if(n&&n.waitForUnmount){if(r)return r.promise;{let e=new Promise((n,r)=>{rb(t,()=>e,n,r)});return e}}{let e;return r?(e=r.promise,rE(t,r.resolve,r.reject)):e=new Promise((n,r)=>{rb(t,()=>e,n,r),rE(t,n,r)}),e}}function rE(e,n,t){Promise.resolve().then(()=>{if(tF(rk(),n=>n===tI(e)))return rO()}).then(()=>tq(e).then(rm).then(()=>{n(),setTimeout(()=>{rT()})})).catch(t)}function rD(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function rS(e,n){let t=function(e,n){let t=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],o=r&&"/"===t;(!r&&":"===t||o)&&i(n)}return i(e.length),RegExp(o,"i");function i(i){let a=e.slice(t,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":a,i===e.length)if(r)n&&(o+="$");else{let e=n?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,t=i}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let r=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(r)}}let rM=!1,rz=[],rP=re&&window.location.href;function rO(){return rT()}function rT(e=[],n,t=!1){let r,o,i,a,s;if(rM)return new Promise((e,t)=>{rz.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(r=[],o=[],i=[],a=[],s=(new Date).getTime(),ry.forEach(e=>{let n=e.status!==tO&&tB(e);switch(e.status){case tP:n&&s-e.loadErrorTime>=200&&i.push(e);break;case tA:case tw:n&&i.push(e);break;case tk:case tC:!n&&rh[tI(e)]?r.push(e):n&&a.push(e);break;case tD:n||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:i,appsToMount:a}),d,f=[],h=rP,m=rP=window.location.href;return rI?(rM=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return rs.call(window.history,history.state,"",h.substring(location.origin.length)),rP=location.href,rM=!1,rT(e,n,!0);let r=l.map(rm),o=Promise.all(c.map(tq).map(e=>e.then(rm)).concat(r));o.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let i=u.map(e=>t9(e).then(e=>rB(e,o))),a=p.filter(e=>0>u.indexOf(e)).map(e=>rB(e,o));return o.catch(e=>{throw y(),e}).then(()=>(y(),Promise.all(i.concat(a)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(b).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(t9)).then(y).then(()=>[]).catch(e=>{throw y(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(tv(42,!1))),console.warn(e),!1)))}function b(){let n=r_();e.forEach(e=>e.resolve(n));try{$(0===d.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(rM=!1,rz.length>0){let e=rz;rz=[],rT(e)}return n}function y(){t||(e.forEach(e=>{ro(e.eventArguments)}),ro(n))}function v(e=!1,t){let r={},o={[tD]:[],[tC]:[],[tA]:[],[tO]:[]};e?(u.concat(p).forEach((e,n)=>{a(e,tD)}),l.forEach(e=>{a(e,tA)}),c.forEach(e=>{a(e,tC)})):d.forEach(e=>{a(e)});let i={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:m}};return t&&tR(i.detail,t),i;function a(e,n){let t=tI(e);n=n||r$(t),r[t]=n,(o[n]=o[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new tm(`single-spa:${e}`,n))}}function rB(e,n){return tB(e)?tU(e).then(e=>n.then(()=>tB(e)?tY(e):e)):n.then(()=>e)}let rI=!1;function rN(e){rI=!0,re&&(rc(e),rT())}function rj(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return rR(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function rR(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function rF({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),r=rj(e,n).replace(window.location.origin,"");r.startsWith(t)?rr(r):window.location.assign(r)}re&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...ry]},reroute:rT,NOT_LOADED:tA,toLoadPromise:t9,toBootstrapPromise:tU,unregisterApplication:rx,getProfilerData:function(){return tG}});let rL="openmrs:history";function rW(){return JSON.parse(sessionStorage.getItem(rL)??"[]")}function rV({toUrl:e}){let n=rW(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);rF({to:n[t]}),sessionStorage.setItem(rL,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function rG(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}nx.Boolean,nx.String,to.isUrl,nx.Array,nx.Number,to.inRange(100,600),nx.Boolean,nx.Boolean;let rU="/ws/rest/v1",rq="/ws/fhir2/R4",rH=`${rU}/session`;function rK(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function rY(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)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 t=rK(e);if(n.headers||(n.headers={}),ep(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(rU)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(rq)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let r=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await nK("@openmrs/esm-api");if(e.ok)if(204!==e.status)return e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e});else{if(o&&e.headers.has("location")){let n=e.headers.get("location");n&&rF({to:n})}return e.data=null,e}return t===rK(rH)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(sessionStorage.removeItem(rL),rF({to:n.url||e.headers.get("location")||"${openmrsSpaBase}/login"}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let o=n;try{o=JSON.parse(n)}catch(e){}throw new rZ(t,e,o,r)},n=>{throw new rZ(t,e,null,r)})})}function rJ(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new er.Observable(r=>{let o=!1;return rY(e,n).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||t.abort()}})}class rZ extends Error{constructor(e,n,t,r){super(),rG(this,"response",void 0),rG(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
12
|
+
${n}`)}return r}let n3=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let r=t[n],o=e[n];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=o._default);let e=o._elements;if(r&&n5(e)){if(o._type===nx.Array&&Array.isArray(r)){let o=r.map(n=>n3(e,n));t[n]=o}else if(o._type===nx.Object)for(let n of Object.keys(r))r[n]=n3(e,r[n])}}else if(n4(o)){let e=r??{};n4(e)&&(t[n]=n3(o,e))}}return t};function n5(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function n4(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let n6=new Set;function n8(e,n){let t=`${e}:::${n}`;n6||(n6=new Set),n6.has(t)||(console.error(n),n6.add(t))}let n7={"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:nx.Object,_default:{},_validators:[nC(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=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: ${n.join(", ")}.`})]}},n9={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nx.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nx.String,_default:void 0}},...n7},te=(e,n)=>nC(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),tn=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return nC(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,r=t.exec(e);for(;r;){if(!n.includes(r[1]))return!1;r=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},tt=tn([]),tr=e=>nC(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),to={inRange:te,isUrl:tt,isUrlWithTemplateParameters:tn,oneOf:tr};var ti=t(48067);let ta=L("breadcrumbs",[]);function ts(e){return tl([e])}function tl(e){let n=[...tc(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ti.pathToRegexp)(e.matcher).regexp:(0,ti.pathToRegexp)(e.path).regexp,settings:e}))];ta.setState(n,!0)}function tc(){return ta.getState()}function tu(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=tu(e,t.join("/"));if(n)return n}}(e,n)}function tp(e,n){if(e.length>0){let t=tu(e,n);if(t){let n=[t],r=tu(e,t.settings.parent);for(;void 0!==r;)n.push(r),r=tu(e,r.settings.parent);return n.reverse()}}return[]}function td(e){return tp(tc(),e)}var tf=Object.freeze({__proto__:null,get start(){return rN},get ensureJQuerySupport(){return rd},get setBootstrapMaxTime(){return t3},get setMountMaxTime(){return t5},get setUnmountMaxTime(){return t4},get setUnloadMaxTime(){return t6},get registerApplication(){return rw},get unregisterApplication(){return rx},get getMountedApps(){return r_},get getAppStatus(){return r$},get unloadApplication(){return rC},get checkActivityFunctions(){return rk},get getAppNames(){return rv},get pathToActiveWhen(){return rS},get navigateToUrl(){return rr},get patchHistoryApi(){return rc},get triggerAppChange(){return rO},get addErrorHandler(){return ty},get removeErrorHandler(){return t_},get mountRootParcel(){return tX},get NOT_LOADED(){return tA},get LOADING_SOURCE_CODE(){return tw},get NOT_BOOTSTRAPPED(){return tk},get BOOTSTRAPPING(){return tx},get NOT_MOUNTED(){return tC},get MOUNTING(){return tE},get UPDATING(){return tS},get LOAD_ERROR(){return tP},get MOUNTED(){return tD},get UNLOADING(){return tz},get UNMOUNTING(){return tM},get SKIP_BECAUSE_BROKEN(){return tO}}),th=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,tm=!function(){try{var e=new th("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,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:th;let tg=[];function tb(e,n,t){let r=t$(e,n,t);tg.length?tg.forEach(e=>e(r)):setTimeout(()=>{throw r})}function ty(e){if("function"!=typeof e)throw Error(tv(28,!1));tg.push(e)}function t_(e){if("function"!=typeof e)throw Error(tv(29,!1));let n=!1;return tg=tg.filter(t=>{let r=t===e;return n=n||r,!r}),n}function tv(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function t$(e,n,t){let r,o=`${tj(n)} '${tI(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(tv(30,!1,n.status,tI(n)));try{r=Error(o+JSON.stringify(e))}catch(n){r=e}}return r.appOrParcelName=tI(n),n.status=t,r}let tA="NOT_LOADED",tw="LOADING_SOURCE_CODE",tk="NOT_BOOTSTRAPPED",tx="BOOTSTRAPPING",tC="NOT_MOUNTED",tE="MOUNTING",tD="MOUNTED",tS="UPDATING",tM="UNMOUNTING",tz="UNLOADING",tP="LOAD_ERROR",tO="SKIP_BECAUSE_BROKEN";function tT(e){return e.status===tD}function tB(e){try{return e.activeWhen(window.location)}catch(n){return tb(n,e,tO),!1}}function tI(e){return e.name}function tN(e){return!!e.unmountThisParcel}function tj(e){return tN(e)?"parcel":"application"}function tR(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function tF(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function tL(e){return e&&("function"==typeof e||Array.isArray(e)&&!tF(e,e=>"function"!=typeof e))}function tW(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let r=tj(e),o=tI(e);return function(e){return t.reduce((t,i,a)=>t.then(()=>{let t=i(e);return tV(t)?t:Promise.reject(tv(15,!1,r,o,n,a))}),Promise.resolve())}}function tV(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let tG=[];function tU(e,n){return Promise.resolve().then(()=>e.status!==tk?e:(e.status=tx,e.bootstrap?t8(e,"bootstrap").then(t).catch(t=>{if(n)throw t$(t,e,tO);return tb(t,e,tO),e}):Promise.resolve().then(t)));function t(){return e.status=tC,e}}function tq(e,n){return Promise.resolve().then(()=>{if(e.status!==tD)return e;return e.status=tM,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,r=>t().then(()=>{let t=Error(r.message);if(n)throw t$(t,e,tO);tb(t,e,tO)})).then(()=>e);function t(){return t8(e,"unmount").then(()=>{e.status=tC},t=>{if(n)throw t$(t,e,tO);tb(t,e,tO)})}})}let tH=!1,tK=!1;function tY(e,n){return Promise.resolve().then(()=>e.status!==tC?e:(tH||(window.dispatchEvent(new tm("single-spa:before-first-mount")),tH=!0),e.status=tE,t8(e,"mount").then(()=>(e.status=tD,tK||(window.dispatchEvent(new tm("single-spa:first-mount")),tK=!0),e)).catch(t=>{return e.status=tD,tq(e,!0).then(r,r);function r(){if(n)throw t$(t,e,tO);return tb(t,e,tO),e}})))}let tJ=0,tZ={parcels:{}};function tX(){return tQ.apply(tZ,arguments)}function tQ(e,n){let t,r,o,i=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(tv(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(tv(3,!1,typeof e.name));let a=tJ++,s=e.name||`parcel-${a}`;if("object"!=typeof n)throw Error(tv(4,!1,s,typeof n));if(!n.domElement)throw Error(tv(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:a,parcels:{},status:l?tw:tk,customProps:n,parentName:tI(i),unmountThisParcel:()=>f.then(()=>{if(u.status!==tD)throw Error(tv(6,!1,s,u.status));return tq(u,!0)}).then(e=>(u.parentName&&delete i.parcels[u.id],e)).then(e=>(r(e),e)).catch(e=>{throw u.status=tO,o(e),e})};i.parcels[a]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(tv(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(tv(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!tL(e.bootstrap))throw Error(tv(9,!1,s));if(!tL(e.mount))throw Error(tv(10,!1,s));if(!tL(e.unmount))throw Error(tv(11,!1,s));if(e.update&&!tL(e.update))throw Error(tv(12,!1,s));let n=tW(e,"bootstrap"),r=tW(e,"mount"),o=tW(e,"unmount");u.status=tk,u.name=s,u.bootstrap=n,u.mount=r,u.unmount=o,u.timeouts=t7(e.timeouts),e.update&&(u.update=tW(e,"update"),t.update=function(e){return u.customProps=e,t0(Promise.resolve().then(()=>{if(u.status!==tD)throw Error(tv(32,!1,tI(u)));return u.status=tS,t8(u,"update").then(()=>(u.status=tD,u)).catch(e=>{throw t$(e,u,tO)})}))})})).then(()=>tU(u,!0)),f=d.then(()=>tY(u,!0)),h=new Promise((e,n)=>{r=e,o=n});return t={mount:()=>t0(Promise.resolve().then(()=>{if(u.status!==tC)throw Error(tv(13,!1,s,u.status));return i.parcels[a]=u,tY(u)})),unmount:()=>t0(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:t0(p),bootstrapPromise:t0(d),mountPromise:t0(f),unmountPromise:t0(h)}}function t0(e){return e.then(()=>null)}function t1(e){let n=tI(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(tv(40,!1),n,t));let r=tR({},t,{name:n,mountParcel:tQ.bind(e),singleSpa:tf});return tN(e)&&(r.unmountSelf=e.unmountThisParcel),r}let t2={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 t3(e,n,t){if("number"!=typeof e||e<=0)throw Error(tv(16,!1));t2.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function t5(e,n,t){if("number"!=typeof e||e<=0)throw Error(tv(17,!1));t2.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function t4(e,n,t){if("number"!=typeof e||e<=0)throw Error(tv(18,!1));t2.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function t6(e,n,t){if("number"!=typeof e||e<=0)throw Error(tv(19,!1));t2.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function t8(e,n){let t=e.timeouts[n],r=t.warningMillis,o=tj(e);return new Promise((i,a)=>{let s=!1,l=!1;e[n](t1(e)).then(e=>{s=!0,i(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>u(1),r),setTimeout(()=>u(!0),t.millis);let c=tv(31,!1,n,o,tI(e),t.millis);function u(e){s||(!0===e?(l=!0,t.dieOnTimeout?a(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<t.millis&&setTimeout(()=>u(e+1),r)))}})}function t7(e){let n={};for(let t in t2)n[t]=tR({},t2[t],e&&e[t]||{});return n}function t9(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==tA&&e.status!==tP?e:(e.status=tw,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(t1(e));if(!tV(r))throw t=!0,Error(tv(33,!1,tI(e)));return r.then(t=>{let r;e.loadErrorTime=null,"object"!=typeof(n=t)&&(r=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!tL(n.bootstrap)&&(r=35),tL(n.mount)||(r=36),tL(n.unmount)||(r=37);let o=tj(n);if(r){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(tv(r,!1,o,tI(e),t),n),tb(void 0,e,tO),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=tR({},e.devtools.overlays,n.devtools.overlays)),e.status=tk,e.bootstrap=tW(n,"bootstrap"),e.mount=tW(n,"mount"),e.unmount=tW(n,"unmount"),e.unload=tW(n,"unload"),e.timeouts=t7(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let r;return delete e.loadPromise,t?r=tO:(r=tP,e.loadErrorTime=(new Date).getTime()),tb(n,e,r),e}))})}let re="u">typeof window,rn={hashchange:[],popstate:[]},rt=["hashchange","popstate"];function rr(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(tv(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=ru(window.location.href),r=ru(n);0===n.indexOf("#")?window.location.hash=r.hash:t.host!==r.host&&r.host?window.location.href=n:r.pathname===t.pathname&&r.search===t.search?window.location.hash=r.hash:window.history.pushState(null,null,n)}function ro(e){if(e){let n=e[0].type;rt.indexOf(n)>=0&&rn[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function ri(){rT([],arguments)}function ra(e,n){return function(){let t=window.location.href,o=e.apply(this,arguments),i=window.location.href;return r&&t===i||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),o}}let rs=null,rl=!1;function rc(e){if(rl)throw Error(tv(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,rl=!0,rs=window.history.replaceState,window.addEventListener("hashchange",ri),window.addEventListener("popstate",ri);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&rt.indexOf(e)>=0)||tF(rn[e],e=>e===t))return n.apply(this,arguments);rn[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&rt.indexOf(e)>=0&&(rn[e]=rn[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=ra(window.history.pushState,"pushState"),window.history.replaceState=ra(rs,"replaceState")}function ru(e){let n=document.createElement("a");return n.href=e,n}re&&(window.singleSpaNavigate?console.warn(tv(41,!1)):window.singleSpaNavigate=rr);let rp=!1;function rd(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!rp){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return rf.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return rf.call(this,t,window.removeEventListener,e,n,arguments)},rp=!0}}function rf(e,n,t,r,o){return"string"!=typeof t?e.apply(this,o):(t.split(/\s+/).forEach(e=>{rt.indexOf(e)>=0&&(n(e,r),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,o))}let rh={};function rm(e){return Promise.resolve().then(()=>{let n=rh[tI(e)];if(!n)return e;if(e.status===tA)return rg(e,n),e;if(e.status===tz)return n.promise.then(()=>e);if(e.status!==tC&&e.status!==tP)return e;let t=e.status===tP?Promise.resolve():t8(e,"unload");return e.status=tz,t.then(()=>(rg(e,n),e)).catch(t=>(delete rh[tI(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,tb(t,e,tO),n.reject(t),e))})}function rg(e,n){delete rh[tI(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=tA,n.resolve()}function rb(e,n,t,r){rh[tI(e)]={app:e,resolve:t,reject:r},Object.defineProperty(rh[tI(e)],"promise",{get:n})}let ry=[];function r_(){return ry.filter(tT).map(tI)}function rv(){return ry.map(tI)}function r$(e){let n=tF(ry,n=>tI(n)===e);return n?n.status:null}let rA=!1;function rw(e,n,t,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(tv(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(tv(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(tv(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(tv(24,!1));if(!rD(e.customProps))throw Error(tv(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,n,t,r){if("string"!=typeof e||0===e.length)throw Error(tv(20,!1));if(!n)throw Error(tv(23,!1));if("function"!=typeof t)throw Error(tv(24,!1));if(!rD(r))throw Error(tv(22,!1))}(e,n,t,r),a.name=e,a.loadApp=n,a.activeWhen=t,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:rS(e)),a.activeWhen=e=>s.some(n=>n(e)),a);if(rI||rA||(rA=!0,setTimeout(()=>{rI||console.warn(tv(1,!1))},5e3)),-1!==rv().indexOf(l.name))throw Error(tv(21,!1,l.name));ry.push(tR({loadErrorTime:null,status:tA,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),re&&(rd(),rT())}function rk(e=window.location){return ry.filter(n=>n.activeWhen(e)).map(tI)}function rx(e){if(0===ry.filter(n=>tI(n)===e).length)throw Error(tv(25,!1,e));return(re?rC(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=ry.map(tI).indexOf(e);ry.splice(n,1)})}function rC(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(tv(26,!1));let t=tF(ry,n=>tI(n)===e);if(!t)throw Error(tv(27,!1,e));let r=rh[tI(t)];if(n&&n.waitForUnmount){if(r)return r.promise;{let e=new Promise((n,r)=>{rb(t,()=>e,n,r)});return e}}{let e;return r?(e=r.promise,rE(t,r.resolve,r.reject)):e=new Promise((n,r)=>{rb(t,()=>e,n,r),rE(t,n,r)}),e}}function rE(e,n,t){Promise.resolve().then(()=>{if(tF(rk(),n=>n===tI(e)))return rO()}).then(()=>tq(e).then(rm).then(()=>{n(),setTimeout(()=>{rT()})})).catch(t)}function rD(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function rS(e,n){let t=function(e,n){let t=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],o=r&&"/"===t;(!r&&":"===t||o)&&i(n)}return i(e.length),RegExp(o,"i");function i(i){let a=e.slice(t,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":a,i===e.length)if(r)n&&(o+="$");else{let e=n?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,t=i}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let r=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(r)}}let rM=!1,rz=[],rP=re&&window.location.href;function rO(){return rT()}function rT(e=[],n,t=!1){let r,o,i,a,s;if(rM)return new Promise((e,t)=>{rz.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(r=[],o=[],i=[],a=[],s=(new Date).getTime(),ry.forEach(e=>{let n=e.status!==tO&&tB(e);switch(e.status){case tP:n&&s-e.loadErrorTime>=200&&i.push(e);break;case tA:case tw:n&&i.push(e);break;case tk:case tC:!n&&rh[tI(e)]?r.push(e):n&&a.push(e);break;case tD:n||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:i,appsToMount:a}),d,f=[],h=rP,m=rP=window.location.href;return rI?(rM=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return rs.call(window.history,history.state,"",h.substring(location.origin.length)),rP=location.href,rM=!1,rT(e,n,!0);let r=l.map(rm),o=Promise.all(c.map(tq).map(e=>e.then(rm)).concat(r));o.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let i=u.map(e=>t9(e).then(e=>rB(e,o))),a=p.filter(e=>0>u.indexOf(e)).map(e=>rB(e,o));return o.catch(e=>{throw y(),e}).then(()=>(y(),Promise.all(i.concat(a)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(b).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(t9)).then(y).then(()=>[]).catch(e=>{throw y(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(tv(42,!1))),console.warn(e),!1)))}function b(){let n=r_();e.forEach(e=>e.resolve(n));try{$(0===d.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(rM=!1,rz.length>0){let e=rz;rz=[],rT(e)}return n}function y(){t||(e.forEach(e=>{ro(e.eventArguments)}),ro(n))}function v(e=!1,t){let r={},o={[tD]:[],[tC]:[],[tA]:[],[tO]:[]};e?(u.concat(p).forEach((e,n)=>{a(e,tD)}),l.forEach(e=>{a(e,tA)}),c.forEach(e=>{a(e,tC)})):d.forEach(e=>{a(e)});let i={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:m}};return t&&tR(i.detail,t),i;function a(e,n){let t=tI(e);n=n||r$(t),r[t]=n,(o[n]=o[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new tm(`single-spa:${e}`,n))}}function rB(e,n){return tB(e)?tU(e).then(e=>n.then(()=>tB(e)?tY(e):e)):n.then(()=>e)}let rI=!1;function rN(e){rI=!0,re&&(rc(e),rT())}function rj(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return rR(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function rR(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function rF({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),r=rj(e,n).replace(window.location.origin,"");r.startsWith(t)?rr(r):window.location.assign(r)}re&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...ry]},reroute:rT,NOT_LOADED:tA,toLoadPromise:t9,toBootstrapPromise:tU,unregisterApplication:rx,getProfilerData:function(){return tG}});let rL="openmrs:history";function rW(){return JSON.parse(sessionStorage.getItem(rL)??"[]")}function rV({toUrl:e}){let n=rW(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);rF({to:n[t]}),sessionStorage.setItem(rL,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function rG(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}nx.Boolean,nx.String,to.isUrl,nx.Array,nx.Number,to.inRange(100,600),nx.Boolean,nx.Boolean;let rU="/ws/rest/v1",rq="/ws/fhir2/R4",rH=`${rU}/session`;function rK(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function rY(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)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 t=rK(e);if(n.headers||(n.headers={}),ep(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(rU)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(rq)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let r=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await nK("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(o&&n&&(t===rK(rH)||204===e.status)&&rF({to:n}),204===e.status)?(e.data=null,e):e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e})}return t===rK(rH)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(sessionStorage.removeItem(rL),rF({to:n.url||e.headers.get("location")||"${openmrsSpaBase}/login"}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let o=n;try{o=JSON.parse(n)}catch(e){}throw new rZ(t,e,o,r)},n=>{throw new rZ(t,e,null,r)})})}function rJ(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new er.Observable(r=>{let o=!1;return rY(e,n).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||t.abort()}})}class rZ extends Error{constructor(e,n,t,r){super(),rG(this,"response",void 0),rG(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${r.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
15
|
${this.stack}`}}let rX=L("session",{loaded:!1,session:null}),rQ=0;function r0(e={includeAuthStatus:!0}){return(rQ<Date.now()-6e4||!rX.getState().loaded)&&r3(),new er.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(rX.getState()),rX.subscribe(t)})}function r1(){return(rQ<Date.now()-6e4||!rX.getState().loaded)&&r3(),rX}function r2(e){let n=e.locale??e.user?.userProperties?.defaultLocale;n&&n.includes("_")&&(n=n.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(n)&&n!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",n)}function r3(e,n){rQ=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),oe(rY(rH,{headers:t}))}function r5(){rX.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function r4(e,n){var t,r;if(void 0===n)return!e;if(!e)return!0;return t=e,r=n,("string"==typeof t?!U(r.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!U(r.privileges.find(n=>e===n.display))):(U(t)||console.error(`Could not understand privileges "${t}"`),!0))||!U(n.roles.find(e=>"System Developer"===e.display))}function r6(){let e,n;return new Promise(t=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,t(r.session.user),n&&n())};r(rX.getState()),e||(n=rX.subscribe(r))})}function r8(){return new Promise((e,n)=>{r0().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function r7(e,n){return oe(rY(rH,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function r9(e,n,t){return t||(t=new AbortController),await rY(`${rU}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),r3()}function oe(e){return new Promise((n,t)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},rX.setState(r),n(r)):(r={loaded:!1,session:null},rX.setState(r),t(r))}).catch(e=>{z(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};rX.setState(n),t(n)})})}function on(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}rX.subscribe(e=>{e.loaded&&e.session&&r2(e.session)});let ot={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"},or=j()(()=>({}));(p=F[X="openmrs-app-context"])?(p.active?R()||console.error(`Attempted to override the existing store ${X}. Make sure that stores are only created once.`):p.value=or,p.active=!0,p.value):F[X]={value:or,active:!0};let oo={};function oi(e,n=oo){or.setState(t=>{if(e in t)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({},t,{[e]:n===oo?{}:n})})}function oa(e){or.setState(n=>(e in n&&delete n[e],n))}function os(e,n=e=>e){let t=or.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function ol(e,n){or.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function oc(e,n){let t=os(e);return n(ou(t)),or.subscribe(r=>{let o=e in r?r[e]:null;o!==t&&(t=o,n(ou(o)))})}function ou(e){return null===e?null:Object.freeze(Object.assign({},e))}let op={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"},od=e=>"string"==typeof e,of=()=>{let e,n,t=new Promise((t,r)=>{e=t,n=r});return t.resolve=e,t.reject=n,t},oh=e=>null==e?"":""+e,om=/###/g,og=e=>e&&e.indexOf("###")>-1?e.replace(om,"."):e,ob=e=>!e||od(e),oy=(e,n,t)=>{let r=od(n)?n.split("."):n,o=0;for(;o<r.length-1;){if(ob(e))return{};let n=og(r[o]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++o}return ob(e)?{}:{obj:e,k:og(r[o])}},o_=(e,n,t)=>{let{obj:r,k:o}=oy(e,n,Object);if(void 0!==r||1===n.length){r[o]=t;return}let i=n[n.length-1],a=n.slice(0,n.length-1),s=oy(e,a,Object);for(;void 0===s.obj&&a.length;)i=`${a[a.length-1]}.${i}`,s=oy(e,a=a.slice(0,a.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${i}`]&&(s.obj=void 0);s.obj[`${s.k}.${i}`]=t},ov=(e,n)=>{let{obj:t,k:r}=oy(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,r))return t[r]},o$=(e,n,t)=>{for(let r in n)"__proto__"!==r&&"constructor"!==r&&(r in e?od(e[r])||e[r]instanceof String||od(n[r])||n[r]instanceof String?t&&(e[r]=n[r]):o$(e[r],n[r],t):e[r]=n[r]);return e};var oA={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let ow=e=>od(e)?e.replace(/[&<>"'\/]/g,e=>oA[e]):e,ok=[" ",",","?","!",";"],ox=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(void 0!==n)return n;let t=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,t),this.regExpQueue.push(e),t}}(20),oC=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let r=n.split(t),o=e;for(let e=0;e<r.length;){let n;if(!o||"object"!=typeof o)return;let i="";for(let a=e;a<r.length;++a)if(a!==e&&(i+=t),i+=r[a],void 0!==(n=o[i])){if(["string","number","boolean"].indexOf(typeof n)>-1&&a<r.length-1)continue;e+=a-e+1;break}o=n}return o},oE=e=>e?.replace("_","-"),oD={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,n){console?.[e]?.apply?.(console,n)}};class oS{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||oD,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,t,r){return r&&!this.debug?null:(od(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new oS(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new oS(this.logger,e)}}var oM=new oS;class oz{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let t=this.observers[e].get(n)||0;this.observers[e].set(n,t+1)}),this}off(e,n){if(this.observers[e]){if(!n)return void delete this.observers[e];this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,t])=>{for(let r=0;r<t;r++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,r])=>{for(let o=0;o<r;o++)t.apply(t,[e,...n])})}}class oP extends oz{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,t,r={}){let o,i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,a=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],t&&(Array.isArray(t)?o.push(...t):od(t)&&i?o.push(...t.split(i)):o.push(t)));let s=ov(this.data,o);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=o[0],n=o[1],t=o.slice(2).join(".")),!s&&a&&od(t))?oC(this.data?.[e]?.[n],t,i):s}addResource(e,n,t,r,o={silent:!1}){let i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=[e,n];t&&(a=a.concat(i?t.split(i):t)),e.indexOf(".")>-1&&(a=e.split("."),r=n,n=a[1]),this.addNamespaces(n),o_(this.data,a,r),o.silent||this.emit("added",e,n,t,r)}addResources(e,n,t,r={silent:!1}){for(let r in t)(od(t[r])||Array.isArray(t[r]))&&this.addResource(e,n,r,t[r],{silent:!0});r.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,r,o,i={silent:!1,skipCopy:!1}){let a=[e,n];e.indexOf(".")>-1&&(a=e.split("."),r=t,t=n,n=a[1]),this.addNamespaces(n);let s=ov(this.data,a)||{};i.skipCopy||(t=JSON.parse(JSON.stringify(t))),r?o$(s,t,o):s={...s,...t},o_(this.data,a,s),i.silent||this.emit("added",e,n,t)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return void 0!==this.getResource(e,n)}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(e=>n[e]&&Object.keys(n[e]).length>0)}toJSON(){return this.data}}var oO={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,r,o){return e.forEach(e=>{n=this.processors[e]?.process(n,t,r,o)??n}),n}};let oT=Symbol("i18next/PATH_KEY");function oB(e,n){let t,r,o,{[oT]:i}=e((r=[],(o=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===oT)?r:(r.push(n),(t=Proxy.revocable(e,o)).proxy),Proxy.revocable(Object.create(null),o).proxy));return i.join(n?.keySeparator??".")}let oI={},oN=e=>!od(e)&&"boolean"!=typeof e&&"number"!=typeof e;class oj extends oz{constructor(e,n={}){super(),((e,n,t)=>{e.forEach(e=>{n[e]&&(t[e]=n[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=oM.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let r=this.resolve(e,t);if(r?.res===void 0)return!1;let o=oN(r.res);return!1!==t.returnObjects||!o}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let r=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,o=n.ns||this.options.defaultNS||[],i=t&&e.indexOf(t)>-1,a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let r=ok.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===r.length)return!0;let o=ox.getRegExp(`(${r.map(e=>"?"===e?"\\?":e).join("|")})`),i=!o.test(e);if(!i){let n=e.indexOf(t);n>0&&!o.test(e.substring(0,n))&&(i=!0)}return i})(e,t,r);if(i&&!a){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:od(o)?[o]:o};let i=e.split(t);(t!==r||t===r&&this.options.ns.indexOf(i[0])>-1)&&(o=i.shift()),e=i.join(r)}return{key:e,namespaces:od(o)?[o]:o}}translate(e,n,t){let r="object"==typeof n?{...n}:n;if("object"!=typeof r&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof r&&(r={...r}),r||(r={}),null==e)return"";"function"==typeof e&&(e=oB(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);let o=void 0!==r.returnDetails?r.returnDetails:this.options.returnDetails,i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],r),l=s[s.length-1],c=void 0!==r.nsSeparator?r.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let u=r.lng||this.language,p=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?o?{res:`${l}${c}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${c}${a}`:o?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:a;let d=this.resolve(e,r),f=d?.res,h=d?.usedKey||a,m=d?.exactUsedKey||a,g=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,y=void 0!==r.count&&!od(r.count),v=oj.hasDefaultValue(r),$=y?this.pluralResolver.getSuffix(u,r.count,r):"",A=r.ordinal&&y?this.pluralResolver.getSuffix(u,r.count,{ordinal:!1}):"",w=y&&!r.ordinal&&0===r.count,k=w&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${$}`]||r[`defaultValue${A}`]||r.defaultValue,x=f;b&&!f&&v&&(x=k);let C=oN(x),E=Object.prototype.toString.apply(x);if(b&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(od(g)&&Array.isArray(x))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,x,{...r,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return o?(d.res=e,d.usedParams=this.getUsedParamsDetails(r),d):e}if(i){let e=Array.isArray(x),n=e?[]:{},t=e?m:h;for(let e in x)if(Object.prototype.hasOwnProperty.call(x,e)){let o=`${t}${i}${e}`;v&&!f?n[e]=this.translate(o,{...r,defaultValue:oN(k)?k[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(o,{...r,joinArrays:!1,ns:s}),n[e]===o&&(n[e]=x[e])}f=n}}else if(b&&od(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,r,t));else{let n=!1,o=!1;!this.isValidLookup(f)&&v&&(n=!0,f=k),this.isValidLookup(f)||(o=!0,f=a);let s=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:f,p=v&&k!==f&&this.options.updateMissing;if(o||n||p){if(this.logger.log(p?"updateKey":"missingKey",u,l,a,p?k:f),i){let e=this.resolve(a,{...r,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if("fallback"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t<n.length;t++)e.push(n[t]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(r.lng||this.language):e.push(r.lng||this.language);let t=(e,n,t)=>{let o=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,o,p,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,o,p,r),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&y?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,r);w&&r[`defaultValue${this.options.pluralSeparator}zero`]&&0>n.indexOf(`${this.options.pluralSeparator}zero`)&&n.push(`${this.options.pluralSeparator}zero`),n.forEach(n=>{t([e],a+n,r[`defaultValue${n}`]||k)})}):t(e,a,k))}f=this.extendTranslation(f,e,r,d,t),o&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${a}`),(o||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${a}`:a,n?f:void 0,r))}return o?(d.res=f,d.usedParams=this.getUsedParamsDetails(r),d):f}extendTranslation(e,n,t,r,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!t.skipInterpolation){let i;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let a=od(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let n=e.match(this.interpolator.nestingRegexp);i=n&&n.length}let s=t.replace&&!od(t.replace)?t.replace:t;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,t.lng||this.language||r.usedLng,t),a){let n=e.match(this.interpolator.nestingRegexp);i<(n&&n.length)&&(t.nest=!1)}!t.lng&&r&&r.res&&(t.lng=this.language||r.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>o?.[0]!==e[0]||t.context?this.translate(...e,n):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null),t)),t.interpolation&&this.interpolator.reset()}let i=t.postProcess||this.options.postProcess,a=od(i)?[i]:i;return null!=e&&a?.length&&!1!==t.applyPostProcessor&&(e=oO.handle(a,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,r,o,i,a;return od(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;r=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let u=void 0!==n.count&&!od(n.count),p=u&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(od(n.context)||"number"==typeof n.context)&&""!==n.context,f=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(e=>{this.isValidLookup(t)||(a=e,!oI[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(oI[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${f.join(", ")}" won't get resolved as namespace "${a}" 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!!!")),f.forEach(r=>{let a;if(this.isValidLookup(t))return;i=r;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,r,e,n);else{let e;u&&(e=this.pluralResolver.getSuffix(r,n.count,n));let t=`${this.options.pluralSeparator}zero`,o=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(n.ordinal&&0===e.indexOf(o)&&s.push(l+e.replace(o,this.options.pluralSeparator)),s.push(l+e),p&&s.push(l+t)),d){let r=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(r),u&&(n.ordinal&&0===e.indexOf(o)&&s.push(r+e.replace(o,this.options.pluralSeparator)),s.push(r+e),p&&s.push(r+t))}}for(;a=s.pop();)this.isValidLookup(t)||(o=a,t=this.getResource(r,e,a,n))}))})}),{res:t,usedKey:r,exactUsedKey:o,usedLng:i,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,r):this.resourceStore.getResource(e,n,t,r)}getUsedParamsDetails(e={}){let n=e.replace&&!od(e.replace),t=n?e.replace:e;if(n&&void 0!==e.count&&(t.count=e.count),this.options.interpolation.defaultVariables&&(t={...this.options.interpolation.defaultVariables,...t}),!n)for(let e of(t={...t},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete t[e];return t}static hasDefaultValue(e){let n="defaultValue";for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n===t.substring(0,n.length)&&void 0!==e[t])return!0;return!1}}class oR{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=oM.create("languageUtils")}getScriptPartFromCode(e){if(!(e=oE(e))||0>e.indexOf("-"))return null;let n=e.split("-");return 2===n.length||(n.pop(),"x"===n[n.length-1].toLowerCase())?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(!(e=oE(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(od(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch(e){}return(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)?n:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let n;return e?(e.forEach(e=>{if(n)return;let t=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(t))&&(n=t)}),!n&&this.options.supportedLngs&&e.forEach(e=>{if(n)return;let t=this.getScriptPartFromCode(e);if(this.isSupportedCode(t))return n=t;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return n=r;n=this.options.supportedLngs.find(e=>{if(e===r||!(0>e.indexOf("-")&&0>r.indexOf("-"))&&(e.indexOf("-")>0&&0>r.indexOf("-")&&e.substring(0,e.indexOf("-"))===r||0===e.indexOf(r)&&r.length>1))return e})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n):null}getFallbackCodes(e,n){if(!e)return[];if("function"==typeof e&&(e=e(n)),od(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let t=e[n];return t||(t=e[this.getScriptPartFromCode(n)]),t||(t=e[this.formatLanguageCode(n)]),t||(t=e[this.getLanguagePartFromCode(n)]),t||(t=e.default),t||[]}toResolveHierarchy(e,n){let t=this.getFallbackCodes((!1===n?[]:n)||this.options.fallbackLng||[],e),r=[],o=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return od(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):od(e)&&o(this.formatLanguageCode(e)),t.forEach(e=>{0>r.indexOf(e)&&o(this.formatLanguageCode(e))}),r}}let oF={zero:0,one:1,two:2,few:3,many:4,other:5},oL={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class oW{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=oM.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,r=oE("dev"===e?"en":e),o=n.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:r,type:o});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];try{t=new Intl.PluralRules(r,{type:o})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),oL;if(!e.match(/-|_/))return oL;let r=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(r,n)}return this.pluralRulesCache[i]=t,t}needsPlural(e,n={}){let t=this.getRule(e,n);return t||(t=this.getRule("dev",n)),t?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,t={}){return this.getSuffixes(e,t).map(e=>`${n}${e}`)}getSuffixes(e,n={}){let t=this.getRule(e,n);return(t||(t=this.getRule("dev",n)),t)?t.resolvedOptions().pluralCategories.sort((e,n)=>oF[e]-oF[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let r=this.getRule(e,t);return r?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${r.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let oV=(e,n,t,r=".",o=!0)=>{let i,a=void 0!==(i=ov(e,t))?i:ov(n,t);return!a&&o&&od(t)&&void 0===(a=oC(e,t,r))&&(a=oC(n,t,r)),a};class oG{constructor(e={}){this.logger=oM.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:n,escapeValue:t,useRawValueToEscape:r,prefix:o,prefixEscaped:i,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:g,alwaysFormat:b}=e.interpolation;this.escape=void 0!==n?n:ow,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==r&&r,this.prefix=o?o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):i||"{{",this.suffix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==b&&b,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,n)=>e?.source===n?(e.lastIndex=0,e):RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,t,r){let o,i,a,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let o=oV(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(o,void 0,t,{...r,...n,interpolationkey:e}):o}let o=e.split(this.formatSeparator),i=o.shift().trim(),a=o.join(this.formatSeparator).trim();return this.format(oV(n,s,i,this.options.keySeparator,this.options.ignoreJSONStructure),a,t,{...r,...n,interpolationkey:i})};this.resetRegExp();let c=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(n=>{for(a=0;o=n.regex.exec(e);){let t=o[1].trim();if(void 0===(i=l(t)))if("function"==typeof c){let n=c(e,o,r);i=od(n)?n:""}else if(r&&Object.prototype.hasOwnProperty.call(r,t))i="";else if(u){i=o[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),i="";else od(i)||this.useRawValueToEscape||(i=oh(i));let s=n.safeValue(i);if(e=e.replace(o[0],s),u?(n.regex.lastIndex+=i.length,n.regex.lastIndex-=o[0].length):n.regex.lastIndex=0,++a>=this.maxReplaces)break}}),e}nest(e,n,t={}){let r,o,i,a=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let r=e.split(RegExp(`${t}[ ]*{`)),o=`{${r[1]}`;e=r[0];let a=(o=this.interpolate(o,i)).match(/'/g),s=o.match(/"/g);((a?.length??0)%2!=0||s)&&s.length%2==0||(o=o.replace(/'/g,'"'));try{i=JSON.parse(o),n&&(i={...n,...i})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${o}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];(i=(i={...t}).replace&&!od(i.replace)?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;let l=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==l&&(s=r[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),(o=n(a.call(this,r[1].trim(),i),i))&&r[0]===e&&!od(o))return o;od(o)||(o=oh(o)),o||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),o=""),s.length&&(o=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:r[1].trim()}),o.trim())),e=e.replace(r[0],o),this.regexp.lastIndex=0}return e}}let oU=e=>{let n={};return(t,r,o)=>{let i=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(i={...i,[o.interpolationkey]:void 0});let a=r+JSON.stringify(i),s=n[a];return s||(s=e(oE(r),o),n[a]=s),s(t)}},oq=e=>(n,t,r)=>e(oE(t),r)(n);class oH{constructor(e={}){this.logger=oM.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?oU:oq;this.formats={number:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n});return e=>t.format(e)}),currency:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n,style:"currency"});return e=>t.format(e)}),datetime:t((e,n)=>{let t=new Intl.DateTimeFormat(e,{...n});return e=>t.format(e)}),relativetime:t((e,n)=>{let t=new Intl.RelativeTimeFormat(e,{...n});return e=>t.format(e,n.range||"day")}),list:t((e,n)=>{let t=new Intl.ListFormat(e,{...n});return e=>t.format(e)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=oU(n)}format(e,n,t,r={}){let o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&0>o[0].indexOf(")")&&o.find(e=>e.indexOf(")")>-1)){let e=o.findIndex(e=>e.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,e)].join(this.formatSeparator)}return o.reduce((e,n)=>{let{formatName:o,formatOptions:i}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let r=e.split("(");n=r[0].toLowerCase().trim();let o=r[1].substring(0,r[1].length-1);"currency"===n&&0>o.indexOf(":")?t.currency||(t.currency=o.trim()):"relativetime"===n&&0>o.indexOf(":")?t.range||(t.range=o.trim()):o.split(";").forEach(e=>{if(e){let[n,...r]=e.split(":"),o=r.join(":").trim().replace(/^'+|'+$/g,""),i=n.trim();t[i]||(t[i]=o),"false"===o&&(t[i]=!1),"true"===o&&(t[i]=!0),isNaN(o)||(t[i]=parseInt(o,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[o]){let n=e;try{let a=r?.formatParams?.[r.interpolationkey]||{},s=a.locale||a.lng||r.locale||r.lng||t;n=this.formats[o](e,s,{...i,...r,...a})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class oK extends oz{constructor(e,n,t,r={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=r,this.logger=oM.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,r.backend,r)}queueLoad(e,n,t,r){let o={},i={},a={},s={};return e.forEach(e=>{let r=!0;n.forEach(n=>{let a=`${e}|${n}`;!t.reload&&this.store.hasResourceBundle(e,n)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===i[a]&&(i[a]=!0):(this.state[a]=1,r=!1,void 0===i[a]&&(i[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===s[n]&&(s[n]=!0)))}),r||(a[e]=!0)}),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let r=e.split("|"),o=r[0],i=r[1];n&&this.emit("failedLoading",o,i,n),!n&&t&&this.store.addResourceBundle(o,i,t,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&t&&(this.state[e]=0);let a={};this.queue.forEach(t=>{((e,n,t,r)=>{let{obj:o,k:i}=oy(e,n,Object);o[i]=o[i]||[],o[i].push(t)})(t.loaded,[o],i),void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--),n&&t.errors.push(n),0!==t.pendingCount||t.done||(Object.keys(t.loaded).forEach(e=>{a[e]||(a[e]={});let n=t.loaded[e];n.length&&n.forEach(n=>{void 0===a[e][n]&&(a[e][n]=!0)})}),t.done=!0,t.errors.length?t.callback(t.errors):t.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,n,t,r=0,o=this.retryTimeout,i){if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:r,wait:o,callback:i});this.readingCalls++;let a=(a,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&s&&r<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,r+1,2*o,i)},o):i(a,s)},s=this.backend[t].bind(this.backend);if(2===s.length){try{let t=s(e,n);t&&"function"==typeof t.then?t.then(e=>a(null,e)).catch(a):a(null,t)}catch(e){a(e)}return}return s(e,n,a)}prepareLoading(e,n,t={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();od(e)&&(e=this.languageUtils.toResolveHierarchy(e)),od(n)&&(n=[n]);let o=this.queueLoad(e,n,t,r);if(!o.toLoad.length)return o.pending.length||r(),null;o.toLoad.forEach(e=>{this.loadOne(e)})}load(e,n,t){this.prepareLoading(e,n,{},t)}reload(e,n,t){this.prepareLoading(e,n,{reload:!0},t)}loadOne(e,n=""){let t=e.split("|"),r=t[0],o=t[1];this.read(r,o,"read",void 0,void 0,(t,i)=>{t&&this.logger.warn(`${n}loading namespace ${o} for language ${r} failed`,t),!t&&i&&this.logger.log(`${n}loaded namespace ${o} for language ${r}`,i),this.loaded(e,t,i)})}saveMissing(e,n,t,r,o,i={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n))return void this.logger.warn(`did not save key "${t}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=t&&""!==t){if(this.backend?.create){let s={...i,isUpdate:o},l=this.backend.create.bind(this.backend);if(l.length<6)try{let o;(o=5===l.length?l(e,n,t,r,s):l(e,n,t,r))&&"function"==typeof o.then?o.then(e=>a(null,e)).catch(a):a(null,o)}catch(e){a(e)}else l(e,n,t,r,a,s)}e&&e[0]&&this.store.addResource(e[0],n,t,r)}}}let oY=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let n={};if("object"==typeof e[1]&&(n=e[1]),od(e[1])&&(n.defaultValue=e[1]),od(e[2])&&(n.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let t=e[3]||e[2];Object.keys(t).forEach(e=>{n[e]=t[e]})}return n},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),oJ=e=>(od(e.ns)&&(e.ns=[e.ns]),od(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),od(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),oZ=()=>{};class oX extends oz{constructor(e={},n){if(super(),this.options=oJ(e),this.services={},this.logger=oM,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{"function"==typeof e[n]&&(e[n]=e[n].bind(e))})})(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,"function"==typeof e&&(n=e,e={}),null==e.defaultNS&&e.ns&&(od(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=oY();this.options={...t,...this.options,...oJ(e)},this.options.interpolation={...t.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?oM.init(r(this.modules.logger),this.options):oM.init(null,this.options),e=this.modules.formatter?this.modules.formatter:oH;let n=new oR(this.options);this.store=new oP(this.options.resources,this.options);let o=this.services;o.logger=oM,o.resourceStore=this.store,o.languageUtils=n,o.pluralResolver=new oW(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==t.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===t.interpolation.format)&&(o.formatter=r(e),o.formatter.init&&o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new oG(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new oK(r(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(o.languageDetector=r(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=r(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new oj(this.services,this.options),this.translator.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||(n=oZ),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...n)=>this.store[e](...n)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...n)=>(this.store[e](...n),this)});let o=of(),i=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(t),n(e,t)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?i():setTimeout(i,0),o}loadResources(e,n=oZ){let t=n,r=od(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return t();let e=[],n=n=>{n&&"cimode"!==n&&this.services.languageUtils.toResolveHierarchy(n).forEach(n=>{"cimode"!==n&&0>e.indexOf(n)&&e.push(n)})};r?n(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>n(e)),this.options.preload?.forEach?.(e=>n(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,n,t){let r=of();return"function"==typeof e&&(t=e,e=void 0),"function"==typeof n&&(t=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),t||(t=oZ),this.services.backendConnector.reload(e,n,e=>{r.resolve(),t(e)}),r}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&oO.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let n=this.languages[e];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;let t=of();this.emit("languageChanging",e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(o,i)=>{i?this.isLanguageChangingTo===e&&(r(i),this.translator.changeLanguage(i),this.isLanguageChangingTo=void 0,this.emit("languageChanged",i),this.logger.log("languageChanged",i)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(o,(...e)=>this.t(...e))},i=n=>{e||n||!this.services.languageDetector||(n=[]);let t=od(n)?n:n&&n[0],i=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(od(n)?[n]:n);i&&(this.language||r(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,e=>{o(e,i)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),t}getFixedT(e,n,t){let r=(e,n,...o)=>{let i,a;(i="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(o)):{...n}).lng=i.lng||r.lng,i.lngs=i.lngs||r.lngs,i.ns=i.ns||r.ns,""!==i.keyPrefix&&(i.keyPrefix=i.keyPrefix||t||r.keyPrefix);let s=this.options.keySeparator||".";return i.keyPrefix&&Array.isArray(e)?a=e.map(e=>("function"==typeof e&&(e=oB(e,{...this.options,...n})),`${i.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=oB(e,{...this.options,...n})),a=i.keyPrefix?`${i.keyPrefix}${s}${e}`:e),this.t(a,i)};return od(e)?r.lng=e:r.lngs=e,r.ns=n,r.keyPrefix=t,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let t=n.lng||this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let i=(e,n)=>{let t=this.services.backendConnector.state[`${e}|${n}`];return -1===t||0===t||2===t};if(n.precheck){let e=n.precheck(this,i);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(t,e)&&(!r||i(o,e)))}loadNamespaces(e,n){let t=of();return this.options.ns?(od(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}loadLanguages(e,n){let t=of();od(e)&&(e=[e]);let r=this.options.preload||[],o=e.filter(e=>0>r.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=r.concat(o),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let n=new Intl.Locale(e);if(n&&n.getTextInfo){let e=n.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let n=this.services?.languageUtils||new oR(oY());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){return new oX(e,n)}cloneInstance(e={},n=oZ){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let r={...this.options,...e,isClone:!0},o=new oX(r);return(void 0!==e.debug||void 0!==e.prefix)&&(o.logger=o.logger.clone(e)),["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},t&&(o.store=new oP(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,r)=>(t[r]={...e[n][r]},t),e[n]),e),{}),r),o.services.resourceStore=o.store),o.translator=new oj(o.services,r),o.translator.on("*",(e,...n)=>{o.emit(e,...n)}),o.init(r,n),o.translator.options=r,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let oQ=oX.createInstance();oQ.createInstance=oX.createInstance,oQ.createInstance,oQ.dir,oQ.init,oQ.loadResources,oQ.reloadResources,oQ.use,oQ.changeLanguage,oQ.getFixedT,oQ.t,oQ.exists,oQ.setDefaultNamespace,oQ.hasLoadedNamespace,oQ.loadNamespaces,oQ.loadLanguages;let o0=oQ.default||oQ;function o1(e,n,t,r){return o0.t(n,{ns:e,defaultValue:t,...r})}function o2(e,n,t){return op[e]?o1("core",e,n??op[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}o0.on("initialized",function(){window.i18next.loadNamespaces(["core"])});async function o3(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let r=e[t];try{if(r.src){let e=await fetch(r.src);n.push(await e.json())}else r.textContent&&n.push(JSON.parse(r.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return function(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}(n)}async function o5(){return await o3()}function o4(e){return e.replace(/[\/\-@]/g,"_")}async function o6(e,n="./start",r){var o;let i,a=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([o8(e,r?.importMap),new Promise((n,t)=>{i=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=a)<1e3?`${n} milliseconds`:n<6e4?`${Math.floor(n/1e3)} seconds`:n<36e5?`${Math.floor(n/6e4)} minutes`:n<864e5?`${Math.floor(n/36e5)} hours`:`${Math.floor(n/864e5)} days`}.`))},a)})]),i&&clearTimeout(i);let s=o4(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(t.S.default);let c=(await l.get(n))();if("object"!=typeof c||null===c){let n=`Container for ${e} did not return an ESM module as expected`;throw console.error(n),Error(n)}return c}async function o8(e,n){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 t=o4(e);if(!window[t]){let t=n??await o7();if(!t.imports.hasOwnProperty(e)){let n=`Could not find the package ${e} defined in the current importmap`;throw console.error(n),Error(n)}let r=t.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in{};try{return await new Promise((e,n)=>{!function(e,n,t){let r=document.head.querySelector(`script[src="${e}"]`),o=window[o9];if(o||(o=window[o9]=new Set([])),r)if(o.has(e)){let e,o,i;i=()=>{e&&r.removeEventListener("load",e),o&&r.removeEventListener("error",o)},e=()=>{i(),n(null)},o=e=>{i(),t(e.message)},r.addEventListener("load",e),r.addEventListener("error",o)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(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(),n(null)},i=n=>{a();let r=`Failed to load script from ${e}`;console.error(r,n),t(n.message??r)},s.addEventListener("load",r),s.addEventListener("error",i),document.head.appendChild(s)}}(r,e,n)})}catch(e){return o&&C({kind:"error",title:o2("scriptLoadingFailed","Error: Script failed to load"),description:o2("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:o2("resetOverrides","Reset overrides"),onActionButtonClick(){console.warn("[Security] Import map overrides are disabled in production mode."),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function o7(){return o5()}let o9=Symbol("__openmrs_script_loading"),ie=`${rU}/attachment`;function it(e,n){return rY(`${ie}/${e}`,{signal:n.signal})}function ir(e,n,t){return rY(`${ie}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function io(e,n){let t=new FormData;return t.append("fileCaption",n.fileDescription),t.append("patient",e),n.file?t.append("file",n.file,n.fileName):(t.append("file",new File([""],n.fileName),n.fileName),t.append("base64Content",n.base64Content)),rY(`${ie}`,{method:"POST",body:t})}function ii(e,n){return rY(`${ie}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function ia(e,n){return new Promise(function(t){var r=new MessageChannel;r.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[r.port2])})}function is(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function il(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var ic=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function iu(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var ip=function(e,n){this.type=e,Object.assign(this,n)};function id(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function ih(){}var im={type:"SKIP_WAITING"};function ig(e,n){if(!n)return e&&e.then?e.then(ih):Promise.resolve()}async function ib(e){let n=await (d??Promise.resolve(void 0));return n?await n.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."}}!function(e){function n(n,t){var r,o;return void 0===t&&(t={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new ic,r.en=new ic,r.on=new ic,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,n=e.installing;r.tn>0||!iu(n.scriptURL,r.sn.toString())||performance.now()>r.un+6e4?(r.vn=n,e.removeEventListener("updatefound",r.cn)):(r.hn=n,r.an.add(n),r.rn.resolve(n)),++r.tn,n.addEventListener("statechange",r.ln)},r.ln=function(e){var n=r.fn,t=e.target,o=t.state,i=t===r.vn,a={sw:t,isExternal:i,originalEvent:e};!i&&r.mn&&(a.isUpdate=!0),r.dispatchEvent(new ip(o,a)),"installed"===o?r.wn=self.setTimeout(function(){"installed"===o&&n.waiting===t&&r.dispatchEvent(new ip("waiting",a))},200):"activating"===o&&(clearTimeout(r.wn),i||r.en.resolve(t))},r.dn=function(e){var n=r.hn,t=n!==navigator.serviceWorker.controller;r.dispatchEvent(new ip("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:r.mn})),t||r.on.resolve(n)},o=function(e){var n=e.data,t=e.ports,o=e.source;return id(r.getSW(),function(){r.an.has(o)&&r.dispatchEvent(new ip("message",{data:n,originalEvent:e,ports:t,sw:o}))})},r.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},r.sn=n,r.nn=t,navigator.serviceWorker.addEventListener("message",r.gn),r}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,r=n.prototype;r.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var r,o,i,a=this;return r=function(){if(!t&&"complete"!==document.readyState)return ig(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),id(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 n=a.fn.waiting;return n&&iu(n.scriptURL,a.sn.toString())&&(a.hn=n,Promise.resolve().then(function(){a.dispatchEvent(new ip("waiting",{sw:n,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)}},r.update=function(){try{return this.fn?ig(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},r.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},r.messageSW=function(e){try{return id(this.getSW(),function(n){return ia(n,e)})}catch(e){return Promise.reject(e)}},r.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&ia(this.fn.waiting,im)},r.pn=function(){var e=navigator.serviceWorker.controller;return e&&iu(e.scriptURL,this.sn.toString())?e:void 0},r.bn=function(){try{var e=this;return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return id(navigator.serviceWorker.register(e.sn,e.nn),function(n){return e.un=performance.now(),n})},function(e){throw e})}catch(e){return Promise.reject(e)}},is(n.prototype,[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}]),t&&is(n,t)}(function(){function e(){this.Pn=new Map}var n=e.prototype;return n.addEventListener=function(e,n){this.Sn(e).add(n)},n.removeEventListener=function(e,n){this.Sn(e).delete(n)},n.dispatchEvent=function(e){e.target=this;for(var n,t=function(e){var n;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return il(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?il(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(this.Sn(e.type));!(n=t()).done;)(0,n.value)(e)},n.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());let iy="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,i_=Object.keys,iv=Array.isArray;function i$(e,n){return"object"!=typeof n||i_(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||iy.Promise||(iy.Promise=Promise);let iA=Object.getPrototypeOf,iw={}.hasOwnProperty;function ik(e,n){return iw.call(e,n)}function ix(e,n){"function"==typeof n&&(n=n(iA(e))),("u"<typeof Reflect?i_:Reflect.ownKeys)(n).forEach(t=>{iE(e,t,n[t])})}let iC=Object.defineProperty;function iE(e,n,t,r){iC(e,n,i$(t&&ik(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},r))}function iD(e){return{from:function(n){return e.prototype=Object.create(n.prototype),iE(e.prototype,"constructor",e),{extend:ix.bind(null,e.prototype)}}}}let iS=Object.getOwnPropertyDescriptor;function iM(e,n){let t;return iS(e,n)||(t=iA(e))&&iM(t,n)}let iz=[].slice;function iP(e,n,t){return iz.call(e,n,t)}function iO(e,n){return n(e)}function iT(e){if(!e)throw Error("Assertion Failed")}function iB(e){iy.setImmediate?setImmediate(e):setTimeout(e,0)}function iI(e,n){return e.reduce((e,t,r)=>{var o=n(t,r);return o&&(e[o[0]]=o[1]),e},{})}function iN(e,n){if("string"==typeof n&&ik(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],r=0,o=n.length;r<o;++r){var i=iN(e,n[r]);t.push(i)}return t}var a=n.indexOf(".");if(-1!==a){var s=e[n.substr(0,a)];return null==s?void 0:iN(s,n.substr(a+1))}}function ij(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){iT("string"!=typeof t&&"length"in t);for(var r=0,o=n.length;r<o;++r)ij(e,n[r],t[r])}else{var i=n.indexOf(".");if(-1!==i){var a=n.substr(0,i),s=n.substr(i+1);if(""===s)void 0===t?iv(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=t;else{var l=e[a];l&&ik(e,a)||(l=e[a]={}),ij(l,s,t)}}else void 0===t?iv(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function iR(e){var n={};for(var t in e)ik(e,t)&&(n[t]=e[t]);return n}let iF=[].concat;function iL(e){return iF.apply([],e)}let iW="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(iL([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>iy[e]),iV=iW.map(e=>iy[e]);iI(iW,e=>[e,!0]);let iG=null;function iU(e){iG="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=iG&&iG.get(n);if(t)return t;if(iv(n)){t=[],iG&&iG.set(n,t);for(var r=0,o=n.length;r<o;++r)t.push(e(n[r]))}else if(iV.indexOf(n.constructor)>=0)t=n;else{let r=iA(n);for(var i in t=r===Object.prototype?{}:Object.create(r),iG&&iG.set(n,t),n)ik(n,i)&&(t[i]=e(n[i]))}return t}(e);return iG=null,n}let{toString:iq}={};function iH(e){return iq.call(e).slice(8,-1)}let iK="u">typeof Symbol?Symbol.iterator:"@@iterator",iY="symbol"==typeof iK?function(e){var n;return null!=e&&(n=e[iK])&&n.apply(e)}:function(){return null},iJ={};function iZ(e){var n,t,r,o;if(1==arguments.length){if(iv(e))return e.slice();if(this===iJ&&"string"==typeof e)return[e];if(o=iY(e)){for(t=[];!(r=o.next()).done;)t.push(r.value);return t}if(null==e)return[e];if("number"==typeof(n=e.length)){for(t=Array(n);n--;)t[n]=e[n];return t}return[e]}for(n=arguments.length,t=Array(n);n--;)t[n]=arguments[n];return t}let iX="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var iQ="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),i0=()=>!0;let i1=!Error("").stack;function i2(){if(i1)try{throw i2.arguments,Error()}catch(e){return e}return Error()}function i3(e,n){var t=e.stack;return t?(n=n||0,0===t.indexOf(e.name)&&(n+=(e.name+e.message).split("\n").length),t.split("\n").slice(n).filter(i0).map(e=>"\n"+e).join("")):""}var i5=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],i4=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(i5),i6={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 i8(e,n){this._e=i2(),this.name=e,this.message=n}function i7(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function i9(e,n,t,r){this._e=i2(),this.failures=n,this.failedKeys=r,this.successCount=t,this.message=i7(e,n)}function ae(e,n){this._e=i2(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=i7(e,n)}iD(i8).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+i3(this._e,2))}},toString:function(){return this.name+": "+this.message}}),iD(i9).from(i8),iD(ae).from(i8);var an=i4.reduce((e,n)=>(e[n]=n+"Error",e),{}),at=i4.reduce((e,n)=>{var t=n+"Error";function r(e,r){this._e=i2(),this.name=t,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=i6[n]||t,this.inner=null)}return iD(r).from(i8),e[n]=r,e},{});at.Syntax=SyntaxError,at.Type=TypeError,at.Range=RangeError;var ar=i5.reduce((e,n)=>(e[n+"Error"]=at[n],e),{}),ao=i4.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=at[n]),e),{});function ai(){}function aa(e){return e}function as(e,n){return null==e||e===aa?n:function(t){return n(e(t))}}function al(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function ac(e,n){return e===ai?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?al(r,this.onsuccess):r),o&&(this.onerror=this.onerror?al(o,this.onerror):o),void 0!==i?i:t}}function au(e,n){return e===ai?n:function(){e.apply(this,arguments);var t=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?al(t,this.onsuccess):t),r&&(this.onerror=this.onerror?al(r,this.onerror):r)}}function ap(e,n){return e===ai?n:function(t){var r=e.apply(this,arguments);i$(t,r);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var a=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?al(o,this.onsuccess):o),i&&(this.onerror=this.onerror?al(i,this.onerror):i),void 0===r?void 0===a?void 0:a:i$(r,a)}}function ad(e,n){return e===ai?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function af(e,n){return e===ai?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var r=this,o=arguments.length,i=Array(o);o--;)i[o]=arguments[o];return t.then(function(){return n.apply(r,i)})}return n.apply(this,arguments)}}ao.ModifyError=i9,ao.DexieError=i8,ao.BulkError=ae;var ah={};let[am,ag,ab]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,iA(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,iA(n),e]})(),ay=ag&&ag.then,a_=am&&am.constructor,av=!!ab;var a$=!1,aA=ab?()=>{ab.then(aV)}:iy.setImmediate?setImmediate.bind(null,aV):iy.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{aV(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(aV,0)},aw=function(e,n){aP.push([e,n]),ax&&(aA(),ax=!1)},ak=!0,ax=!0,aC=[],aE=[],aD=null,aS=aa,aM={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:sr,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{sr(e[0],e[1])}catch(e){}})}},az=aM,aP=[],aO=0,aT=[];function aB(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ai,this._lib=!1;var n=this._PSD=az;if(iQ&&(this._stackHolder=i2(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==ah)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&aj(this,this._value))}this._state=null,this._value=null,++n.ref,function e(n,t){try{t(t=>{if(null===n._state){if(t===n)throw TypeError("A promise cannot be resolved with itself.");var r=n._lib&&aG();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof aB?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,aR(n)),r&&aU()}},aj.bind(null,n))}catch(e){aj(n,e)}}(this,e)}let aI={get:function(){var e=az,n=aQ;function t(t,r){var o=!e.global&&(e!==az||n!==aQ);let i=o&&!a3();var a=new aB((n,a)=>{aF(this,new aN(se(t,e,o,i),se(r,e,o,i),n,a,e))});return iQ&&aW(a,this),a}return t.prototype=ah,t},set:function(e){iE(this,"then",e&&e.prototype===ah?aI:{get:function(){return e},set:aI.set})}};function aN(e,n,t,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=r,this.psd=o}function aj(e,n){if(aE.push(n),null===e._state){var t=e._lib&&aG();n=aS(n),e._state=!1,e._value=n,iQ&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=iM(n,"stack");n._promise=e,iE(n,"stack",{get:()=>a$?t&&(t.get?t.get.apply(n):t.value):e.stack})}),aC.some(n=>n._value===e._value)||aC.push(e),aR(e),t&&aU()}}function aR(e){var n=e._listeners;e._listeners=[];for(var t=0,r=n.length;t<r;++t)aF(e,n[t]);var o=e._PSD;--o.ref||o.finalize(),0===aO&&(++aO,aw(()=>{0==--aO&&aq()},[]))}function aF(e,n){if(null!==e._state){var t=e._state?n.onFulfilled:n.onRejected;if(null===t)return(e._state?n.resolve:n.reject)(e._value);++n.psd.ref,++aO,aw(aL,[t,e,n])}else e._listeners.push(n)}function aL(e,n,t){try{aD=n;var r,o=n._value;n._state?r=e(o):(aE.length&&(aE=[]),r=e(o),-1===aE.indexOf(o)&&function(e){for(var n=aC.length;n;)if(aC[--n]._value===e._value)return void aC.splice(n,1)}(n)),t.resolve(r)}catch(e){t.reject(e)}finally{aD=null,0==--aO&&aq(),--t.psd.ref||t.psd.finalize()}}function aW(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function aV(){aG()&&aU()}function aG(){var e=ak;return ak=!1,ax=!1,e}function aU(){var e,n,t;do for(;aP.length>0;)for(e=aP,aP=[],t=e.length,n=0;n<t;++n){var r=e[n];r[0].apply(null,r[1])}while(aP.length>0);ak=!0,ax=!0}function aq(){var e=aC;aC=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=aT.slice(0),t=n.length;t;)n[--t]()}function aH(e){return new aB(ah,!1,e)}function aK(e,n){var t=az;return function(){var r=aG(),o=az;try{return a8(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{a8(o,!1),r&&aU()}}}ix(aB.prototype,{then:aI,_then:function(e,n){aF(this,new aN(null,null,e,n,az))},catch:function(e){if(1==arguments.length)return this.then(null,e);var n=arguments[0],t=arguments[1];return"function"==typeof n?this.then(null,e=>e instanceof n?t(e):aH(e)):this.then(null,e=>e&&e.name===n?t(e):aH(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),aH(n)))},stack:{get:function(){if(this._stack)return this._stack;try{a$=!0;var e=(function e(n,t,r){if(t.length===r)return t;var o="";if(!1===n._state){var i,a,s=n._value;null!=s?(i=s.name||"Error",a=s.message||s,o=i3(s,0)):(i=s,a=""),t.push(i+(a?": "+a:"")+o)}return iQ&&((o=i3(n._stackHolder,2))&&-1===t.indexOf(o)&&t.push(o),n._prev&&e(n._prev,t,r)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{a$=!1}}},timeout:function(e,n){return e<1/0?new aB((t,r)=>{var o=setTimeout(()=>r(new at.Timeout(n)),e);this.then(t,r).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&iE(aB.prototype,Symbol.toStringTag,"Dexie.Promise"),aM.env=a7(),ix(aB,{all:function(){var e=iZ.apply(null,arguments).map(a5);return new aB(function(n,t){0===e.length&&n([]);var r=e.length;e.forEach((o,i)=>aB.resolve(o).then(t=>{e[i]=t,--r||n(e)},t))})},resolve:e=>{if(e instanceof aB)return e;if(e&&"function"==typeof e.then)return new aB((n,t)=>{e.then(n,t)});var n=new aB(ah,!0,e);return aW(n,aD),n},reject:aH,race:function(){var e=iZ.apply(null,arguments).map(a5);return new aB((n,t)=>{e.map(e=>aB.resolve(e).then(n,t))})},PSD:{get:()=>az,set:e=>az=e},totalEchoes:{get:()=>aQ},newPSD:a1,usePSD:a9,scheduler:{get:()=>aw,set:e=>{aw=e}},rejectionMapper:{get:()=>aS,set:e=>{aS=e}},follow:(e,n)=>new aB((t,r)=>a1((n,t)=>{var r=az;r.unhandleds=[],r.onunhandled=t,r.finalize=al(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},aT.push(function n(){e(),aT.splice(aT.indexOf(n),1)}),++aO,aw(()=>{0==--aO&&aq()},[])},r.finalize),e()},n,t,r))}),a_&&(a_.allSettled&&iE(aB,"allSettled",function(){let e=iZ.apply(null,arguments).map(a5);return new aB(n=>{0===e.length&&n([]);let t=e.length,r=Array(t);e.forEach((e,o)=>aB.resolve(e).then(e=>r[o]={status:"fulfilled",value:e},e=>r[o]={status:"rejected",reason:e}).then(()=>--t||n(r)))})}),a_.any&&"u">typeof AggregateError&&iE(aB,"any",function(){let e=iZ.apply(null,arguments).map(a5);return new aB((n,t)=>{0===e.length&&t(AggregateError([]));let r=e.length,o=Array(r);e.forEach((e,i)=>aB.resolve(e).then(e=>n(e),e=>{o[i]=e,--r||t(AggregateError(o))}))})}));let aY={awaits:0,echoes:0,id:0};var aJ=0,aZ=[],aX=0,aQ=0,a0=0;function a1(e,n,t,r){var o=az,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++a0;var a=aM.env;i.env=av?{Promise:aB,PromiseProp:{value:aB,configurable:!0,writable:!0},all:aB.all,race:aB.race,allSettled:aB.allSettled,any:aB.any,resolve:aB.resolve,reject:aB.reject,nthen:sn(a.nthen,i),gthen:sn(a.gthen,i)}:{},n&&i$(i,n),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=a9(i,e,t,r);return 0===i.ref&&i.finalize(),s}function a2(){return aY.id||(aY.id=++aJ),++aY.awaits,aY.echoes+=100,aY.id}function a3(){return!!aY.awaits&&(0==--aY.awaits&&(aY.id=0),aY.echoes=100*aY.awaits,!0)}function a5(e){return aY.echoes&&e&&e.constructor===a_?(a2(),e.then(e=>(a3(),e),e=>(a3(),so(e)))):e}function a4(e){++aQ,aY.echoes&&0!=--aY.echoes||(aY.echoes=aY.id=0),aZ.push(az),a8(e,!0)}function a6(){var e=aZ[aZ.length-1];aZ.pop(),a8(e,!1)}function a8(e,n){var t,r=az;if((n?!aY.echoes||aX++&&e===az:!aX||--aX&&e===az)||(t=n?a4.bind(null,e):a6,ay.call(am,t)),e!==az&&(az=e,r===aM&&(aM.env=a7()),av)){var o=aM.env.Promise,i=e.env;ag.then=i.nthen,o.prototype.then=i.gthen,(r.global||e.global)&&(Object.defineProperty(iy,"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 a7(){var e=iy.Promise;return av?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(iy,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:ag.then,gthen:e.prototype.then}:{}}function a9(e,n,t,r,o){var i=az;try{return a8(e,!0),n(t,r,o)}finally{a8(i,!1)}}function se(e,n,t,r){return"function"!=typeof e?e:function(){var o,i=az;t&&a2(),a8(n,!0);try{return e.apply(this,arguments)}finally{a8(i,!1),r&&(o=a3,ay.call(am,o))}}}function sn(e,n){return function(t,r){return e.call(this,se(t,n),se(r,n))}}-1===(""+ay).indexOf("[native code]")&&(a2=a3=ai);let st="unhandledrejection";function sr(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var r,o={promise:n,reason:e};if(iy.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(st,!0,!0),i$(r,o)):iy.CustomEvent&&i$(r=new CustomEvent(st,{detail:o}),o),r&&iy.dispatchEvent&&(dispatchEvent(r),!iy.PromiseRejectionEvent&&iy.onunhandledrejection))try{iy.onunhandledrejection(r)}catch(e){}iQ&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var so=aB.reject;let si="3.2.7",sa=String.fromCharCode(65535),ss=-1/0,sl="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",sc="String expected.",su=[],sp="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),sd=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),sf="__dbnames",sh="readonly",sm="readwrite";function sg(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let sb={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function sy(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=iU(n))[e],n)}class s_{_trans(e,n,t){let r=this._tx||az.trans,o=this.name;function i(e,t,r){if(!r.schema[o])throw new at.NotFound("Table "+o+" not part of transaction");return n(r.idbtrans,r)}let a=aG();try{return r&&r.db===this.db?r===az.trans?r._promise(e,i,t):a1(()=>r._promise(e,i,t),{trans:r,transless:az.transless||az}):function e(n,t,r,o){if(n.idbdb&&(n._state.openComplete||az.letThrough||n._vip)){var i=n._createTransaction(t,r,n._dbSchema);try{i.create(),n._state.PR1398_maxLoop=3}catch(i){return i.name===an.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,o))):so(i)}return i._promise(t,(e,n)=>a1(()=>(az.trans=i,o(e,n,i)))).then(e=>i._completion.then(()=>e))}if(n._state.openComplete)return so(new at.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return so(new at.DatabaseClosed);n.open().catch(ai)}return n._state.dbReadyPromise.then(()=>e(n,t,r,o))}(this.db,e,[this.name],i)}finally{a&&aU()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(e=>this.hook.reading.fire(e))).then(n)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(iv(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=i_(e);if(1===n.length)return this.where(n[0]).equals(e[n[0]]);let t=this.schema.indexes.concat(this.schema.primKey).filter(e=>{if(e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)){for(let t=0;t<n.length;++t)if(-1===n.indexOf(e.keyPath[t]))return!1;return!0}return!1}).sort((e,n)=>e.keyPath.length-n.keyPath.length)[0];if(t&&this.db._maxKey!==sa){let r=t.keyPath.slice(0,n.length);return this.where(r).equals(r.map(n=>e[n]))}!t&&iQ&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:r}=this.schema,o=this.db._deps.indexedDB;function i(e,n){try{return 0===o.cmp(e,n)}catch(e){return!1}}let[a,s]=n.reduce(([n,t],o)=>{let a=r[o],s=e[o];return[n||a,n||!a?sg(t,a&&a.multi?e=>{let n=iN(e,o);return iv(n)&&n.some(e=>i(s,e))}:e=>i(s,iN(e,o))):t]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):t?this.filter(s):this.where(n).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,iv(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let n=n=>{if(!n)return n;let t=Object.create(e.prototype);for(var r in n)if(ik(n,r))try{t[r]=n[r]}catch(e){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){i$(this,e)})}add(e,n){let{auto:t,keyPath:r}=this.schema.primKey,o=e;return r&&t&&(o=sy(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[o]})).then(e=>e.numFailures?aB.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{ij(e,r,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||iv(e))return this.where(":id").equals(e).modify(n);{let t=iN(e,this.schema.primKey.keyPath);if(void 0===t)return so(new at.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?i_(n).forEach(t=>{ij(e,t,n[t])}):n(e,{value:e,primKey:t})}catch(e){}return this.where(":id").equals(t).modify(n)}}put(e,n){let{auto:t,keyPath:r}=this.schema.primKey,o=e;return r&&t&&(o=sy(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=n?[n]:null})).then(e=>e.numFailures?aB.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{ij(e,r,n)}catch(e){}return n})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(e=>e.numFailures?aB.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:sb})).then(e=>e.numFailures?aB.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,n,t){let r=Array.isArray(n)?n:void 0,o=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:i}=this.schema.primKey;if(i&&r)throw new at.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new at.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&t?e.map(sy(i)):e;return this.core.mutate({trans:n,type:"add",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return o?n:t;throw new ae(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,r)})})}bulkPut(e,n,t){let r=Array.isArray(n)?n:void 0,o=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:i}=this.schema.primKey;if(i&&r)throw new at.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new at.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&t?e.map(sy(i)):e;return this.core.mutate({trans:n,type:"put",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return o?n:t;throw new ae(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,r)})})}bulkDelete(e){let n=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:e,lastResult:t,failures:r})=>{if(0===e)return t;throw new ae(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,r)})}}function sv(e){var n={},t=function(t,r){if(r){for(var o=arguments.length,i=Array(o-1);--o;)i[o-1]=arguments[o];return n[t].subscribe.apply(null,i),e}if("string"==typeof t)return n[t]};t.addEventType=i;for(var r=1,o=arguments.length;r<o;++r)i(arguments[r]);return t;function i(e,r,o){if("object"!=typeof e){r||(r=ad),o||(o=ai);var a={subscribers:[],fire:o,subscribe:function(e){-1===a.subscribers.indexOf(e)&&(a.subscribers.push(e),a.fire=r(a.fire,e))},unsubscribe:function(e){a.subscribers=a.subscribers.filter(function(n){return n!==e}),a.fire=a.subscribers.reduce(r,o)}};return n[e]=t[e]=a,a}i_(e).forEach(function(n){var t=e[n];if(iv(t))i(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new at.InvalidArgument("Invalid event config");var r=i(n,aa,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];r.subscribers.forEach(function(e){iB(function(){e.apply(null,n)})})})}})}}function s$(e,n){return iD(n).from({prototype:e}),n}function sA(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function sw(e,n){e.filter=sg(e.filter,n)}function sk(e,n,t){var r=e.replayFilter;e.replayFilter=r?()=>sg(r(),n()):n,e.justLimit=t&&!r}function sx(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new at.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function sC(e,n,t){let r=sx(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function sE(e,n,t,r){let o=e.replayFilter?sg(e.filter,e.replayFilter()):e.filter;if(e.or){let i={},a=(e,t,r)=>{if(!o||o(t,r,e=>t.stop(e),e=>t.fail(e))){var a=t.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),ik(i,s)||(i[s]=!0,n(e,t,r))}};return Promise.all([e.or._iterate(a,t),sD(sC(e,r,t),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return sD(sC(e,r,t),sg(e.algorithm,o),n,!e.keysOnly&&e.valueMapper)}function sD(e,n,t,r){var o=aK(r?(e,n,o)=>t(r(e),n,o):t);return e.then(e=>{if(e)return e.start(()=>{var t=()=>e.continue();n&&!n(e,e=>t=e,n=>{e.stop(n),t=ai},n=>{e.fail(n),t=ai})||o(e.value,e,e=>t=e),t()})})}function sS(e,n){try{let t=sM(e),r=sM(n);if(t!==r)return"Array"===t?1:"Array"===r?-1:"binary"===t?1:"binary"===r?-1:"string"===t?1:"string"===r?-1:"Date"===t?1:"Date"!==r?NaN:-1;switch(t){case"number":case"Date":case"string":return e>n?1:e<n?-1:0;case"binary":return function(e,n){let t=e.length,r=n.length,o=t<r?t:r;for(let t=0;t<o;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===r?0:t<r?-1:1}(sz(e),sz(n));case"Array":return function(e,n){let t=e.length,r=n.length,o=t<r?t:r;for(let t=0;t<o;++t){let r=sS(e[t],n[t]);if(0!==r)return r}return t===r?0:t<r?-1:1}(e,n)}}catch(e){}return NaN}function sM(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=iH(e);return"ArrayBuffer"===t?"binary":t}function sz(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class sP{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,so.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,so.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=sg(n.algorithm,e)}_iterate(e,n){return sE(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&i$(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>sE(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(sA(n,!0))return t.count({trans:e,query:{index:sx(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var r=0;return sE(n,()=>(++r,!1),e,t).then(()=>r)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),r=t[0],o=t.length-1;function i(e,n){return n?i(e[t[n]],n-1):e[r]}var a="next"===this._ctx.dir?1:-1;function s(e,n){var t=i(e,o),r=i(n,o);return t<r?-a:t>r?a:0}return this.toArray(function(e){return e.sort(s)}).then(n)}toArray(e){return this._read(e=>{var n=this._ctx;if("next"===n.dir&&sA(n,!0)&&n.limit>0){let{valueMapper:t}=n,r=sx(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:r,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return sE(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,sA(n)?sk(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):sk(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),sk(this._ctx,()=>{var n=e;return function(e,t,r){return--n<=0&&t(r),n>=0}},!0),this}until(e,n){return sw(this._ctx,function(t,r,o){return!e(t.value)||(r(o),n)}),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 n;return sw(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=sg(n.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 n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.key,t)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.primaryKey,t)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.key)}).then(function(){return t}).then(e)}primaryKeys(e){var n=this._ctx;if("next"===n.dir&&sA(n,!0)&&n.limit>0)return this._read(e=>{var t=sx(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(({result:e})=>e).then(e);n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.primaryKey)}).then(function(){return t}).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,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var t={};return sw(this._ctx,function(e){var n=e.primaryKey.toString(),r=ik(t,n);return t[n]=!0,!r}),this}modify(e){var n=this._ctx;return this._write(t=>{var r;if("function"==typeof e)r=e;else{var o=i_(e),i=o.length;r=function(n){for(var t=!1,r=0;r<i;++r){var a=o[r],s=e[a];iN(n,a)!==s&&(ij(n,a,s),t=!0)}return t}}let a=n.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,c=this.db._options.modifyChunkSize||200,u=[],p=0,d=[],f=(e,n)=>{let{failures:t,numFailures:r}=n;for(let n of(p+=e-r,i_(t)))u.push(t[n])};return this.clone().primaryKeys().then(o=>{let i=u=>{let p=Math.min(c,o.length-u);return a.getMany({trans:t,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 n=d[e],t={value:iU(n),primKey:o[u+e]};!1!==r.call(t,t.value,t)&&(null==t.value?b.push(o[u+e]):s||0===sS(l(n),l(t.value))?(m.push(t.value),s&&g.push(o[u+e])):(b.push(o[u+e]),h.push(t.value)))}let y=sA(n)&&n.limit===1/0&&("function"!=typeof e||e===sO)&&{index:n.index,range:n.range};return Promise.resolve(h.length>0&&a.mutate({trans:t,type:"add",values:h}).then(e=>{for(let n in e.failures)b.splice(parseInt(n),1);f(h.length,e)})).then(()=>(m.length>0||y&&"object"==typeof e)&&a.mutate({trans:t,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===sO)&&a.mutate({trans:t,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 i9("Error modifying one or more objects",u,p,d);return o.length})})})}delete(){var e=this._ctx,n=e.range;return sA(e)&&(e.isPrimKey&&!sp||3===n.type)?this._write(t=>{let{primaryKey:r}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:r,range:n}}).then(r=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:o})=>{if(o)throw new i9("Could not delete some values",Object.keys(e).map(n=>e[n]),r-o);return r-o}))}):this.modify(sO)}}let sO=(e,n)=>n.value=null;function sT(e,n){return e<n?-1:+(e!==n)}function sB(e,n){return e>n?-1:+(e!==n)}function sI(e,n,t){var r=e instanceof sL?new e.Collection(e):e;return r._ctx.error=t?new t(n):TypeError(n),r}function sN(e){return new e.Collection(e,()=>sF("")).limit(0)}function sj(e,n,t,r){var o,i,a,s,l,c,u,p=t.length;if(!t.every(e=>"string"==typeof e))return sI(e,sc);function d(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),i="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?sT:sB;var n=t.map(function(e){return{lower:i(e),upper:o(e)}}).sort(function(e,n){return a(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,u="next"===e?"":r}d("next");var f=new e.Collection(e,()=>sR(s[0],l[p-1]+r));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,r){var o=e.key;if("string"!=typeof o)return!1;var d=i(o);if(n(d,l,h))return!0;for(var f=null,m=h;m<p;++m){var g=function(e,n,t,r,o,i){for(var a=Math.min(e.length,r.length),s=-1,l=0;l<a;++l){var c=n[l];if(c!==r[l])return 0>o(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>o(e[l],r[l])?e.substr(0,l)+r[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>o(e[l],c)&&(s=l)}return a<r.length&&"next"===i?e+t.substr(e.length):a<e.length&&"prev"===i?e.substr(0,t.length):s<0?null:e.substr(0,s)+r[s]+t.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 t(null!==f?function(){e.continue(f+u)}:r),!1}),f}function sR(e,n,t,r){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:r}}function sF(e){return{type:1,lower:e,upper:e}}class sL{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,r){t=!1!==t,r=!0===r;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||r)&&(!t||!r)?sN(this):new this.Collection(this,()=>sR(e,n,!t,!r))}catch(e){return sI(this,sl)}}equals(e){return null==e?sI(this,sl):new this.Collection(this,()=>sF(e))}above(e){return null==e?sI(this,sl):new this.Collection(this,()=>sR(e,void 0,!0))}aboveOrEqual(e){return null==e?sI(this,sl):new this.Collection(this,()=>sR(e,void 0,!1))}below(e){return null==e?sI(this,sl):new this.Collection(this,()=>sR(void 0,e,!1,!0))}belowOrEqual(e){return null==e?sI(this,sl):new this.Collection(this,()=>sR(void 0,e))}startsWith(e){return"string"!=typeof e?sI(this,sc):this.between(e,e+sa,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):sj(this,(e,n)=>0===e.indexOf(n[0]),[e],sa)}equalsIgnoreCase(e){return sj(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=iZ.apply(iJ,arguments);return 0===e.length?sN(this):sj(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=iZ.apply(iJ,arguments);return 0===e.length?sN(this):sj(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,sa)}anyOf(){let e=iZ.apply(iJ,arguments),n=this._cmp;try{e.sort(n)}catch(e){return sI(this,sl)}if(0===e.length)return sN(this);let t=new this.Collection(this,()=>sR(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let r=0;return t._addAlgorithm((t,o,i)=>{let a=t.key;for(;n(a,e[r])>0;)if(++r===e.length)return o(i),!1;return 0===n(a,e[r])||(o(()=>{t.continue(e[r])}),!1)}),t}notEqual(e){return this.inAnyRange([[ss,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=iZ.apply(iJ,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return sI(this,sl)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[ss,n]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){let t=this._cmp,r=this._ascending,o=this._descending,i=this._min,a=this._max;if(0===e.length)return sN(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=r(e[0],e[1])))return sI(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",at.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,u=r;function p(e,n){return u(e[0],n[0])}try{(c=e.reduce(function(e,n){let r=0,o=e.length;for(;r<o;++r){let o=e[r];if(0>t(n[0],o[1])&&t(n[1],o[0])>0){o[0]=i(o[0],n[0]),o[1]=a(o[1],n[1]);break}}return r===o&&e.push(n),e},[])).sort(p)}catch(e){return sI(this,sl)}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,()=>sR(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,n,t)=>{for(var o=e.key;m(o);)if(++d===c.length)return n(t),!1;return!!(!f(o)&&!h(o))||(0===this._cmp(o,c[d][1])||0===this._cmp(o,c[d][0])||n(()=>{u===r?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=iZ.apply(iJ,arguments);return e.every(e=>"string"==typeof e)?0===e.length?sN(this):this.inAnyRange(e.map(e=>[e,e+sa])):sI(this,"startsWithAnyOf() only works with strings")}}function sW(e){return aK(function(n){return sV(n),e(n.target.error),!1})}function sV(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let sG="storagemutated",sU="x-storagemutated-1",sq=sv(null,sG);class sH{_lock(){return iT(!az.global),++this._reculock,1!==this._reculock||az.global||(az.lockOwnerFor=this),this}_unlock(){if(iT(!az.global),0==--this._reculock)for(az.global||(az.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{a9(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&az.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(iT(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new at.DatabaseClosed(t);case"MissingAPIError":throw new at.MissingAPI(t.message,t);default:throw new at.OpenFailed(t)}if(!this.active)throw new at.TransactionInactive;return iT(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=aK(n=>{sV(n),this._reject(e.error)}),e.onabort=aK(n=>{sV(n),this.active&&this._reject(new at.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=aK(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&sq.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return so(new at.ReadOnly("Transaction is readonly"));if(!this.active)return so(new at.TransactionInactive);if(this._locked())return new aB((r,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(r,o)},az])});if(t)return a1(()=>{var e=new aB((e,t)=>{this._lock();let r=n(e,t,this);r&&r.then&&r.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var r=new aB((e,t)=>{var r=n(e,t,this);r&&r.then&&r.then(e,t)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=aB.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var r=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var o=n._waitingFor;return new aB((e,r)=>{t.then(t=>n._waitingQueue.push(aK(e.bind(null,t))),e=>n._waitingQueue.push(aK(r.bind(null,e)))).finally(()=>{n._waitingFor===o&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new at.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(ik(n,e))return n[e];let t=this.schema[e];if(!t)throw new at.NotFound("Table "+e+" not part of transaction");let r=new this.db.Table(e,t,this);return r.core=this.db.core.table(e),n[e]=r,r}}function sK(e,n,t,r,o,i,a){return{name:e,keyPath:n,unique:t,multi:r,auto:o,compound:i,src:(t&&!a?"&":"")+(r?"*":"")+(o?"++":"")+sY(n)}}function sY(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function sJ(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:iI(t,e=>[e.name,e])}}let sZ=e=>{try{return e.only([[]]),sZ=()=>[[]],[[]]}catch(e){return sZ=()=>sa,sa}};function sX(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>iN(n,e):n=>iN(n,e)}function sQ(e){return[].slice.call(e)}let s0=0;function s1(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function s2({_novip:e},n){let t=n.db,r=function(e,n,{IDBKeyRange:t,indexedDB:r},o){var i;return{dbcore:(i=function(e,n,t){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:t,upper:r,lowerOpen:o,upperOpen:i}=e;return void 0===t?void 0===r?null:n.upperBound(r,!!i):void 0===r?n.lowerBound(t,!!o):n.bound(t,r,!!o,!!i)}let{schema:i,hasGetAll:a}=(r=sQ(e.objectStoreNames),{schema:{name:e.name,tables:r.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,r=iv(n),o=null==n,i={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:n,autoIncrement:t,unique:!0,extractKey:sX(n)},indexes:sQ(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:r,keyPath:o}=e,a={name:n,compound:iv(o),keyPath:o,unique:t,multiEntry:r,extractKey:sX(o)};return i[s1(o)]=a,a}),getIndexByKeyPath:e=>i[s1(e)]};return i[":id"]=a.primaryKey,null!=n&&(i[s1(n)]=a.primaryKey),a})},hasGetAll:r.length>0&&"getAll"in t.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 n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:r,values:i,range:a}){return new Promise((s,l)=>{let c;s=aK(s);let u=e.objectStore(n),p=null==u.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);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,sV(e)};if("deleteRange"===t){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,n]=d?p?[i,r]:[i,null]:[r,null];if(d)for(let r=0;r<f;++r)h.push(c=n&&void 0!==n[r]?u[t](e[r],n[r]):u[t](e[r])),c.onerror=b;else for(let n=0;n<f;++n)h.push(c=u[t](e[n])),c.onerror=b}let y=e=>{let n=e.target.result;h.forEach((e,n)=>null!=e.error&&(m[n]=e.error)),s({numFailures:g,failures:m,results:"delete"===t?r:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{b(e),y(e)},c.onsuccess=y})},getMany:({trans:e,keys:t})=>new Promise((r,o)=>{r=aK(r);let i=e.objectStore(n),a=t.length,s=Array(a),l,c=0,u=0,p=e=>{let n=e.target;s[n._pos]=n.result,++u===c&&r(s)},d=sW(o);for(let e=0;e<a;++e)null!=t[e]&&((l=i.get(t[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&r(s)}),get:({trans:e,key:t})=>new Promise((r,o)=>{r=aK(r);let i=e.objectStore(n).get(t);i.onsuccess=e=>r(e.target.result),i.onerror=sW(o)}),query:e=>new Promise((t,r)=>{t=aK(t);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(n),h=p.isPrimaryKey?f:f.index(p.name),m=o(d);if(0===l)return t({result:[]});if(a){let e=s?h.getAll(m,u):h.getAllKeys(m,u);e.onsuccess=e=>t({result:e.target.result}),e.onerror=sW(r)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];n.onsuccess=r=>{let i=n.result;return i?(o.push(s?i.value:i.primaryKey),++e===l?t({result:o}):void i.continue()):t({result:o})},n.onerror=sW(r)}}),openCursor:function({trans:e,values:t,query:r,reverse:i,unique:a}){return new Promise((s,l)=>{s=aK(s);let{index:c,range:u}=r,p=e.objectStore(n),d=c.isPrimaryKey?p:p.index(c.name),f=i?a?"prevunique":"prev":a?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(o(u),f):d.openCursor(o(u),f);h.onerror=sW(l),h.onsuccess=aK(n=>{let t=h.result;if(!t)return void s(null);t.___id=++s0,t.done=!1;let r=t.continue.bind(t),o=t.continuePrimaryKey;o&&(o=o.bind(t));let i=t.advance.bind(t),a=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=aK(l),t.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},t.start=e=>{let n=new Promise((e,n)=>{e=aK(e),h.onerror=sW(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=a,e(n)}}),s=()=>{if(h.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return h.onsuccess=aK(e=>{h.onsuccess=s,s()}),t.continue=r,t.continuePrimaryKey=o,t.advance=i,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:r,range:i}=e;return new Promise((e,a)=>{let s=t.objectStore(n),l=r.isPrimaryKey?s:s.index(r.name),c=o(i),u=c?l.count(c):l.count();u.onsuccess=aK(n=>e(n.target.result)),u.onerror=sW(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:sZ(n),schema:i}}(n,t,o),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),i))}}(e._middlewares,t,e._deps,n);e.core=r.dbcore,e.tables.forEach(n=>{let t=n.name;e.core.schema.tables.some(e=>e.name===t)&&(n.core=e.core.table(t),e[t]instanceof e.Table&&(e[t].core=n.core))})}function s3({_novip:e},n,t,r){t.forEach(t=>{let o=r[t];n.forEach(n=>{let r=iM(n,t);(!r||"value"in r&&void 0===r.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?iE(n,t,{get(){return this.table(t)},set(e){iC(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,o))})})}function s5({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function s4(e,n){return e._cfg.version-n._cfg.version}function s6(e,n){let t,r={del:[],add:[],change:[]};for(t in e)n[t]||r.del.push(t);for(t in n){let o=e[t],i=n[t];if(o){let e={name:t,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(i.primKey.keyPath||"")&&(o.primKey.auto===i.primKey.auto||sp)){let n,t=o.idxByName,a=i.idxByName;for(n in t)a[n]||e.del.push(n);for(n in a){let r=t[n],o=a[n];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([t,i])}return r}function s8(e,n,t,r){let o=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return r.forEach(e=>s7(o,e)),o}function s7(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function s9(e,n,t){let r={};return iP(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),o=n.keyPath,i=sK(sY(o),o||"",!1,!1,!!n.autoIncrement,o&&"string"!=typeof o,!0),a=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);o=t.keyPath;var s=sK(t.name,o,!!t.unique,!!t.multiEntry,!1,o&&"string"!=typeof o,!1);a.push(s)}r[e]=sJ(e,i,a)}),r}function le({_novip:e},n,t){let r=t.db.objectStoreNames;for(let o=0;o<r.length;++o){let i=r[o],a=t.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let t=a.indexNames[e],r=a.index(t).keyPath,o="string"==typeof r?r:"["+iP(r).join("+")+"]";if(n[i]){let e=n[i].idxByName[o];e&&(e.name=t,delete n[i].idxByName[o],n[i].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&iy.WorkerGlobalScope&&iy instanceof iy.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class ln{_parseStoresSpec(e,n){i_(e).forEach(t=>{if(null!==e[t]){var r=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return sK(t,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),iv(r),0===n)}),o=r.shift();if(o.multi)throw new at.Schema("Primary key cannot be multi-valued");r.forEach(e=>{if(e.auto)throw new at.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new at.Schema("Index must have a name and cannot be an empty string")}),n[t]=sJ(t,o,r)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?i$(this._cfg.storesSource,e):e;let t=n._versions,r={},o={};return t.forEach(e=>{i$(r,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(r,o)}),n._dbSchema=o,s5(n,[n._allTables,n,n.Transaction.prototype]),s3(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],i_(o),o),n._storeNames=i_(o),this}upgrade(e){return this._cfg.contentUpgrade=af(this._cfg.contentUpgrade||ai,e),this}}function lt(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new l$(sf,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function lr(e){return e&&"function"==typeof e.databases}function lo(e){return a1(function(){return az.letThrough=!0,e()})}function li(e){var n=n=>e.next(n),t=o(n),r=o(n=>e.throw(n));function o(e){return n=>{var o=e(n),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(t,r):iv(i)?Promise.all(i).then(t,r):t(i)}}return o(n)()}function la(e,n,t){var r=arguments.length;if(r<2)throw new at.InvalidArgument("Too few arguments");for(var o=Array(r-1);--r;)o[r-1]=arguments[r];return t=o.pop(),[e,iL(o),t]}function ls(e,n,t){let r=iv(e)?e.slice():[e];for(let e=0;e<t;++e)r.push(n);return r}let ll={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:r}=t,o={},i=[];function a(e,n,t){let r=s1(e),s=o[r]=o[r]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,u={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:sX(e),unique:!c&&t.unique};return s.push(u),u.isPrimaryKey||i.push(u),l>1&&a(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.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(n){var t,r;let o=n.query.index;return o.isVirtual?{...n,query:{index:o,range:(t=n.query.range,r=o.keyTail,{type:1===t.type?2:t.type,lower:ls(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:ls(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:n}return{...t,schema:{...r,primaryKey:s,indexes:i,getIndexByKeyPath:function(e){let n=o[s1(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:r,isVirtual:o,keyLength:i}=n.query.index;return o?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(o){null!=o?t.continue(ls(o,n.reverse?e.MAX_KEY:e.MIN_KEY,r)):n.unique?t.continue(t.key.slice(0,i).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,r)):t.continue()}},continuePrimaryKey:{value(n,o){t.continuePrimaryKey(ls(n,e.MAX_KEY,r),o)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function lc(e,n,t,r){return t=t||{},r=r||"",i_(e).forEach(o=>{if(ik(n,o)){var i=e[o],a=n[o];if("object"==typeof i&&"object"==typeof a&&i&&a){let e=iH(i);e!==iH(a)?t[r+o]=n[o]:"Object"===e?lc(i,a,t,r+o+"."):i!==a&&(t[r+o]=n[o])}else i!==a&&(t[r+o]=n[o])}else t[r+o]=void 0}),i_(n).forEach(o=>{ik(e,o)||(t[r+o]=n[o])}),t}let lu={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:r}=t.schema;return{...t,mutate(e){let o=az.trans,{deleting:i,creating:a,updating:s}=o.table(n).hook;switch(e.type){case"add":if(a.fire===ai)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===ai&&s.fire===ai)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(i.fire===ai)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(i.fire===ai)break;return o._promise("readwrite",()=>(function e(n,o,i){return t.query({trans:n,values:!1,query:{index:r,range:o},limit:i}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(r=>r.numFailures>0?Promise.reject(r.failures[0]):t.length<i?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...o,lower:t[t.length-1],lowerOpen:!0},i)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,o;let l=az.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.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([]):t.getMany({trans:o.trans,keys:c,cache:"immutable"})).then(n=>{let o=c.map((t,o)=>{let c=n[o],u={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(u,t,c,l);else if("add"===e.type||void 0===c){let n=a.fire.call(u,t,e.values[o],l);null==t&&null!=n&&(t=n,e.keys[o]=t,r.outbound||ij(e.values[o],r.keyPath,t))}else{let n=lc(c,e.values[o]),r=s.fire.call(u,n,t,c,l);if(r){let n=e.values[o];Object.keys(r).forEach(e=>{ik(n,e)?n[e]=r[e]:ij(n,e,r[e])})}}return u});return t.mutate(e).then(({failures:t,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(t[i]):s.onsuccess&&s.onsuccess("put"===e.type&&n[i]?e.values[i]:a)}return{failures:t,results:r,numFailures:i,lastResult:a}}).catch(e=>(o.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function lp(e,n,t){try{if(!n||n.keys.length<e.length)return null;let r=[];for(let o=0,i=0;o<n.keys.length&&i<e.length;++o)0===sS(n.keys[o],e[i])&&(r.push(t?iU(n.values[o]):n.values[o]),++i);return r.length===e.length?r:null}catch(e){return null}}let ld={stack:"dbcore",level:-1,create:e=>({table:n=>{let t=e.table(n);return{...t,getMany:e=>{if(!e.cache)return t.getMany(e);let n=lp(e.keys,e.trans._cache,"clone"===e.cache);return n?aB.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?iU(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function lf(e){return!("from"in e)}let lh=function(e,n){if(!this){let n=new lh;return e&&"d"in e&&i$(n,e),n}i$(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function lm(e,n,t){let r=sS(n,t);if(isNaN(r))return;if(r>0)throw RangeError();if(lf(e))return i$(e,{from:n,to:t,d:1});let o=e.l,i=e.r;if(0>sS(t,e.from))return o?lm(o,n,t):e.l={from:n,to:t,d:1,l:null,r:null},ly(e);if(sS(n,e.to)>0)return i?lm(i,n,t):e.r={from:n,to:t,d:1,l:null,r:null},ly(e);0>sS(n,e.from)&&(e.from=n,e.l=null,e.d=i?i.d+1:1),sS(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;o&&!e.l&&lg(e,o),i&&a&&lg(e,i)}function lg(e,n){lf(n)||function e(n,{from:t,to:r,l:o,r:i}){lm(n,t,r),o&&e(n,o),i&&e(n,i)}(e,n)}function lb(e){let n=lf(e)?null:{s:0,n:e};return{next(e){let t=arguments.length>0;for(;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&0>sS(e,n.n.from);)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||0>=sS(e,n.n.to))return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function ly(e){var n,t;let r=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),o=r>1?"r":r<-1?"l":"";if(o){let n="r"===o?"l":"r",t={...e},r=e[o];e.from=r.from,e.to=r.to,e[o]=r[o],t[o]=r[n],e[n]=t,t.d=l_(t)}e.d=l_(e)}function l_({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}ix(lh.prototype,{add(e){return lg(this,e),this},addKey(e){return lm(this,e,e),this},addKeys(e){return e.forEach(e=>lm(this,e,e)),this},[iK](){return lb(this)}});let lv={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new lh(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 t=`idb://${n}/${r}/${e}`;return s[t]||(s[t]=new lh)},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(iv(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let n=lp(d,h);n||"add"===p||u.addKeys(d),(n||f)&&i.indexes.forEach(function(e){let t=l(e.name||"");function r(n){return null!=n?e.extractKey(n):null}let o=n=>e.multiEntry&&iv(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let i=n&&r(n[t]),a=f&&r(f[t]);0!==sS(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(t),u.add(t),i.indexes.forEach(e=>l(e.name).add(t));return e})}},u=({query:{index:n,range:t}})=>{var r,o;return[n,new lh(null!=(r=t.lower)?r:e.MIN_KEY,null!=(o=t.upper)?o:e.MAX_KEY)]},p={get:e=>[a,new lh(e.key)],getMany:e=>[a,(new lh).addKeys(e.keys)],count:u,query:u,openCursor:u};return i_(p).forEach(e=>{c[e]=function(i){let{subscr:a}=az;if(a){let c=e=>{let t=`idb://${n}/${r}/${e}`;return a[t]||(a[t]=new lh)},u=c(""),d=c(":dels"),[f,h]=p[e](i);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&i.values&&o.query({...i,values:!1});return o[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&i.values)return n.then(({result:e})=>(u.addKeys(e),t));let e=i.values?t.result.map(s):t.result;i.values?u.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=i.values;return t&&Object.create(t,{key:{get:()=>(d.addKey(t.primaryKey),t.key)},primaryKey:{get(){let e=t.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&u.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return o[e].apply(this,arguments)}}),c}}}};class l${constructor(e,n){var t;this._middlewares={},this.verno=0;const r=l$.dependencies;this._options=n={addons:l$.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;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:ai,dbReadyPromise:null,cancelOpen:ai,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};i.dbReadyPromise=new aB(e=>{i.dbReadyResolve=e}),i.openCanceller=new aB((e,n)=>{i.cancelOpen=n}),this._state=i,this.name=e,this.on=sv(this,"populate","blocked","versionchange","close",{ready:[af,ai]}),this.on.ready.subscribe=iO(this.on.ready.subscribe,e=>(n,t)=>{l$.vip(()=>{let r=this._state;if(r.openComplete)r.dbOpenError||aB.resolve().then(n),t&&e(n);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(n),t&&e(n);else{e(n);let r=this;t||e(function e(){r.on.ready.unsubscribe(n),r.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,s$(sP.prototype,function(e,n){this.db=t;let r=sb,o=null;if(n)try{r=n()}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!==aa?s:null}})),this.Table=function(e){return s$(s_.prototype,function(n,t,r){this.db=e,this._tx=r,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:sv(null,{creating:[ac,ai],reading:[as,aa],updating:[ap,ai],deleting:[au,ai]})})}(this),this.Transaction=function(e){return s$(sH.prototype,function(n,t,r,o,i){this.db=e,this.mode=n,this.storeNames=t,this.schema=r,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=sv(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 aB((e,n)=>{this._resolve=e,this._reject=n}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var n=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):n&&this.idbtrans&&this.idbtrans.abort(),so(e)})})}(this),this.Version=function(e){return s$(ln.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return s$(sL.prototype,function(n,t,r){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:r};let o=e._deps.indexedDB;if(!o)throw new at.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,n)=>o.cmp(n,e),this._max=(e,n)=>o.cmp(e,n)>0?e:n,this._min=(e,n)=>0>o.cmp(e,n)?e:n,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=sZ(n.IDBKeyRange),this._createTransaction=(e,n,t,r)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),su.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(ll),this.use(lu),this.use(lv),this.use(ld),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new at.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new at.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var t=n.filter(n=>n._cfg.version===e)[0];return t||(t=new this.Version(e),n.push(t),n.sort(s4),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||az.letThrough||this._vip)?e():new aB((e,n)=>{if(this._state.openComplete)return n(new at.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new at.DatabaseClosed);this.open().catch(ai)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:r}){r&&this.unuse({stack:e,name:r});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:n,level:null==t?10:t,name:r}),o.sort((e,n)=>e.level-n.level),this}unuse({stack:e,name:n,create:t}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>t?e.create!==t:!!n&&e.name!==n)),this}open(){return function(e){var n;let t=e._state,{indexedDB:r}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?so(t.dbOpenError):e);iQ&&(t.openCanceller._stackHolder=i2()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let o=t.openCanceller;function i(){if(t.openCanceller!==o)throw new at.DatabaseClosed("db.open() was cancelled")}let a=t.dbReadyResolve,s=null,l=!1,c=()=>new aB((n,o)=>{if(i(),!r)throw new at.MissingAPI;let a=e.name,c=t.autoSchema?r.open(a):r.open(a,Math.round(10*e.verno));if(!c)throw new at.MissingAPI;c.onerror=sW(o),c.onblocked=aK(e._fireOnBlocked),c.onupgradeneeded=aK(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=sV,s.abort(),c.result.close();let e=r.deleteDatabase(a);e.onsuccess=e.onerror=aK(()=>{o(new at.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let t,r,a,d;s.onerror=sW(o);var i,u,p=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=p<1,e._novip.idbdb=c.result,i=p/10,u=s,t=e._dbSchema,(r=e._createTransaction("readwrite",e._storeNames,t)).create(u),r._completion.catch(o),a=r._reject.bind(r),d=az.transless||az,a1(()=>{az.trans=r,az.transless=d,0===i?(i_(t).forEach(e=>{s8(u,e,t[e].primKey,t[e].indexes)}),s2(e,u),aB.follow(()=>e.on.populate.fire(r)).catch(a)):(function({_novip:e},n,t,r){let o=[],i=e._versions,a=e._dbSchema=s9(e,e.idbdb,r),s=!1;return i.filter(e=>e._cfg.version>=n).forEach(i=>{o.push(()=>{let o=a,l=i._cfg.dbschema;le(e,o,r),le(e,l,r),a=e._dbSchema=l;let c=s6(o,l);c.add.forEach(e=>{s8(r,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new at.Upgrade("Not yet support for changing primary key");{let n=r.objectStore(e.name);e.add.forEach(e=>s7(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),s7(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let u=i._cfg.contentUpgrade;if(u&&i._cfg.version>n){let n;s2(e,r),t._memoizedTables={},s=!0;let i=iR(l);c.del.forEach(e=>{i[e]=o[e]}),s5(e,[e.Transaction.prototype]),s3(e,[e.Transaction.prototype],i_(i),i),t.schema=i;let a=iX(u);a&&a2();let p=aB.follow(()=>{if((n=u(t))&&a){var e=a3.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?aB.resolve(n):p.then(()=>n)}}),o.push(n=>{var r;s&&sp||(r=i._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==r[e]&&n.db.deleteObjectStore(e))),s5(e,[e.Transaction.prototype]),s3(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return o.length?aB.resolve(o.shift()(t.idbtrans)).then(e):aB.resolve()})().then(()=>{var e;i_(e=a).forEach(n=>{r.db.objectStoreNames.contains(n)||s8(r,n,e[n].primKey,e[n].indexes)})})})(e,i,r,u).catch(a)})}},o),c.onsuccess=aK(()=>{s=null;let r=e._novip.idbdb=c.result,o=iP(r.objectStoreNames);if(o.length>0)try{let n,i=r.transaction(1===o.length?o[0]:o,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let r=e._dbSchema=s9(0,n,t);e._storeNames=iP(n.objectStoreNames,0),s3(e,[e._allTables],i_(r),r)}(e,r,i):(le(e,e._dbSchema,i),((n=s6(s9(0,e.idbdb,i),e._dbSchema)).add.length||n.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.")),s2(e,i)}catch(e){}su.push(e),r.onversionchange=aK(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),r.onclose=aK(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){lr(e)||t===sf||lt(e,n).put({name:t}).catch(ai)}(e._deps,a),n()},o)}).catch(e=>e&&"UnknownError"===e.name&&t.PR1398_maxLoop>0?(t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),c()):aB.reject(e));return aB.race([o,("u"<typeof navigator?aB.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var t=function(){return indexedDB.databases().finally(e)};n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(c)]).then(()=>(i(),t.onReadyBeingFired=[],aB.resolve(lo(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let r=t.onReadyBeingFired.reduce(af,ai);return t.onReadyBeingFired=[],aB.resolve(lo(()=>r(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return o===t.openCanceller&&e._close(),so(n)}).finally(()=>{t.openComplete=!0,a()})}(this)}_close(){let e=this._state,n=su.indexOf(this);if(n>=0&&su.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new aB(n=>{e.dbReadyResolve=n}),e.openCanceller=new aB((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new at.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new aB((t,r)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=aK(()=>{!function({indexedDB:e,IDBKeyRange:n},t){lr(e)||t===sf||lt(e,n).delete(t).catch(ai)}(this._deps,this.name),t()}),e.onerror=sW(r),e.onblocked=this._fireOnBlocked};if(e)throw new at.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.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 i_(this._allTables).map(e=>this._allTables[e])}transaction(){let e=la.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let r,o,i=az.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=n.map(e=>{var n=e instanceof this.Table?e.name:e;if("string"!=typeof n)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}),"r"==e||e===sh)r=sh;else{if("rw"!=e&&e!=sm)throw new at.InvalidArgument("Invalid transaction mode: "+e);r=sm}if(i){if(i.mode===sh&&r===sm){if(!a)throw new at.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 at.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),a&&i&&!i.active&&(i=null)}}catch(e){return i?i._promise(null,(n,t)=>{t(e)}):so(e)}let s=(function e(n,t,r,o,i){return aB.resolve().then(()=>{let a,s=az.transless||az,l=n._createTransaction(t,r,n._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===an.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,null,i))):so(o)}let c=iX(i);c&&a2();let u=aB.follow(()=>{if(a=i.call(l,l))if(c){var e=a3.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=li(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?aB.resolve(a).then(e=>l.active?e:so(new at.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),so(e)))})}).bind(null,this,r,o,i,t);return i?i._promise(r,s,"lock"):az.trans?a9(az.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!ik(this._allTables,e))throw new at.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let lA="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class lw{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[lA](){return this}}function lk(e,n){return i_(n).forEach(t=>{lg(e[t]||(e[t]=new lh),n[t])}),e}try{o={indexedDB:iy.indexedDB||iy.mozIndexedDB||iy.webkitIndexedDB||iy.msIndexedDB,IDBKeyRange:iy.IDBKeyRange||iy.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function lx(e){let n=lC;try{lC=!0,sq.storagemutated.fire(e)}finally{lC=n}}ix(l$,{...ao,delete:e=>new l$(e,{addons:[]}).delete(),exists:e=>new l$(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return lr(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==sf)):lt(e,n).toCollection().primaryKeys()})(l$.dependencies).then(e)}catch(e){return so(new at.MissingAPI)}},defineClass:()=>function(e){i$(this,e)},ignoreTransaction:e=>az.trans?a9(az.transless,e):e(),vip:lo,async:function(e){return function(){try{var n=li(e.apply(this,arguments));return n&&"function"==typeof n.then?n:aB.resolve(n)}catch(e){return so(e)}}},spawn:function(e,n,t){try{var r=li(e.apply(t,n||[]));return r&&"function"==typeof r.then?r:aB.resolve(r)}catch(e){return so(e)}},currentTransaction:{get:()=>az.trans||null},waitFor:function(e,n){let t=aB.resolve("function"==typeof e?l$.ignoreTransaction(e):e).timeout(n||6e4);return az.trans?az.trans.waitFor(t):t},Promise:aB,debug:{get:()=>iQ,set:e=>{iQ=e,i0="dexie"===e?()=>!0:sd}},derive:iD,extend:i$,props:ix,override:iO,Events:sv,on:sq,liveQuery:function(e){let n,t=!1,r=new lw(r=>{let o=iX(e),i=!1,a={},s={},l={get closed(){return i},unsubscribe:()=>{i=!0,sq.storagemutated.unsubscribe(d)}};r.start&&r.start(l);let c=!1,u=!1;function p(){return i_(s).some(e=>a[e]&&function(e,n){let t=lb(n),r=t.next();if(r.done)return!1;let o=r.value,i=lb(e),a=i.next(o.from),s=a.value;for(;!r.done&&!a.done;){if(0>=sS(s.from,o.to)&&sS(s.to,o.from)>=0)return!0;0>sS(o.from,s.from)?o=(r=t.next(s.from)).value:s=(a=i.next(o.from)).value}return!1}(a[e],s[e]))}let d=e=>{lk(a,e),p()&&f()},f=()=>{let h,m;if(c||i)return;a={};let g={},b=(o&&a2(),h=()=>a1(e,{subscr:g,trans:null}),m=az.trans?a9(az.transless,h):h(),o&&m.then(a3,a3),m);u||(sq(sG,d),u=!0),c=!0,Promise.resolve(b).then(e=>{t=!0,n=e,c=!1,i||(p()?f():(a={},s=g,r.next&&r.next(e)))},e=>{c=!1,t=!1,r.error&&r.error(e),l.unsubscribe()})};return f(),l});return r.hasValue=()=>t,r.getValue=()=>n,r},extendObservabilitySet:lk,getByKeyPath:iN,setByKeyPath:ij,delByKeyPath:function(e,n){"string"==typeof n?ij(e,n,void 0):"length"in n&&[].map.call(n,function(n){ij(e,n,void 0)})},shallowClone:iR,deepClone:iU,getObjectDiff:lc,cmp:sS,asap:iB,minKey:ss,addons:[],connections:su,errnames:an,dependencies:o,semVer:si,version:si.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),l$.maxKey=sZ(l$.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(sq(sG,e=>{if(!lC){let n;sp?(n=document.createEvent("CustomEvent")).initCustomEvent(sU,!0,!0,e):n=new CustomEvent(sU,{detail:e}),lC=!0,dispatchEvent(n),lC=!1}}),addEventListener(sU,({detail:e})=>{lC||lx(e)}));let lC=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(sU);"function"==typeof e.unref&&e.unref(),sq(sG,n=>{lC||e.postMessage(n)}),e.onmessage=e=>{e.data&&lx(e.data)}}else if("u">typeof self&&"u">typeof navigator){sq(sG,e=>{try{lC||("u">typeof localStorage&&localStorage.setItem(sU,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:sU,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===sU){let n=JSON.parse(e.newValue);n&&lx(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===sU&&lx(e.changedParts)})}function lE(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}aB.rejectionMapper=function(e,n){if(!e||e instanceof i8||e instanceof TypeError||e instanceof SyntaxError||!e.name||!ar[e.name])return e;var t=new ar[e.name](n||e.message,e);return"stack"in e&&iE(t,"stack",{get:function(){return this.inner.stack}}),t},i0=sd;class lD extends l${constructor(){super("EsmOffline"),lE(this,"syncQueue",void 0),lE(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 lS(){return new lD}let lM=new lD,lz={};async function lP(){let e=await r6();return e?.uuid||"*"}async function lO(e,n,t,r){let o=r&&r.id;return void 0!==o&&await lM.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(l$.errnames.DatabaseClosed),await lM.syncQueue.add({type:n,content:t,userId:e,descriptor:r||{},createdOn:new Date}).catch(l$.errnames.DatabaseClosed,()=>-1)}async function lT(e,n,t){let r=await lP();return await lO(r,e,n,t)}async function lB(e,n){return(await lI(e,n)).map(e=>e.content)}async function lI(e,n){return await lM.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(l$.errnames.DatabaseClosed,()=>[])}async function lN(e){let n=await lP();return await lB(n,e)}async function lj(e){let n=await lP();return await lI(n,e)}async function lR(e){return await lM.syncQueue.get(e).catch(l$.errnames.DatabaseClosed,()=>void 0)}function lF(e){return!!lz[e]?.options.onBeginEditSyncItem}async function lL(e){let n=await lR(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=lz[n.type]?.options.onBeginEditSyncItem;if(!t)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 "${n.type}" supports editing items.`);t(n)}async function lW(e){await lM.syncQueue.delete(e).catch(l$.errnames.DatabaseClosed)}function lV(e,n,t,r={}){lz[e]={type:e,dependsOn:n,process:t,options:r}}L("offline-synchronization",{});let lG={};function lU(){return Object.values(lG)}function lq(e){lG[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.`),lG[e.id]=e}async function lH(e){let n=await l1();return await lK(n,e)}async function lK(e,n){let t=new lD;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(l$.errnames.DatabaseClosed,()=>[])}async function lY(e,n){let t=await l1();return await lJ(t,e,n)}async function lJ(e,n,t){let r=new lD,o=await r.dynamicOfflineData.get({type:n,identifier:t}).catch(l$.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(l$.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(l$.errnames.DatabaseClosed)}async function lZ(e,n){let t=await l1();return await lX(t,e,n)}async function lX(e,n,t){let r=new lD,o=await r.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(l$.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(n=>n!==e)}).catch(l$.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(l$.errnames.DatabaseClosed))}async function lQ(e,n){let t=await lH(e);await Promise.all(t.map(async e=>l0(e.type,e.identifier,n)))}async function l0(e,n,t){await lY(e,n);let r=new lD,o=await l1(),i=await r.dynamicOfflineData.get({type:e,identifier:n}).catch(l$.errnames.DatabaseClosed,()=>void 0),a=lU().filter(n=>n.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(n,t),{id:e.id,error:void 0}}catch(t){let n=t.message?.toString()??t.toString();return{id:e.id,error:n}}})),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(l$.errnames.DatabaseClosed)}async function l1(){let e=(await r6()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let l2=L("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function l3(){return l6(),l2}function l5(e,n){l6(),lq({type:"patient",displayName:n.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,t)=>n.onOfflinePatientAdded({patientUuid:e,signal:t??new AbortController().signal})})}async function l4(e){l6(),await l0("patient",e)}function l6(){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 l8(e,n,t=!0){if(e){let r=null,[o,i]=await Promise.all([rY(`${rq}/Patient/${e}`,n).catch(e=>r=e),t?l7(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(r)throw r}return null}async function l7(e){let n=(await lN("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function l9(e,n){let t=e=>{n("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,t),()=>{window.removeEventListener(`openmrs:${e}`,t)}}var ce=((Q={}).NEWVISIT="startVisit",Q.EDITVISIT="editVisit",Q.LOADING="loadingVisit",Q),cn=((ee={}).NOTSTARTED="notStarted",ee.ONGOING="ongoing",ee);let ct="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))",cr=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function co(){return W("visit",cr)}function ci(e,n){co().setState({patientUuid:e,manuallySetVisitUuid:n})}function ca(e,n){return rY(`${rU}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function cs(e,n,t){return rY(`${rU}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function cl(e,n,t){return rY(`${rU}/visit?patient=${e}&v=${t??ct}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}co().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let cc=new er.BehaviorSubject(null);var cu=t(33789);function cp(e){return{uuid:e.uuid,display:e.display,name:e.name}}function cd(){return rJ(`${rU}/visittype`).pipe((0,cu.map)(e=>e.data.results.map(cp))).pipe((0,cu.take)(1))}function cf(e){return{uuid:e.uuid,display:e.display}}function ch(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let r=t.toString();return rJ(`${rU}/location${r?"?"+r:""}`).pipe((0,cu.map)(e=>e.data.results.map(cf))).pipe((0,cu.take)(1))}class cm{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+cm.version}static addUnaryOp(e){return cm.max_unop_len=Math.max(e.length,cm.max_unop_len),cm.unary_ops[e]=1,cm}static addBinaryOp(e,n,t){return cm.max_binop_len=Math.max(e.length,cm.max_binop_len),cm.binary_ops[e]=n,t?cm.right_associative.add(e):cm.right_associative.delete(e),cm}static addIdentifierChar(e){return cm.additional_identifier_chars.add(e),cm}static addLiteral(e,n){return cm.literals[e]=n,cm}static removeUnaryOp(e){return delete cm.unary_ops[e],e.length===cm.max_unop_len&&(cm.max_unop_len=cm.getMaxKeyLen(cm.unary_ops)),cm}static removeAllUnaryOps(){return cm.unary_ops={},cm.max_unop_len=0,cm}static removeIdentifierChar(e){return cm.additional_identifier_chars.delete(e),cm}static removeBinaryOp(e){return delete cm.binary_ops[e],e.length===cm.max_binop_len&&(cm.max_binop_len=cm.getMaxKeyLen(cm.binary_ops)),cm.right_associative.delete(e),cm}static removeAllBinaryOps(){return cm.binary_ops={},cm.max_binop_len=0,cm}static removeLiteral(e){return delete cm.literals[e],cm}static removeAllLiterals(){return cm.literals={},cm}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 cm(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 cm.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!cm.binary_ops[String.fromCharCode(e)]||cm.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return cm.isIdentifierStart(e)||cm.isDecimalDigit(e)}throwError(e){let n=Error(e+" at character "+this.index);throw n.index=this.index,n.description=e,n}runHook(e,n){if(cm.hooks[e]){let t={context:this,node:n};return cm.hooks.run(e,t),t.node}return n}searchHook(e){if(cm.hooks[e]){let n={context:this};return cm.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===cm.SPACE_CODE||e===cm.TAB_CODE||e===cm.LF_CODE||e===cm.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),n=1===e.length?e[0]:{type:cm.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,r;for(;this.index<this.expr.length;)if((t=this.code)===cm.SEMCOL_CODE||t===cm.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())n.push(r);else if(this.index<this.expr.length){if(t===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}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,cm.max_binop_len),n=e.length;for(;n>0;){if(cm.binary_ops.hasOwnProperty(e)&&(!cm.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!cm.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=n,e;e=e.substr(0,--n)}return!1}gobbleBinaryExpression(){let e,n,t,r,o,i,a,s,l;if(!(i=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return i;for(o={value:n,prec:cm.binaryPrecedence(n),right_a:cm.right_associative.has(n)},(a=this.gobbleToken())||this.throwError("Expected expression after "+n),r=[i,o,a];n=this.gobbleBinaryOp();){if(0===(t=cm.binaryPrecedence(n))){this.index-=n.length;break}o={value:n,prec:t,right_a:cm.right_associative.has(n)},l=n;let s=e=>o.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;r.length>2&&s(r[r.length-2]);)a=r.pop(),n=r.pop().value,i=r.pop(),e={type:cm.BINARY_EXP,operator:n,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:cm.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,cm.isDecimalDigit(e)||e===cm.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===cm.SQUOTE_CODE||e===cm.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===cm.OBRACK_CODE)r=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,cm.max_unop_len)).length;t>0;){if(cm.unary_ops.hasOwnProperty(n)&&(!cm.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!cm.isIdentifierPart(this.expr.charCodeAt(this.index+n.length)))){this.index+=t;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:cm.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}cm.isIdentifierStart(e)?(r=this.gobbleIdentifier(),cm.literals.hasOwnProperty(r.name)?r={type:cm.LITERAL,value:cm.literals[r.name],raw:r.name}:r.name===cm.this_str&&(r={type:cm.THIS_EXP})):e===cm.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 n=this.code;for(;n===cm.PERIOD_CODE||n===cm.OBRACK_CODE||n===cm.OPAREN_CODE||n===cm.QUMARK_CODE;){let t;if(n===cm.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==cm.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===cm.OBRACK_CODE?((e={type:cm.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==cm.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===cm.OPAREN_CODE?e={type:cm.CALL_EXP,arguments:this.gobbleArguments(cm.CPAREN_CODE),callee:e}:(n===cm.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:cm.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),t&&(e.optional=!0),this.gobbleSpaces(),n=this.code}return e}gobbleNumericLiteral(){let e="",n,t;for(;cm.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===cm.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);cm.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(n=this.char)||"E"===n){for(e+=this.expr.charAt(this.index++),("+"===(n=this.char)||"-"===n)&&(e+=this.expr.charAt(this.index++));cm.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);cm.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,cm.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===cm.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===cm.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:cm.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){r=!0;break}if("\\"===n)switch(n=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+=n}else e+=n}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:cm.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(cm.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,cm.isIdentifierPart(e))this.index++;else break;return{type:cm.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){t=!0,this.index++,e===cm.CPAREN_CODE&&r&&r>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===cm.COMMA_CODE){if(this.index++,++r!==n.length){if(e===cm.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===cm.CBRACK_CODE)for(let e=n.length;e<r;e++)n.push(null)}}else if(n.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==cm.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(cm.CPAREN_CODE);if(this.code===cm.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:cm.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:cm.ARRAY_EXP,elements:this.gobbleArguments(cm.CBRACK_CODE)}}}Object.assign(cm,{hooks:new class{add(e,n,t){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]||[],n&&this[e][t?"unshift":"push"](n)},this)}run(e,n){this[e]=this[e]||[],this[e].forEach(function(e){e.call(n&&n.context?n.context:n,n)})}},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)})}}(cm),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"}),cm.max_unop_len=cm.getMaxKeyLen(cm.unary_ops),cm.max_binop_len=cm.getMaxKeyLen(cm.binary_ops);let cg=e=>new cm(e).parse(),cb=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(cm).filter(e=>!cb.includes(e)&&void 0===cg[e]).forEach(e=>{cg[e]=cm[e]}),cg.Jsep=cm,cg.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.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"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let cy="ArrowFunctionExpression",c_={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)}},cv={...c_,Promise};function c$(e,n={}){return cE(e,n,cM)}async function cA(e,n={}){return cD(e,n,cM)}function cw(e,n={}){return cE(e,n,cz)}function ck(e,n={}){return cD(e,n,cz)}function cx(e,n={}){return cE(e,n,cP)}function cC(e,n={}){return cD(e,n,cP)}function cE(e,n={},t){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==n&&(n={});let r=cB(n,c_),o=cO("string"==typeof e?cg(e):e,r);if(t(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 cD(e,n={},t){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==n&&(n={});let r=cB(n,cv);return Promise.resolve(cO("string"==typeof e?cg(e):e,r)).then(n=>{if(t(n))return n;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 cS(e){return cg(e)}function cM(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function cz(e){return"boolean"==typeof e}function cP(e){return"number"==typeof e}function cO(e,n){switch(e.type){case"UnaryExpression":var t,r,o,i,a,s,l,c,u,p,d,f,h=e,m=n;let g=cO(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=n;let v=cO(b.left,y),$=cO(b.right,y);switch(b.operator){case"+":return v+$;case"-":return v-$;case"*":return v*$;case"/":return v/$;case"%":return v%$;case"**":return v**$;case"==":return v==$;case"===":return v===$;case"!=":return v!=$;case"!==":return v!==$;case">":return v>$;case">=":return v>=$;case"<":return v<$;case"<=":return v<=$;case"in":return v in $;case"&&":return v&&$;case"||":return v||$;case"??":return v??$;default:throw`Expression evaluator does not support operator '${b.operator}' operator`}case"ConditionalExpression":return t=e,r=n,cO(t.test,r)?cO(t.consequent,r):cO(t.alternate,r);case"CallExpression":var A=e,w=n;let k=A.arguments?.map(cI(w)),x=cO(A.callee,w);if(x){if("function"!=typeof x)throw`${cj(A.callee)} is not a function`}else throw`No function named ${cj(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return o=e,i=n,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 n=Object.fromEntries(C.reduce((n,t,r)=>{let o=e[r];return function e(n){if("string"==typeof n||"number"==typeof n||"boolean"==typeof n||"function"==typeof n||null===n||n instanceof RegExp)return!0;if("object"==typeof n){for(let t of Object.keys(n))if(!e(n[t]))return!1;return!0}if(Array.isArray(n)){for(let t of n)if(!e(t))break}return!1}(o)&&n.push([t,o]),n},[]));return cO(o.body,i.addVariables(n))}).bind(i.thisObj??null);case"MemberExpression":return function(e,n){let t,r=cO(e.object,n);if(void 0===r)switch(e.object.type){case"Identifier":{let t=cT(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=cT(e.property,n);throw TypeError(`TypeError: cannot read properties of undefined (reading '${t}')`)}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(n.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":t=cO(e.property,n);break;default:{let o=cO(e.property,n);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};cN(o),t=r[o]}}return"function"==typeof t?t.bind(r):t}(e,n);case"ArrayExpression":return a=e,s=n,a.elements?.map(cI(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(cI(c)))[E.length-1];case"NewExpression":var D=e,S=n;if(D.callee&&"Identifier"===D.callee.type){let e=D.arguments?.map(cI(S));switch(D.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${D.callee.name}`}}if(D.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return cN((u=e).value),u.value;case"Identifier":var M=e,z=n;cN(M.name);let P=z.thisObj;if(P&&("object"==typeof P||"function"==typeof P)&&M.name in P){let e=P[M.name];return cN(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return cN(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let O,T;return p=e,d=n,O=p.expressions?.map(cI(d))??[],(T=p.quasis?.map(cI(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+O.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 cT(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return cT(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function cB(e,n){let t={thisObj:void 0,variables:{...e},globals:{...n},addVariables(e){return this.variables={...this.variables,...e},this}};return t.addVariables.bind(t),t}function cI(e){return function(n){return null===n?null:cO(n,e)}}function cN(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function cj(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function cR(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 n={globals:{...cv},isLocalExpression:!1,variables:new Set};return cF("string"==typeof e?cg(e):e,n),[...n.variables]}function cF(e,n){switch(e.type){case"UnaryExpression":return r=e,o=n,cF(r.argument,o);case"BinaryExpression":return i=e,a=n,[cF(i.left,a),cF(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[cF(s.consequent,l),cF(s.test,l),cF(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,u=n,t=cF(c.callee,u),c.arguments?.map(cL(u)),t;case"ArrowFunctionExpression":var r,o,i,a,s,l,c,u,p,d,f,h,m,g,b,y,v,$,A=e,w=n;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(cL(k))??[],C=cF(A.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=n,cF(p.object,d),void((E={...d}).isLocalExpression=!0,cF(p.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(cL(h));case"SequenceExpression":return m=e,g=n,void m.expressions?.map(cL(g));case"NewExpression":return b=e,y=n,void b.arguments?.map(cL(y));case"Literal":case"TemplateElement":return;case"Identifier":var D=e,S=n;if(!(D.name in S.globals))if(S.isLocalExpression)return D.name;else S.variables.add(D.name);return;case"TemplateLiteral":return v=e,$=n,void(v.expressions?.map(cL($)),v.quasis?.map(cL($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function cL(e){return function(n){return null===n?null:cF(n,e)}}cg.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(n){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let t=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let t=this.gobbleBinaryExpression();t||this.throwError("Expected expression after "+e),n.node={type:cy,params:null,body:t};return}}this.index=t}}),e.hooks.add("after-expression",function(n){!function n(t){t&&(Object.values(t).forEach(e=>{e&&"object"==typeof e&&n(e)}),"=>"===t.operator&&(t.type=cy,t.params=t.left?[t.left]:null,t.body=t.right,t.params&&t.params[0].type===e.SEQUENCE_EXP&&(t.params=t.params[0].expressions),delete t.left,delete t.right,delete t.operator))}(n.node)})}}),cg.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(n){let t=n.node;if(t&&"new"===t.operator){t.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(t.argument.type)||this.throwError("Expected new function()"),n.node=t.argument;let r=n.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"}})}}),cg.plugins.register({name:"numbers",init(e){function n(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 t(n){let t=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=t;return}n.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(t,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=n.call(this,l);if(!c)return;let u="";for(;o=this.code,i=c,95===o||i.some(([e,n])=>o>=e&&o<=n);)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,t.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)&&t.call(this,r)})}}),cg.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,o=this.expr.slice(t,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 n.node={type:e.LITERAL,value:r,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.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")}})}}),cg.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.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"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),cg.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},r="",o="",i=!1,a=this.expr.length,s=()=>n.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=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",r="",n.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",n),e.hooks.add("after-token",function(t){if((t.node.type===e.IDENTIFIER||t.node.type===e.MEMBER_EXP)&&96===this.code)return t.node={type:"TaggedTemplateExpression",tag:t.node,quasi:n.bind(this)(t,!1)},t.node=this.gobbleTokenProperty(t.node),t.node})}}),cg.addBinaryOp("in",7),cg.addBinaryOp("??",1);let cW=W("feature-flags",{flags:function(){let e={};for(let n of Object.keys(localStorage))if(n.startsWith("openmrs:feature-flag:")){let t=n.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...r}}return e}()});function cV(e,n,t){cW.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:n,description:t}}}))}function cG(e){return cW.getState().flags[e].enabled}function cU(e){return!window.offlineEnabled||(e??navigator.onLine)}cW.subscribe(e=>{for(let[n,t]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${n}`,t.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${n}`,JSON.stringify({label:t.label,description:t.description}))});var cq=eV(function(e,n,t){eP(e,n,t)});function cH(e,n=!0,t=!1){return!!(e?n:t)}let cK=L("extensionsInternal",{slots:{},extensions:{}}),cY=()=>W("extensionsInternal",{slots:{},extensions:{}});function cJ(e){let n=cK.getState(),t=e(n);t!==n&&cK.setState(t)}let cZ=()=>W("extensions",{slots:{}});function cX(e){let n=[];for(let t of Object.values(e.extensions))for(let e of t.instances)n.push({slotModuleName:e.slotModuleName,extensionModuleName:t.moduleName,slotName:e.slotName,extensionId:e.id});nn(nB.getState().mountedExtensions,n)||nB.setState({mountedExtensions:n})}cX(cK.getState()),cK.subscribe(cX);let cQ=cY(),c0=cZ(),c1=nN(),c2=nR();function c3(e,n,t,r,o){let i={},a=cU(),s=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,l]of Object.entries(e.slots)){let{config:c}=nj(n,l.name),u=ur(r,e,c,t,s,a,o.session);i[r]={moduleName:l.moduleName,assignedExtensions:u}}nn(c0.getState().slots,i)||c0.setState({slots:i})}function c5(){c3(cQ.getState(),c1.getState(),c2.getState(),cW.getState(),rX.getState())}function c4(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function c6(e){let[n]=e.split("#");return n}function c8(e){var n;let t;return n=cQ.getState(),t=c6(e),n.extensions[t]}cQ.subscribe(e=>{c3(e,c1.getState(),c2.getState(),cW.getState(),rX.getState())}),c1.subscribe(e=>{c3(cQ.getState(),e,c2.getState(),cW.getState(),rX.getState())}),c2.subscribe(e=>{c3(cQ.getState(),c1.getState(),e,cW.getState(),rX.getState())}),cW.subscribe(e=>{c3(cQ.getState(),c1.getState(),c2.getState(),e,rX.getState())}),rX.subscribe(e=>{c3(cQ.getState(),c1.getState(),c2.getState(),cW.getState(),e)}),c5(),b(c5);let c7=e=>cQ.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function c9(e,n){cJ(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[...r.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...c4(e),attachedIds:[n]}}}})}function ue(e,n){cJ(t=>{let r=t.slots[e];return r&&r.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==n)}}}:t})}function un(e){cJ(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function ut(e,n,t,r){let o=n.indexOf(e);if(-1!==o)return o;{if(void 0!==t)return 1e3+t;let n=r.indexOf(e);return -1!==n?2e3+n:-1}}function ur(e,n,t,r,o,i,a){let s=function(e,n){let t=e.add||[],r=e.remove||[],o=e.order||[],{extensions:i}=cQ.getState();return[...n,...t].filter(e=>!r.includes(e)).sort((e,t)=>{let r=ut(e,o,i[c6(e)]?.order,n),a=ut(t,o,i[c6(t)]?.order,n);return -1===a?-1:-1===r?1:r-a})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,u=c&&"object"==typeof c?{session:a,...c}:{session:a};for(let c of s){let{config:s}=nF(r,e,c),p=cq(s,t.configure?.[c]??null),d=c6(c),f=n.extensions[d];if(f){let n=p?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!a?.user||!r4(n,a.user)))continue;let t=p?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!cw(t,u))continue}catch(n){console.error(`Error while evaluating expression '${t}' for extension ${d} in slot ${e}`,n);continue}if(f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!cH(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 uo(e){let n=cQ.getState(),{config:t}=nj(nN().getState(),e),r=c2.getState(),o=cW.getState(),i=rX.getState(),a=cU();return ur(e,n,t,r,Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),a,i.session)}let ui=(e,n,t)=>cQ.setState(r=>{let o=r.slots[n]?.moduleName;if(o&&o!=e)return console.warn(`An extension slot with the name '${n}' 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[n])return{...r,slots:{...r.slots,[n]:{...r.slots[n],moduleName:e,state:t}}};let i=c4(n,e,t);return{...r,slots:{...r.slots,[n]:{...i}}}}),ua=L("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function us({name:e,basePath:n,mode:t,componentContext:r,state:o}){ua.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:r,state:o})}function ul(e){ua.getState().slotName===e&&ua.setState(ua.getInitialState(),!0)}let uc=0;async function uu(e,n,t,r,o=e=>e,i={}){let a=c6(r),s=c8(r),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${n}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(function(e=!0,n=!1){return cH(cU(),e,n)}(p,d)){cJ(o=>({...o,extensions:{...o.extensions,[a]:{...o.extensions[a],instances:[...o.extensions[a].instances,{domElement:e,id:r,slotName:n,slotModuleName:t}]}}}));let s=await f(),p=uc++;l=tX(o({...s,name:`${n}/${a}-${p}`}),{...i,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:u},domElement:e})}}else console.warn(`Tried to render ${r} into ${n} but no DOM element was available.`);return l}function up(){return{current:"unavailable",notAvailable:!0,active:!1}}let ud="x-omrs-offline-response-body",uf="x-omrs-offline-response-status",uh="x-omrs-offline-caching-strategy",um="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ug=new Uint8Array(16),ub=[];for(let e=0;e<256;++e)ub.push((e+256).toString(16).slice(1));let uy=function(e,n,t){if(um&&!n&&!e)return um();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(ug)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=r[e];return n}return function(e,n=0){return ub[e[n+0]]+ub[e[n+1]]+ub[e[n+2]]+ub[e[n+3]]+"-"+ub[e[n+4]]+ub[e[n+5]]+"-"+ub[e[n+6]]+ub[e[n+7]]+"-"+ub[e[n+8]]+ub[e[n+9]]+"-"+ub[e[n+10]]+ub[e[n+11]]+ub[e[n+12]]+ub[e[n+13]]+ub[e[n+14]]+ub[e[n+15]]}(r)},u_="OFFLINE+";function uv(){return u_+uy()}function u$(e){return e.startsWith(u_)}var uA=t(47499),uw=t.n(uA);function uk({to:e,templateParams:n,onBeforeNavigate:t,children:r,...o}){return(0,uA.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}`)},[]),uw().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),t?.(r),rF({to:e,templateParams:n})),0===r.button&&(r.ctrlKey||r.metaKey)&&t?.(r),0===r.button&&r.shiftKey&&t?.(r),1===r.button&&t?.(r)},href:rj(e,n),...o},r)}let ux=L("modalRegistry",{modals:{}}),uC=L("workspaceRegistrations",{workspaces:{}}),uE=L("workspaceGroups",{workspaceGroups:{}}),uD=new Set;function uS(e){let n=uC.getState().workspaces;if(n[e])return n[e];{let n=c8(e);if(n){var t;let r;return uD.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.`),uD.add(e)),{name:n.name,title:(t=n,"string"==typeof(r=t?.meta?.title)?r:r&&"object"==typeof r?o1(t.moduleName,r.key,r.default):t.name),moduleName:n.moduleName,preferredWindowSize:n.meta?.screenSize??"normal",load:n.load,type:n.meta?.type??"form",canHide:n.meta?.canHide??!1,canMaximize:n.meta?.canMaximize??!1,width:n.meta?.width??"narrow",groups:n.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}let uM=L("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function uz(e){let{openedWindows:n}=uM.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}let uP=(0,uA.createContext)({moduleName:"",featureName:""});function uO(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[r,o]of Object.entries(n)){let n=function(...n){e.setState(e=>o(e,...n))};t[r]=n}return t}let uT=()=>e=>e;function uB(e,n=uT(),t){let r=(0,uA.useCallback)(n=>e.subscribe(n),[e]),o=(0,uA.useCallback)(()=>n(e.getState()),[e,n]),i=(0,uA.useSyncExternalStore)(r,o,o),a=(0,uA.useMemo)(()=>t?uO(e,t):{},[e,t]);return{...i,...a}}function uI(e,n){return uB(e,uT(),n)}function uN(e){return function(n){let t=(0,uA.useCallback)(n=>e.subscribe(n),[]),r=(0,uA.useCallback)(()=>e.getState(),[]),o=(0,uA.useSyncExternalStore)(t,r,r),i=(0,uA.useMemo)(()=>n?uO(e,n):{},[n]);return{...o,...i}}}let uj=e=>uB(cZ(),n=>n.slots?.[e]);function uR(e){let n=uj(e);return n?.assignedExtensions??[]}function uF(e,n){let{moduleName:t}=(0,uA.useContext)(uP),r=(0,uA.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,uA.useEffect)(()=>{ui(t,e,n),r.current=!1},[]),(0,uA.useEffect)(()=>{r.current||function(e,n,t=!1){cQ.setState(r=>{let o=t?cq(r.slots[e].state,n):n;return{...r,slots:{...r.slots,[e]:{...r.slots[e],state:o}}}})}(e,n)},[e,n]),{extensions:uR(e),extensionSlotName:e,extensionSlotModuleName:t}}function uL(e){return e}function uW({name:e,extensionSlotName:n,select:t=uL,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??n,l=(0,uA.useRef)(null),{extensions:c,extensionSlotModuleName:u}=uF(s,o),p=(0,uA.useMemo)(()=>t(c),[t,c]),d=(0,uA.useMemo)(()=>{if("function"==typeof r&&!uw().isValidElement(r))return p.map(e=>r(e,o))},[r,p]);return uw().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...i,position:"relative"},...a},s&&p?.map((e,n)=>uw().createElement(uP.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[n]??("function"!=typeof r?r:null)??uw().createElement(dr,{state:o}))))}var uV=t(5338);function uG(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function uU(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?uG(Object(t),!0).forEach(function(n){var r,o,i;r=e,o=n,i=t[n],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(t)):uG(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function uq(e){return(uq="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 uH(e){return(uH="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 uK(e,n){var t;if("function"!=typeof(t=n.domElement?function(){return n.domElement}:n.domElementGetter?n.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var n=e.appName||e.name;if(!n)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 t="single-spa-application:".concat(n);return function(){var e=document.getElementById(t);return e||((e=document.createElement("div")).id=t,document.body.appendChild(e)),e}}(n)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(n.name,"'. Expected a function, received ").concat(uH(t)));return function(){var e=t(n);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(n.name,"'. Expected HTMLElement, received ").concat(uH(e)));return e}}var uY=null;try{uY=require("react").createContext()}catch(e){}var uJ={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 uZ(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function uX(e,n){return new Promise(function(t,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var n=e.version.slice(0,e.version.indexOf("."));try{return Number(n)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(n.name||n.appName||n.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=u2(e,n,function(){t(this)}),a=uK(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,r=e.elementToRender,o=e.domElement,i=n[t];if("function"!=typeof i)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){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:u1(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[n.name]=a,e.renderResults[n.name]=s})}function uQ(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var r=e.renderResults[n.name];r&&r.unmount?r.unmount():u1(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function u0(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var r=u2(e,n,null),o=e.renderResults[n.name];if(o&&o.render)o.render(r);else{var i=uK(e,n)();u1(e).render(r,i)}})}function u1(e){return e.ReactDOMClient||e.ReactDOM}function u2(e,n,t){var r=e.React.createElement(e.rootComponent,n),o=uY?e.React.createElement(uY.Provider,{value:n},r):r;return(e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,n){function t(n){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},t.displayName="SingleSpaReactErrorBoundary(".concat(n.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||n.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},t.prototype.componentDidCatch=function(e,n){this.setState({caughtError:e,caughtErrorInfo:n})},t}(e,n),o=e.React.createElement(e.errorBoundaryClass,n,o)),o=e.React.createElement(e.SingleSpaRoot,uU(uU({},n),{},{mountFinished:t,updateFinished:function(){e.updateResolves[n.name]&&(e.updateResolves[n.name].forEach(function(e){return e()}),delete e.updateResolves[n.name])},unmountFinished:function(){e.unmountResolves[n.name]&&(e.unmountResolves[n.name](),delete e.unmountResolves[n.name])}}),o)}var u3=t(58779),u5=t(59324),u4=t(14993);let u6={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},u8=new Map;(0,u4.r2)(u8);let u7={errorRetryCount:3,fetcher:rY,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof rZ){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>u8};function u9(e,n){return function(e){if("object"!==uq(e))throw Error("single-spa-react requires a configuration object");var n,t=uU(uU({},uJ),e);if(!t.React)throw Error("single-spa-react must be passed opts.React");if(!t.ReactDOM&&!t.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(t.renderType||(null!=(n=t.ReactDOMClient)&&n.createRoot?t.renderType="createRoot":t.renderType="render"),!t.rootComponent&&!t.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(t.errorBoundary&&"function"!=typeof t.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!uY&&t.React.createContext&&(uY=t.React.createContext()),t.SingleSpaRoot=function(e){function n(e){n.displayName="SingleSpaRoot(".concat(e.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},n.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},n.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},n}(t);var r={bootstrap:uZ.bind(null,t),mount:uX.bind(null,t),unmount:uQ.bind(null,t)};return t.parcelCanUpdate&&(r.update=u0.bind(null,t)),r}({React:uw(),ReactDOMClient:uV,rootComponent:(function(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},u6,e),t={...u7,...n.swrConfig};return function(e){var r,o,i,a,s;return i=o=class extends(r=uw().Component){componentDidCatch(e,t){t&&t.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:t.componentStack})),n.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:t})}render(){if(this.state.caughtError)return uw().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=uw().createElement(uA.Suspense,{fallback:null},uw().createElement(u5.BE,{value:t},uw().createElement(uP.Provider,{value:this.state.config},n.disableTranslations?uw().createElement(e,this.props):uw().createElement(u3.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},uw().createElement(e,this.props)))));return n.strictMode&&uw().StrictMode?uw().createElement(uw().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${n.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}})(n)(e)})}function pe(e,n){return()=>e().then(({default:e})=>u9(e,n))}function pn(e,n){return()=>Promise.resolve(u9(e,n))}let pt=pe,pr=new Map;function po(e,n){let t=(0,uA.useRef)(n??{}),r=(0,uA.useRef)(n=>ol(e,n)),o=(0,uA.useRef)(Symbol());return(0,uA.useEffect)(()=>{let t=n??{},r=o.current;return null===os(e)?oi(e,t):(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.`),ol(e,()=>t)),pr.set(e,r),()=>{pr.get(e)===r&&(oa(e),pr.delete(e))}},[e]),(0,uA.useEffect)(()=>{let r=n??{};T(t.current,r)||(ol(e,()=>r),t.current=r)},[n]),r.current}function pi({namespace:e,value:n}){return po(e,n),null}let pa=({children:e,value:n,fallback:t})=>n?uw().createElement(uw().Fragment,null,e):t?uw().createElement(uw().Fragment,null,t):null;function ps(){let e=(0,uA.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,uA.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function pl(e,n=e=>e??{}){let[t,r]=(0,uA.useState)(()=>{if(pc(e))return;let t=os(e);if(null!==t)return n?n(t):t});return(0,uA.useEffect)(()=>{if(pc(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,uA.useEffect)(()=>oc(e,e=>{if(null==e)return void r(void 0);let t=n?n(e):e;r(e=>T(e,t)?e:t)}),[e,n]),t}function pc(e){return"string"!=typeof e||0===e.trim().length}function pu(e){let[n,t]=(0,uA.useState)([]);return(0,uA.useEffect)(()=>cZ().subscribe(r=>{let o=r.slots[e]?.assignedExtensions.map(e=>e.id)??[];nn(o,n)||t(o)}),[]),n}function pp(e,n){let{data:t,error:r,mutate:o,isLoading:i,isValidating:a}=(0,u5.Ay)(`${ie}?patient=${e}&includeEncounterless=${n}`,rY);return(0,uA.useMemo)(()=>({isLoading:i,data:t?.data.results??[],error:r,mutate:o,isValidating:a}),[t,r,i,a,o])}function pd(e){(0,uA.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let pf={},ph=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|