@openmrs/esm-active-visits-app 11.1.1-pre.9708 → 11.1.1-pre.9712
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/.turbo/turbo-build.log +1 -1
- package/dist/1442.js +1 -0
- package/dist/1442.js.map +1 -0
- package/dist/2129.js +1 -1
- package/dist/2152.js +1 -0
- package/dist/2152.js.map +1 -0
- package/dist/2342.js +1 -1
- package/dist/3378.js +1 -1
- package/dist/3671.js +1 -1
- package/dist/3958.js +1 -1
- package/dist/3989.js +1 -1
- package/dist/3989.js.map +1 -1
- package/dist/3996.js +1 -1
- package/dist/4560.js +1 -0
- package/dist/4560.js.map +1 -0
- package/dist/7209.js +1 -0
- package/dist/7209.js.map +1 -0
- package/dist/9061.js +1 -1
- package/dist/9061.js.map +1 -1
- package/dist/9590.js +1 -0
- package/dist/9590.js.map +1 -0
- package/dist/9771.js +1 -1
- package/dist/9771.js.map +1 -1
- package/dist/openmrs-esm-active-visits-app.js +2 -2
- package/dist/openmrs-esm-active-visits-app.js.buildmanifest.json +154 -88
- package/dist/openmrs-esm-active-visits-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/dist/1744.js +0 -1
- package/dist/1744.js.map +0 -1
package/dist/2129.js
CHANGED
|
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
|
|
|
12
12
|
${t}`)}return n}let ik=(e,t)=>{let r=structuredClone(t);if(!e)return r;for(let t of Object.keys(e)){let n=r[t],i=e[t];if(i&&(i.hasOwnProperty("_type")||i.hasOwnProperty("_default"))){r.hasOwnProperty(t)||(r[t]=i._default);let e=i._elements;if(n&&ij(e)){if(i._type===nN.Array&&Array.isArray(n)){let i=n.map(t=>ik(e,t));r[t]=i}else if(i._type===nN.Object)for(let t of Object.keys(n))n[t]=ik(e,n[t])}}else if(iT(i)){let e=n??{};iT(e)&&(r[t]=ik(i,e))}}return r};function ij(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function iT(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let iR=new Set;function iA(e,t){let r=`${e}:::${t}`;iR||(iR=new Set),iR.has(r)||(console.error(t),iR.add(r))}function iN(e){e?iR.forEach(t=>{t.startsWith(e)&&iR.delete(t)}):iR.clear()}function iM(){it.forEach(e=>e()),it.length=0,ia.clear(),iv.clear(),iw.clear(),ib.clear(),ii()}let iI={"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:nN.Object,_default:{},_validators:[nM(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let t=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${t.join(", ")}.`})]}},i$={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nN.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nN.String,_default:void 0}},...iI},iL=(e,t)=>nM(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),iF=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return nM(e=>{if(!e||"string"!=typeof e)return!1;let r=/\${(.*?)}/g,n=r.exec(e);for(;n;){if(!t.includes(n[1]))return!1;n=r.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},iB=iF([]),iV=e=>nM(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),iU={inRange:iL,isUrl:iB,isUrlWithTemplateParameters:iF,oneOf:iV};var iW=r(2034);let iz=Z("breadcrumbs",[]);function iK(e){return iH([e])}function iH(e){let t=[...iG(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,iW.pathToRegexp)(e.matcher).regexp:(0,iW.pathToRegexp)(e.path).regexp,settings:e}))];iz.setState(t,!0)}function iG(){return iz.getState()}function iq(e,t){if(t)return function(e,t){let[r]=e.filter(e=>e.matcher.test(t));return r}(e,t)||function(e,t){let r=t.split("/");for(;r.length>1;){r.pop();let t=iq(e,r.join("/"));if(t)return t}}(e,t)}function iZ(e,t){if(e.length>0){let r=iq(e,t);if(r){let t=[r],n=iq(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=iq(e,n.settings.parent);return t.reverse()}}return[]}function iY(e){return iZ(iG(),e)}var iJ=Object.freeze({__proto__:null,get start(){return ad},get ensureJQuerySupport(){return oY},get setBootstrapMaxTime(){return oT},get setMountMaxTime(){return oR},get setUnmountMaxTime(){return oA},get setUnloadMaxTime(){return oN},get registerApplication(){return o9},get unregisterApplication(){return o8},get getMountedApps(){return o3},get getAppStatus(){return o6},get unloadApplication(){return ae},get checkActivityFunctions(){return o7},get getAppNames(){return o4},get pathToActiveWhen(){return an},get navigateToUrl(){return oV},get patchHistoryApi(){return oG},get triggerAppChange(){return as},get addErrorHandler(){return i2},get removeErrorHandler(){return i3},get mountRootParcel(){return oO},get NOT_LOADED(){return i5},get LOADING_SOURCE_CODE(){return i9},get NOT_BOOTSTRAPPED(){return i7},get BOOTSTRAPPING(){return i8},get NOT_MOUNTED(){return oe},get MOUNTING(){return ot},get UPDATING(){return on},get LOAD_ERROR(){return oa},get MOUNTED(){return or},get UNLOADING(){return oo},get UNMOUNTING(){return oi},get SKIP_BECAUSE_BROKEN(){return os}}),iX=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,iQ=!function(){try{var e=new iX("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var r=document.createEvent("CustomEvent");return t?r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):r.initCustomEvent(e,!1,!1,void 0),r}:function(e,t){var r=document.createEventObject();return r.type=e,t?(r.bubbles=!!t.bubbles,r.cancelable=!!t.cancelable,r.detail=t.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r}:iX;let i0=[];function i1(e,t,r){let n=i6(e,t,r);i0.length?i0.forEach(e=>e(n)):setTimeout(()=>{throw n})}function i2(e){if("function"!=typeof e)throw Error(i4(28,!1));i0.push(e)}function i3(e){if("function"!=typeof e)throw Error(i4(29,!1));let t=!1;return i0=i0.filter(r=>{let n=r===e;return t=t||n,!n}),t}function i4(e,t,...r){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${r.length?`&arg=${r.join("&arg=")}`:""}`}function i6(e,t,r){let n,i=`${op(t)} '${oc(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=i+e.message}catch(e){}n=e}else{console.warn(i4(30,!1,t.status,oc(t)));try{n=Error(i+JSON.stringify(e))}catch(t){n=e}}return n.appOrParcelName=oc(t),t.status=r,n}let i5="NOT_LOADED",i9="LOADING_SOURCE_CODE",i7="NOT_BOOTSTRAPPED",i8="BOOTSTRAPPING",oe="NOT_MOUNTED",ot="MOUNTING",or="MOUNTED",on="UPDATING",oi="UNMOUNTING",oo="UNLOADING",oa="LOAD_ERROR",os="SKIP_BECAUSE_BROKEN";function ol(e){return e.status===or}function ou(e){try{return e.activeWhen(window.location)}catch(t){return i1(t,e,os),!1}}function oc(e){return e.name}function od(e){return!!e.unmountThisParcel}function op(e){return od(e)?"parcel":"application"}function of(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function oh(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r];return null}function om(e){return e&&("function"==typeof e||Array.isArray(e)&&!oh(e,e=>"function"!=typeof e))}function oy(e,t){let r=e[t]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[()=>Promise.resolve()]);let n=op(e),i=oc(e);return function(e){return r.reduce((r,o,a)=>r.then(()=>{let r=o(e);return og(r)?r:Promise.reject(i4(15,!1,n,i,t,a))}),Promise.resolve())}}function og(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let ov=[];function ob(e,t){return Promise.resolve().then(()=>e.status!==i7?e:(e.status=i8,e.bootstrap?oM(e,"bootstrap").then(r).catch(r=>{if(t)throw i6(r,e,os);return i1(r,e,os),e}):Promise.resolve().then(r)));function r(){return e.status=oe,e}}function ow(e,t){return Promise.resolve().then(()=>{if(e.status!==or)return e;return e.status=oi,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(r,n=>r().then(()=>{let r=Error(n.message);if(t)throw i6(r,e,os);i1(r,e,os)})).then(()=>e);function r(){return oM(e,"unmount").then(()=>{e.status=oe},r=>{if(t)throw i6(r,e,os);i1(r,e,os)})}})}let o_=!1,ox=!1;function oE(e,t){return Promise.resolve().then(()=>e.status!==oe?e:(o_||(window.dispatchEvent(new iQ("single-spa:before-first-mount")),o_=!0),e.status=ot,oM(e,"mount").then(()=>(e.status=or,ox||(window.dispatchEvent(new iQ("single-spa:first-mount")),ox=!0),e)).catch(r=>{return e.status=or,ow(e,!0).then(n,n);function n(){if(t)throw i6(r,e,os);return i1(r,e,os),e}})))}let oS=0,oD={parcels:{}};function oO(){return oP.apply(oD,arguments)}function oP(e,t){let r,n,i,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(i4(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(i4(3,!1,typeof e.name));let a=oS++,s=e.name||`parcel-${a}`;if("object"!=typeof t)throw Error(i4(4,!1,s,typeof t));if(!t.domElement)throw Error(i4(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:a,parcels:{},status:l?i9:i7,customProps:t,parentName:oc(o),unmountThisParcel:()=>f.then(()=>{if(c.status!==or)throw Error(i4(6,!1,s,c.status));return ow(c,!0)}).then(e=>(c.parentName&&delete o.parcels[c.id],e)).then(e=>(n(e),e)).catch(e=>{throw c.status=os,i(e),e})};o.parcels[a]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(i4(7,!1));let p=(d=d.then(e=>{if(!e)throw Error(i4(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!om(e.bootstrap))throw Error(i4(9,!1,s));if(!om(e.mount))throw Error(i4(10,!1,s));if(!om(e.unmount))throw Error(i4(11,!1,s));if(e.update&&!om(e.update))throw Error(i4(12,!1,s));let t=oy(e,"bootstrap"),n=oy(e,"mount"),i=oy(e,"unmount");c.status=i7,c.name=s,c.bootstrap=t,c.mount=n,c.unmount=i,c.timeouts=oI(e.timeouts),e.update&&(c.update=oy(e,"update"),r.update=function(e){return c.customProps=e,oC(Promise.resolve().then(()=>{if(c.status!==or)throw Error(i4(32,!1,oc(c)));return c.status=on,oM(c,"update").then(()=>(c.status=or,c)).catch(e=>{throw i6(e,c,os)})}))})})).then(()=>ob(c,!0)),f=p.then(()=>oE(c,!0)),h=new Promise((e,t)=>{n=e,i=t});return r={mount:()=>oC(Promise.resolve().then(()=>{if(c.status!==oe)throw Error(i4(13,!1,s,c.status));return o.parcels[a]=c,oE(c)})),unmount:()=>oC(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:oC(d),bootstrapPromise:oC(p),mountPromise:oC(f),unmountPromise:oC(h)}}function oC(e){return e.then(()=>null)}function ok(e){let t=oc(e),r="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(i4(40,!1),t,r));let n=of({},r,{name:t,mountParcel:oP.bind(e),singleSpa:iJ});return od(e)&&(n.unmountSelf=e.unmountThisParcel),n}let oj={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 oT(e,t,r){if("number"!=typeof e||e<=0)throw Error(i4(16,!1));oj.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function oR(e,t,r){if("number"!=typeof e||e<=0)throw Error(i4(17,!1));oj.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function oA(e,t,r){if("number"!=typeof e||e<=0)throw Error(i4(18,!1));oj.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function oN(e,t,r){if("number"!=typeof e||e<=0)throw Error(i4(19,!1));oj.unload={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function oM(e,t){let r=e.timeouts[t],n=r.warningMillis,i=op(e);return new Promise((o,a)=>{let s=!1,l=!1;e[t](ok(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>c(1),n),setTimeout(()=>c(!0),r.millis);let u=i4(31,!1,t,i,oc(e),r.millis);function c(e){s||(!0===e?(l=!0,r.dieOnTimeout?a(Error(u)):console.error(u)):!l&&(console.warn(u),e*n+n<r.millis&&setTimeout(()=>c(e+1),n)))}})}function oI(e){let t={};for(let r in oj)t[r]=of({},oj[r],e&&e[r]||{});return t}function o$(e){return Promise.resolve().then(()=>{let t,r;return e.loadPromise?e.loadPromise:e.status!==i5&&e.status!==oa?e:(e.status=i9,e.loadPromise=Promise.resolve().then(()=>{let n=e.loadApp(ok(e));if(!og(n))throw r=!0,Error(i4(33,!1,oc(e)));return n.then(r=>{let n;e.loadErrorTime=null,"object"!=typeof(t=r)&&(n=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!om(t.bootstrap)&&(n=35),om(t.mount)||(n=36),om(t.unmount)||(n=37);let i=op(t);if(n){let r;try{r=JSON.stringify(t)}catch(e){}return console.error(i4(n,!1,i,oc(e),r),t),i1(void 0,e,os),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=of({},e.devtools.overlays,t.devtools.overlays)),e.status=i7,e.bootstrap=oy(t,"bootstrap"),e.mount=oy(t,"mount"),e.unmount=oy(t,"unmount"),e.unload=oy(t,"unload"),e.timeouts=oI(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let n;return delete e.loadPromise,r?n=os:(n=oa,e.loadErrorTime=(new Date).getTime()),i1(t,e,n),e}))})}let oL="u">typeof window,oF={hashchange:[],popstate:[]},oB=["hashchange","popstate"];function oV(e){let t;if("string"==typeof e)t=e;else if(this&&this.href)t=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(i4(14,!1));t=e.currentTarget.href,e.preventDefault()}let r=oq(window.location.href),n=oq(t);0===t.indexOf("#")?window.location.hash=n.hash:r.host!==n.host&&n.host?window.location.href=t:n.pathname===r.pathname&&n.search===r.search?window.location.hash=n.hash:window.history.pushState(null,null,t)}function oU(e){if(e){let t=e[0].type;oB.indexOf(t)>=0&&oF[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function oW(){al([],arguments)}function oz(e,t){return function(){let r=window.location.href,n=e.apply(this,arguments),o=window.location.href;return i&&r===o||window.dispatchEvent(function(e,t){let r;try{r=new PopStateEvent("popstate",{state:e})}catch(t){(r=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return r.singleSpa=!0,r.singleSpaTrigger=t,r}(window.history.state,t)),n}}let oK=null,oH=!1;function oG(e){if(oH)throw Error(i4(43,!1));i=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,oH=!0,oK=window.history.replaceState,window.addEventListener("hashchange",oW),window.addEventListener("popstate",oW);let t=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(e,r){if(!("function"==typeof r&&oB.indexOf(e)>=0)||oh(oF[e],e=>e===r))return t.apply(this,arguments);oF[e].push(r)},window.removeEventListener=function(e,t){return"function"==typeof t&&oB.indexOf(e)>=0&&(oF[e]=oF[e].filter(e=>e!==t)),r.apply(this,arguments)},window.history.pushState=oz(window.history.pushState,"pushState"),window.history.replaceState=oz(oK,"replaceState")}function oq(e){let t=document.createElement("a");return t.href=e,t}oL&&(window.singleSpaNavigate?console.warn(i4(41,!1)):window.singleSpaNavigate=oV);let oZ=!1;function oY(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!oZ){let t=e.fn.on,r=e.fn.off;e.fn.on=function(e,r){return oJ.call(this,t,window.addEventListener,e,r,arguments)},e.fn.off=function(e,t){return oJ.call(this,r,window.removeEventListener,e,t,arguments)},oZ=!0}}function oJ(e,t,r,n,i){return"string"!=typeof r?e.apply(this,i):(r.split(/\s+/).forEach(e=>{oB.indexOf(e)>=0&&(t(e,n),r=r.replace(e,""))}),""===r.trim()?this:e.apply(this,i))}let oX={};function oQ(e){return Promise.resolve().then(()=>{let t=oX[oc(e)];if(!t)return e;if(e.status===i5)return o0(e,t),e;if(e.status===oo)return t.promise.then(()=>e);if(e.status!==oe&&e.status!==oa)return e;let r=e.status===oa?Promise.resolve():oM(e,"unload");return e.status=oo,r.then(()=>(o0(e,t),e)).catch(r=>(delete oX[oc(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,i1(r,e,os),t.reject(r),e))})}function o0(e,t){delete oX[oc(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=i5,t.resolve()}function o1(e,t,r,n){oX[oc(e)]={app:e,resolve:r,reject:n},Object.defineProperty(oX[oc(e)],"promise",{get:t})}let o2=[];function o3(){return o2.filter(ol).map(oc)}function o4(){return o2.map(oc)}function o6(e){let t=oh(o2,t=>oc(t)===e);return t?t.status:null}let o5=!1;function o9(e,t,r,n){var i,o;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(i4(39,!1));let t=["name","app","activeWhen","customProps"],r=Object.keys(e).reduce((e,r)=>t.indexOf(r)>=0?e:e.concat(r),[]);if(0!==r.length)throw Error(i4(38,!1,t.join(", "),r.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(i4(20,!1));let n=e=>"string"==typeof e||"function"==typeof e;if(!(n(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(n)))throw Error(i4(24,!1));if(!ar(e.customProps))throw Error(i4(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,t,r,n){if("string"!=typeof e||0===e.length)throw Error(i4(20,!1));if(!t)throw Error(i4(23,!1));if("function"!=typeof r)throw Error(i4(24,!1));if(!ar(n))throw Error(i4(22,!1))}(e,t,r,n),a.name=e,a.loadApp=t,a.activeWhen=r,a.customProps=n),a.loadApp="function"!=typeof(i=a.loadApp)?()=>Promise.resolve(i):i,a.customProps=a.customProps||{},s=(s=Array.isArray(o=a.activeWhen)?o:[o]).map(e=>"function"==typeof e?e:an(e)),a.activeWhen=e=>s.some(t=>t(e)),a);if(ac||o5||(o5=!0,setTimeout(()=>{ac||console.warn(i4(1,!1))},5e3)),-1!==o4().indexOf(l.name))throw Error(i4(21,!1,l.name));o2.push(of({loadErrorTime:null,status:i5,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),oL&&(oY(),al())}function o7(e=window.location){return o2.filter(t=>t.activeWhen(e)).map(oc)}function o8(e){if(0===o2.filter(t=>oc(t)===e).length)throw Error(i4(25,!1,e));return(oL?ae(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=o2.map(oc).indexOf(e);o2.splice(t,1)})}function ae(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(i4(26,!1));let r=oh(o2,t=>oc(t)===e);if(!r)throw Error(i4(27,!1,e));let n=oX[oc(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{o1(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,at(r,n.resolve,n.reject)):e=new Promise((t,n)=>{o1(r,()=>e,t,n),at(r,t,n)}),e}}function at(e,t,r){Promise.resolve().then(()=>{if(oh(o7(),t=>t===oc(e)))return as()}).then(()=>ow(e).then(oQ).then(()=>{t(),setTimeout(()=>{al()})})).catch(r)}function ar(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function an(e,t){let r=function(e,t){let r=0,n=!1,i="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let r=e[t],i=n&&"/"===r;(!n&&":"===r||i)&&o(t)}return o(e.length),RegExp(i,"i");function o(o){let a=e.slice(r,o).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(i+=n?"[^/]+/?":a,o===e.length)if(n)t&&(i+="$");else{let e=t?"":".*";i="/"===i.charAt(i.length-1)?`${i}${e}$`:`${i}(/${e})?(#.*)?$`}n=!n,r=o}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let n=e.href.replace(t,"").replace(e.search,"").split("?")[0];return r.test(n)}}let ai=!1,ao=[],aa=oL&&window.location.href;function as(){return al()}function al(e=[],t,r=!1){let n,i,o,a,s;if(ai)return new Promise((e,r)=>{ao.push({resolve:e,reject:r,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(n=[],i=[],o=[],a=[],s=(new Date).getTime(),o2.forEach(e=>{let t=e.status!==os&&ou(e);switch(e.status){case oa:t&&s-e.loadErrorTime>=200&&o.push(e);break;case i5:case i9:t&&o.push(e);break;case i7:case oe:!t&&oX[oc(e)]?n.push(e):t&&a.push(e);break;case or:t||i.push(e)}}),{appsToUnload:n,appsToUnmount:i,appsToLoad:o,appsToMount:a}),p,f=[],h=aa,m=aa=window.location.href;return ac?(ai=!0,p=l.concat(c,u,d),Promise.resolve().then(()=>(w(0===p.length?"before-no-app-change":"before-app-change",b(!0)),w("before-routing-event",b(!0,{cancelNavigation:y})),Promise.all(f).then(r=>{if(r.some(e=>e))return oK.call(window.history,history.state,"",h.substring(location.origin.length)),aa=location.href,ai=!1,al(e,t,!0);let n=l.map(oQ),i=Promise.all(u.map(ow).map(e=>e.then(oQ)).concat(n));i.then(()=>{w("before-mount-routing-event",b(!0))},e=>{throw e});let o=c.map(e=>o$(e).then(e=>au(e,i))),a=d.filter(e=>0>c.indexOf(e)).map(e=>au(e,i));return i.catch(e=>{throw v(),e}).then(()=>(v(),Promise.all(o.concat(a)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(g).then(()=>{},e=>{throw e})))})))):(p=c,Promise.resolve().then(()=>Promise.all(c.map(o$)).then(v).then(()=>[]).catch(e=>{throw v(),e}).finally(()=>{})));function y(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(t.catch(e=>(console.warn(Error(i4(42,!1))),console.warn(e),!1)))}function g(){let t=o3();e.forEach(e=>e.resolve(t));try{w(0===p.length?"no-app-change":"app-change",b()),w("routing-event",b())}catch(e){setTimeout(()=>{throw e})}if(ai=!1,ao.length>0){let e=ao;ao=[],al(e)}return t}function v(){r||(e.forEach(e=>{oU(e.eventArguments)}),oU(t))}function b(e=!1,r){let n={},i={[or]:[],[oe]:[],[i5]:[],[os]:[]};e?(c.concat(d).forEach((e,t)=>{a(e,or)}),l.forEach(e=>{a(e,i5)}),u.forEach(e=>{a(e,oe)})):p.forEach(e=>{a(e)});let o={detail:{newAppStatuses:n,appsByNewStatus:i,totalAppChanges:p.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return r&&of(o.detail,r),o;function a(e,t){let r=oc(e);t=t||o6(r),n[r]=t,(i[t]=i[t]||[]).push(r)}}function w(e,t){r||window.dispatchEvent(new iQ(`single-spa:${e}`,t))}}function au(e,t){return ou(e)?ob(e).then(e=>t.then(()=>ou(e)?oE(e):e)):t.then(()=>e)}let ac=!1;function ad(e){ac=!0,oL&&(oG(e),al())}function ap(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,"");return af(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t}).replace(/^\/\//,"/")}function af(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function ah({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=ap(e,t).replace(window.location.origin,"");n.startsWith(r)?oV(n):window.location.assign(n)}oL&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...o2]},reroute:al,NOT_LOADED:i5,toLoadPromise:o$,toBootstrapPromise:ob,unregisterApplication:o8,getProfilerData:function(){return ov}});let am="openmrs:history";function ay(e){let t=JSON.parse(sessionStorage.getItem(am)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(am,JSON.stringify(t))}function ag(){0===JSON.parse(sessionStorage.getItem(am)??"[]").length&&document.referrer&&ay(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=av();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(am,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?ab({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&ay(window.location.href)})}function av(){return JSON.parse(sessionStorage.getItem(am)??"[]")}function ab({toUrl:e}){let t=av(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);ah({to:t[r]}),sessionStorage.setItem(am,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function aw(){sessionStorage.removeItem(am)}let a_="${openmrsSpaBase}/login",ax={redirectAuthFailure:{enabled:{_type:nN.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nN.String,_default:a_,_validators:[iU.isUrl],_description:"The url to which users will be redirected when they are logged out. If set to blank, the `location` header from the response will be used."},errors:{_type:nN.Array,_default:[401],_elements:{_type:nN.Number,_validators:[iU.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nN.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}},followRedirects:{_type:nN.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function aE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let aS="/ws/rest/v1",aD="/ws/fhir2/R4",aO=`${aS}/session`;function aP(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function aC(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let r=aP(e);if(t.headers||(t.headers={}),eq(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept,e.startsWith(aS)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(aD)){let e=new URL(r,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),r=e.toString())}let n=Error();return window.fetch(r,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:i}=await im("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(i&&t&&(r===aP(aO)||204===e.status)&&ah({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return r===aP(aO)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(aw(),ah({to:t.url||e.headers.get("location")||a_}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let i=t;try{i=JSON.parse(t)}catch(e){}throw new aj(r,e,i,n)},t=>{throw new aj(r,e,null,n)})})}function ak(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let r=new AbortController;return t.signal=r.signal,new eL(n=>{let i=!1;return aC(e,t).then(e=>{i=!0,n.next(e),n.complete()},e=>{i=!0,n.error(e)}),()=>{i||r.abort()}})}class aj extends Error{constructor(e,t,r,n){super(),aE(this,"response",void 0),aE(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${n.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
|
-
${this.stack}`}}let aT=Z("session",{loaded:!1,session:null}),aR=0;function aA(e={includeAuthStatus:!0}){return(aR<Date.now()-6e4||!aT.getState().loaded)&&aI(),new eL(t=>{let r=r=>{r.loaded&&(e.includeAuthStatus?t.next(r.session):t.next(r.session?.user))};return r(aT.getState()),aT.subscribe(r)})}function aN(){return(aR<Date.now()-6e4||!aT.getState().loaded)&&aI(),aT}function aM(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function aI(e,t){aR=Date.now();let r={};return e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),aW(aC(aO,{headers:r}))}function a$(){aT.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function aL(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!ee(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!ee(n.privileges.find(t=>e===t.display))):(ee(r)||console.error(`Could not understand privileges "${r}"`),!0))||!ee(t.roles.find(e=>"System Developer"===e.display))}function aF(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(aT.getState()),e||(t=aT.subscribe(n))})}function aB(){return new Promise((e,t)=>{aA().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function aV(e,t){return aW(aC(aO,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function aU(e,t,r){return r||(r=new AbortController),await aC(`${aS}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),aI()}function aW(e){return new Promise((t,r)=>{e.then(e=>{let n;"object"==typeof e?.data?(n={loaded:!0,session:e.data},aT.setState(n),t(n)):(n={loaded:!1,session:null},aT.setState(n),r(n))}).catch(e=>{I(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};aT.setState(t),r(t)})})}function az(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}aT.subscribe(e=>{e.loaded&&e.session&&aM(e.session)});let aK={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function aH(){is("@openmrs/esm-api",ax),aI()}let aG={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",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",localVersion:"Local Build",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}}",prereleaseVersion:"Prerelease",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"},aq=e=>"string"==typeof e,aZ=()=>{let e,t,r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r},aY=e=>null==e?"":""+e,aJ=/###/g,aX=e=>e&&e.indexOf("###")>-1?e.replace(aJ,"."):e,aQ=e=>!e||aq(e),a0=(e,t,r)=>{let n=aq(t)?t.split("."):t,i=0;for(;i<n.length-1;){if(aQ(e))return{};let t=aX(n[i]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return aQ(e)?{}:{obj:e,k:aX(n[i])}},a1=(e,t,r)=>{let{obj:n,k:i}=a0(e,t,Object);if(void 0!==n||1===t.length){n[i]=r;return}let o=t[t.length-1],a=t.slice(0,t.length-1),s=a0(e,a,Object);for(;void 0===s.obj&&a.length;)o=`${a[a.length-1]}.${o}`,s=a0(e,a=a.slice(0,a.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${o}`]&&(s.obj=void 0);s.obj[`${s.k}.${o}`]=r},a2=(e,t)=>{let{obj:r,k:n}=a0(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},a3=(e,t,r)=>{for(let n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?aq(e[n])||e[n]instanceof String||aq(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):a3(e[n],t[n],r):e[n]=t[n]);return e};var a4={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let a6=e=>aq(e)?e.replace(/[&<>"'\/]/g,e=>a4[e]):e,a5=[" ",",","?","!",";"],a9=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(void 0!==t)return t;let r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}(20),a7=(e,t,r=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let n=t.split(r),i=e;for(let e=0;e<n.length;){let t;if(!i||"object"!=typeof i)return;let o="";for(let a=e;a<n.length;++a)if(a!==e&&(o+=r),o+=n[a],void 0!==(t=i[o])){if(["string","number","boolean"].indexOf(typeof t)>-1&&a<n.length-1)continue;e+=a-e+1;break}i=t}return i},a8=e=>e?.replace("_","-"),se={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class st{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||se,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,r,n){return n&&!this.debug?null:(aq(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new st(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new st(this.logger,e)}}var sr=new st;class sn{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let r=this.observers[e].get(t)||0;this.observers[e].set(t,r+1)}),this}off(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,r])=>{for(let n=0;n<r;n++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,n])=>{for(let i=0;i<n;i++)r.apply(r,[e,...t])})}}class si extends sn{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,n={}){let i,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,a=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?i=e.split("."):(i=[e,t],r&&(Array.isArray(r)?i.push(...r):aq(r)&&o?i.push(...r.split(o)):i.push(r)));let s=a2(this.data,i);return(!s&&!t&&!r&&e.indexOf(".")>-1&&(e=i[0],t=i[1],r=i.slice(2).join(".")),!s&&a&&aq(r))?a7(this.data?.[e]?.[t],r,o):s}addResource(e,t,r,n,i={silent:!1}){let o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,a=[e,t];r&&(a=a.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(a=e.split("."),n=t,t=a[1]),this.addNamespaces(t),a1(this.data,a,n),i.silent||this.emit("added",e,t,r,n)}addResources(e,t,r,n={silent:!1}){for(let n in r)(aq(r[n])||Array.isArray(r[n]))&&this.addResource(e,t,n,r[n],{silent:!0});n.silent||this.emit("added",e,t,r)}addResourceBundle(e,t,r,n,i,o={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),n=r,r=t,t=a[1]),this.addNamespaces(t);let s=a2(this.data,a)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),n?a3(s,r,i):s={...s,...r},a1(this.data,a,s),o.silent||this.emit("added",e,t,r)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var so={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,n,i){return e.forEach(e=>{t=this.processors[e]?.process(t,r,n,i)??t}),t}};let sa=Symbol("i18next/PATH_KEY");function ss(e,t){let r,n,i,{[sa]:o}=e((n=[],(i=Object.create(null)).get=(e,t)=>(r?.revoke?.(),t===sa)?n:(n.push(t),(r=Proxy.revocable(e,i)).proxy),Proxy.revocable(Object.create(null),i).proxy));return o.join(t?.keySeparator??".")}let sl={},su=e=>!aq(e)&&"boolean"!=typeof e&&"number"!=typeof e;class sc extends sn{constructor(e,t={}){super(),((e,t,r)=>{e.forEach(e=>{t[e]&&(r[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=sr.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let r={...t};if(null==e)return!1;let n=this.resolve(e,r);if(n?.res===void 0)return!1;let i=su(n.res);return!1!==r.returnObjects||!i}extractFromKey(e,t){let r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");let n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],o=r&&e.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,r)=>{t=t||"",r=r||"";let n=a5.filter(e=>0>t.indexOf(e)&&0>r.indexOf(e));if(0===n.length)return!0;let i=a9.getRegExp(`(${n.map(e=>"?"===e?"\\?":e).join("|")})`),o=!i.test(e);if(!o){let t=e.indexOf(r);t>0&&!i.test(e.substring(0,t))&&(o=!0)}return o})(e,r,n);if(o&&!a){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:aq(i)?[i]:i};let o=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(o[0])>-1)&&(i=o.shift()),e=o.join(n)}return{key:e,namespaces:aq(i)?[i]:i}}translate(e,t,r){let n="object"==typeof t?{...t}:t;if("object"!=typeof n&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof n&&(n={...n}),n||(n={}),null==e)return"";"function"==typeof e&&(e=ss(e,{...this.options,...n})),Array.isArray(e)||(e=[String(e)]);let i=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],n),l=s[s.length-1],u=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c?.toLowerCase()==="cimode")return d?i?{res:`${l}${u}${a}`,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${u}${a}`:i?{res:a,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a;let p=this.resolve(e,n),f=p?.res,h=p?.usedKey||a,m=p?.exactUsedKey||a,y=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,g=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==n.count&&!aq(n.count),b=sc.hasDefaultValue(n),w=v?this.pluralResolver.getSuffix(c,n.count,n):"",x=n.ordinal&&v?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",E=v&&!n.ordinal&&0===n.count,S=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${w}`]||n[`defaultValue${x}`]||n.defaultValue,D=f;g&&!f&&b&&(D=S);let O=su(D),P=Object.prototype.toString.apply(D);if(g&&D&&O&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(P)&&!(aq(y)&&Array.isArray(D))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,D,{...n,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return i?(p.res=e,p.usedParams=this.getUsedParamsDetails(n),p):e}if(o){let e=Array.isArray(D),t=e?[]:{},r=e?m:h;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let i=`${r}${o}${e}`;b&&!f?t[e]=this.translate(i,{...n,defaultValue:su(S)?S[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(i,{...n,joinArrays:!1,ns:s}),t[e]===i&&(t[e]=D[e])}f=t}}else if(g&&aq(y)&&Array.isArray(f))(f=f.join(y))&&(f=this.extendTranslation(f,e,n,r));else{let t=!1,i=!1;!this.isValidLookup(f)&&b&&(t=!0,f=S),this.isValidLookup(f)||(i=!0,f=a);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&i?void 0:f,d=b&&S!==f&&this.options.updateMissing;if(i||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,a,d?S:f),o){let e=this.resolve(a,{...n,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let r=0;r<t.length;r++)e.push(t[r]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(n.lng||this.language):e.push(n.lng||this.language);let r=(e,t,r)=>{let i=b&&r!==f?r:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,i,d,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,i,d,n),this.emit("missingKey",e,l,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,n);E&&n[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{r([e],a+t,n[`defaultValue${t}`]||S)})}):r(e,a,S))}f=this.extendTranslation(f,e,n,p,r),i&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${l}${u}${a}`),(i||t)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,t?f:void 0,n))}return i?(p.res=f,p.usedParams=this.getUsedParamsDetails(n),p):f}extendTranslation(e,t,r,n,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){let o;r.interpolation&&this.interpolator.init({...r,...{interpolation:{...this.options.interpolation,...r.interpolation}}});let a=aq(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=r.replace&&!aq(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,r.lng||this.language||n.usedLng,r),a){let t=e.match(this.interpolator.nestingRegexp);o<(t&&t.length)&&(r.nest=!1)}!r.lng&&n&&n.res&&(r.lng=this.language||n.usedLng),!1!==r.nest&&(e=this.interpolator.nest(e,(...e)=>i?.[0]!==e[0]||r.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),r)),r.interpolation&&this.interpolator.reset()}let o=r.postProcess||this.options.postProcess,a=aq(o)?[o]:o;return null!=e&&a?.length&&!1!==r.applyPostProcessor&&(e=so.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,n,i,o,a;return aq(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(r))return;let s=this.extractFromKey(e,t),l=s.key;n=l;let u=s.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let c=void 0!==t.count&&!aq(t.count),d=c&&!t.ordinal&&0===t.count,p=void 0!==t.context&&(aq(t.context)||"number"==typeof t.context)&&""!==t.context,f=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(a=e,!sl[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(sl[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${n}" 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(n=>{let a;if(this.isValidLookup(r))return;o=n;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,n,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(n,t.count,t));let r=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(i)&&s.push(l+e.replace(i,this.options.pluralSeparator)),s.push(l+e),d&&s.push(l+r)),p){let n=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(n),c&&(t.ordinal&&0===e.indexOf(i)&&s.push(n+e.replace(i,this.options.pluralSeparator)),s.push(n+e),d&&s.push(n+r))}}for(;a=s.pop();)this.isValidLookup(r)||(i=a,r=this.getResource(n,e,a,t))}))})}),{res:r,usedKey:n,exactUsedKey:i,usedLng:o,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,r,n={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}getUsedParamsDetails(e={}){let t=e.replace&&!aq(e.replace),r=t?e.replace:e;if(t&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!t)for(let e of(r={...r},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete r[e];return r}static hasDefaultValue(e){let t="defaultValue";for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}class sd{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=sr.create("languageUtils")}getScriptPartFromCode(e){if(!(e=a8(e))||0>e.indexOf("-"))return null;let t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(!(e=a8(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(aq(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return(t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t)?t:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let t;return e?(e.forEach(e=>{if(t)return;let r=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let r=this.getScriptPartFromCode(e);if(this.isSupportedCode(r))return t=r;let n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(e=>{if(e===n||!(0>e.indexOf("-")&&0>n.indexOf("-"))&&(e.indexOf("-")>0&&0>n.indexOf("-")&&e.substring(0,e.indexOf("-"))===n||0===e.indexOf(n)&&n.length>1))return e})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),aq(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}toResolveHierarchy(e,t){let r=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),n=[],i=e=>{e&&(this.isSupportedCode(e)?n.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return aq(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&i(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&i(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&i(this.getLanguagePartFromCode(e))):aq(e)&&i(this.formatLanguageCode(e)),r.forEach(e=>{0>n.indexOf(e)&&i(this.formatLanguageCode(e))}),n}}let sp={zero:0,one:1,two:2,few:3,many:4,other:5},sf={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class sh{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=sr.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let r,n=a8("dev"===e?"en":e),i=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:n,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];try{r=new Intl.PluralRules(n,{type:i})}catch(i){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),sf;if(!e.match(/-|_/))return sf;let n=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(n,t)}return this.pluralRulesCache[o]=r,r}needsPlural(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,r={}){return this.getSuffixes(e,r).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let r=this.getRule(e,t);return(r||(r=this.getRule("dev",t)),r)?r.resolvedOptions().pluralCategories.sort((e,t)=>sp[e]-sp[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,r={}){let n=this.getRule(e,r);return n?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${n.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,r))}}let sm=(e,t,r,n=".",i=!0)=>{let o,a=void 0!==(o=a2(e,r))?o:a2(t,r);return!a&&i&&aq(r)&&void 0===(a=a7(e,r,n))&&(a=a7(t,r,n)),a};class sy{constructor(e={}){this.logger=sr.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:t,escapeValue:r,useRawValueToEscape:n,prefix:i,prefixEscaped:o,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:p,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:y,alwaysFormat:g}=e.interpolation;this.escape=void 0!==t?t:a6,this.escapeValue=void 0===r||r,this.useRawValueToEscape=void 0!==n&&n,this.prefix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):o||"{{",this.suffix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=d?d.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):p||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=y||1e3,this.alwaysFormat=void 0!==g&&g,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,r,n){let i,o,a,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let i=sm(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,r,{...n,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),o=i.shift().trim(),a=i.join(this.formatSeparator).trim();return this.format(sm(t,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),a,r,{...n,...t,interpolationkey:o})};this.resetRegExp();let u=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(t=>{for(a=0;i=t.regex.exec(e);){let r=i[1].trim();if(void 0===(o=l(r)))if("function"==typeof u){let t=u(e,i,n);o=aq(t)?t:""}else if(n&&Object.prototype.hasOwnProperty.call(n,r))o="";else if(c){o=i[0];continue}else this.logger.warn(`missed to pass in variable ${r} for interpolating ${e}`),o="";else aq(o)||this.useRawValueToEscape||(o=aY(o));let s=t.safeValue(o);if(e=e.replace(i[0],s),c?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++a>=this.maxReplaces)break}}),e}nest(e,t,r={}){let n,i,o,a=(e,t)=>{let r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;let n=e.split(RegExp(`${r}[ ]*{`)),i=`{${n[1]}`;e=n[0];let a=(i=this.interpolate(i,o)).match(/'/g),s=i.match(/"/g);((a?.length??0)%2!=0||s)&&s.length%2==0||(i=i.replace(/'/g,'"'));try{o=JSON.parse(i),t&&(o={...t,...o})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${r}${i}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,e};for(;n=this.nestingRegexp.exec(e);){let s=[];(o=(o={...r}).replace&&!aq(o.replace)?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;let l=/{.*}/.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==l&&(s=n[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,l)),(i=t(a.call(this,n[1].trim(),o),o))&&n[0]===e&&!aq(i))return i;aq(i)||(i=aY(i)),i||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),i=""),s.length&&(i=s.reduce((e,t)=>this.format(e,t,r.lng,{...r,interpolationkey:n[1].trim()}),i.trim())),e=e.replace(n[0],i),this.regexp.lastIndex=0}return e}}let sg=e=>{let t={};return(r,n,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});let a=n+JSON.stringify(o),s=t[a];return s||(s=e(a8(n),i),t[a]=s),s(r)}},sv=e=>(t,r,n)=>e(a8(r),n)(t);class sb{constructor(e={}){this.logger=sr.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let r=t.cacheInBuiltFormats?sg:sv;this.formats={number:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t});return e=>r.format(e)}),currency:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>r.format(e)}),datetime:r((e,t)=>{let r=new Intl.DateTimeFormat(e,{...t});return e=>r.format(e)}),relativetime:r((e,t)=>{let r=new Intl.RelativeTimeFormat(e,{...t});return e=>r.format(e,t.range||"day")}),list:r((e,t)=>{let r=new Intl.ListFormat(e,{...t});return e=>r.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=sg(t)}format(e,t,r,n={}){let i=t.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&0>i[0].indexOf(")")&&i.find(e=>e.indexOf(")")>-1)){let e=i.findIndex(e=>e.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,e)].join(this.formatSeparator)}return i.reduce((e,t)=>{let{formatName:i,formatOptions:o}=(e=>{let t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){let n=e.split("(");t=n[0].toLowerCase().trim();let i=n[1].substring(0,n[1].length-1);"currency"===t&&0>i.indexOf(":")?r.currency||(r.currency=i.trim()):"relativetime"===t&&0>i.indexOf(":")?r.range||(r.range=i.trim()):i.split(";").forEach(e=>{if(e){let[t,...n]=e.split(":"),i=n.join(":").trim().replace(/^'+|'+$/g,""),o=t.trim();r[o]||(r[o]=i),"false"===i&&(r[o]=!1),"true"===i&&(r[o]=!0),isNaN(i)||(r[o]=parseInt(i,10))}})}return{formatName:t,formatOptions:r}})(t);if(this.formats[i]){let t=e;try{let a=n?.formatParams?.[n.interpolationkey]||{},s=a.locale||a.lng||n.locale||n.lng||r;t=this.formats[i](e,s,{...o,...n,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}}class sw extends sn{constructor(e,t,r,n={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=n,this.logger=sr.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,n.backend,n)}queueLoad(e,t,r,n){let i={},o={},a={},s={};return e.forEach(e=>{let n=!0;t.forEach(t=>{let a=`${e}|${t}`;!r.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===o[a]&&(o[a]=!0):(this.state[a]=1,n=!1,void 0===o[a]&&(o[a]=!0),void 0===i[a]&&(i[a]=!0),void 0===s[t]&&(s[t]=!0)))}),n||(a[e]=!0)}),(Object.keys(i).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(i),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,t,r){let n=e.split("|"),i=n[0],o=n[1];t&&this.emit("failedLoading",i,o,t),!t&&r&&this.store.addResourceBundle(i,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&r&&(this.state[e]=0);let a={};this.queue.forEach(r=>{((e,t,r,n)=>{let{obj:i,k:o}=a0(e,t,Object);i[o]=i[o]||[],i[o].push(r)})(r.loaded,[i],o),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(e=>{a[e]||(a[e]={});let t=r.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,r,n=0,i=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:n,wait:i,callback:o});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&&n<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,r,n+1,2*i,o)},i):o(a,s)},s=this.backend[r].bind(this.backend);if(2===s.length){try{let r=s(e,t);r&&"function"==typeof r.then?r.then(e=>a(null,e)).catch(a):a(null,r)}catch(e){a(e)}return}return s(e,t,a)}prepareLoading(e,t,r={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();aq(e)&&(e=this.languageUtils.toResolveHierarchy(e)),aq(t)&&(t=[t]);let i=this.queueLoad(e,t,r,n);if(!i.toLoad.length)return i.pending.length||n(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,r){this.prepareLoading(e,t,{},r)}reload(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}loadOne(e,t=""){let r=e.split("|"),n=r[0],i=r[1];this.read(n,i,"read",void 0,void 0,(r,o)=>{r&&this.logger.warn(`${t}loading namespace ${i} for language ${n} failed`,r),!r&&o&&this.logger.log(`${t}loaded namespace ${i} for language ${n}`,o),this.loaded(e,r,o)})}saveMissing(e,t,r,n,i,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${r}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=r&&""!==r){if(this.backend?.create){let s={...o,isUpdate:i},l=this.backend.create.bind(this.backend);if(l.length<6)try{let i;(i=5===l.length?l(e,t,r,n,s):l(e,t,r,n))&&"function"==typeof i.then?i.then(e=>a(null,e)).catch(a):a(null,i)}catch(e){a(e)}else l(e,t,r,n,a,s)}e&&e[0]&&this.store.addResource(e[0],t,r,n)}}}let s_=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),aq(e[1])&&(t.defaultValue=e[1]),aq(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let r=e[3]||e[2];Object.keys(r).forEach(e=>{t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),sx=e=>(aq(e.ns)&&(e.ns=[e.ns]),aq(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),aq(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),sE=()=>{};class sS extends sn{constructor(e={},t){if(super(),this.options=sx(e),this.services={},this.logger=sr,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{"function"==typeof e[t]&&(e[t]=e[t].bind(e))})})(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(aq(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let r=s_();this.options={...r,...this.options,...sx(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let n=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?sr.init(n(this.modules.logger),this.options):sr.init(null,this.options),e=this.modules.formatter?this.modules.formatter:sb;let t=new sd(this.options);this.store=new si(this.options.resources,this.options);let i=this.services;i.logger=sr,i.resourceStore=this.store,i.languageUtils=t,i.pluralResolver=new sh(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(i.formatter=n(e),i.formatter.init&&i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new sy(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new sw(n(this.modules.backend),i.resourceStore,i,this.options),i.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(i.languageDetector=n(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=n(this.modules.i18nFormat),i.i18nFormat.init&&i.i18nFormat.init(this)),this.translator=new sc(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=sE),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let i=aZ(),o=()=>{let e=(e,r)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),i.resolve(r),t(e,r)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),i}loadResources(e,t=sE){let r=t,n=aq(e)?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(n?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return r();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};n?t(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,t,r){let n=aZ();return"function"==typeof e&&(r=e,e=void 0),"function"==typeof t&&(r=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),r||(r=sE),this.services.backendConnector.reload(e,t,e=>{n.resolve(),r(e)}),n}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&so.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let r=aZ();this.emit("languageChanging",e);let n=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,o)=>{o?this.isLanguageChangingTo===e&&(n(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,r.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},o=t=>{e||t||!this.services.languageDetector||(t=[]);let r=aq(t)?t:t&&t[0],o=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(aq(t)?[t]:t);o&&(this.language||n(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,e=>{i(e,o)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),r}getFixedT(e,t,r){let n=(e,t,...i)=>{let o,a;(o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(i)):{...t}).lng=o.lng||n.lng,o.lngs=o.lngs||n.lngs,o.ns=o.ns||n.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||r||n.keyPrefix);let s=this.options.keySeparator||".";return o.keyPrefix&&Array.isArray(e)?a=e.map(e=>("function"==typeof e&&(e=ss(e,{...this.options,...t})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=ss(e,{...this.options,...t})),a=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(a,o)};return aq(e)?n.lng=e:n.lngs=e,n.ns=t,n.keyPrefix=r,n}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let r=t.lng||this.resolvedLanguage||this.languages[0],n=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;let o=(e,t)=>{let r=this.services.backendConnector.state[`${e}|${t}`];return -1===r||0===r||2===r};if(t.precheck){let e=t.precheck(this,o);if(void 0!==e)return e}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!n||o(i,e)))}loadNamespaces(e,t){let r=aZ();return this.options.ns?(aq(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}loadLanguages(e,t){let r=aZ();aq(e)&&(e=[e]);let n=this.options.preload||[],i=e.filter(e=>0>n.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=n.concat(i),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let t=this.services?.languageUtils||new sd(s_());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new sS(e,t)}cloneInstance(e={},t=sE){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let n={...this.options,...e,isClone:!0},i=new sS(n);return(void 0!==e.debug||void 0!==e.prefix)&&(i.logger=i.logger.clone(e)),["store","services","language"].forEach(e=>{i[e]=this[e]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},r&&(i.store=new si(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((r,n)=>(r[n]={...e[t][n]},r),e[t]),e),{}),n),i.services.resourceStore=i.store),i.translator=new sc(i.services,n),i.translator.on("*",(e,...t)=>{i.emit(e,...t)}),i.init(n,t),i.translator.options=n,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let sD=sS.createInstance();sD.createInstance=sS.createInstance,sD.createInstance,sD.dir,sD.init,sD.loadResources,sD.reloadResources,sD.use,sD.changeLanguage,sD.getFixedT,sD.t,sD.exists,sD.setDefaultNamespace,sD.hasLoadedNamespace,sD.loadNamespaces,sD.loadLanguages;let sO=sD.default||sD;function sP(e,t,r,n){return sO.t(t,{ns:e,defaultValue:r,...n})}function sC(e,t,r){return aG[e]?sP("core",e,t??aG[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}sO.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let sk="import-map-override:",sj="import-map-overrides-disabled",sT="import-map-overrides:change",sR=!1,sA=null,sN=null;async function sM(){return sN??(sN=sI().then(({map:e,complete:t})=>(t||(sN=null),e))),sN}async function sI(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let i=e[n];try{if(i.src){let e=await fetch(i.src);if(!e.ok)throw Error(`Request for ${i.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else i.textContent&&t.push(JSON.parse(i.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:s$(t),complete:r}}function s$(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function sL(){let e={};try{let t=sW();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(sk)){let r=n.slice(sk.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function sF(){let e=await sM();return sR?s$([e,sA??sL()]):e}async function sB(){return sM()}async function sV(){return sR?s$([await sM(),sL()]):sM()}function sU(e){if(!sR)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sk)){let t=localStorage.getItem(r);t&&(e[r.slice(sk.length)]=t)}}return{imports:e}}return sL()}function sW(){if(!sR)return[];try{let e=localStorage.getItem(sj);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function sz(e){return!!sR&&sW().includes(e)}function sK(e,t){if(!sR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sk+e,t),window.dispatchEvent(new CustomEvent(sT))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sH(e){if(!sR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sk+e);let t=sW().filter(t=>t!==e);t.length>0?localStorage.setItem(sj,JSON.stringify(t)):localStorage.removeItem(sj),window.dispatchEvent(new CustomEvent(sT))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sG(){if(!sR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(sk)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(sj),window.dispatchEvent(new CustomEvent(sT))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function sq(e){if(!sR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=sW().filter(t=>t!==e);t.length>0?localStorage.setItem(sj,JSON.stringify(t)):localStorage.removeItem(sj),window.dispatchEvent(new CustomEvent(sT))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let sZ=!1;function sY(){!sZ&&(sZ=!0,(sR="development"===window.spaEnv)&&(sA=sL()))}function sJ(e){return e.replace(/[\/\-@]/g,"_")}async function sX(e,t="./start",n){var i;let o,a=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([sQ(e,n?.importMap),new Promise((t,r)=>{o=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=a)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},a)})]),o&&clearTimeout(o);let s=sJ(e),l=window[s];if(!("object"==typeof(i=l)&&null!==i&&"init"in i&&"function"==typeof i.init&&"get"in i&&"function"==typeof i.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function sQ(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=sJ(e);if(!window[r]){let r=t??await s0();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let i=e in sU().imports;try{return await function(e){var t;let r=(t=window)[s1]??(t[s1]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let i=document.createElement("script");i.src=e,i.type="text/javascript",i.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function a(){clearTimeout(o),i.removeEventListener("load",s),i.removeEventListener("error",l)}function s(){a(),t()}function l(t){a(),r.delete(e),i.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}i.addEventListener("load",s),i.addEventListener("error",l),document.head.appendChild(i)});return r.set(e,o),o}(n)}catch(e){return i&&T({kind:"error",title:sC("scriptLoadingFailed","Error: Script failed to load"),description:sC("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:sC("resetOverrides","Reset overrides"),onActionButtonClick(){sG(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function s0(){return sF()}let s1=Symbol.for("__openmrs_script_loading");function s2(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function s3(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&s2(t))}let s4="openmrs-routes:",s6="openmrs-routes:change",s5=!1,s9=null,s7=null;async function s8(){return s7??(s7=le().then(({map:e,complete:t})=>(t||(s7=null),e))),s7}async function le(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let i=e[n];try{let e;if(i.src){let t=await fetch(i.src);if(!t.ok)throw Error(`Request for ${i.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else i.textContent&&(e=JSON.parse(i.textContent));e&&s3(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:lt(t),complete:r}}function lt(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function lr(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(s4)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(s4.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(s2(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(s2(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function ln(){let e=await s8();return s5?lt([e,s9??await lr()]):e}async function li(){return s8()}async function lo(){return s5?lt([await s8(),await lr()]):s8()}function la(){if(!s5)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(s4)){let t=localStorage.getItem(r);t&&(e[r.slice(s4.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function ls(e,t){if(!s5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(s4+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!s2(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(s4+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(s4+e,JSON.stringify(t.toString()));else{if(!s2(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(s4+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(s6))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function ll(e){if(!s5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(s4+e),window.dispatchEvent(new CustomEvent(s6))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function lu(){if(!s5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(s4)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(s6))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let lc=null;function ld(){return lc||(lc=(s5="development"===window.spaEnv)?lr().then(e=>{s9=e}):Promise.resolve())}let lp=`${aS}/attachment`;function lf(e,t){return aC(`${lp}/${e}`,{signal:t.signal})}function lh(e,t,r,n){return aC(lm(e,t,n),{signal:r.signal})}function lm(e,t,r){return r?`${lp}?patient=${e}&encounter=${r}`:`${lp}?patient=${e}&includeEncounterless=${t}`}async function ly(e,t,r){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),r&&n.append("encounter",r),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),aC(`${lp}`,{method:"POST",body:n})}function lg(e,t){return aC(`${lp}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function lv(e,t){return new Promise(function(r){var n=new MessageChannel;n.port1.onmessage=function(e){r(e.data)},e.postMessage(t,[n.port2])})}function lb(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function lw(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var l_=function(){var e=this;this.promise=new Promise(function(t,r){e.resolve=t,e.reject=r})};function lx(e,t){var r=location.href;return new URL(e,r).href===new URL(t,r).href}var lE=function(e,t){this.type=e,Object.assign(this,t)};function lS(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function lD(){}var lO={type:"SKIP_WAITING"};function lP(e,t){if(!t)return e&&e.then?e.then(lD):Promise.resolve()}var lC=function(e){function t(t,r){var n,i;return void 0===r&&(r={}),(n=e.call(this)||this).nn={},n.tn=0,n.rn=new l_,n.en=new l_,n.on=new l_,n.un=0,n.an=new Set,n.cn=function(){var e=n.fn,t=e.installing;n.tn>0||!lx(t.scriptURL,n.sn.toString())||performance.now()>n.un+6e4?(n.vn=t,e.removeEventListener("updatefound",n.cn)):(n.hn=t,n.an.add(t),n.rn.resolve(t)),++n.tn,t.addEventListener("statechange",n.ln)},n.ln=function(e){var t=n.fn,r=e.target,i=r.state,o=r===n.vn,a={sw:r,isExternal:o,originalEvent:e};!o&&n.mn&&(a.isUpdate=!0),n.dispatchEvent(new lE(i,a)),"installed"===i?n.wn=self.setTimeout(function(){"installed"===i&&t.waiting===r&&n.dispatchEvent(new lE("waiting",a))},200):"activating"===i&&(clearTimeout(n.wn),o||n.en.resolve(r))},n.dn=function(e){var t=n.hn,r=t!==navigator.serviceWorker.controller;n.dispatchEvent(new lE("controlling",{isExternal:r,originalEvent:e,sw:t,isUpdate:n.mn})),r||n.on.resolve(t)},i=function(e){var t=e.data,r=e.ports,i=e.source;return lS(n.getSW(),function(){n.an.has(i)&&n.dispatchEvent(new lE("message",{data:t,originalEvent:e,ports:r,sw:i}))})},n.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(i.apply(this,e))}catch(e){return Promise.reject(e)}},n.sn=t,n.nn=r,navigator.serviceWorker.addEventListener("message",n.gn),n}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var r,n,i=t.prototype;return i.register=function(e){var t=(void 0===e?{}:e).immediate,r=void 0!==t&&t;try{var n,i,o,a=this;return n=function(){if(!r&&"complete"!==document.readyState)return lP(new Promise(function(e){return window.addEventListener("load",e)}))},i=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),lS(a.bn(),function(e){a.fn=e,a.yn&&(a.hn=a.yn,a.en.resolve(a.yn),a.on.resolve(a.yn),a.yn.addEventListener("statechange",a.ln,{once:!0}));var t=a.fn.waiting;return t&&lx(t.scriptURL,a.sn.toString())&&(a.hn=t,Promise.resolve().then(function(){a.dispatchEvent(new lE("waiting",{sw:t,wasWaitingBeforeRegister:!0}))}).then(function(){})),a.hn&&(a.rn.resolve(a.hn),a.an.add(a.hn)),a.fn.addEventListener("updatefound",a.cn),navigator.serviceWorker.addEventListener("controllerchange",a.dn),a.fn})},(o=n())&&o.then?o.then(i):i(o)}catch(e){return Promise.reject(e)}},i.update=function(){try{return this.fn?lP(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},i.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},i.messageSW=function(e){try{return lS(this.getSW(),function(t){return lv(t,e)})}catch(e){return Promise.reject(e)}},i.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&lv(this.fn.waiting,lO)},i.pn=function(){var e=navigator.serviceWorker.controller;return e&&lx(e.scriptURL,this.sn.toString())?e:void 0},i.bn=function(){try{var e=this;return function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return lS(navigator.serviceWorker.register(e.sn,e.nn),function(t){return e.un=performance.now(),t})},function(e){throw e})}catch(e){return Promise.reject(e)}},r=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],lb(t.prototype,r),n&&lb(t,n),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,r=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return lw(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?lw(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=r()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function lk(e,t){if(void 0!==p)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),p;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let r=new lC(e,t);return p=r.register().then(()=>r.controlling.then(()=>r))}function lj(){return p??Promise.resolve(void 0)}let lT="x-omrs-offline-response-body",lR="x-omrs-offline-response-status",lA="x-omrs-offline-caching-strategy";async function lN(e){let t=await lj();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function lM(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function lI(){return!window.indexedDB}async function l$(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function lL(){return await l$()||await lI()||await lM()}let lF="openmrs3:offline-mode",lB="unavailable";function lV(){return{current:lB,notAvailable:"unavailable"===lB,active:"on"===lB}}function lU(e){"unavailable"!==lB&&"unavailable"!==e&&(localStorage.setItem(lF,"on"===e?"active":"disabled"),lB=e)}async function lW(){await lL()||(lB="active"===localStorage.getItem(lF)?"on":"off"),navigator.onLine}let lz="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,lK=Object.keys,lH=Array.isArray;function lG(e,t){return"object"!=typeof t||lK(t).forEach(function(r){e[r]=t[r]}),e}"u"<typeof Promise||lz.Promise||(lz.Promise=Promise);let lq=Object.getPrototypeOf,lZ={}.hasOwnProperty;function lY(e,t){return lZ.call(e,t)}function lJ(e,t){"function"==typeof t&&(t=t(lq(e))),("u"<typeof Reflect?lK:Reflect.ownKeys)(t).forEach(r=>{lQ(e,r,t[r])})}let lX=Object.defineProperty;function lQ(e,t,r,n){lX(e,t,lG(r&&lY(r,"get")&&"function"==typeof r.get?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function l0(e){return{from:function(t){return e.prototype=Object.create(t.prototype),lQ(e.prototype,"constructor",e),{extend:lJ.bind(null,e.prototype)}}}}let l1=Object.getOwnPropertyDescriptor;function l2(e,t){let r;return l1(e,t)||(r=lq(e))&&l2(r,t)}let l3=[].slice;function l4(e,t,r){return l3.call(e,t,r)}function l6(e,t){return t(e)}function l5(e){if(!e)throw Error("Assertion Failed")}function l9(e){lz.setImmediate?setImmediate(e):setTimeout(e,0)}function l7(e,t){return e.reduce((e,r,n)=>{var i=t(r,n);return i&&(e[i[0]]=i[1]),e},{})}function l8(e,t){if("string"==typeof t&&lY(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var r=[],n=0,i=t.length;n<i;++n){var o=l8(e,t[n]);r.push(o)}return r}var a=t.indexOf(".");if(-1!==a){var s=e[t.substr(0,a)];return null==s?void 0:l8(s,t.substr(a+1))}}function ue(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){l5("string"!=typeof r&&"length"in r);for(var n=0,i=t.length;n<i;++n)ue(e,t[n],r[n])}else{var o=t.indexOf(".");if(-1!==o){var a=t.substr(0,o),s=t.substr(o+1);if(""===s)void 0===r?lH(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=r;else{var l=e[a];l&&lY(e,a)||(l=e[a]={}),ue(l,s,r)}}else void 0===r?lH(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function ut(e){var t={};for(var r in e)lY(e,r)&&(t[r]=e[r]);return t}let ur=[].concat;function un(e){return ur.apply([],e)}let ui="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(un([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>lz[e]),uo=ui.map(e=>lz[e]);l7(ui,e=>[e,!0]);let ua=null;function us(e){ua="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let r=ua&&ua.get(t);if(r)return r;if(lH(t)){r=[],ua&&ua.set(t,r);for(var n=0,i=t.length;n<i;++n)r.push(e(t[n]))}else if(uo.indexOf(t.constructor)>=0)r=t;else{let n=lq(t);for(var o in r=n===Object.prototype?{}:Object.create(n),ua&&ua.set(t,r),t)lY(t,o)&&(r[o]=e(t[o]))}return r}(e);return ua=null,t}let{toString:ul}={};function uu(e){return ul.call(e).slice(8,-1)}let uc="u">typeof Symbol?Symbol.iterator:"@@iterator",ud="symbol"==typeof uc?function(e){var t;return null!=e&&(t=e[uc])&&t.apply(e)}:function(){return null},up={};function uf(e){var t,r,n,i;if(1==arguments.length){if(lH(e))return e.slice();if(this===up&&"string"==typeof e)return[e];if(i=ud(e)){for(r=[];!(n=i.next()).done;)r.push(n.value);return r}if(null==e)return[e];if("number"==typeof(t=e.length)){for(r=Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=Array(t);t--;)r[t]=arguments[t];return r}let uh="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var um="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),uy=()=>!0;let ug=!Error("").stack;function uv(){if(ug)try{throw uv.arguments,Error()}catch(e){return e}return Error()}function ub(e,t){var r=e.stack;return r?(t=t||0,0===r.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),r.split("\n").slice(t).filter(uy).map(e=>"\n"+e).join("")):""}var uw=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],u_=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(uw),ux={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 uE(e,t){this._e=uv(),this.name=e,this.message=t}function uS(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,r)=>r.indexOf(e)===t).join("\n")}function uD(e,t,r,n){this._e=uv(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=uS(e,t)}function uO(e,t){this._e=uv(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=uS(e,t)}l0(uE).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+ub(this._e,2))}},toString:function(){return this.name+": "+this.message}}),l0(uD).from(uE),l0(uO).from(uE);var uP=u_.reduce((e,t)=>(e[t]=t+"Error",e),{}),uC=u_.reduce((e,t)=>{var r=t+"Error";function n(e,n){this._e=uv(),this.name=r,e?"string"==typeof e?(this.message=`${e}${n?"\n "+n:""}`,this.inner=n||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=ux[t]||r,this.inner=null)}return l0(n).from(uE),e[t]=n,e},{});uC.Syntax=SyntaxError,uC.Type=TypeError,uC.Range=RangeError;var uk=uw.reduce((e,t)=>(e[t+"Error"]=uC[t],e),{}),uj=u_.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=uC[t]),e),{});function uT(){}function uR(e){return e}function uA(e,t){return null==e||e===uR?t:function(r){return t(e(r))}}function uN(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function uM(e,t){return e===uT?t:function(){var r=e.apply(this,arguments);void 0!==r&&(arguments[0]=r);var n=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?uN(n,this.onsuccess):n),i&&(this.onerror=this.onerror?uN(i,this.onerror):i),void 0!==o?o:r}}function uI(e,t){return e===uT?t:function(){e.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?uN(r,this.onsuccess):r),n&&(this.onerror=this.onerror?uN(n,this.onerror):n)}}function u$(e,t){return e===uT?t:function(r){var n=e.apply(this,arguments);lG(r,n);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?uN(i,this.onsuccess):i),o&&(this.onerror=this.onerror?uN(o,this.onerror):o),void 0===n?void 0===a?void 0:a:lG(n,a)}}function uL(e,t){return e===uT?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function uF(e,t){return e===uT?t:function(){var r=e.apply(this,arguments);if(r&&"function"==typeof r.then){for(var n=this,i=arguments.length,o=Array(i);i--;)o[i]=arguments[i];return r.then(function(){return t.apply(n,o)})}return t.apply(this,arguments)}}uj.ModifyError=uD,uj.DexieError=uE,uj.BulkError=uO;var uB={};let[uV,uU,uW]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,lq(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,lq(t),e]})(),uz=uU&&uU.then,uK=uV&&uV.constructor,uH=!!uW;var uG=!1,uq=uW?()=>{uW.then(co)}:lz.setImmediate?setImmediate.bind(null,co):lz.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{co(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(co,0)},uZ=function(e,t){u4.push([e,t]),uJ&&(uq(),uJ=!1)},uY=!0,uJ=!0,uX=[],uQ=[],u0=null,u1=uR,u2={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ck,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{ck(e[0],e[1])}catch(e){}})}},u3=u2,u4=[],u6=0,u5=[];function u9(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=uT,this._lib=!1;var t=this._PSD=u3;if(um&&(this._stackHolder=uv(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==uB)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&ce(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,r){try{r(r=>{if(null===t._state){if(r===t)throw TypeError("A promise cannot be resolved with itself.");var n=t._lib&&ca();r&&"function"==typeof r.then?e(t,(e,t)=>{r instanceof u9?r._then(e,t):r.then(e,t)}):(t._state=!0,t._value=r,ct(t)),n&&cs()}},ce.bind(null,t))}catch(e){ce(t,e)}}(this,e)}let u7={get:function(){var e=u3,t=cm;function r(r,n){var i=!e.global&&(e!==u3||t!==cm);let o=i&&!cb();var a=new u9((t,a)=>{cr(this,new u8(cO(r,e,i,o),cO(n,e,i,o),t,a,e))});return um&&ci(a,this),a}return r.prototype=uB,r},set:function(e){lQ(this,"then",e&&e.prototype===uB?u7:{get:function(){return e},set:u7.set})}};function u8(e,t,r,n,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=r,this.reject=n,this.psd=i}function ce(e,t){if(uQ.push(t),null===e._state){var r=e._lib&&ca();t=u1(t),e._state=!1,e._value=t,um&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var r=l2(t,"stack");t._promise=e,lQ(t,"stack",{get:()=>uG?r&&(r.get?r.get.apply(t):r.value):e.stack})}),uX.some(t=>t._value===e._value)||uX.push(e),ct(e),r&&cs()}}function ct(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)cr(e,t[r]);var i=e._PSD;--i.ref||i.finalize(),0===u6&&(++u6,uZ(()=>{0==--u6&&cl()},[]))}function cr(e,t){if(null!==e._state){var r=e._state?t.onFulfilled:t.onRejected;if(null===r)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++u6,uZ(cn,[r,e,t])}else e._listeners.push(t)}function cn(e,t,r){try{u0=t;var n,i=t._value;t._state?n=e(i):(uQ.length&&(uQ=[]),n=e(i),-1===uQ.indexOf(i)&&function(e){for(var t=uX.length;t;)if(uX[--t]._value===e._value)return void uX.splice(t,1)}(t)),r.resolve(n)}catch(e){r.reject(e)}finally{u0=null,0==--u6&&cl(),--r.psd.ref||r.psd.finalize()}}function ci(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function co(){ca()&&cs()}function ca(){var e=uY;return uY=!1,uJ=!1,e}function cs(){var e,t,r;do for(;u4.length>0;)for(e=u4,u4=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(u4.length>0);uY=!0,uJ=!0}function cl(){var e=uX;uX=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=u5.slice(0),r=t.length;r;)t[--r]()}function cu(e){return new u9(uB,!1,e)}function cc(e,t){var r=u3;return function(){var n=ca(),i=u3;try{return cE(r,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{cE(i,!1),n&&cs()}}}lJ(u9.prototype,{then:u7,_then:function(e,t){cr(this,new u8(null,null,e,t,u3))},catch:function(e){if(1==arguments.length)return this.then(null,e);var t=arguments[0],r=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?r(e):cu(e)):this.then(null,e=>e&&e.name===t?r(e):cu(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),cu(t)))},stack:{get:function(){if(this._stack)return this._stack;try{uG=!0;var e=(function e(t,r,n){if(r.length===n)return r;var i="";if(!1===t._state){var o,a,s=t._value;null!=s?(o=s.name||"Error",a=s.message||s,i=ub(s,0)):(o=s,a=""),r.push(o+(a?": "+a:"")+i)}return um&&((i=ub(t._stackHolder,2))&&-1===r.indexOf(i)&&r.push(i),t._prev&&e(t._prev,r,n)),r})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{uG=!1}}},timeout:function(e,t){return e<1/0?new u9((r,n)=>{var i=setTimeout(()=>n(new uC.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,i))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&lQ(u9.prototype,Symbol.toStringTag,"Dexie.Promise"),u2.env=cS(),lJ(u9,{all:function(){var e=uf.apply(null,arguments).map(cw);return new u9(function(t,r){0===e.length&&t([]);var n=e.length;e.forEach((i,o)=>u9.resolve(i).then(r=>{e[o]=r,--n||t(e)},r))})},resolve:e=>{if(e instanceof u9)return e;if(e&&"function"==typeof e.then)return new u9((t,r)=>{e.then(t,r)});var t=new u9(uB,!0,e);return ci(t,u0),t},reject:cu,race:function(){var e=uf.apply(null,arguments).map(cw);return new u9((t,r)=>{e.map(e=>u9.resolve(e).then(t,r))})},PSD:{get:()=>u3,set:e=>u3=e},totalEchoes:{get:()=>cm},newPSD:cg,usePSD:cD,scheduler:{get:()=>uZ,set:e=>{uZ=e}},rejectionMapper:{get:()=>u1,set:e=>{u1=e}},follow:(e,t)=>new u9((r,n)=>cg((t,r)=>{var n=u3;n.unhandleds=[],n.onunhandled=r,n.finalize=uN(function(){var e;e=()=>{0===this.unhandleds.length?t():r(this.unhandleds[0])},u5.push(function t(){e(),u5.splice(u5.indexOf(t),1)}),++u6,uZ(()=>{0==--u6&&cl()},[])},n.finalize),e()},t,r,n))}),uK&&(uK.allSettled&&lQ(u9,"allSettled",function(){let e=uf.apply(null,arguments).map(cw);return new u9(t=>{0===e.length&&t([]);let r=e.length,n=Array(r);e.forEach((e,i)=>u9.resolve(e).then(e=>n[i]={status:"fulfilled",value:e},e=>n[i]={status:"rejected",reason:e}).then(()=>--r||t(n)))})}),uK.any&&"u">typeof AggregateError&&lQ(u9,"any",function(){let e=uf.apply(null,arguments).map(cw);return new u9((t,r)=>{0===e.length&&r(AggregateError([]));let n=e.length,i=Array(n);e.forEach((e,o)=>u9.resolve(e).then(e=>t(e),e=>{i[o]=e,--n||r(AggregateError(i))}))})}));let cd={awaits:0,echoes:0,id:0};var cp=0,cf=[],ch=0,cm=0,cy=0;function cg(e,t,r,n){var i=u3,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++cy;var a=u2.env;o.env=uH?{Promise:u9,PromiseProp:{value:u9,configurable:!0,writable:!0},all:u9.all,race:u9.race,allSettled:u9.allSettled,any:u9.any,resolve:u9.resolve,reject:u9.reject,nthen:cP(a.nthen,o),gthen:cP(a.gthen,o)}:{},t&&lG(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=cD(o,e,r,n);return 0===o.ref&&o.finalize(),s}function cv(){return cd.id||(cd.id=++cp),++cd.awaits,cd.echoes+=100,cd.id}function cb(){return!!cd.awaits&&(0==--cd.awaits&&(cd.id=0),cd.echoes=100*cd.awaits,!0)}function cw(e){return cd.echoes&&e&&e.constructor===uK?(cv(),e.then(e=>(cb(),e),e=>(cb(),cj(e)))):e}function c_(e){++cm,cd.echoes&&0!=--cd.echoes||(cd.echoes=cd.id=0),cf.push(u3),cE(e,!0)}function cx(){var e=cf[cf.length-1];cf.pop(),cE(e,!1)}function cE(e,t){var r,n=u3;if((t?!cd.echoes||ch++&&e===u3:!ch||--ch&&e===u3)||(r=t?c_.bind(null,e):cx,uz.call(uV,r)),e!==u3&&(u3=e,n===u2&&(u2.env=cS()),uH)){var i=u2.env.Promise,o=e.env;uU.then=o.nthen,i.prototype.then=o.gthen,(n.global||e.global)&&(Object.defineProperty(lz,"Promise",o.PromiseProp),i.all=o.all,i.race=o.race,i.resolve=o.resolve,i.reject=o.reject,o.allSettled&&(i.allSettled=o.allSettled),o.any&&(i.any=o.any))}}function cS(){var e=lz.Promise;return uH?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(lz,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:uU.then,gthen:e.prototype.then}:{}}function cD(e,t,r,n,i){var o=u3;try{return cE(e,!0),t(r,n,i)}finally{cE(o,!1)}}function cO(e,t,r,n){return"function"!=typeof e?e:function(){var i,o=u3;r&&cv(),cE(t,!0);try{return e.apply(this,arguments)}finally{cE(o,!1),n&&(i=cb,uz.call(uV,i))}}}function cP(e,t){return function(r,n){return e.call(this,cO(r,t),cO(n,t))}}-1===(""+uz).indexOf("[native code]")&&(cv=cb=uT);let cC="unhandledrejection";function ck(e,t){var r;try{r=t.onuncatched(e)}catch(e){}if(!1!==r)try{var n,i={promise:t,reason:e};if(lz.document&&document.createEvent?((n=document.createEvent("Event")).initEvent(cC,!0,!0),lG(n,i)):lz.CustomEvent&&lG(n=new CustomEvent(cC,{detail:i}),i),n&&lz.dispatchEvent&&(dispatchEvent(n),!lz.PromiseRejectionEvent&&lz.onunhandledrejection))try{lz.onunhandledrejection(n)}catch(e){}um&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var cj=u9.reject;let cT="3.2.7",cR=String.fromCharCode(65535),cA=-1/0,cN="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",cM="String expected.",cI=[],c$="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),cL=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),cF="__dbnames",cB="readonly",cV="readwrite";function cU(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let cW={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function cz(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=us(t))[e],t)}class cK{_trans(e,t,r){let n=this._tx||u3.trans,i=this.name;function o(e,r,n){if(!n.schema[i])throw new uC.NotFound("Table "+i+" not part of transaction");return t(n.idbtrans,n)}let a=ca();try{return n&&n.db===this.db?n===u3.trans?n._promise(e,o,r):cg(()=>n._promise(e,o,r),{trans:n,transless:u3.transless||u3}):function e(t,r,n,i){if(t.idbdb&&(t._state.openComplete||u3.letThrough||t._vip)){var o=t._createTransaction(r,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===uP.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,i))):cj(o)}return o._promise(r,(e,t)=>cg(()=>(u3.trans=o,i(e,t,o)))).then(e=>o._completion.then(()=>e))}if(t._state.openComplete)return cj(new uC.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return cj(new uC.DatabaseClosed);t.open().catch(uT)}return t._state.dbReadyPromise.then(()=>e(t,r,n,i))}(this.db,e,[this.name],o)}finally{a&&cs()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(lH(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=lK(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let r=this.schema.indexes.concat(this.schema.primKey).filter(e=>{if(e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)){for(let r=0;r<t.length;++r)if(-1===t.indexOf(e.keyPath[r]))return!1;return!0}return!1}).sort((e,t)=>e.keyPath.length-t.keyPath.length)[0];if(r&&this.db._maxKey!==cR){let n=r.keyPath.slice(0,t.length);return this.where(n).equals(n.map(t=>e[t]))}!r&&um&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:n}=this.schema,i=this.db._deps.indexedDB;function o(e,t){try{return 0===i.cmp(e,t)}catch(e){return!1}}let[a,s]=t.reduce(([t,r],i)=>{let a=n[i],s=e[i];return[t||a,t||!a?cU(r,a&&a.multi?e=>{let t=l8(e,i);return lH(t)&&t.some(e=>o(s,e))}:e=>o(s,l8(e,i))):r]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):r?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,lH(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let r=Object.create(e.prototype);for(var n in t)if(lY(t,n))try{r[n]=t[n]}catch(e){}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){lG(this,e)})}add(e,t){let{auto:r,keyPath:n}=this.schema.primKey,i=e;return n&&r&&(i=cz(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[i]})).then(e=>e.numFailures?u9.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{ue(e,n,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||lH(e))return this.where(":id").equals(e).modify(t);{let r=l8(e,this.schema.primKey.keyPath);if(void 0===r)return cj(new uC.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?lK(t).forEach(r=>{ue(e,r,t[r])}):t(e,{value:e,primKey:r})}catch(e){}return this.where(":id").equals(r).modify(t)}}put(e,t){let{auto:r,keyPath:n}=this.schema.primKey,i=e;return n&&r&&(i=cz(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[i],keys:null!=t?[t]:null})).then(e=>e.numFailures?u9.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{ue(e,n,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?u9.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:cW})).then(e=>e.numFailures?u9.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,r){let n=Array.isArray(t)?t:void 0,i=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:o}=this.schema.primKey;if(o&&n)throw new uC.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new uC.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&r?e.map(cz(o)):e;return this.core.mutate({trans:t,type:"add",keys:n,values:s,wantResults:i}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return i?t:r;throw new uO(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,n)})})}bulkPut(e,t,r){let n=Array.isArray(t)?t:void 0,i=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:o}=this.schema.primKey;if(o&&n)throw new uC.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new uC.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&r?e.map(cz(o)):e;return this.core.mutate({trans:t,type:"put",keys:n,values:s,wantResults:i}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return i?t:r;throw new uO(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,n)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:r,failures:n})=>{if(0===e)return r;throw new uO(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,n)})}}function cH(e){var t={},r=function(r,n){if(n){for(var i=arguments.length,o=Array(i-1);--i;)o[i-1]=arguments[i];return t[r].subscribe.apply(null,o),e}if("string"==typeof r)return t[r]};r.addEventType=o;for(var n=1,i=arguments.length;n<i;++n)o(arguments[n]);return r;function o(e,n,i){if("object"!=typeof e){n||(n=uL),i||(i=uT);var a={subscribers:[],fire:i,subscribe:function(e){-1===a.subscribers.indexOf(e)&&(a.subscribers.push(e),a.fire=n(a.fire,e))},unsubscribe:function(e){a.subscribers=a.subscribers.filter(function(t){return t!==e}),a.fire=a.subscribers.reduce(n,i)}};return t[e]=r[e]=a,a}lK(e).forEach(function(t){var r=e[t];if(lH(r))o(t,e[t][0],e[t][1]);else{if("asap"!==r)throw new uC.InvalidArgument("Invalid event config");var n=o(t,uR,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){l9(function(){e.apply(null,t)})})})}})}}function cG(e,t){return l0(t).from({prototype:e}),t}function cq(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function cZ(e,t){e.filter=cU(e.filter,t)}function cY(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>cU(n(),t()):t,e.justLimit=r&&!n}function cJ(e,t){if(e.isPrimKey)return t.primaryKey;let r=t.getIndexByKeyPath(e.index);if(!r)throw new uC.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function cX(e,t,r){let n=cJ(e,t.schema);return t.openCursor({trans:r,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:n,range:e.range}})}function cQ(e,t,r,n){let i=e.replayFilter?cU(e.filter,e.replayFilter()):e.filter;if(e.or){let o={},a=(e,r,n)=>{if(!i||i(r,n,e=>r.stop(e),e=>r.fail(e))){var a=r.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),lY(o,s)||(o[s]=!0,t(e,r,n))}};return Promise.all([e.or._iterate(a,r),c0(cX(e,n,r),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return c0(cX(e,n,r),cU(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function c0(e,t,r,n){var i=cc(n?(e,t,i)=>r(n(e),t,i):r);return e.then(e=>{if(e)return e.start(()=>{var r=()=>e.continue();t&&!t(e,e=>r=e,t=>{e.stop(t),r=uT},t=>{e.fail(t),r=uT})||i(e.value,e,e=>r=e),r()})})}function c1(e,t){try{let r=c2(e),n=c2(t);if(r!==n)return"Array"===r?1:"Array"===n?-1:"binary"===r?1:"binary"===n?-1:"string"===r?1:"string"===n?-1:"Date"===r?1:"Date"!==n?NaN:-1;switch(r){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let r=e.length,n=t.length,i=r<n?r:n;for(let r=0;r<i;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return r===n?0:r<n?-1:1}(c3(e),c3(t));case"Array":return function(e,t){let r=e.length,n=t.length,i=r<n?r:n;for(let r=0;r<i;++r){let n=c1(e[r],t[r]);if(0!==n)return n}return r===n?0:r<n?-1:1}(e,t)}}catch(e){}return NaN}function c2(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let r=uu(e);return"ArrayBuffer"===r?"binary":r}function c3(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class c4{_read(e,t){var r=this._ctx;return r.error?r.table._trans(null,cj.bind(null,r.error)):r.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,cj.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=cU(t.algorithm,e)}_iterate(e,t){return cQ(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&lG(r,e),t._ctx=r,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(r=>cQ(t,e,r,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,r=t.table.core;if(cq(t,!0))return r.count({trans:e,query:{index:cJ(t,r.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var n=0;return cQ(t,()=>(++n,!1),e,r).then(()=>n)}).then(e)}sortBy(e,t){let r=e.split(".").reverse(),n=r[0],i=r.length-1;function o(e,t){return t?o(e[r[t]],t-1):e[n]}var a="next"===this._ctx.dir?1:-1;function s(e,t){var r=o(e,i),n=o(t,i);return r<n?-a:r>n?a:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&cq(t,!0)&&t.limit>0){let{valueMapper:r}=t,n=cJ(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:n,range:t.range}}).then(({result:e})=>r?e.map(r):e)}{let r=[];return cQ(t,e=>r.push(e),e,t.table.core).then(()=>r)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,cq(t)?cY(t,()=>{var t=e;return(e,r)=>0===t||(1===t?--t:r(()=>{e.advance(t),t=0}),!1)}):cY(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),cY(this._ctx,()=>{var t=e;return function(e,r,n){return--t<=0&&r(n),t>=0}},!0),this}until(e,t){return cZ(this._ctx,function(r,n,i){return!e(r.value)||(n(i),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return cZ(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=cU(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.key,r)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.primaryKey,r)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.key)}).then(function(){return r}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&cq(t,!0)&&t.limit>0)return this._read(e=>{var r=cJ(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:r,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var r={};return cZ(this._ctx,function(e){var t=e.primaryKey.toString(),n=lY(r,t);return r[t]=!0,!n}),this}modify(e){var t=this._ctx;return this._write(r=>{var n;if("function"==typeof e)n=e;else{var i=lK(e),o=i.length;n=function(t){for(var r=!1,n=0;n<o;++n){var a=i[n],s=e[a];l8(t,a)!==s&&(ue(t,a,s),r=!0)}return r}}let a=t.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,u=this.db._options.modifyChunkSize||200,c=[],d=0,p=[],f=(e,t)=>{let{failures:r,numFailures:n}=t;for(let t of(d+=e-n,lK(r)))c.push(r[t])};return this.clone().primaryKeys().then(i=>{let o=c=>{let d=Math.min(u,i.length-c);return a.getMany({trans:r,keys:i.slice(c,c+d),cache:"immutable"}).then(p=>{let h=[],m=[],y=s?[]:null,g=[];for(let e=0;e<d;++e){let t=p[e],r={value:us(t),primKey:i[c+e]};!1!==n.call(r,r.value,r)&&(null==r.value?g.push(i[c+e]):s||0===c1(l(t),l(r.value))?(m.push(r.value),s&&y.push(i[c+e])):(g.push(i[c+e]),h.push(r.value)))}let v=cq(t)&&t.limit===1/0&&("function"!=typeof e||e===c6)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&a.mutate({trans:r,type:"add",values:h}).then(e=>{for(let t in e.failures)g.splice(parseInt(t),1);f(h.length,e)})).then(()=>(m.length>0||v&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:y,values:m,criteria:v,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(g.length>0||v&&e===c6)&&a.mutate({trans:r,type:"delete",keys:g,criteria:v}).then(e=>f(g.length,e))).then(()=>i.length>c+d&&o(c+u))})};return o(0).then(()=>{if(c.length>0)throw new uD("Error modifying one or more objects",c,d,p);return i.length})})})}delete(){var e=this._ctx,t=e.range;return cq(e)&&(e.isPrimKey&&!c$||3===t.type)?this._write(r=>{let{primaryKey:n}=e.table.core.schema;return e.table.core.count({trans:r,query:{index:n,range:t}}).then(n=>e.table.core.mutate({trans:r,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:r,numFailures:i})=>{if(i)throw new uD("Could not delete some values",Object.keys(e).map(t=>e[t]),n-i);return n-i}))}):this.modify(c6)}}let c6=(e,t)=>t.value=null;function c5(e,t){return e<t?-1:+(e!==t)}function c9(e,t){return e>t?-1:+(e!==t)}function c7(e,t,r){var n=e instanceof dn?new e.Collection(e):e;return n._ctx.error=r?new r(t):TypeError(t),n}function c8(e){return new e.Collection(e,()=>dr("")).limit(0)}function de(e,t,r,n){var i,o,a,s,l,u,c,d=r.length;if(!r.every(e=>"string"==typeof e))return c7(e,cM);function p(e){i="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),o="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?c5:c9;var t=r.map(function(e){return{lower:o(e),upper:i(e)}}).sort(function(e,t){return a(e.lower,t.lower)});s=t.map(function(e){return e.upper}),l=t.map(function(e){return e.lower}),u=e,c="next"===e?"":n}p("next");var f=new e.Collection(e,()=>dt(s[0],l[d-1]+n));f._ondirectionchange=function(e){p(e)};var h=0;return f._addAlgorithm(function(e,r,n){var i=e.key;if("string"!=typeof i)return!1;var p=o(i);if(t(p,l,h))return!0;for(var f=null,m=h;m<d;++m){var y=function(e,t,r,n,i,o){for(var a=Math.min(e.length,n.length),s=-1,l=0;l<a;++l){var u=t[l];if(u!==n[l])return 0>i(e[l],r[l])?e.substr(0,l)+r[l]+r.substr(l+1):0>i(e[l],n[l])?e.substr(0,l)+n[l]+r.substr(l+1):s>=0?e.substr(0,s)+t[s]+r.substr(s+1):null;0>i(e[l],u)&&(s=l)}return a<n.length&&"next"===o?e+r.substr(e.length):a<e.length&&"prev"===o?e.substr(0,r.length):s<0?null:e.substr(0,s)+n[s]+r.substr(s+1)}(i,p,s[m],l[m],a,u);null===y&&null===f?h=m+1:(null===f||a(f,y)>0)&&(f=y)}return r(null!==f?function(){e.continue(f+c)}:n),!1}),f}function dt(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function dr(e){return{type:1,lower:e,upper:e}}class dn{get Collection(){return this._ctx.table.db.Collection}between(e,t,r,n){r=!1!==r,n=!0===n;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(r||n)&&(!r||!n)?c8(this):new this.Collection(this,()=>dt(e,t,!r,!n))}catch(e){return c7(this,cN)}}equals(e){return null==e?c7(this,cN):new this.Collection(this,()=>dr(e))}above(e){return null==e?c7(this,cN):new this.Collection(this,()=>dt(e,void 0,!0))}aboveOrEqual(e){return null==e?c7(this,cN):new this.Collection(this,()=>dt(e,void 0,!1))}below(e){return null==e?c7(this,cN):new this.Collection(this,()=>dt(void 0,e,!1,!0))}belowOrEqual(e){return null==e?c7(this,cN):new this.Collection(this,()=>dt(void 0,e))}startsWith(e){return"string"!=typeof e?c7(this,cM):this.between(e,e+cR,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):de(this,(e,t)=>0===e.indexOf(t[0]),[e],cR)}equalsIgnoreCase(e){return de(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=uf.apply(up,arguments);return 0===e.length?c8(this):de(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=uf.apply(up,arguments);return 0===e.length?c8(this):de(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,cR)}anyOf(){let e=uf.apply(up,arguments),t=this._cmp;try{e.sort(t)}catch(e){return c7(this,cN)}if(0===e.length)return c8(this);let r=new this.Collection(this,()=>dt(e[0],e[e.length-1]));r._ondirectionchange=r=>{t="next"===r?this._ascending:this._descending,e.sort(t)};let n=0;return r._addAlgorithm((r,i,o)=>{let a=r.key;for(;t(a,e[n])>0;)if(++n===e.length)return i(o),!1;return 0===t(a,e[n])||(i(()=>{r.continue(e[n])}),!1)}),r}notEqual(e){return this.inAnyRange([[cA,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=uf.apply(up,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return c7(this,cN)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[cA,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let r=this._cmp,n=this._ascending,i=this._descending,o=this._min,a=this._max;if(0===e.length)return c8(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=n(e[0],e[1])))return c7(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",uC.InvalidArgument);let s=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,u,c=n;function d(e,t){return c(e[0],t[0])}try{(u=e.reduce(function(e,t){let n=0,i=e.length;for(;n<i;++n){let i=e[n];if(0>r(t[0],i[1])&&r(t[1],i[0])>0){i[0]=o(i[0],t[0]),i[1]=a(i[1],t[1]);break}}return n===i&&e.push(t),e},[])).sort(d)}catch(e){return c7(this,cN)}let p=0,f=l?e=>n(e,u[p][1])>0:e=>n(e,u[p][1])>=0,h=s?e=>i(e,u[p][0])>0:e=>i(e,u[p][0])>=0,m=f,y=new this.Collection(this,()=>dt(u[0][0],u[u.length-1][1],!s,!l));return y._ondirectionchange=e=>{"next"===e?(m=f,c=n):(m=h,c=i),u.sort(d)},y._addAlgorithm((e,t,r)=>{for(var i=e.key;m(i);)if(++p===u.length)return t(r),!1;return!!(!f(i)&&!h(i))||(0===this._cmp(i,u[p][1])||0===this._cmp(i,u[p][0])||t(()=>{c===n?e.continue(u[p][0]):e.continue(u[p][1])}),!1)}),y}startsWithAnyOf(){let e=uf.apply(up,arguments);return e.every(e=>"string"==typeof e)?0===e.length?c8(this):this.inAnyRange(e.map(e=>[e,e+cR])):c7(this,"startsWithAnyOf() only works with strings")}}function di(e){return cc(function(t){return da(t),e(t.target.error),!1})}function da(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let ds="storagemutated",dl="x-storagemutated-1",du=cH(null,ds);class dc{_lock(){return l5(!u3.global),++this._reculock,1!==this._reculock||u3.global||(u3.lockOwnerFor=this),this}_unlock(){if(l5(!u3.global),0==--this._reculock)for(u3.global||(u3.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{cD(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&u3.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,r=this.db._state.dbOpenError;if(l5(!this.idbtrans),!e&&!t)switch(r&&r.name){case"DatabaseClosedError":throw new uC.DatabaseClosed(r);case"MissingAPIError":throw new uC.MissingAPI(r.message,r);default:throw new uC.OpenFailed(r)}if(!this.active)throw new uC.TransactionInactive;return l5(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=cc(t=>{da(t),this._reject(e.error)}),e.onabort=cc(t=>{da(t),this.active&&this._reject(new uC.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=cc(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&du.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,r){if("readwrite"===e&&"readwrite"!==this.mode)return cj(new uC.ReadOnly("Transaction is readonly"));if(!this.active)return cj(new uC.TransactionInactive);if(this._locked())return new u9((n,i)=>{this._blockedFuncs.push([()=>{this._promise(e,t,r).then(n,i)},u3])});if(r)return cg(()=>{var e=new u9((e,r)=>{this._lock();let n=t(e,r,this);n&&n.then&&n.then(e,r)});return e.finally(()=>this._unlock()),e._lib=!0,e});var n=new u9((e,r)=>{var n=t(e,r,this);n&&n.then&&n.then(e,r)});return n._lib=!0,n}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let r=u9.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>r);else{t._waitingFor=r,t._waitingQueue=[];var n=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(n.get(-1/0).onsuccess=e)}()}var i=t._waitingFor;return new u9((e,n)=>{r.then(r=>t._waitingQueue.push(cc(e.bind(null,r))),e=>t._waitingQueue.push(cc(n.bind(null,e)))).finally(()=>{t._waitingFor===i&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new uC.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(lY(t,e))return t[e];let r=this.schema[e];if(!r)throw new uC.NotFound("Table "+e+" not part of transaction");let n=new this.db.Table(e,r,this);return n.core=this.db.core.table(e),t[e]=n,n}}function dd(e,t,r,n,i,o,a){return{name:e,keyPath:t,unique:r,multi:n,auto:i,compound:o,src:(r&&!a?"&":"")+(n?"*":"")+(i?"++":"")+dp(t)}}function dp(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function df(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:l7(r,e=>[e.name,e])}}let dh=e=>{try{return e.only([[]]),dh=()=>[[]],[[]]}catch(e){return dh=()=>cR,cR}};function dm(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>l8(t,e):t=>l8(t,e)}function dy(e){return[].slice.call(e)}let dg=0;function dv(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function db({_novip:e},t){let r=t.db,n=function(e,t,{IDBKeyRange:r,indexedDB:n},i){var o;return{dbcore:(o=function(e,t,r){let n;function i(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:r,upper:n,lowerOpen:i,upperOpen:o}=e;return void 0===r?void 0===n?null:t.upperBound(n,!!o):void 0===n?t.lowerBound(r,!!i):t.bound(r,n,!!i,!!o)}let{schema:o,hasGetAll:a}=(n=dy(e.objectStoreNames),{schema:{name:e.name,tables:n.map(e=>r.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:r}=e,n=lH(t),i=null==t,o={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:i,compound:n,keyPath:t,autoIncrement:r,unique:!0,extractKey:dm(t)},indexes:dy(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:r,multiEntry:n,keyPath:i}=e,a={name:t,compound:lH(i),keyPath:i,unique:r,multiEntry:n,extractKey:dm(i)};return o[dv(i)]=a,a}),getIndexByKeyPath:e=>o[dv(e)]};return o[":id"]=a.primaryKey,null!=t&&(o[dv(t)]=a.primaryKey),a})},hasGetAll:n.length>0&&"getAll"in r.objectStore(n[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=o.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:r,keys:n,values:o,range:a}){return new Promise((s,l)=>{let u;s=cc(s);let c=e.objectStore(t),d=null==c.keyPath,p="put"===r||"add"===r;if(!p&&"delete"!==r&&"deleteRange"!==r)throw Error("Invalid operation type: "+r);let{length:f}=n||o||{length:1};if(n&&o&&n.length!==o.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=[],y=0,g=e=>{++y,da(e)};if("deleteRange"===r){if(4===a.type)return s({numFailures:y,failures:m,results:[],lastResult:void 0});3===a.type?h.push(u=c.clear()):h.push(u=c.delete(i(a)))}else{let[e,t]=p?d?[o,n]:[o,null]:[n,null];if(p)for(let n=0;n<f;++n)h.push(u=t&&void 0!==t[n]?c[r](e[n],t[n]):c[r](e[n])),u.onerror=g;else for(let t=0;t<f;++t)h.push(u=c[r](e[t])),u.onerror=g}let v=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:y,failures:m,results:"delete"===r?n:h.map(e=>e.result),lastResult:t})};u.onerror=e=>{g(e),v(e)},u.onsuccess=v})},getMany:({trans:e,keys:r})=>new Promise((n,i)=>{n=cc(n);let o=e.objectStore(t),a=r.length,s=Array(a),l,u=0,c=0,d=e=>{let t=e.target;s[t._pos]=t.result,++c===u&&n(s)},p=di(i);for(let e=0;e<a;++e)null!=r[e]&&((l=o.get(r[e]))._pos=e,l.onsuccess=d,l.onerror=p,++u);0===u&&n(s)}),get:({trans:e,key:r})=>new Promise((n,i)=>{n=cc(n);let o=e.objectStore(t).get(r);o.onsuccess=e=>n(e.target.result),o.onerror=di(i)}),query:e=>new Promise((r,n)=>{r=cc(r);let{trans:o,values:s,limit:l,query:u}=e,c=l===1/0?void 0:l,{index:d,range:p}=u,f=o.objectStore(t),h=d.isPrimaryKey?f:f.index(d.name),m=i(p);if(0===l)return r({result:[]});if(a){let e=s?h.getAll(m,c):h.getAllKeys(m,c);e.onsuccess=e=>r({result:e.target.result}),e.onerror=di(n)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),i=[];t.onsuccess=n=>{let o=t.result;return o?(i.push(s?o.value:o.primaryKey),++e===l?r({result:i}):void o.continue()):r({result:i})},t.onerror=di(n)}}),openCursor:function({trans:e,values:r,query:n,reverse:o,unique:a}){return new Promise((s,l)=>{s=cc(s);let{index:u,range:c}=n,d=e.objectStore(t),p=u.isPrimaryKey?d:d.index(u.name),f=o?a?"prevunique":"prev":a?"nextunique":"next",h=!r&&"openKeyCursor"in p?p.openKeyCursor(i(c),f):p.openCursor(i(c),f);h.onerror=di(l),h.onsuccess=cc(t=>{let r=h.result;if(!r)return void s(null);r.___id=++dg,r.done=!1;let n=r.continue.bind(r),i=r.continuePrimaryKey;i&&(i=i.bind(r));let o=r.advance.bind(r),a=()=>{throw Error("Cursor not stopped")};r.trans=e,r.stop=r.continue=r.continuePrimaryKey=r.advance=()=>{throw Error("Cursor not started")},r.fail=cc(l),r.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},r.start=e=>{let t=new Promise((e,t)=>{e=cc(e),h.onerror=di(t),r.fail=t,r.stop=t=>{r.stop=r.continue=r.continuePrimaryKey=r.advance=a,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){r.fail(e)}else r.done=!0,r.start=()=>{throw Error("Cursor behind last entry")},r.stop()};return h.onsuccess=cc(e=>{h.onsuccess=s,s()}),r.continue=n,r.continuePrimaryKey=i,r.advance=o,s(),t},s(r)},l)})},count({query:e,trans:r}){let{index:n,range:o}=e;return new Promise((e,a)=>{let s=r.objectStore(t),l=n.isPrimaryKey?s:s.index(n.name),u=i(o),c=u?l.count(u):l.count();c.onsuccess=cc(t=>e(t.target.result)),c.onerror=di(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:dh(t),schema:o}}(t,r,i),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),o))}}(e._middlewares,r,e._deps,t);e.core=n.dbcore,e.tables.forEach(t=>{let r=t.name;e.core.schema.tables.some(e=>e.name===r)&&(t.core=e.core.table(r),e[r]instanceof e.Table&&(e[r].core=t.core))})}function dw({_novip:e},t,r,n){r.forEach(r=>{let i=n[r];t.forEach(t=>{let n=l2(t,r);(!n||"value"in n&&void 0===n.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?lQ(t,r,{get(){return this.table(r)},set(e){lX(this,r,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[r]=new e.Table(r,i))})})}function d_({_novip:e},t){t.forEach(t=>{for(let r in t)t[r]instanceof e.Table&&delete t[r]})}function dx(e,t){return e._cfg.version-t._cfg.version}function dE(e,t){let r,n={del:[],add:[],change:[]};for(r in e)t[r]||n.del.push(r);for(r in t){let i=e[r],o=t[r];if(i){let e={name:r,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")==""+(o.primKey.keyPath||"")&&(i.primKey.auto===o.primKey.auto||c$)){let t,r=i.idxByName,a=o.idxByName;for(t in r)a[t]||e.del.push(t);for(t in a){let n=r[t],i=a[t];n?n.src!==i.src&&e.change.push(i):e.add.push(i)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}else e.recreate=!0,n.change.push(e)}else n.add.push([r,o])}return n}function dS(e,t,r,n){let i=e.db.createObjectStore(t,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(e=>dD(i,e)),i}function dD(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function dO(e,t,r){let n={};return l4(t.objectStoreNames,0).forEach(e=>{let t=r.objectStore(e),i=t.keyPath,o=dd(dp(i),i||"",!1,!1,!!t.autoIncrement,i&&"string"!=typeof i,!0),a=[];for(let e=0;e<t.indexNames.length;++e){let r=t.index(t.indexNames[e]);i=r.keyPath;var s=dd(r.name,i,!!r.unique,!!r.multiEntry,!1,i&&"string"!=typeof i,!1);a.push(s)}n[e]=df(e,o,a)}),n}function dP({_novip:e},t,r){let n=r.db.objectStoreNames;for(let i=0;i<n.length;++i){let o=n[i],a=r.objectStore(o);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let r=a.indexNames[e],n=a.index(r).keyPath,i="string"==typeof n?n:"["+l4(n).join("+")+"]";if(t[o]){let e=t[o].idxByName[i];e&&(e.name=r,delete t[o].idxByName[i],t[o].idxByName[r]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&lz.WorkerGlobalScope&&lz instanceof lz.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class dC{_parseStoresSpec(e,t){lK(e).forEach(r=>{if(null!==e[r]){var n=e[r].split(",").map((e,t)=>{let r=(e=e.trim()).replace(/([&*]|\+\+)/g,""),n=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return dd(r,n||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),lH(n),0===t)}),i=n.shift();if(i.multi)throw new uC.Schema("Primary key cannot be multi-valued");n.forEach(e=>{if(e.auto)throw new uC.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new uC.Schema("Index must have a name and cannot be an empty string")}),t[r]=df(r,i,n)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?lG(this._cfg.storesSource,e):e;let r=t._versions,n={},i={};return r.forEach(e=>{lG(n,e._cfg.storesSource),i=e._cfg.dbschema={},e._parseStoresSpec(n,i)}),t._dbSchema=i,d_(t,[t._allTables,t,t.Transaction.prototype]),dw(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],lK(i),i),t._storeNames=lK(i),this}upgrade(e){return this._cfg.contentUpgrade=uF(this._cfg.contentUpgrade||uT,e),this}}function dk(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new dq(cF,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),r.table("dbnames")}function dj(e){return e&&"function"==typeof e.databases}function dT(e){return cg(function(){return u3.letThrough=!0,e()})}function dR(e){var t=t=>e.next(t),r=i(t),n=i(t=>e.throw(t));function i(e){return t=>{var i=e(t),o=i.value;return i.done?o:o&&"function"==typeof o.then?o.then(r,n):lH(o)?Promise.all(o).then(r,n):r(o)}}return i(t)()}function dA(e,t,r){var n=arguments.length;if(n<2)throw new uC.InvalidArgument("Too few arguments");for(var i=Array(n-1);--n;)i[n-1]=arguments[n];return r=i.pop(),[e,un(i),r]}function dN(e,t,r){let n=lH(e)?e.slice():[e];for(let e=0;e<r;++e)n.push(t);return n}let dM={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let r=e.table(t),{schema:n}=r,i={},o=[];function a(e,t,r){let n=dv(e),s=i[n]=i[n]||[],l=null==e?0:"string"==typeof e?1:e.length,u=t>0,c={...r,isVirtual:u,keyTail:t,keyLength:l,extractKey:dm(e),unique:!u&&r.unique};return s.push(c),c.isPrimaryKey||o.push(c),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,r),s.sort((e,t)=>e.keyTail-t.keyTail),c}let s=a(n.primaryKey.keyPath,0,n.primaryKey);for(let e of(i[":id"]=[s],n.indexes))a(e.keyPath,0,e);function l(t){var r,n;let i=t.query.index;return i.isVirtual?{...t,query:{index:i,range:(r=t.query.range,n=i.keyTail,{type:1===r.type?2:r.type,lower:dN(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,n),lowerOpen:!0,upper:dN(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,n),upperOpen:!0})}}:t}return{...r,schema:{...n,primaryKey:s,indexes:o,getIndexByKeyPath:function(e){let t=i[dv(e)];return t&&t[0]}},count:e=>r.count(l(e)),query:e=>r.query(l(e)),openCursor(t){let{keyTail:n,isVirtual:i,keyLength:o}=t.query.index;return i?r.openCursor(l(t)).then(r=>r&&Object.create(r,{continue:{value:function(i){null!=i?r.continue(dN(i,t.reverse?e.MAX_KEY:e.MIN_KEY,n)):t.unique?r.continue(r.key.slice(0,o).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,n)):r.continue()}},continuePrimaryKey:{value(t,i){r.continuePrimaryKey(dN(t,e.MAX_KEY,n),i)}},primaryKey:{get:()=>r.primaryKey},key:{get(){let e=r.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:()=>r.value}})):r.openCursor(t)}}}}}};function dI(e,t,r,n){return r=r||{},n=n||"",lK(e).forEach(i=>{if(lY(t,i)){var o=e[i],a=t[i];if("object"==typeof o&&"object"==typeof a&&o&&a){let e=uu(o);e!==uu(a)?r[n+i]=t[i]:"Object"===e?dI(o,a,r,n+i+"."):o!==a&&(r[n+i]=t[i])}else o!==a&&(r[n+i]=t[i])}else r[n+i]=void 0}),lK(t).forEach(i=>{lY(e,i)||(r[n+i]=t[i])}),r}let d$={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let r=e.table(t),{primaryKey:n}=r.schema;return{...r,mutate(e){let i=u3.trans,{deleting:o,creating:a,updating:s}=i.table(t).hook;switch(e.type){case"add":if(a.fire===uT)break;return i._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===uT&&s.fire===uT)break;return i._promise("readwrite",()=>l(e),!0);case"delete":if(o.fire===uT)break;return i._promise("readwrite",()=>l(e),!0);case"deleteRange":if(o.fire===uT)break;return i._promise("readwrite",()=>(function e(t,i,o){return r.query({trans:t,values:!1,query:{index:n,range:i},limit:o}).then(({result:r})=>l({type:"delete",keys:r,trans:t}).then(n=>n.numFailures>0?Promise.reject(n.failures[0]):r.length<o?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...i,lower:r[r.length-1],lowerOpen:!0},o)))})(e.trans,e.range,1e4),!0)}return r.mutate(e);function l(e){var t,i;let l=u3.trans,u=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(n.extractKey));if(!u)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:u}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(i=e).type?Promise.resolve([]):r.getMany({trans:i.trans,keys:u,cache:"immutable"})).then(t=>{let i=u.map((r,i)=>{let u=t[i],c={onerror:null,onsuccess:null};if("delete"===e.type)o.fire.call(c,r,u,l);else if("add"===e.type||void 0===u){let t=a.fire.call(c,r,e.values[i],l);null==r&&null!=t&&(r=t,e.keys[i]=r,n.outbound||ue(e.values[i],n.keyPath,r))}else{let t=dI(u,e.values[i]),n=s.fire.call(c,t,r,u,l);if(n){let t=e.values[i];Object.keys(n).forEach(e=>{lY(t,e)?t[e]=n[e]:ue(t,e,n[e])})}}return c});return r.mutate(e).then(({failures:r,results:n,numFailures:o,lastResult:a})=>{for(let o=0;o<u.length;++o){let a=n?n[o]:u[o],s=i[o];null==a?s.onerror&&s.onerror(r[o]):s.onsuccess&&s.onsuccess("put"===e.type&&t[o]?e.values[o]:a)}return{failures:r,results:n,numFailures:o,lastResult:a}}).catch(e=>(i.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function dL(e,t,r){try{if(!t||t.keys.length<e.length)return null;let n=[];for(let i=0,o=0;i<t.keys.length&&o<e.length;++i)0===c1(t.keys[i],e[o])&&(n.push(r?us(t.values[i]):t.values[i]),++o);return n.length===e.length?n:null}catch(e){return null}}let dF={stack:"dbcore",level:-1,create:e=>({table:t=>{let r=e.table(t);return{...r,getMany:e=>{if(!e.cache)return r.getMany(e);let t=dL(e.keys,e.trans._cache,"clone"===e.cache);return t?u9.resolve(t):r.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?us(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),r.mutate(e))}}})};function dB(e){return!("from"in e)}let dV=function(e,t){if(!this){let t=new dV;return e&&"d"in e&&lG(t,e),t}lG(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function dU(e,t,r){let n=c1(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(dB(e))return lG(e,{from:t,to:r,d:1});let i=e.l,o=e.r;if(0>c1(r,e.from))return i?dU(i,t,r):e.l={from:t,to:r,d:1,l:null,r:null},dK(e);if(c1(t,e.to)>0)return o?dU(o,t,r):e.r={from:t,to:r,d:1,l:null,r:null},dK(e);0>c1(t,e.from)&&(e.from=t,e.l=null,e.d=o?o.d+1:1),c1(r,e.to)>0&&(e.to=r,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;i&&!e.l&&dW(e,i),o&&a&&dW(e,o)}function dW(e,t){dB(t)||function e(t,{from:r,to:n,l:i,r:o}){dU(t,r,n),i&&e(t,i),o&&e(t,o)}(e,t)}function dz(e){let t=dB(e)?null:{s:0,n:e};return{next(e){let r=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&0>c1(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||0>=c1(e,t.n.to))return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function dK(e){var t,r;let n=((null==(t=e.r)?void 0:t.d)||0)-((null==(r=e.l)?void 0:r.d)||0),i=n>1?"r":n<-1?"l":"";if(i){let t="r"===i?"l":"r",r={...e},n=e[i];e.from=n.from,e.to=n.to,e[i]=n[i],r[i]=n[t],e[t]=r,r.d=dH(r)}e.d=dH(e)}function dH({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}lJ(dV.prototype,{add(e){return dW(this,e),this},addKey(e){return dU(this,e,e),this},addKeys(e){return e.forEach(e=>dU(this,e,e)),this},[uc](){return dz(this)}});let dG={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,r=new dV(e.MIN_KEY,e.MAX_KEY);return{...e,table:n=>{let i=e.table(n),{schema:o}=i,{primaryKey:a}=o,{extractKey:s,outbound:l}=a,u={...i,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),l=e=>{let r=`idb://${t}/${n}/${e}`;return s[r]||(s[r]=new dV)},u=l(""),c=l(":dels"),{type:d}=e,[p,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return i.mutate(e).then(e=>{if(lH(p)){"delete"!==d&&(p=e.results),u.addKeys(p);let t=dL(p,h);t||"add"===d||c.addKeys(p),(t||f)&&o.indexes.forEach(function(e){let r=l(e.name||"");function n(t){return null!=t?e.extractKey(t):null}let i=t=>e.multiEntry&&lH(t)?t.forEach(e=>r.addKey(e)):r.addKey(t);(t||f).forEach((e,r)=>{let o=t&&n(t[r]),a=f&&n(f[r]);0!==c1(o,a)&&(null!=o&&i(o),null!=a&&i(a))})})}else if(p){let e={from:p.lower,to:p.upper};c.add(e),u.add(e)}else u.add(r),c.add(r),o.indexes.forEach(e=>l(e.name).add(r));return e})}},c=({query:{index:t,range:r}})=>{var n,i;return[t,new dV(null!=(n=r.lower)?n:e.MIN_KEY,null!=(i=r.upper)?i:e.MAX_KEY)]},d={get:e=>[a,new dV(e.key)],getMany:e=>[a,(new dV).addKeys(e.keys)],count:c,query:c,openCursor:c};return lK(d).forEach(e=>{u[e]=function(o){let{subscr:a}=u3;if(a){let u=e=>{let r=`idb://${t}/${n}/${e}`;return a[r]||(a[r]=new dV)},c=u(""),p=u(":dels"),[f,h]=d[e](o);if(u(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&o.values&&i.query({...o,values:!1});return i[e].apply(this,arguments).then(r=>{if("query"===e){if(l&&o.values)return t.then(({result:e})=>(c.addKeys(e),r));let e=o.values?r.result.map(s):r.result;o.values?c.addKeys(e):p.addKeys(e)}else if("openCursor"===e){let e=o.values;return r&&Object.create(r,{key:{get:()=>(p.addKey(r.primaryKey),r.key)},primaryKey:{get(){let e=r.primaryKey;return p.addKey(e),e}},value:{get:()=>(e&&c.addKey(r.primaryKey),r.value)}})}return r})}p.add(r)}}return i[e].apply(this,arguments)}}),u}}}};class dq{constructor(e,t){var r;this._middlewares={},this.verno=0;const n=dq.dependencies;this._options=t={addons:dq.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:i}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:uT,dbReadyPromise:null,cancelOpen:uT,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new u9(e=>{o.dbReadyResolve=e}),o.openCanceller=new u9((e,t)=>{o.cancelOpen=t}),this._state=o,this.name=e,this.on=cH(this,"populate","blocked","versionchange","close",{ready:[uF,uT]}),this.on.ready.subscribe=l6(this.on.ready.subscribe,e=>(t,r)=>{dq.vip(()=>{let n=this._state;if(n.openComplete)n.dbOpenError||u9.resolve().then(t),r&&e(t);else if(n.onReadyBeingFired)n.onReadyBeingFired.push(t),r&&e(t);else{e(t);let n=this;r||e(function e(){n.on.ready.unsubscribe(t),n.on.ready.unsubscribe(e)})}})}),this.Collection=(r=this,cG(c4.prototype,function(e,t){this.db=r;let n=cW,i=null;if(t)try{n=t()}catch(e){i=e}let o=e._ctx,a=o.table,s=a.hook.reading.fire;this._ctx={table:a,index:o.index,isPrimKey:!o.index||a.schema.primKey.keyPath&&o.index===a.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:i,or:o.or,valueMapper:s!==uR?s:null}})),this.Table=function(e){return cG(cK.prototype,function(t,r,n){this.db=e,this._tx=n,this.name=t,this.schema=r,this.hook=e._allTables[t]?e._allTables[t].hook:cH(null,{creating:[uM,uT],reading:[uA,uR],updating:[u$,uT],deleting:[uI,uT]})})}(this),this.Transaction=function(e){return cG(dc.prototype,function(t,r,n,i,o){this.db=e,this.mode=t,this.storeNames=r,this.schema=n,this.chromeTransactionDurability=i,this.idbtrans=null,this.on=cH(this,"complete","error","abort"),this.parent=o||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 u9((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),cj(e)})})}(this),this.Version=function(e){return cG(dC.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return cG(dn.prototype,function(t,r,n){this.db=e,this._ctx={table:t,index:":id"===r?null:r,or:n};let i=e._deps.indexedDB;if(!i)throw new uC.MissingAPI;this._cmp=this._ascending=i.cmp.bind(i),this._descending=(e,t)=>i.cmp(t,e),this._max=(e,t)=>i.cmp(e,t)>0?e:t,this._min=(e,t)=>0>i.cmp(e,t)?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=dh(t.IDBKeyRange),this._createTransaction=(e,t,r,n)=>new this.Transaction(e,t,r,this._options.chromeTransactionDurability,n),this._fireOnBlocked=e=>{this.on("blocked").fire(e),cI.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(dM),this.use(d$),this.use(dG),this.use(dF),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new uC.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new uC.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let t=this._versions;var r=t.filter(t=>t._cfg.version===e)[0];return r||(r=new this.Version(e),t.push(r),t.sort(dx),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||u3.letThrough||this._vip)?e():new u9((e,t)=>{if(this._state.openComplete)return t(new uC.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new uC.DatabaseClosed);this.open().catch(uT)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:r,name:n}){n&&this.unuse({stack:e,name:n});let i=this._middlewares[e]||(this._middlewares[e]=[]);return i.push({stack:e,create:t,level:null==r?10:r,name:n}),i.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>r?e.create!==r:!!t&&e.name!==t)),this}open(){return function(e){var t;let r=e._state,{indexedDB:n}=e._deps;if(r.isBeingOpened||e.idbdb)return r.dbReadyPromise.then(()=>r.dbOpenError?cj(r.dbOpenError):e);um&&(r.openCanceller._stackHolder=uv()),r.isBeingOpened=!0,r.dbOpenError=null,r.openComplete=!1;let i=r.openCanceller;function o(){if(r.openCanceller!==i)throw new uC.DatabaseClosed("db.open() was cancelled")}let a=r.dbReadyResolve,s=null,l=!1,u=()=>new u9((t,i)=>{if(o(),!n)throw new uC.MissingAPI;let a=e.name,u=r.autoSchema?n.open(a):n.open(a,Math.round(10*e.verno));if(!u)throw new uC.MissingAPI;u.onerror=di(i),u.onblocked=cc(e._fireOnBlocked),u.onupgradeneeded=cc(t=>{if(s=u.transaction,r.autoSchema&&!e._options.allowEmptyDB){u.onerror=da,s.abort(),u.result.close();let e=n.deleteDatabase(a);e.onsuccess=e.onerror=cc(()=>{i(new uC.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let r,n,a,p;s.onerror=di(i);var o,c,d=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=d<1,e._novip.idbdb=u.result,o=d/10,c=s,r=e._dbSchema,(n=e._createTransaction("readwrite",e._storeNames,r)).create(c),n._completion.catch(i),a=n._reject.bind(n),p=u3.transless||u3,cg(()=>{u3.trans=n,u3.transless=p,0===o?(lK(r).forEach(e=>{dS(c,e,r[e].primKey,r[e].indexes)}),db(e,c),u9.follow(()=>e.on.populate.fire(n)).catch(a)):(function({_novip:e},t,r,n){let i=[],o=e._versions,a=e._dbSchema=dO(e,e.idbdb,n),s=!1;return o.filter(e=>e._cfg.version>=t).forEach(o=>{i.push(()=>{let i=a,l=o._cfg.dbschema;dP(e,i,n),dP(e,l,n),a=e._dbSchema=l;let u=dE(i,l);u.add.forEach(e=>{dS(n,e[0],e[1].primKey,e[1].indexes)}),u.change.forEach(e=>{if(e.recreate)throw new uC.Upgrade("Not yet support for changing primary key");{let t=n.objectStore(e.name);e.add.forEach(e=>dD(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),dD(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=o._cfg.contentUpgrade;if(c&&o._cfg.version>t){let t;db(e,n),r._memoizedTables={},s=!0;let o=ut(l);u.del.forEach(e=>{o[e]=i[e]}),d_(e,[e.Transaction.prototype]),dw(e,[e.Transaction.prototype],lK(o),o),r.schema=o;let a=uh(c);a&&cv();let d=u9.follow(()=>{if((t=c(r))&&a){var e=cb.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?u9.resolve(t):d.then(()=>t)}}),i.push(t=>{var n;s&&c$||(n=o._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==n[e]&&t.db.deleteObjectStore(e))),d_(e,[e.Transaction.prototype]),dw(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema})}),(function e(){return i.length?u9.resolve(i.shift()(r.idbtrans)).then(e):u9.resolve()})().then(()=>{var e;lK(e=a).forEach(t=>{n.db.objectStoreNames.contains(t)||dS(n,t,e[t].primKey,e[t].indexes)})})})(e,o,n,c).catch(a)})}},i),u.onsuccess=cc(()=>{s=null;let n=e._novip.idbdb=u.result,i=l4(n.objectStoreNames);if(i.length>0)try{let t,o=n.transaction(1===i.length?i[0]:i,"readonly");r.autoSchema?function({_novip:e},t,r){e.verno=t.version/10;let n=e._dbSchema=dO(0,t,r);e._storeNames=l4(t.objectStoreNames,0),dw(e,[e._allTables],lK(n),n)}(e,n,o):(dP(e,e._dbSchema,o),((t=dE(dO(0,e.idbdb,o),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),db(e,o)}catch(e){}cI.push(e),n.onversionchange=cc(t=>{r.vcFired=!0,e.on("versionchange").fire(t)}),n.onclose=cc(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},r){dj(e)||r===cF||dk(e,t).put({name:r}).catch(uT)}(e._deps,a),t()},i)}).catch(e=>e&&"UnknownError"===e.name&&r.PR1398_maxLoop>0?(r.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),u()):u9.reject(e));return u9.race([i,("u"<typeof navigator?u9.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var r=function(){return indexedDB.databases().finally(e)};t=setInterval(r,100),r()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(u)]).then(()=>(o(),r.onReadyBeingFired=[],u9.resolve(dT(()=>e.on.ready.fire(e.vip))).then(function t(){if(r.onReadyBeingFired.length>0){let n=r.onReadyBeingFired.reduce(uF,uT);return r.onReadyBeingFired=[],u9.resolve(dT(()=>n(e.vip))).then(t)}}))).finally(()=>{r.onReadyBeingFired=null,r.isBeingOpened=!1}).then(()=>e).catch(t=>{r.dbOpenError=t;try{s&&s.abort()}catch(e){}return i===r.openCanceller&&e._close(),cj(t)}).finally(()=>{r.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=cI.indexOf(this);if(t>=0&&cI.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new u9(t=>{e.dbReadyResolve=t}),e.openCanceller=new u9((t,r)=>{e.cancelOpen=r})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new uC.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new u9((r,n)=>{let i=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=cc(()=>{!function({indexedDB:e,IDBKeyRange:t},r){dj(e)||r===cF||dk(e,t).delete(r).catch(uT)}(this._deps,this.name),r()}),e.onerror=di(n),e.onblocked=this._fireOnBlocked};if(e)throw new uC.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(i):i()})}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 lK(this._allTables).map(e=>this._allTables[e])}transaction(){let e=dA.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,r){let n,i,o=u3.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(i=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||e===cB)n=cB;else{if("rw"!=e&&e!=cV)throw new uC.InvalidArgument("Invalid transaction mode: "+e);n=cV}if(o){if(o.mode===cB&&n===cV){if(!a)throw new uC.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&i.forEach(e=>{if(o&&-1===o.storeNames.indexOf(e)){if(!a)throw new uC.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),a&&o&&!o.active&&(o=null)}}catch(e){return o?o._promise(null,(t,r)=>{r(e)}):cj(e)}let s=(function e(t,r,n,i,o){return u9.resolve().then(()=>{let a,s=u3.transless||u3,l=t._createTransaction(r,n,t._dbSchema,i);if(i)l.idbtrans=i.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===uP.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,null,o))):cj(i)}let u=uh(o);u&&cv();let c=u9.follow(()=>{if(a=o.call(l,l))if(u){var e=cb.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=dR(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?u9.resolve(a).then(e=>l.active?e:cj(new uC.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>a)).then(e=>(i&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),cj(e)))})}).bind(null,this,n,i,o,r);return o?o._promise(n,s,"lock"):u3.trans?cD(u3.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!lY(this._allTables,e))throw new uC.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let dZ="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class dY{constructor(e){this._subscribe=e}subscribe(e,t,r){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:r})}[dZ](){return this}}function dJ(e,t){return lK(t).forEach(r=>{dW(e[r]||(e[r]=new dV),t[r])}),e}try{o={indexedDB:lz.indexedDB||lz.mozIndexedDB||lz.webkitIndexedDB||lz.msIndexedDB,IDBKeyRange:lz.IDBKeyRange||lz.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function dX(e){let t=dQ;try{dQ=!0,du.storagemutated.fire(e)}finally{dQ=t}}lJ(dq,{...uj,delete:e=>new dq(e,{addons:[]}).delete(),exists:e=>new dq(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return dj(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==cF)):dk(e,t).toCollection().primaryKeys()})(dq.dependencies).then(e)}catch(e){return cj(new uC.MissingAPI)}},defineClass:()=>function(e){lG(this,e)},ignoreTransaction:e=>u3.trans?cD(u3.transless,e):e(),vip:dT,async:function(e){return function(){try{var t=dR(e.apply(this,arguments));return t&&"function"==typeof t.then?t:u9.resolve(t)}catch(e){return cj(e)}}},spawn:function(e,t,r){try{var n=dR(e.apply(r,t||[]));return n&&"function"==typeof n.then?n:u9.resolve(n)}catch(e){return cj(e)}},currentTransaction:{get:()=>u3.trans||null},waitFor:function(e,t){let r=u9.resolve("function"==typeof e?dq.ignoreTransaction(e):e).timeout(t||6e4);return u3.trans?u3.trans.waitFor(r):r},Promise:u9,debug:{get:()=>um,set:e=>{um=e,uy="dexie"===e?()=>!0:cL}},derive:l0,extend:lG,props:lJ,override:l6,Events:cH,on:du,liveQuery:function(e){let t,r=!1,n=new dY(n=>{let i=uh(e),o=!1,a={},s={},l={get closed(){return o},unsubscribe:()=>{o=!0,du.storagemutated.unsubscribe(p)}};n.start&&n.start(l);let u=!1,c=!1;function d(){return lK(s).some(e=>a[e]&&function(e,t){let r=dz(t),n=r.next();if(n.done)return!1;let i=n.value,o=dz(e),a=o.next(i.from),s=a.value;for(;!n.done&&!a.done;){if(0>=c1(s.from,i.to)&&c1(s.to,i.from)>=0)return!0;0>c1(i.from,s.from)?i=(n=r.next(s.from)).value:s=(a=o.next(i.from)).value}return!1}(a[e],s[e]))}let p=e=>{dJ(a,e),d()&&f()},f=()=>{let h,m;if(u||o)return;a={};let y={},g=(i&&cv(),h=()=>cg(e,{subscr:y,trans:null}),m=u3.trans?cD(u3.transless,h):h(),i&&m.then(cb,cb),m);c||(du(ds,p),c=!0),u=!0,Promise.resolve(g).then(e=>{r=!0,t=e,u=!1,o||(d()?f():(a={},s=y,n.next&&n.next(e)))},e=>{u=!1,r=!1,n.error&&n.error(e),l.unsubscribe()})};return f(),l});return n.hasValue=()=>r,n.getValue=()=>t,n},extendObservabilitySet:dJ,getByKeyPath:l8,setByKeyPath:ue,delByKeyPath:function(e,t){"string"==typeof t?ue(e,t,void 0):"length"in t&&[].map.call(t,function(t){ue(e,t,void 0)})},shallowClone:ut,deepClone:us,getObjectDiff:dI,cmp:c1,asap:l9,minKey:cA,addons:[],connections:cI,errnames:uP,dependencies:o,semVer:cT,version:cT.split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),dq.maxKey=dh(dq.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(du(ds,e=>{if(!dQ){let t;c$?(t=document.createEvent("CustomEvent")).initCustomEvent(dl,!0,!0,e):t=new CustomEvent(dl,{detail:e}),dQ=!0,dispatchEvent(t),dQ=!1}}),addEventListener(dl,({detail:e})=>{dQ||dX(e)}));let dQ=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(dl);"function"==typeof e.unref&&e.unref(),du(ds,t=>{dQ||e.postMessage(t)}),e.onmessage=e=>{e.data&&dX(e.data)}}else if("u">typeof self&&"u">typeof navigator){du(ds,e=>{try{dQ||("u">typeof localStorage&&localStorage.setItem(dl,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:dl,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===dl){let t=JSON.parse(e.newValue);t&&dX(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===dl&&dX(e.changedParts)})}function d0(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}u9.rejectionMapper=function(e,t){if(!e||e instanceof uE||e instanceof TypeError||e instanceof SyntaxError||!e.name||!uk[e.name])return e;var r=new uk[e.name](t||e.message,e);return"stack"in e&&lQ(r,"stack",{get:function(){return this.inner.stack}}),r},uy=cL;class d1 extends dq{constructor(){super("EsmOffline"),d0(this,"syncQueue",void 0),d0(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 d2(){return new d1}let d3=new d1,d4={},d6=Z("offline-synchronization",{});function d5(){return d6}async function d9(){if(d6.getState().synchronization)return;let e=await d3.syncQueue.count(),t={},r=Object.entries(d4),n=r.length,i={},o=new AbortController,a=()=>{let e=d6.getState().synchronization;d6.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{d6.setState({synchronization:{totalCount:e,pendingCount:e,abortController:o}});for(let e=0;e<n&&r.length>0;e++)for(let e=r.length;e--;){let[n,s]=r[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(i[n]={},await Promise.all(l),t[n]=d7(s,i,o,a),r.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{d6.setState({synchronization:void 0})}}async function d7({type:e,dependsOn:t,process:r},n,i,o){let a=[],s=[],l=await d8();await d3.syncQueue.where({type:e,userId:l}).each((e,t)=>{a.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let u=0;u<a.length;u++){let[c,d,{id:p,dependencies:f=[]}]=a[u];try{let o=await r(d,{abort:i,index:u,items:s,userId:l,dependencies:f.map(({id:e,type:r})=>t.includes(r)?n[r][e]:void 0)});void 0!==p&&(n[e][p]=o),await d3.syncQueue.delete(c)}catch(e){await d3.syncQueue.update(c,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{o()}}}async function d8(){let e=await aF();return e?.uuid||"*"}async function pe(e,t,r,n){let i=n&&n.id;return void 0!==i&&await d3.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===i).delete().catch(dq.errnames.DatabaseClosed),await d3.syncQueue.add({type:t,content:r,userId:e,descriptor:n||{},createdOn:new Date}).catch(dq.errnames.DatabaseClosed,()=>-1)}async function pt(e,t,r){let n=await d8();return await pe(n,e,t,r)}async function pr(e,t){return(await pn(e,t)).map(e=>e.content)}async function pn(e,t){return await d3.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(dq.errnames.DatabaseClosed,()=>[])}async function pi(e){let t=await d8();return await pr(t,e)}async function po(e){let t=await d8();return await pn(t,e)}async function pa(e){return await d3.syncQueue.get(e).catch(dq.errnames.DatabaseClosed,()=>void 0)}function ps(e){return!!d4[e]?.options.onBeginEditSyncItem}async function pl(e){let t=await pa(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let r=d4[t.type]?.options.onBeginEditSyncItem;if(!r)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);r(t)}async function pu(e){await d3.syncQueue.delete(e).catch(dq.errnames.DatabaseClosed)}function pc(e,t,r,n={}){d4[e]={type:e,dependsOn:t,process:r,options:n}}let pd="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pp=new Uint8Array(16),pf=[];for(let e=0;e<256;++e)pf.push((e+256).toString(16).slice(1));let ph=function(e,t,r){if(pd&&!t&&!e)return pd();let n=(e=e||{}).random||(e.rng||function(){if(!a&&!(a="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 a(pp)})();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return pf[e[t+0]]+pf[e[t+1]]+pf[e[t+2]]+pf[e[t+3]]+"-"+pf[e[t+4]]+pf[e[t+5]]+"-"+pf[e[t+6]]+pf[e[t+7]]+"-"+pf[e[t+8]]+pf[e[t+9]]+"-"+pf[e[t+10]]+pf[e[t+11]]+pf[e[t+12]]+pf[e[t+13]]+pf[e[t+14]]+pf[e[t+15]]}(n)},pm="OFFLINE+";function py(){return pm+ph()}function pg(e){return e.startsWith(pm)}let pv={};function pb(){return Object.values(pv)}function pw(e){pv[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.`),pv[e.id]=e}async function p_(e){let t=await pk();return await px(t,e)}async function px(e,t){let r=new d1;return await r.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(dq.errnames.DatabaseClosed,()=>[])}async function pE(e,t){let r=await pk();return await pS(r,e,t)}async function pS(e,t,r){let n=new d1,i=await n.dynamicOfflineData.get({type:t,identifier:r}).catch(dq.errnames.DatabaseClosed,()=>void 0);i?i.users.includes(e)||await n.dynamicOfflineData.update(i.id,{users:[...i.users,e]}).catch(dq.errnames.DatabaseClosed):await n.dynamicOfflineData.add({users:[e],type:t,identifier:r}).catch(dq.errnames.DatabaseClosed)}async function pD(e,t){let r=await pk();return await pO(r,e,t)}async function pO(e,t,r){let n=new d1,i=await n.dynamicOfflineData.get({type:t,identifier:r,users:e}).catch(dq.errnames.DatabaseClosed,()=>void 0);i&&(i.users.length>1?await n.dynamicOfflineData.update(i.id,{users:i.users.filter(t=>t!==e)}).catch(dq.errnames.DatabaseClosed):await n.dynamicOfflineData.delete(i.id).catch(dq.errnames.DatabaseClosed))}async function pP(e,t){let r=await p_(e);await Promise.all(r.map(async e=>pC(e.type,e.identifier,t)))}async function pC(e,t,r){await pE(e,t);let n=new d1,i=await pk(),o=await n.dynamicOfflineData.get({type:e,identifier:t}).catch(dq.errnames.DatabaseClosed,()=>void 0),a=pb().filter(t=>t.type===e);if(!o)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,r),{id:e.id,error:void 0}}catch(r){let t=r.message?.toString()??r.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),d={syncedOn:new Date,syncedBy:i,succeededHandlers:l,erroredHandlers:u,errors:c};o.id&&await n.dynamicOfflineData.update(o.id,{syncState:d}).catch(dq.errnames.DatabaseClosed)}async function pk(){let e=(await aF()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let pj=Z("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function pT(){return pN(),pj}function pR(e,t){pN(),pw({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,r)=>t.onOfflinePatientAdded({patientUuid:e,signal:r??new AbortController().signal})})}async function pA(e){pN(),await pC("patient",e)}function pN(){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 pM(e,t,r=!0){if(e){let n=null,[i,o]=await Promise.all([aC(`${aD}/Patient/${e}`,t).catch(e=>n=e),r?pI(e):Promise.resolve(null)]);if(i.ok)return i.data;if(o)return o;if(n)throw n}return null}async function pI(e){let t=(await pi("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function p$(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function pL(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}var pF=r(9549);function pB(e){return{uuid:e.uuid,display:e.display}}function pV(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return ak(`${aS}/location${n?"?"+n:""}`).pipe((0,pF.map)(e=>e.data.results.map(pB))).pipe((0,pF.take)(1))}function pU(e){return{uuid:e.uuid,display:e.display,name:e.name}}function pW(){return ak(`${aS}/visittype`).pipe((0,pF.map)(e=>e.data.results.map(pU))).pipe((0,pF.take)(1))}var pz=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),pK=function(e){function t(t,r){var n=e.call(this)||this;return n.subject=t,n.subscriber=r,n.closed=!1,n}return eS(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var r=t.indexOf(this.subscriber);-1!==r&&t.splice(r,1)}}},t}(eR),pH=function(e){function t(t){var r=e.call(this,t)||this;return r.destination=t,r}return eS(t,e),t}(eM),pG=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return eS(t,e),t.prototype[eN]=function(){return new pH(this)},t.prototype.lift=function(e){var t=new pq(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new pz;if(!this.isStopped)for(var t=this.observers,r=t.length,n=t.slice(),i=0;i<r;i++)n[i].next(e)},t.prototype.error=function(e){if(this.closed)throw new pz;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,r=t.length,n=t.slice(),i=0;i<r;i++)n[i].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new pz;this.isStopped=!0;for(var e=this.observers,t=e.length,r=e.slice(),n=0;n<t;n++)r[n].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new pz},t.prototype._subscribe=function(e){if(this.closed)throw new pz;return this.hasError?(e.error(this.thrownError),eR.EMPTY):this.isStopped?(e.complete(),eR.EMPTY):(this.observers.push(e),new pK(this,e))},t.prototype.asObservable=function(){var e=new eL;return e.source=this,e},t.create=function(e,t){return new pq(e,t)},t}(eL),pq=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return eS(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):eR.EMPTY},t}(pG),pZ=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return eS(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return r&&!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new pz},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(pG),pY=((eu={}).NEWVISIT="startVisit",eu.EDITVISIT="editVisit",eu.LOADING="loadingVisit",eu),pJ=((ec={}).NOTSTARTED="notStarted",ec.ONGOING="ongoing",ec);let pX="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))",pQ=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function p0(){return J("visit",pQ)}function p1(e,t){p0().setState({patientUuid:e,manuallySetVisitUuid:t})}function p2(e,t){return aC(`${aS}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function p3(e,t,r){return aC(`${aS}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function p4(e,t,r){return aC(`${aS}/visit?patient=${e}&v=${r??pX}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}p0().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let p6=new pZ(null);class p5{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+p5.version}static addUnaryOp(e){return p5.max_unop_len=Math.max(e.length,p5.max_unop_len),p5.unary_ops[e]=1,p5}static addBinaryOp(e,t,r){return p5.max_binop_len=Math.max(e.length,p5.max_binop_len),p5.binary_ops[e]=t,r?p5.right_associative.add(e):p5.right_associative.delete(e),p5}static addIdentifierChar(e){return p5.additional_identifier_chars.add(e),p5}static addLiteral(e,t){return p5.literals[e]=t,p5}static removeUnaryOp(e){return delete p5.unary_ops[e],e.length===p5.max_unop_len&&(p5.max_unop_len=p5.getMaxKeyLen(p5.unary_ops)),p5}static removeAllUnaryOps(){return p5.unary_ops={},p5.max_unop_len=0,p5}static removeIdentifierChar(e){return p5.additional_identifier_chars.delete(e),p5}static removeBinaryOp(e){return delete p5.binary_ops[e],e.length===p5.max_binop_len&&(p5.max_binop_len=p5.getMaxKeyLen(p5.binary_ops)),p5.right_associative.delete(e),p5}static removeAllBinaryOps(){return p5.binary_ops={},p5.max_binop_len=0,p5}static removeLiteral(e){return delete p5.literals[e],p5}static removeAllLiterals(){return p5.literals={},p5}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 p5(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 p5.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!p5.binary_ops[String.fromCharCode(e)]||p5.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return p5.isIdentifierStart(e)||p5.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(p5.hooks[e]){let r={context:this,node:t};return p5.hooks.run(e,r),r.node}return t}searchHook(e){if(p5.hooks[e]){let t={context:this};return p5.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===p5.SPACE_CODE||e===p5.TAB_CODE||e===p5.LF_CODE||e===p5.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:p5.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===p5.SEMCOL_CODE||r===p5.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,p5.max_binop_len),t=e.length;for(;t>0;){if(p5.binary_ops.hasOwnProperty(e)&&(!p5.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!p5.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,i,o,a,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(i={value:t,prec:p5.binaryPrecedence(t),right_a:p5.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,i,a];t=this.gobbleBinaryOp();){if(0===(r=p5.binaryPrecedence(t))){this.index-=t.length;break}i={value:t,prec:r,right_a:p5.right_associative.has(t)},l=t;let s=e=>i.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)a=n.pop(),t=n.pop().value,o=n.pop(),e={type:p5.BINARY_EXP,operator:t,left:o,right:a},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(i,e)}for(s=n.length-1,e=n[s];s>1;)e={type:p5.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,p5.isDecimalDigit(e)||e===p5.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===p5.SQUOTE_CODE||e===p5.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===p5.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,p5.max_unop_len)).length;r>0;){if(p5.unary_ops.hasOwnProperty(t)&&(!p5.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!p5.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:p5.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}p5.isIdentifierStart(e)?(n=this.gobbleIdentifier(),p5.literals.hasOwnProperty(n.name)?n={type:p5.LITERAL,value:p5.literals[n.name],raw:n.name}:n.name===p5.this_str&&(n={type:p5.THIS_EXP})):e===p5.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===p5.PERIOD_CODE||t===p5.OBRACK_CODE||t===p5.OPAREN_CODE||t===p5.QUMARK_CODE;){let r;if(t===p5.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==p5.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===p5.OBRACK_CODE?((e={type:p5.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==p5.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===p5.OPAREN_CODE?e={type:p5.CALL_EXP,arguments:this.gobbleArguments(p5.CPAREN_CODE),callee:e}:(t===p5.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:p5.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;p5.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===p5.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);p5.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));p5.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);p5.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,p5.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===p5.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===p5.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:p5.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:p5.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(p5.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,p5.isIdentifierPart(e))this.index++;else break;return{type:p5.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let i=this.code;if(i===e){r=!0,this.index++,e===p5.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(i===p5.COMMA_CODE){if(this.index++,++n!==t.length){if(e===p5.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===p5.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==p5.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(p5.CPAREN_CODE);if(this.code===p5.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:p5.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:p5.ARRAY_EXP,elements:this.gobbleArguments(p5.CBRACK_CODE)}}}Object.assign(p5,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(p5),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"}),p5.max_unop_len=p5.getMaxKeyLen(p5.unary_ops),p5.max_binop_len=p5.getMaxKeyLen(p5.binary_ops);let p9=e=>new p5(e).parse(),p7=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(p5).filter(e=>!p7.includes(e)&&void 0===p9[e]).forEach(e=>{p9[e]=p5[e]}),p9.Jsep=p5,p9.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let p8="ArrowFunctionExpression",fe={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)}},ft={...fe,Promise};function fr(e,t={}){return fl(e,t,fd)}async function fn(e,t={}){return fu(e,t,fd)}function fi(e,t={}){return fl(e,t,fp)}function fo(e,t={}){return fu(e,t,fp)}function fa(e,t={}){return fl(e,t,ff)}function fs(e,t={}){return fu(e,t,ff)}function fl(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=fv(t,fe),i=fh("string"==typeof e?p9(e):e,n);if(r(i))return i;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 fu(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=fv(t,ft);return Promise.resolve(fh("string"==typeof e?p9(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function fc(e){return p9(e)}function fd(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function fp(e){return"boolean"==typeof e}function ff(e){return"number"==typeof e}function fh(e,t){switch(e.type){case"UnaryExpression":var r,n,i,o,a,s,l,u,c,d,p,f,h,m=e,y=t;let g=fh(m.argument,y);switch(m.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${m.operator}''`}case"BinaryExpression":var v=e,b=t;switch(v.operator){case"&&":return fh(v.left,b)&&fh(v.right,b);case"||":return fh(v.left,b)||fh(v.right,b);case"??":return fh(v.left,b)??fh(v.right,b)}let w=fh(v.left,b),x=fh(v.right,b);switch(v.operator){case"+":return w+x;case"-":return w-x;case"*":return w*x;case"/":return w/x;case"%":return w%x;case"**":return w**x;case"==":return w==x;case"===":return w===x;case"!=":return w!=x;case"!==":return w!==x;case">":return w>x;case">=":return w>=x;case"<":return w<x;case"<=":return w<=x;case"in":return w in x;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,fh(r.test,n)?fh(r.consequent,n):fh(r.alternate,n);case"CallExpression":return f_(fy(e,t));case"ArrowFunctionExpression":let E;return i=e,o=t,E=i.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<E.length)throw`Required argument(s) ${E.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(E.reduce((t,r,n)=>{let i=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(i)&&t.push([r,i]),t},[]));return fh(i.body,o.addVariables(t))}).bind(null);case"MemberExpression":return f_(fg(e,t));case"ArrayExpression":return a=e,s=t,a.elements?.map(fx(s));case"SequenceExpression":let S;return l=e,u=t,(S=l.expressions.map(fx(u)))[S.length-1];case"NewExpression":var D=e,O=t;if(D.callee&&"Identifier"===D.callee.type){let e=D.arguments?.map(fx(O));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 e.value;case"Identifier":return c=e,d=t,(fE(c.name),d.variables&&Object.hasOwn(d.variables,c.name))?d.variables[c.name]:Object.hasOwn(d.globals,c.name)?d.globals[c.name]:void 0;case"TemplateLiteral":let P,C;return p=e,f=t,P=p.expressions?.map(fx(f))??[],(C=p.quasis?.map(fx(f))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.join("")+C.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(h=e).cooked,tail:h.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function fm(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return fm(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function fy(e,t){let r=fw(e.callee,t);if(r===fb||e.optional&&null==r)return fb;let n=e.arguments?.map(fx(t));if(r){if("function"!=typeof r)throw`${fO(e.callee)} is not a function`}else throw`No function named ${fO(e.callee)} is defined in this context`;return r(...n)}function fg(e,t){let r=fw(e.object,t);if(r===fb||e.optional&&null==r)return fb;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${fD(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=fm(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${fD(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof r&&"function"!=typeof r&&"string"!=typeof r&&"number"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;let n=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(fh(e.property,t)):function(e){if("Identifier"!==e.type)throw`VisitMemberExpression does not support a property of type '${e.type}'`;return e.name}(e.property);fE(n),function(e,t){if(fS.has(String(t)))return;let r=Object(e);for(;null!==r;){if(Object.hasOwn(r,t)){if(r===Object.prototype||r===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}r=Object.getPrototypeOf(r)}}(r,n);let i=r[n];return"function"==typeof i?i.bind(r):i}function fv(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}p9.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:p8,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=p8,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),p9.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),p9.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",i=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};i(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),i());let o=this.char;("e"===o||"E"===o)&&(n+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(n+=this.expr.charAt(this.index++)),i(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(a===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var i,o,a;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;i=this.code,o=u,95===i||o.some(([e,t])=>i>=e&&i<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(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)&&r.call(this,n)})}}),p9.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,i=this.expr.slice(r,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{n=new RegExp(i,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),p9.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),p9.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",i="",o=!1,a=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:i,cooked:n},tail:o});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,o=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),i="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(i+=a,a=this.expr.charAt(++this.index),i+=a,a){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=a}else n+=a,i+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),p9.addBinaryOp("in",7),p9.addBinaryOp("??",1);let fb=Symbol("optional chain short-circuited");function fw(e,t){switch(e.type){case"MemberExpression":return fg(e,t);case"CallExpression":return fy(e,t);default:return fh(e,t)}}function f_(e){return e===fb?void 0:e}function fx(e){return function(t){return null===t?null:fh(t,e)}}function fE(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let fS=new Set(["toString","valueOf","hasOwnProperty"]);function fD(e,t){try{return fm(e,t)}catch{return"<computed>"}}function fO(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function fP(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...ft},isLocalExpression:!1,variables:new Set};return fC("string"==typeof e?p9(e):e,t),[...t.variables]}function fC(e,t){switch(e.type){case"UnaryExpression":return n=e,i=t,fC(n.argument,i);case"BinaryExpression":return o=e,a=t,[fC(o.left,a),fC(o.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[fC(s.consequent,l),fC(s.test,l),fC(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=fC(u.callee,c),u.arguments?.map(fk(c)),r;case"ArrowFunctionExpression":var n,i,o,a,s,l,u,c,d,p,f,h,m,y,g,v,b=e,w=t;let x={...w};x.isLocalExpression=!0;let E=b.params?.map(fk(x))??[],S=fC(b.body,x)??[];if(S&&Array.isArray(S))for(let e of S)E.includes(e)||w.variables.add(e);return;case"MemberExpression":var D=e,O=t;if(fC(D.object,O),D.computed)return void fC(D.property,O);let P={...O};P.isLocalExpression=!0,fC(D.property,P);return;case"ArrayExpression":return d=e,p=t,void d.elements?.map(fk(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(fk(h));case"NewExpression":return m=e,y=t,void m.arguments?.map(fk(y));case"Literal":case"TemplateElement":return;case"Identifier":var C=e,k=t;if(!(C.name in k.globals))if(k.isLocalExpression)return C.name;else k.variables.add(C.name);return;case"TemplateLiteral":return g=e,v=t,void(g.expressions?.map(fk(v)),g.quasis?.map(fk(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function fk(e){return function(t){return null===t?null:fC(t,e)}}let fj=J("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function fT(e,t,r){fj.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function fR(){let e=fj.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function fA(e){return fj.getState().flags[e].enabled}function fN(e,t){fj.subscribe(r=>{t(r.flags[e].enabled)})}function fM(e,t){fj.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}function fI(e){return!window.offlineEnabled||(e??navigator.onLine)}fj.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var f$=ru(function(e,t,r){rt(e,t,r)});function fL(e=!0,t=!1){return fF(fI(),e,t)}function fF(e,t=!0,r=!1){return!!(e?t:r)}let fB=Z("extensionsInternal",{slots:{},extensions:{}}),fV=Z("extensionRenderings",{renderings:new Map}),fU=()=>J("extensionsInternal",{slots:{},extensions:{}}),fW=()=>J("extensionRenderings",{renderings:new Map});function fz(e){let t=fB.getState(),r=e(t);r!==t&&fB.setState(r)}let fK=null,fH=null;function fG(){let e=fV.getState();return fK&&e===fH||(fK=new Map(e.renderings),fH=e,function(e){for(let t of(f3.clear(),e.values()))f6(t,1);f4=!0}(fK)),fK}function fq(e){fH={renderings:e},fV.setState(fH,!0)}function fZ(e){let t=fG();t.has(e.renderingId)||(t.set(e.renderingId,e),f6(e,1),fq(t))}function fY(e){let t=fG(),r=t.get(e);r&&(t.delete(e),f6(r,-1),fq(t))}let fJ=()=>J("extensions",{slots:{}}),fX=0,fQ=new Set;function f0(e){fX++;try{return e()}finally{if(0==--fX&&fQ.size>0){let e=Array.from(fQ);for(let t of(fQ.clear(),e))f1(t)}}}function f1(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function f2(e){fX>0?fQ.add(e):f1(e)}let f3=new Map,f4=!1;function f6(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=f3.get(r);if(!n){if(t<0)return;f3.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),f4=!0;return}n.count+=t,n.count<1&&(f3.delete(r),f4=!0)}function f5(){var e,t;if(fG(),!f4)return;f4=!1;let r=Array.from(f3.values(),({record:e})=>e);r.sort(f9),e=nz.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===f9(e,t[r]))||nz.setState({mountedExtensions:r})}function f9(e,t){return f7(e.slotName,t.slotName)||f7(e.extensionId,t.extensionId)||f7(e.slotModuleName,t.slotModuleName)||f7(e.extensionModuleName,t.extensionModuleName)}function f7(e,t){return e===t?0:e<t?-1:1}f5(),fV.subscribe(()=>f2(f5));let f8=fU(),he=fJ(),ht=nH(),hr=nZ(),hn=new Set,hi=!1;function ho(e){if(null===e)hn=null;else if(null!==hn)for(let t of e)hn.add(t);f2(ha)}function ha(){if(!hi){hi=!0;try{for(let e=1;;e++){let t=hn;if(null!==t&&0===t.size)return;hn=new Set;try{!function(e,t,r,n,i,o=null){let a=he.getState().slots,s={},l=!1,u=fI(),c=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,d]of Object.entries(e.slots)){let p=a[n];if(p&&o&&!o.has(n)){s[n]=p;continue}let{config:f}=nq(t,d.name),h=function(e,t,r,n,i,o,a){let s=function(e,t){let r=e.add||[],n=e.remove||[],i=e.order||[],{extensions:o}=f8.getState();return[...t,...r].filter(e=>!n.includes(e)).sort((e,r)=>hg(e,i,o[hc(e)]?.order,t)-hg(r,i,o[hc(r)]?.order,t))}(r,t.slots[e].attachedIds),l=[];for(let u of s){let{config:s}=nJ(n,e,u),c=nX(r,e,u),d=c?f$({},s,c):s,p=hc(u),f=t.extensions[p];if(f){let e=d?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!aL(e,a.user))||f.featureFlag&&!i.includes(f.featureFlag)||window.offlineEnabled&&!fF(o,f.online,f.offline))continue;l.push({id:u,name:p,moduleName:f.moduleName,config:d,featureFlag:f.featureFlag,meta:f.meta,online:d?.["Display conditions"]?.online??f.online??!0,offline:d?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||f.displayExpression})}}return l}(n,e,f,r,c,u,i.session);p&&p.moduleName===d.moduleName&&r1(p.candidateExtensions,h)?s[n]=p:(s[n]={moduleName:d.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&he.setState({slots:s})}(f8.getState(),ht.getState(),hr.getState(),fj.getState(),aT.getState(),t)}catch(e){throw hn=null===t||null===hn?null:new Set([...t,...hn]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{hi=!1}}}function hs(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function hl(){ho(null)}function hu(e,t){return{moduleName:t,name:e,attachedIds:[]}}function hc(e){let[t]=e.split("#");return t}function hd(e,t){let r=hc(t);return e.extensions[r]}function hp(e){return hd(f8.getState(),e)}f8.subscribe((e,t)=>{ho(e.extensions!==t.extensions?null:hs(e.slots,t.slots))}),ht.subscribe((e,t)=>{ho(hs(e.slots,t.slots))}),hr.subscribe((e,t)=>{ho(hs(e.configs,t.configs))}),fj.subscribe(()=>ho(null)),aT.subscribe(()=>ho(null)),hl(),v(hl);let hf=e=>fz(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function hh(e,t){fz(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...hu(e),attachedIds:[t]}}}})}function hm(e,t){fz(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function hy(e){fz(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function hg(e,t,r,n){let i=t.indexOf(e);if(-1!==i)return i;{if(void 0!==r)return 1e3+r;let t=n.indexOf(e);return -1!==t?2e3+t:3e3}}function hv(e,t){return function(e,t,r=null,n){let i;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;i??(i=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!fi(o,i)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(hb(e),t,aT.getState().session,e)}function hb(e){return he.getState().slots[e]?.candidateExtensions??[]}let hw=(e,t)=>f8.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let i=hu(t,e);return{...r,slots:{...r.slots,[t]:{...i}}}}),h_=()=>{hn=null,fz(()=>({slots:{},extensions:{}})),fW().setState({renderings:new Map}),he.setState({slots:{}})},hx=Z("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function hE({name:e,basePath:t,mode:r,componentContext:n,state:i}){hx.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:i})}function hS(e){hx.getState().slotName===e&&hx.setState(hx.getInitialState(),!0)}let hD=Z("modalRegistry",{modals:{}});function hO(e){hD.setState(t=>(t.modals[e.name]=e,t))}function hP(e){let t=hD.getState().modals[e];if(!t){let r=hp(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),hO(t))}return t}let hC=Z("workspaceRegistrations",{workspaces:{}}),hk=Z("workspaceGroups",{workspaceGroups:{}});function hj(e){hC.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function hT(e){hk.setState(t=>{let r=t.workspaceGroups[e.name];return r?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...r,members:Array.from(new Set([...r.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let hR=new Set;function hA(e){let t=hC.getState().workspaces;if(t[e])return t[e];{let t=hp(e);if(t){var r;let n;return hR.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.`),hR.add(e)),{name:t.name,title:(r=t,"string"==typeof(n=r?.meta?.title)?n:n&&"object"==typeof n?sP(r.moduleName,n.key,n.default):r.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function hN(e){let t=hk.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let hM=Z("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function hI(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=hM.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function h$(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=hM.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function hL(e){let{openedWindows:t}=hM.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function hF(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=hM.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}hM.setState({registeredGroupsByName:n})}function hB(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=hM.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}hM.setState({registeredWindowsByName:n})}function hV(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=hM.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}hM.setState({registeredWorkspacesByName:n})}let hU=0,hW=null,hz={bootstrap:15e3,mount:15e3,unmount:15e3};function hK(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(hz).filter(t=>e[t]).map(n=>{var i,o;let a,s;return[n,(i=e[n],o=hz[n],a=Array.isArray(i)?i:[i],s=e=>a.reduce((t,i,o)=>t.then(()=>{let t=i(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${o} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let i,a=new Promise((e,t)=>{i=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${o}ms`)),o)});return Promise.race([s(e),a]).finally(()=>clearTimeout(i)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function hH(e,t){var r,n;let i,o,a,s,l,u=await (hW??(hW=new Promise((e,t)=>{oO({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),oO))),hW),c={...t},d=(i=c,o=!1,{retarget:e=>i={...e},release:a=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(i),onSettled(e,t){switch(e){case"bootstrap":t&&a();return;case"mount":o||(o=t);return;case"unmount":(t||o)&&a();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>hK(e,r)):hK(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function hG(){return hq}function hq(e,t){let r,n=hH(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function hZ(e,t,r,n,i=e=>e,o={}){let a=hc(n),s=hp(n),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:u,moduleName:c,online:d,offline:p,load:f}=s;if(fL(d,p)){let s,d=hU++,p=`${t}/${n}-${d}`;e.dataset.extensionRenderingId=p;let h=e=>{try{fY(p)}catch(t){console.error(e,t)}};try{fZ({renderingId:p,extensionName:a,extensionModuleName:c,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{s=await f()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await hH(i({...s,name:`${t}/${a}-${d}`}),{...o,_meta:u,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var hY=r(7125),hJ=r.n(hY);let hX=(0,hY.createContext)({moduleName:"",featureName:""});function hQ({to:e,templateParams:t,onBeforeNavigate:r,children:n,...i}){return(0,hY.useEffect)(()=>{i.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${i.href}'`),i.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),hJ().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),ah({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:ap(e,t),...i},n)}let h0=({state:e,children:t,...r})=>{let{extension:n}=(0,hY.useContext)(hX),i=(0,hY.useRef)(null),o=(0,hY.useRef)(Promise.resolve()),a=(0,hY.useRef)(!1),s=(0,hY.useRef)(!1),l=(0,hY.useRef)(e),u=(0,hY.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,hY.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(i.current?.getStatus()==="MOUNTED"&&i.current.update)return i.current.update({...t})}).catch(e=>{let t=i.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,hY.useCallback)(t=>{t&&!i.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,hZ(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,i.current=t,a.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,hY.useEffect)(()=>(a.current=!1,()=>{a.current=!0,u(i.current)}),[]),(0,hY.useEffect)(()=>{l.current=e,i.current&&c(i.current,e)},[e]),n?hJ().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function h1(e){let t=(0,hY.useRef)(e);return F(t.current,e)||(t.current=e),t.current}function h2(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,i]of Object.entries(t)){let t=function(...t){e.setState(e=>i(e,...t))};r[n]=t}return r}let h3=e=>e;function h4(e,t=h3,r){let n=(0,hY.useCallback)(t=>e.subscribe(t),[e]),i=(0,hY.useCallback)(()=>t(e.getState()),[e,t]),o=(0,hY.useSyncExternalStore)(n,i,i),a=(0,hY.useMemo)(()=>r?h2(e,r):null,[e,r]);return(0,hY.useMemo)(()=>a?{...o,...a}:o,[o,a])}function h6(e,t){return h4(e,h3,t)}function h5(e){return function(t){let r=(0,hY.useCallback)(t=>e.subscribe(t),[]),n=(0,hY.useCallback)(()=>e.getState(),[]),i=(0,hY.useSyncExternalStore)(r,n,n),o=(0,hY.useMemo)(()=>t?h2(e,t):null,[t]);return(0,hY.useMemo)(()=>o?{...i,...o}:i,[i,o])}}let h9=[];Object.freeze(h9);let h7={candidateExtensions:h9};Object.freeze(h7);let h8=e=>{let t=(0,hY.useCallback)(t=>t.slots?.[e]??h7,[e]);return h4(fJ(),t)},me=e=>e.session;function mt(e,t){let{candidateExtensions:r}=h8(e),n=h4(aT,me),i=h1(t);return(0,hY.useMemo)(()=>hv(e,i),[e,i,n,r])}function mr(e,t){let{moduleName:r}=(0,hY.useContext)(hX);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,hY.useEffect)(()=>{hw(r,e)},[r,e]),{extensions:mt(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function mn(e){return e}function mi({name:e,extensionSlotName:t,select:r=mn,children:n,state:i,style:o,...a}){if(n&&i)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,hY.useRef)(null),{extensions:u,extensionSlotModuleName:c}=mr(s,i),d=(0,hY.useMemo)(()=>r(u),[r,u]),p=(0,hY.useMemo)(()=>{if("function"==typeof n&&!hJ().isValidElement(n))return d.map(e=>n(e,i))},[n,d]);return hJ().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...a},s&&d?.map((e,t)=>hJ().createElement(hX.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},p?.[t]??("function"!=typeof n?n:null)??hJ().createElement(h0,{state:i}))))}var mo=r(5873);function ma(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ms(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ma(Object(r),!0).forEach(function(t){var n,i,o;n=e,i=t,o=r[t],i in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ma(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ml(e){return(ml="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 mu(e){return(mu="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 mc(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(mu(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(mu(e)));return e}}var md=null;try{md=require("react").createContext()}catch(e){}var mp={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 mf(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function mh(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var i,o=mv(e,t,function(){r(this)}),a=mc(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,i=e.domElement,o=t[r];if("function"!=typeof o)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=o(i);return a.render(n),a;case"hydrateRoot":return o(i,n);default:return o(n,i),null}}({elementToRender:o,domElement:a,reactDom:mg(e),renderType:"function"==typeof(i=e).renderType?i.renderType():i.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function mm(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():mg(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function my(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=mv(e,t,null),i=e.renderResults[t.name];if(i&&i.render)i.render(n);else{var o=mc(e,t)();mg(e).render(n,o)}})}function mg(e){return e.ReactDOMClient||e.ReactDOM}function mv(e,t,r){var n=e.React.createElement(e.rootComponent,t),i=md?e.React.createElement(md.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),i=e.React.createElement(e.errorBoundaryClass,t,i)),i=e.React.createElement(e.SingleSpaRoot,ms(ms({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),i)}var mb=r(5921),mw=r(7364),m_=r.n(mw),mx=r(9106);let mE={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},mS=new Map;(0,mx.initCache)(mS);let mD={errorRetryCount:3,fetcher:aC,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof aj){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>mS};function mO(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},mE,e),r={...mD,...t.swrConfig};return function(e){var n,i,o,a,s;return o=i=class extends(n=hJ().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return hJ().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=hJ().createElement(hY.Suspense,{fallback:null},hJ().createElement(mw.SWRConfig,{value:r},hJ().createElement(hX.Provider,{value:this.state.config},t.disableTranslations?hJ().createElement(e,this.props):hJ().createElement(mb.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},hJ().createElement(e,this.props)))));return t.strictMode&&hJ().StrictMode?hJ().createElement(hJ().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in o?Object.defineProperty(o,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[a]=s,i}}function mP(e,t){return function(e){if("object"!==ml(e))throw Error("single-spa-react requires a configuration object");var t,r=ms(ms({},mp),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!md&&r.React.createContext&&(md=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:mf.bind(null,r),mount:mh.bind(null,r),unmount:mm.bind(null,r)};return r.parcelCanUpdate&&(n.update=my.bind(null,r)),n}({React:hJ(),ReactDOMClient:mo,rootComponent:mO(t)(e)})}function mC(e,t){return()=>e().then(({default:e})=>mP(e,t))}function mk(e,t){return()=>Promise.resolve(mP(e,t))}let mj=mC,mT=W()(()=>({}));Y("openmrs-app-context",mT);let mR={};function mA(e,t=e=>e){let r=mT.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function mN(e,t){mT.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function mM(e){return null===e?null:Object.freeze(Object.assign({},e))}let mI=new Map;function m$(e,t){let r=(0,hY.useRef)(t??{}),n=(0,hY.useRef)(t=>mN(e,t)),i=(0,hY.useRef)(Symbol());return(0,hY.useEffect)(()=>{let r=t??{},n=i.current;return null===mA(e)?!function(e,t=mR){mT.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===mR?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),mN(e,()=>r)),mI.set(e,n),()=>{mI.get(e)===n&&(mT.setState(t=>(e in t&&delete t[e],t)),mI.delete(e))}},[e]),(0,hY.useEffect)(()=>{let n=t??{};F(r.current,n)||(mN(e,()=>n),r.current=n)},[t]),n.current}function mL({namespace:e,value:t}){return m$(e,t),null}let mF=({children:e,value:t,fallback:r})=>t?hJ().createElement(hJ().Fragment,null,e):r?hJ().createElement(hJ().Fragment,null,r):null;function mB(){let e=(0,hY.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,hY.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function mV(e,t=e=>e??{}){let[r,n]=(0,hY.useState)(()=>{if(mU(e))return;let r=mA(e);if(null!==r)return t?t(r):r});return(0,hY.useEffect)(()=>{if(mU(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,hY.useEffect)(()=>{var r;let i;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>F(e,r)?e:r)})(mM(i=mA(e))),mT.subscribe(t=>{let n=e in t?t[e]:null;n!==i&&(i=n,r(mM(n)))})},[e,t]),r}function mU(e){return"string"!=typeof e||0===e.trim().length}function mW(e){let t=mt(e);return(0,hY.useMemo)(()=>t.map(e=>e.id),[t])}function mz(e){return h8(e).candidateExtensions}function mK(e,t,r){let{data:n,error:i,mutate:o,isLoading:a,isValidating:s}=m_()(e?lm(e,t,r):null,aC);return(0,hY.useMemo)(()=>({isLoading:a,data:n?.data.results??[],error:i,mutate:o,isValidating:s}),[n,i,a,s,o])}function mH(e){(0,hY.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let mG={},mq=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let aT=Z("session",{loaded:!1,session:null}),aR=0;function aA(e={includeAuthStatus:!0}){return(aR<Date.now()-6e4||!aT.getState().loaded)&&aI(),new eL(t=>{let r=r=>{r.loaded&&(e.includeAuthStatus?t.next(r.session):t.next(r.session?.user))};return r(aT.getState()),aT.subscribe(r)})}function aN(){return(aR<Date.now()-6e4||!aT.getState().loaded)&&aI(),aT}function aM(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function aI(e,t){aR=Date.now();let r={};return e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),aW(aC(aO,{headers:r}))}function a$(){aT.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function aL(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!ee(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!ee(n.privileges.find(t=>e===t.display))):(ee(r)||console.error(`Could not understand privileges "${r}"`),!0))||!ee(t.roles.find(e=>"System Developer"===e.display))}function aF(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(aT.getState()),e||(t=aT.subscribe(n))})}function aB(){return new Promise((e,t)=>{aA().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function aV(e,t){return aW(aC(aO,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function aU(e,t,r){return r||(r=new AbortController),await aC(`${aS}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),aI()}function aW(e){return new Promise((t,r)=>{e.then(e=>{let n;"object"==typeof e?.data?(n={loaded:!0,session:e.data},aT.setState(n),t(n)):(n={loaded:!1,session:null},aT.setState(n),r(n))}).catch(e=>{I(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};aT.setState(t),r(t)})})}function az(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}aT.subscribe(e=>{e.loaded&&e.session&&aM(e.session)});let aK={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function aH(){is("@openmrs/esm-api",ax),aI()}let aG={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",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",localVersion:"Local Build",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}}",prereleaseVersion:"Prerelease",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"},aq=e=>"string"==typeof e,aZ=()=>{let e,t,r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r},aY=e=>null==e?"":""+e,aJ=/###/g,aX=e=>e&&e.indexOf("###")>-1?e.replace(aJ,"."):e,aQ=e=>!e||aq(e),a0=(e,t,r)=>{let n=aq(t)?t.split("."):t,i=0;for(;i<n.length-1;){if(aQ(e))return{};let t=aX(n[i]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return aQ(e)?{}:{obj:e,k:aX(n[i])}},a1=(e,t,r)=>{let{obj:n,k:i}=a0(e,t,Object);if(void 0!==n||1===t.length){n[i]=r;return}let o=t[t.length-1],a=t.slice(0,t.length-1),s=a0(e,a,Object);for(;void 0===s.obj&&a.length;)o=`${a[a.length-1]}.${o}`,s=a0(e,a=a.slice(0,a.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${o}`]&&(s.obj=void 0);s.obj[`${s.k}.${o}`]=r},a2=(e,t)=>{let{obj:r,k:n}=a0(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},a3=(e,t,r)=>{for(let n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?aq(e[n])||e[n]instanceof String||aq(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):a3(e[n],t[n],r):e[n]=t[n]);return e};var a4={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let a6=e=>aq(e)?e.replace(/[&<>"'\/]/g,e=>a4[e]):e,a5=[" ",",","?","!",";"],a9=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(void 0!==t)return t;let r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}(20),a7=(e,t,r=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let n=t.split(r),i=e;for(let e=0;e<n.length;){let t;if(!i||"object"!=typeof i)return;let o="";for(let a=e;a<n.length;++a)if(a!==e&&(o+=r),o+=n[a],void 0!==(t=i[o])){if(["string","number","boolean"].indexOf(typeof t)>-1&&a<n.length-1)continue;e+=a-e+1;break}i=t}return i},a8=e=>e?.replace("_","-"),se={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class st{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||se,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,r,n){return n&&!this.debug?null:(aq(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new st(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new st(this.logger,e)}}var sr=new st;class sn{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let r=this.observers[e].get(t)||0;this.observers[e].set(t,r+1)}),this}off(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,r])=>{for(let n=0;n<r;n++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,n])=>{for(let i=0;i<n;i++)r.apply(r,[e,...t])})}}class si extends sn{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,n={}){let i,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,a=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?i=e.split("."):(i=[e,t],r&&(Array.isArray(r)?i.push(...r):aq(r)&&o?i.push(...r.split(o)):i.push(r)));let s=a2(this.data,i);return(!s&&!t&&!r&&e.indexOf(".")>-1&&(e=i[0],t=i[1],r=i.slice(2).join(".")),!s&&a&&aq(r))?a7(this.data?.[e]?.[t],r,o):s}addResource(e,t,r,n,i={silent:!1}){let o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,a=[e,t];r&&(a=a.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(a=e.split("."),n=t,t=a[1]),this.addNamespaces(t),a1(this.data,a,n),i.silent||this.emit("added",e,t,r,n)}addResources(e,t,r,n={silent:!1}){for(let n in r)(aq(r[n])||Array.isArray(r[n]))&&this.addResource(e,t,n,r[n],{silent:!0});n.silent||this.emit("added",e,t,r)}addResourceBundle(e,t,r,n,i,o={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),n=r,r=t,t=a[1]),this.addNamespaces(t);let s=a2(this.data,a)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),n?a3(s,r,i):s={...s,...r},a1(this.data,a,s),o.silent||this.emit("added",e,t,r)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var so={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,n,i){return e.forEach(e=>{t=this.processors[e]?.process(t,r,n,i)??t}),t}};let sa=Symbol("i18next/PATH_KEY");function ss(e,t){let r,n,i,{[sa]:o}=e((n=[],(i=Object.create(null)).get=(e,t)=>(r?.revoke?.(),t===sa)?n:(n.push(t),(r=Proxy.revocable(e,i)).proxy),Proxy.revocable(Object.create(null),i).proxy));return o.join(t?.keySeparator??".")}let sl={},su=e=>!aq(e)&&"boolean"!=typeof e&&"number"!=typeof e;class sc extends sn{constructor(e,t={}){super(),((e,t,r)=>{e.forEach(e=>{t[e]&&(r[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=sr.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let r={...t};if(null==e)return!1;let n=this.resolve(e,r);if(n?.res===void 0)return!1;let i=su(n.res);return!1!==r.returnObjects||!i}extractFromKey(e,t){let r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");let n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],o=r&&e.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,r)=>{t=t||"",r=r||"";let n=a5.filter(e=>0>t.indexOf(e)&&0>r.indexOf(e));if(0===n.length)return!0;let i=a9.getRegExp(`(${n.map(e=>"?"===e?"\\?":e).join("|")})`),o=!i.test(e);if(!o){let t=e.indexOf(r);t>0&&!i.test(e.substring(0,t))&&(o=!0)}return o})(e,r,n);if(o&&!a){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:aq(i)?[i]:i};let o=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(o[0])>-1)&&(i=o.shift()),e=o.join(n)}return{key:e,namespaces:aq(i)?[i]:i}}translate(e,t,r){let n="object"==typeof t?{...t}:t;if("object"!=typeof n&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof n&&(n={...n}),n||(n={}),null==e)return"";"function"==typeof e&&(e=ss(e,{...this.options,...n})),Array.isArray(e)||(e=[String(e)]);let i=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],n),l=s[s.length-1],u=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c?.toLowerCase()==="cimode")return d?i?{res:`${l}${u}${a}`,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${u}${a}`:i?{res:a,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a;let p=this.resolve(e,n),f=p?.res,h=p?.usedKey||a,m=p?.exactUsedKey||a,y=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,g=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==n.count&&!aq(n.count),b=sc.hasDefaultValue(n),w=v?this.pluralResolver.getSuffix(c,n.count,n):"",x=n.ordinal&&v?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",E=v&&!n.ordinal&&0===n.count,S=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${w}`]||n[`defaultValue${x}`]||n.defaultValue,D=f;g&&!f&&b&&(D=S);let O=su(D),P=Object.prototype.toString.apply(D);if(g&&D&&O&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(P)&&!(aq(y)&&Array.isArray(D))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,D,{...n,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return i?(p.res=e,p.usedParams=this.getUsedParamsDetails(n),p):e}if(o){let e=Array.isArray(D),t=e?[]:{},r=e?m:h;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let i=`${r}${o}${e}`;b&&!f?t[e]=this.translate(i,{...n,defaultValue:su(S)?S[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(i,{...n,joinArrays:!1,ns:s}),t[e]===i&&(t[e]=D[e])}f=t}}else if(g&&aq(y)&&Array.isArray(f))(f=f.join(y))&&(f=this.extendTranslation(f,e,n,r));else{let t=!1,i=!1;!this.isValidLookup(f)&&b&&(t=!0,f=S),this.isValidLookup(f)||(i=!0,f=a);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&i?void 0:f,d=b&&S!==f&&this.options.updateMissing;if(i||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,a,d?S:f),o){let e=this.resolve(a,{...n,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let r=0;r<t.length;r++)e.push(t[r]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(n.lng||this.language):e.push(n.lng||this.language);let r=(e,t,r)=>{let i=b&&r!==f?r:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,i,d,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,i,d,n),this.emit("missingKey",e,l,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,n);E&&n[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{r([e],a+t,n[`defaultValue${t}`]||S)})}):r(e,a,S))}f=this.extendTranslation(f,e,n,p,r),i&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${l}${u}${a}`),(i||t)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,t?f:void 0,n))}return i?(p.res=f,p.usedParams=this.getUsedParamsDetails(n),p):f}extendTranslation(e,t,r,n,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){let o;r.interpolation&&this.interpolator.init({...r,...{interpolation:{...this.options.interpolation,...r.interpolation}}});let a=aq(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=r.replace&&!aq(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,r.lng||this.language||n.usedLng,r),a){let t=e.match(this.interpolator.nestingRegexp);o<(t&&t.length)&&(r.nest=!1)}!r.lng&&n&&n.res&&(r.lng=this.language||n.usedLng),!1!==r.nest&&(e=this.interpolator.nest(e,(...e)=>i?.[0]!==e[0]||r.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),r)),r.interpolation&&this.interpolator.reset()}let o=r.postProcess||this.options.postProcess,a=aq(o)?[o]:o;return null!=e&&a?.length&&!1!==r.applyPostProcessor&&(e=so.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,n,i,o,a;return aq(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(r))return;let s=this.extractFromKey(e,t),l=s.key;n=l;let u=s.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let c=void 0!==t.count&&!aq(t.count),d=c&&!t.ordinal&&0===t.count,p=void 0!==t.context&&(aq(t.context)||"number"==typeof t.context)&&""!==t.context,f=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(a=e,!sl[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(sl[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${n}" 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(n=>{let a;if(this.isValidLookup(r))return;o=n;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,n,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(n,t.count,t));let r=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(i)&&s.push(l+e.replace(i,this.options.pluralSeparator)),s.push(l+e),d&&s.push(l+r)),p){let n=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(n),c&&(t.ordinal&&0===e.indexOf(i)&&s.push(n+e.replace(i,this.options.pluralSeparator)),s.push(n+e),d&&s.push(n+r))}}for(;a=s.pop();)this.isValidLookup(r)||(i=a,r=this.getResource(n,e,a,t))}))})}),{res:r,usedKey:n,exactUsedKey:i,usedLng:o,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,r,n={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}getUsedParamsDetails(e={}){let t=e.replace&&!aq(e.replace),r=t?e.replace:e;if(t&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!t)for(let e of(r={...r},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete r[e];return r}static hasDefaultValue(e){let t="defaultValue";for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}class sd{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=sr.create("languageUtils")}getScriptPartFromCode(e){if(!(e=a8(e))||0>e.indexOf("-"))return null;let t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(!(e=a8(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(aq(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return(t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t)?t:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let t;return e?(e.forEach(e=>{if(t)return;let r=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let r=this.getScriptPartFromCode(e);if(this.isSupportedCode(r))return t=r;let n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(e=>{if(e===n||!(0>e.indexOf("-")&&0>n.indexOf("-"))&&(e.indexOf("-")>0&&0>n.indexOf("-")&&e.substring(0,e.indexOf("-"))===n||0===e.indexOf(n)&&n.length>1))return e})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),aq(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}toResolveHierarchy(e,t){let r=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),n=[],i=e=>{e&&(this.isSupportedCode(e)?n.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return aq(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&i(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&i(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&i(this.getLanguagePartFromCode(e))):aq(e)&&i(this.formatLanguageCode(e)),r.forEach(e=>{0>n.indexOf(e)&&i(this.formatLanguageCode(e))}),n}}let sp={zero:0,one:1,two:2,few:3,many:4,other:5},sf={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class sh{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=sr.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let r,n=a8("dev"===e?"en":e),i=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:n,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];try{r=new Intl.PluralRules(n,{type:i})}catch(i){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),sf;if(!e.match(/-|_/))return sf;let n=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(n,t)}return this.pluralRulesCache[o]=r,r}needsPlural(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,r={}){return this.getSuffixes(e,r).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let r=this.getRule(e,t);return(r||(r=this.getRule("dev",t)),r)?r.resolvedOptions().pluralCategories.sort((e,t)=>sp[e]-sp[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,r={}){let n=this.getRule(e,r);return n?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${n.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,r))}}let sm=(e,t,r,n=".",i=!0)=>{let o,a=void 0!==(o=a2(e,r))?o:a2(t,r);return!a&&i&&aq(r)&&void 0===(a=a7(e,r,n))&&(a=a7(t,r,n)),a};class sy{constructor(e={}){this.logger=sr.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:t,escapeValue:r,useRawValueToEscape:n,prefix:i,prefixEscaped:o,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:p,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:y,alwaysFormat:g}=e.interpolation;this.escape=void 0!==t?t:a6,this.escapeValue=void 0===r||r,this.useRawValueToEscape=void 0!==n&&n,this.prefix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):o||"{{",this.suffix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=d?d.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):p||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=y||1e3,this.alwaysFormat=void 0!==g&&g,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,r,n){let i,o,a,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let i=sm(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,r,{...n,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),o=i.shift().trim(),a=i.join(this.formatSeparator).trim();return this.format(sm(t,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),a,r,{...n,...t,interpolationkey:o})};this.resetRegExp();let u=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(t=>{for(a=0;i=t.regex.exec(e);){let r=i[1].trim();if(void 0===(o=l(r)))if("function"==typeof u){let t=u(e,i,n);o=aq(t)?t:""}else if(n&&Object.prototype.hasOwnProperty.call(n,r))o="";else if(c){o=i[0];continue}else this.logger.warn(`missed to pass in variable ${r} for interpolating ${e}`),o="";else aq(o)||this.useRawValueToEscape||(o=aY(o));let s=t.safeValue(o);if(e=e.replace(i[0],s),c?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++a>=this.maxReplaces)break}}),e}nest(e,t,r={}){let n,i,o,a=(e,t)=>{let r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;let n=e.split(RegExp(`${r}[ ]*{`)),i=`{${n[1]}`;e=n[0];let a=(i=this.interpolate(i,o)).match(/'/g),s=i.match(/"/g);((a?.length??0)%2!=0||s)&&s.length%2==0||(i=i.replace(/'/g,'"'));try{o=JSON.parse(i),t&&(o={...t,...o})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${r}${i}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,e};for(;n=this.nestingRegexp.exec(e);){let s=[];(o=(o={...r}).replace&&!aq(o.replace)?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;let l=/{.*}/.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==l&&(s=n[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,l)),(i=t(a.call(this,n[1].trim(),o),o))&&n[0]===e&&!aq(i))return i;aq(i)||(i=aY(i)),i||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),i=""),s.length&&(i=s.reduce((e,t)=>this.format(e,t,r.lng,{...r,interpolationkey:n[1].trim()}),i.trim())),e=e.replace(n[0],i),this.regexp.lastIndex=0}return e}}let sg=e=>{let t={};return(r,n,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});let a=n+JSON.stringify(o),s=t[a];return s||(s=e(a8(n),i),t[a]=s),s(r)}},sv=e=>(t,r,n)=>e(a8(r),n)(t);class sb{constructor(e={}){this.logger=sr.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let r=t.cacheInBuiltFormats?sg:sv;this.formats={number:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t});return e=>r.format(e)}),currency:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>r.format(e)}),datetime:r((e,t)=>{let r=new Intl.DateTimeFormat(e,{...t});return e=>r.format(e)}),relativetime:r((e,t)=>{let r=new Intl.RelativeTimeFormat(e,{...t});return e=>r.format(e,t.range||"day")}),list:r((e,t)=>{let r=new Intl.ListFormat(e,{...t});return e=>r.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=sg(t)}format(e,t,r,n={}){let i=t.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&0>i[0].indexOf(")")&&i.find(e=>e.indexOf(")")>-1)){let e=i.findIndex(e=>e.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,e)].join(this.formatSeparator)}return i.reduce((e,t)=>{let{formatName:i,formatOptions:o}=(e=>{let t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){let n=e.split("(");t=n[0].toLowerCase().trim();let i=n[1].substring(0,n[1].length-1);"currency"===t&&0>i.indexOf(":")?r.currency||(r.currency=i.trim()):"relativetime"===t&&0>i.indexOf(":")?r.range||(r.range=i.trim()):i.split(";").forEach(e=>{if(e){let[t,...n]=e.split(":"),i=n.join(":").trim().replace(/^'+|'+$/g,""),o=t.trim();r[o]||(r[o]=i),"false"===i&&(r[o]=!1),"true"===i&&(r[o]=!0),isNaN(i)||(r[o]=parseInt(i,10))}})}return{formatName:t,formatOptions:r}})(t);if(this.formats[i]){let t=e;try{let a=n?.formatParams?.[n.interpolationkey]||{},s=a.locale||a.lng||n.locale||n.lng||r;t=this.formats[i](e,s,{...o,...n,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}}class sw extends sn{constructor(e,t,r,n={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=n,this.logger=sr.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,n.backend,n)}queueLoad(e,t,r,n){let i={},o={},a={},s={};return e.forEach(e=>{let n=!0;t.forEach(t=>{let a=`${e}|${t}`;!r.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===o[a]&&(o[a]=!0):(this.state[a]=1,n=!1,void 0===o[a]&&(o[a]=!0),void 0===i[a]&&(i[a]=!0),void 0===s[t]&&(s[t]=!0)))}),n||(a[e]=!0)}),(Object.keys(i).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(i),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,t,r){let n=e.split("|"),i=n[0],o=n[1];t&&this.emit("failedLoading",i,o,t),!t&&r&&this.store.addResourceBundle(i,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&r&&(this.state[e]=0);let a={};this.queue.forEach(r=>{((e,t,r,n)=>{let{obj:i,k:o}=a0(e,t,Object);i[o]=i[o]||[],i[o].push(r)})(r.loaded,[i],o),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(e=>{a[e]||(a[e]={});let t=r.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,r,n=0,i=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:n,wait:i,callback:o});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&&n<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,r,n+1,2*i,o)},i):o(a,s)},s=this.backend[r].bind(this.backend);if(2===s.length){try{let r=s(e,t);r&&"function"==typeof r.then?r.then(e=>a(null,e)).catch(a):a(null,r)}catch(e){a(e)}return}return s(e,t,a)}prepareLoading(e,t,r={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();aq(e)&&(e=this.languageUtils.toResolveHierarchy(e)),aq(t)&&(t=[t]);let i=this.queueLoad(e,t,r,n);if(!i.toLoad.length)return i.pending.length||n(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,r){this.prepareLoading(e,t,{},r)}reload(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}loadOne(e,t=""){let r=e.split("|"),n=r[0],i=r[1];this.read(n,i,"read",void 0,void 0,(r,o)=>{r&&this.logger.warn(`${t}loading namespace ${i} for language ${n} failed`,r),!r&&o&&this.logger.log(`${t}loaded namespace ${i} for language ${n}`,o),this.loaded(e,r,o)})}saveMissing(e,t,r,n,i,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${r}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=r&&""!==r){if(this.backend?.create){let s={...o,isUpdate:i},l=this.backend.create.bind(this.backend);if(l.length<6)try{let i;(i=5===l.length?l(e,t,r,n,s):l(e,t,r,n))&&"function"==typeof i.then?i.then(e=>a(null,e)).catch(a):a(null,i)}catch(e){a(e)}else l(e,t,r,n,a,s)}e&&e[0]&&this.store.addResource(e[0],t,r,n)}}}let s_=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),aq(e[1])&&(t.defaultValue=e[1]),aq(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let r=e[3]||e[2];Object.keys(r).forEach(e=>{t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),sx=e=>(aq(e.ns)&&(e.ns=[e.ns]),aq(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),aq(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),sE=()=>{};class sS extends sn{constructor(e={},t){if(super(),this.options=sx(e),this.services={},this.logger=sr,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{"function"==typeof e[t]&&(e[t]=e[t].bind(e))})})(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(aq(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let r=s_();this.options={...r,...this.options,...sx(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let n=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?sr.init(n(this.modules.logger),this.options):sr.init(null,this.options),e=this.modules.formatter?this.modules.formatter:sb;let t=new sd(this.options);this.store=new si(this.options.resources,this.options);let i=this.services;i.logger=sr,i.resourceStore=this.store,i.languageUtils=t,i.pluralResolver=new sh(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(i.formatter=n(e),i.formatter.init&&i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new sy(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new sw(n(this.modules.backend),i.resourceStore,i,this.options),i.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(i.languageDetector=n(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=n(this.modules.i18nFormat),i.i18nFormat.init&&i.i18nFormat.init(this)),this.translator=new sc(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=sE),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let i=aZ(),o=()=>{let e=(e,r)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),i.resolve(r),t(e,r)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),i}loadResources(e,t=sE){let r=t,n=aq(e)?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(n?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return r();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};n?t(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,t,r){let n=aZ();return"function"==typeof e&&(r=e,e=void 0),"function"==typeof t&&(r=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),r||(r=sE),this.services.backendConnector.reload(e,t,e=>{n.resolve(),r(e)}),n}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&so.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let r=aZ();this.emit("languageChanging",e);let n=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,o)=>{o?this.isLanguageChangingTo===e&&(n(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,r.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},o=t=>{e||t||!this.services.languageDetector||(t=[]);let r=aq(t)?t:t&&t[0],o=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(aq(t)?[t]:t);o&&(this.language||n(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,e=>{i(e,o)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),r}getFixedT(e,t,r){let n=(e,t,...i)=>{let o,a;(o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(i)):{...t}).lng=o.lng||n.lng,o.lngs=o.lngs||n.lngs,o.ns=o.ns||n.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||r||n.keyPrefix);let s=this.options.keySeparator||".";return o.keyPrefix&&Array.isArray(e)?a=e.map(e=>("function"==typeof e&&(e=ss(e,{...this.options,...t})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=ss(e,{...this.options,...t})),a=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(a,o)};return aq(e)?n.lng=e:n.lngs=e,n.ns=t,n.keyPrefix=r,n}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let r=t.lng||this.resolvedLanguage||this.languages[0],n=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;let o=(e,t)=>{let r=this.services.backendConnector.state[`${e}|${t}`];return -1===r||0===r||2===r};if(t.precheck){let e=t.precheck(this,o);if(void 0!==e)return e}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!n||o(i,e)))}loadNamespaces(e,t){let r=aZ();return this.options.ns?(aq(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}loadLanguages(e,t){let r=aZ();aq(e)&&(e=[e]);let n=this.options.preload||[],i=e.filter(e=>0>n.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=n.concat(i),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let t=this.services?.languageUtils||new sd(s_());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new sS(e,t)}cloneInstance(e={},t=sE){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let n={...this.options,...e,isClone:!0},i=new sS(n);return(void 0!==e.debug||void 0!==e.prefix)&&(i.logger=i.logger.clone(e)),["store","services","language"].forEach(e=>{i[e]=this[e]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},r&&(i.store=new si(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((r,n)=>(r[n]={...e[t][n]},r),e[t]),e),{}),n),i.services.resourceStore=i.store),i.translator=new sc(i.services,n),i.translator.on("*",(e,...t)=>{i.emit(e,...t)}),i.init(n,t),i.translator.options=n,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let sD=sS.createInstance();sD.createInstance=sS.createInstance,sD.createInstance,sD.dir,sD.init,sD.loadResources,sD.reloadResources,sD.use,sD.changeLanguage,sD.getFixedT,sD.t,sD.exists,sD.setDefaultNamespace,sD.hasLoadedNamespace,sD.loadNamespaces,sD.loadLanguages;let sO=sD.default||sD;function sP(e,t,r,n){return sO.t(t,{ns:e,defaultValue:r,...n})}function sC(e,t,r){return aG[e]?sP("core",e,t??aG[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}sO.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let sk="import-map-override:",sj="import-map-overrides-disabled",sT="import-map-overrides:change",sR=!1,sA=null,sN=null;async function sM(){return sN??(sN=sI().then(({map:e,complete:t})=>(t||(sN=null),e))),sN}async function sI(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let i=e[n];try{if(i.src){let e=await fetch(i.src);if(!e.ok)throw Error(`Request for ${i.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else i.textContent&&t.push(JSON.parse(i.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:s$(t),complete:r}}function s$(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function sL(){let e={};try{let t=sW();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(sk)){let r=n.slice(sk.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function sF(){let e=await sM();return sR?s$([e,sA??sL()]):e}async function sB(){return sM()}async function sV(){return sR?s$([await sM(),sL()]):sM()}function sU(e){if(!sR)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sk)){let t=localStorage.getItem(r);t&&(e[r.slice(sk.length)]=t)}}return{imports:e}}return sL()}function sW(){if(!sR)return[];try{let e=localStorage.getItem(sj);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function sz(e){return!!sR&&sW().includes(e)}function sK(e,t){if(!sR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sk+e,t),window.dispatchEvent(new CustomEvent(sT))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sH(e){if(!sR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sk+e);let t=sW().filter(t=>t!==e);t.length>0?localStorage.setItem(sj,JSON.stringify(t)):localStorage.removeItem(sj),window.dispatchEvent(new CustomEvent(sT))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sG(){if(!sR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(sk)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(sj),window.dispatchEvent(new CustomEvent(sT))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function sq(e){if(!sR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=sW().filter(t=>t!==e);t.length>0?localStorage.setItem(sj,JSON.stringify(t)):localStorage.removeItem(sj),window.dispatchEvent(new CustomEvent(sT))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let sZ=!1;function sY(){!sZ&&(sZ=!0,(sR="development"===window.spaEnv)&&(sA=sL()))}function sJ(e){return e.replace(/[\/\-@]/g,"_")}async function sX(e,t="./start",n){var i;let o,a=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([sQ(e,n?.importMap),new Promise((t,r)=>{o=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=a)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},a)})]),o&&clearTimeout(o);let s=sJ(e),l=window[s];if(!("object"==typeof(i=l)&&null!==i&&"init"in i&&"function"==typeof i.init&&"get"in i&&"function"==typeof i.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function sQ(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=sJ(e);if(!window[r]){let r=t??await s0();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let i=e in sU().imports;try{return await function(e){var t;let r=(t=window)[s1]??(t[s1]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let i=document.createElement("script");i.src=e,i.type="text/javascript",i.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function a(){clearTimeout(o),i.removeEventListener("load",s),i.removeEventListener("error",l)}function s(){a(),t()}function l(t){a(),r.delete(e),i.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}i.addEventListener("load",s),i.addEventListener("error",l),document.head.appendChild(i)});return r.set(e,o),o}(n)}catch(e){return i&&T({kind:"error",title:sC("scriptLoadingFailed","Error: Script failed to load"),description:sC("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:sC("resetOverrides","Reset overrides"),onActionButtonClick(){sG(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function s0(){return sF()}let s1=Symbol.for("__openmrs_script_loading");function s2(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function s3(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&s2(t))}let s4="openmrs-routes:",s6="openmrs-routes:change",s5=!1,s9=null,s7=null;async function s8(){return s7??(s7=le().then(({map:e,complete:t})=>(t||(s7=null),e))),s7}async function le(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let i=e[n];try{let e;if(i.src){let t=await fetch(i.src);if(!t.ok)throw Error(`Request for ${i.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else i.textContent&&(e=JSON.parse(i.textContent));e&&s3(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:lt(t),complete:r}}function lt(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function lr(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(s4)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(s4.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(s2(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(s2(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function ln(){let e=await s8();return s5?lt([e,s9??await lr()]):e}async function li(){return s8()}async function lo(){return s5?lt([await s8(),await lr()]):s8()}function la(){if(!s5)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(s4)){let t=localStorage.getItem(r);t&&(e[r.slice(s4.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function ls(e,t){if(!s5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(s4+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!s2(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(s4+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(s4+e,JSON.stringify(t.toString()));else{if(!s2(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(s4+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(s6))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function ll(e){if(!s5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(s4+e),window.dispatchEvent(new CustomEvent(s6))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function lu(){if(!s5)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(s4)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(s6))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let lc=null;function ld(){return lc||(lc=(s5="development"===window.spaEnv)?lr().then(e=>{s9=e}):Promise.resolve())}let lp=`${aS}/attachment`;function lf(e,t){return aC(`${lp}/${e}`,{signal:t.signal})}function lh(e,t,r,n){return aC(lm(e,t,n),{signal:r.signal})}function lm(e,t,r){return r?`${lp}?patient=${e}&encounter=${r}`:`${lp}?patient=${e}&includeEncounterless=${t}`}async function ly(e,t,r){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),r&&n.append("encounter",r),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),aC(`${lp}`,{method:"POST",body:n})}function lg(e,t){return aC(`${lp}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function lv(e,t){return new Promise(function(r){var n=new MessageChannel;n.port1.onmessage=function(e){r(e.data)},e.postMessage(t,[n.port2])})}function lb(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function lw(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var l_=function(){var e=this;this.promise=new Promise(function(t,r){e.resolve=t,e.reject=r})};function lx(e,t){var r=location.href;return new URL(e,r).href===new URL(t,r).href}var lE=function(e,t){this.type=e,Object.assign(this,t)};function lS(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function lD(){}var lO={type:"SKIP_WAITING"};function lP(e,t){if(!t)return e&&e.then?e.then(lD):Promise.resolve()}var lC=function(e){function t(t,r){var n,i;return void 0===r&&(r={}),(n=e.call(this)||this).nn={},n.tn=0,n.rn=new l_,n.en=new l_,n.on=new l_,n.un=0,n.an=new Set,n.cn=function(){var e=n.fn,t=e.installing;n.tn>0||!lx(t.scriptURL,n.sn.toString())||performance.now()>n.un+6e4?(n.vn=t,e.removeEventListener("updatefound",n.cn)):(n.hn=t,n.an.add(t),n.rn.resolve(t)),++n.tn,t.addEventListener("statechange",n.ln)},n.ln=function(e){var t=n.fn,r=e.target,i=r.state,o=r===n.vn,a={sw:r,isExternal:o,originalEvent:e};!o&&n.mn&&(a.isUpdate=!0),n.dispatchEvent(new lE(i,a)),"installed"===i?n.wn=self.setTimeout(function(){"installed"===i&&t.waiting===r&&n.dispatchEvent(new lE("waiting",a))},200):"activating"===i&&(clearTimeout(n.wn),o||n.en.resolve(r))},n.dn=function(e){var t=n.hn,r=t!==navigator.serviceWorker.controller;n.dispatchEvent(new lE("controlling",{isExternal:r,originalEvent:e,sw:t,isUpdate:n.mn})),r||n.on.resolve(t)},i=function(e){var t=e.data,r=e.ports,i=e.source;return lS(n.getSW(),function(){n.an.has(i)&&n.dispatchEvent(new lE("message",{data:t,originalEvent:e,ports:r,sw:i}))})},n.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(i.apply(this,e))}catch(e){return Promise.reject(e)}},n.sn=t,n.nn=r,navigator.serviceWorker.addEventListener("message",n.gn),n}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var r,n,i=t.prototype;return i.register=function(e){var t=(void 0===e?{}:e).immediate,r=void 0!==t&&t;try{var n,i,o,a=this;return n=function(){if(!r&&"complete"!==document.readyState)return lP(new Promise(function(e){return window.addEventListener("load",e)}))},i=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),lS(a.bn(),function(e){a.fn=e,a.yn&&(a.hn=a.yn,a.en.resolve(a.yn),a.on.resolve(a.yn),a.yn.addEventListener("statechange",a.ln,{once:!0}));var t=a.fn.waiting;return t&&lx(t.scriptURL,a.sn.toString())&&(a.hn=t,Promise.resolve().then(function(){a.dispatchEvent(new lE("waiting",{sw:t,wasWaitingBeforeRegister:!0}))}).then(function(){})),a.hn&&(a.rn.resolve(a.hn),a.an.add(a.hn)),a.fn.addEventListener("updatefound",a.cn),navigator.serviceWorker.addEventListener("controllerchange",a.dn),a.fn})},(o=n())&&o.then?o.then(i):i(o)}catch(e){return Promise.reject(e)}},i.update=function(){try{return this.fn?lP(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},i.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},i.messageSW=function(e){try{return lS(this.getSW(),function(t){return lv(t,e)})}catch(e){return Promise.reject(e)}},i.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&lv(this.fn.waiting,lO)},i.pn=function(){var e=navigator.serviceWorker.controller;return e&&lx(e.scriptURL,this.sn.toString())?e:void 0},i.bn=function(){try{var e=this;return function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return lS(navigator.serviceWorker.register(e.sn,e.nn),function(t){return e.un=performance.now(),t})},function(e){throw e})}catch(e){return Promise.reject(e)}},r=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],lb(t.prototype,r),n&&lb(t,n),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,r=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return lw(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?lw(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=r()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function lk(e,t){if(void 0!==p)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),p;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let r=new lC(e,t);return p=r.register().then(()=>r.controlling.then(()=>r))}function lj(){return p??Promise.resolve(void 0)}let lT="x-omrs-offline-response-body",lR="x-omrs-offline-response-status",lA="x-omrs-offline-caching-strategy";async function lN(e){let t=await lj();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function lM(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function lI(){return!window.indexedDB}async function l$(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function lL(){return await l$()||await lI()||await lM()}let lF="openmrs3:offline-mode",lB="unavailable";function lV(){return{current:lB,notAvailable:"unavailable"===lB,active:"on"===lB}}function lU(e){"unavailable"!==lB&&"unavailable"!==e&&(localStorage.setItem(lF,"on"===e?"active":"disabled"),lB=e)}async function lW(){await lL()||(lB="active"===localStorage.getItem(lF)?"on":"off"),navigator.onLine}let lz="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,lK=Object.keys,lH=Array.isArray;function lG(e,t){return"object"!=typeof t||lK(t).forEach(function(r){e[r]=t[r]}),e}"u"<typeof Promise||lz.Promise||(lz.Promise=Promise);let lq=Object.getPrototypeOf,lZ={}.hasOwnProperty;function lY(e,t){return lZ.call(e,t)}function lJ(e,t){"function"==typeof t&&(t=t(lq(e))),("u"<typeof Reflect?lK:Reflect.ownKeys)(t).forEach(r=>{lQ(e,r,t[r])})}let lX=Object.defineProperty;function lQ(e,t,r,n){lX(e,t,lG(r&&lY(r,"get")&&"function"==typeof r.get?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function l0(e){return{from:function(t){return e.prototype=Object.create(t.prototype),lQ(e.prototype,"constructor",e),{extend:lJ.bind(null,e.prototype)}}}}let l1=Object.getOwnPropertyDescriptor;function l2(e,t){let r;return l1(e,t)||(r=lq(e))&&l2(r,t)}let l3=[].slice;function l4(e,t,r){return l3.call(e,t,r)}function l6(e,t){return t(e)}function l5(e){if(!e)throw Error("Assertion Failed")}function l9(e){lz.setImmediate?setImmediate(e):setTimeout(e,0)}function l7(e,t){return e.reduce((e,r,n)=>{var i=t(r,n);return i&&(e[i[0]]=i[1]),e},{})}function l8(e,t){if("string"==typeof t&&lY(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var r=[],n=0,i=t.length;n<i;++n){var o=l8(e,t[n]);r.push(o)}return r}var a=t.indexOf(".");if(-1!==a){var s=e[t.substr(0,a)];return null==s?void 0:l8(s,t.substr(a+1))}}function ue(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){l5("string"!=typeof r&&"length"in r);for(var n=0,i=t.length;n<i;++n)ue(e,t[n],r[n])}else{var o=t.indexOf(".");if(-1!==o){var a=t.substr(0,o),s=t.substr(o+1);if(""===s)void 0===r?lH(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=r;else{var l=e[a];l&&lY(e,a)||(l=e[a]={}),ue(l,s,r)}}else void 0===r?lH(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function ut(e){var t={};for(var r in e)lY(e,r)&&(t[r]=e[r]);return t}let ur=[].concat;function un(e){return ur.apply([],e)}let ui="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(un([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>lz[e]),uo=ui.map(e=>lz[e]);l7(ui,e=>[e,!0]);let ua=null;function us(e){ua="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let r=ua&&ua.get(t);if(r)return r;if(lH(t)){r=[],ua&&ua.set(t,r);for(var n=0,i=t.length;n<i;++n)r.push(e(t[n]))}else if(uo.indexOf(t.constructor)>=0)r=t;else{let n=lq(t);for(var o in r=n===Object.prototype?{}:Object.create(n),ua&&ua.set(t,r),t)lY(t,o)&&(r[o]=e(t[o]))}return r}(e);return ua=null,t}let{toString:ul}={};function uu(e){return ul.call(e).slice(8,-1)}let uc="u">typeof Symbol?Symbol.iterator:"@@iterator",ud="symbol"==typeof uc?function(e){var t;return null!=e&&(t=e[uc])&&t.apply(e)}:function(){return null},up={};function uf(e){var t,r,n,i;if(1==arguments.length){if(lH(e))return e.slice();if(this===up&&"string"==typeof e)return[e];if(i=ud(e)){for(r=[];!(n=i.next()).done;)r.push(n.value);return r}if(null==e)return[e];if("number"==typeof(t=e.length)){for(r=Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=Array(t);t--;)r[t]=arguments[t];return r}let uh="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var um="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),uy=()=>!0;let ug=!Error("").stack;function uv(){if(ug)try{throw uv.arguments,Error()}catch(e){return e}return Error()}function ub(e,t){var r=e.stack;return r?(t=t||0,0===r.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),r.split("\n").slice(t).filter(uy).map(e=>"\n"+e).join("")):""}var uw=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],u_=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(uw),ux={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 uE(e,t){this._e=uv(),this.name=e,this.message=t}function uS(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,r)=>r.indexOf(e)===t).join("\n")}function uD(e,t,r,n){this._e=uv(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=uS(e,t)}function uO(e,t){this._e=uv(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=uS(e,t)}l0(uE).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+ub(this._e,2))}},toString:function(){return this.name+": "+this.message}}),l0(uD).from(uE),l0(uO).from(uE);var uP=u_.reduce((e,t)=>(e[t]=t+"Error",e),{}),uC=u_.reduce((e,t)=>{var r=t+"Error";function n(e,n){this._e=uv(),this.name=r,e?"string"==typeof e?(this.message=`${e}${n?"\n "+n:""}`,this.inner=n||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=ux[t]||r,this.inner=null)}return l0(n).from(uE),e[t]=n,e},{});uC.Syntax=SyntaxError,uC.Type=TypeError,uC.Range=RangeError;var uk=uw.reduce((e,t)=>(e[t+"Error"]=uC[t],e),{}),uj=u_.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=uC[t]),e),{});function uT(){}function uR(e){return e}function uA(e,t){return null==e||e===uR?t:function(r){return t(e(r))}}function uN(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function uM(e,t){return e===uT?t:function(){var r=e.apply(this,arguments);void 0!==r&&(arguments[0]=r);var n=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?uN(n,this.onsuccess):n),i&&(this.onerror=this.onerror?uN(i,this.onerror):i),void 0!==o?o:r}}function uI(e,t){return e===uT?t:function(){e.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?uN(r,this.onsuccess):r),n&&(this.onerror=this.onerror?uN(n,this.onerror):n)}}function u$(e,t){return e===uT?t:function(r){var n=e.apply(this,arguments);lG(r,n);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?uN(i,this.onsuccess):i),o&&(this.onerror=this.onerror?uN(o,this.onerror):o),void 0===n?void 0===a?void 0:a:lG(n,a)}}function uL(e,t){return e===uT?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function uF(e,t){return e===uT?t:function(){var r=e.apply(this,arguments);if(r&&"function"==typeof r.then){for(var n=this,i=arguments.length,o=Array(i);i--;)o[i]=arguments[i];return r.then(function(){return t.apply(n,o)})}return t.apply(this,arguments)}}uj.ModifyError=uD,uj.DexieError=uE,uj.BulkError=uO;var uB={};let[uV,uU,uW]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,lq(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,lq(t),e]})(),uz=uU&&uU.then,uK=uV&&uV.constructor,uH=!!uW;var uG=!1,uq=uW?()=>{uW.then(co)}:lz.setImmediate?setImmediate.bind(null,co):lz.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{co(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(co,0)},uZ=function(e,t){u4.push([e,t]),uJ&&(uq(),uJ=!1)},uY=!0,uJ=!0,uX=[],uQ=[],u0=null,u1=uR,u2={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ck,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{ck(e[0],e[1])}catch(e){}})}},u3=u2,u4=[],u6=0,u5=[];function u9(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=uT,this._lib=!1;var t=this._PSD=u3;if(um&&(this._stackHolder=uv(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==uB)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&ce(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,r){try{r(r=>{if(null===t._state){if(r===t)throw TypeError("A promise cannot be resolved with itself.");var n=t._lib&&ca();r&&"function"==typeof r.then?e(t,(e,t)=>{r instanceof u9?r._then(e,t):r.then(e,t)}):(t._state=!0,t._value=r,ct(t)),n&&cs()}},ce.bind(null,t))}catch(e){ce(t,e)}}(this,e)}let u7={get:function(){var e=u3,t=cm;function r(r,n){var i=!e.global&&(e!==u3||t!==cm);let o=i&&!cb();var a=new u9((t,a)=>{cr(this,new u8(cO(r,e,i,o),cO(n,e,i,o),t,a,e))});return um&&ci(a,this),a}return r.prototype=uB,r},set:function(e){lQ(this,"then",e&&e.prototype===uB?u7:{get:function(){return e},set:u7.set})}};function u8(e,t,r,n,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=r,this.reject=n,this.psd=i}function ce(e,t){if(uQ.push(t),null===e._state){var r=e._lib&&ca();t=u1(t),e._state=!1,e._value=t,um&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var r=l2(t,"stack");t._promise=e,lQ(t,"stack",{get:()=>uG?r&&(r.get?r.get.apply(t):r.value):e.stack})}),uX.some(t=>t._value===e._value)||uX.push(e),ct(e),r&&cs()}}function ct(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)cr(e,t[r]);var i=e._PSD;--i.ref||i.finalize(),0===u6&&(++u6,uZ(()=>{0==--u6&&cl()},[]))}function cr(e,t){if(null!==e._state){var r=e._state?t.onFulfilled:t.onRejected;if(null===r)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++u6,uZ(cn,[r,e,t])}else e._listeners.push(t)}function cn(e,t,r){try{u0=t;var n,i=t._value;t._state?n=e(i):(uQ.length&&(uQ=[]),n=e(i),-1===uQ.indexOf(i)&&function(e){for(var t=uX.length;t;)if(uX[--t]._value===e._value)return void uX.splice(t,1)}(t)),r.resolve(n)}catch(e){r.reject(e)}finally{u0=null,0==--u6&&cl(),--r.psd.ref||r.psd.finalize()}}function ci(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function co(){ca()&&cs()}function ca(){var e=uY;return uY=!1,uJ=!1,e}function cs(){var e,t,r;do for(;u4.length>0;)for(e=u4,u4=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(u4.length>0);uY=!0,uJ=!0}function cl(){var e=uX;uX=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=u5.slice(0),r=t.length;r;)t[--r]()}function cu(e){return new u9(uB,!1,e)}function cc(e,t){var r=u3;return function(){var n=ca(),i=u3;try{return cE(r,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{cE(i,!1),n&&cs()}}}lJ(u9.prototype,{then:u7,_then:function(e,t){cr(this,new u8(null,null,e,t,u3))},catch:function(e){if(1==arguments.length)return this.then(null,e);var t=arguments[0],r=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?r(e):cu(e)):this.then(null,e=>e&&e.name===t?r(e):cu(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),cu(t)))},stack:{get:function(){if(this._stack)return this._stack;try{uG=!0;var e=(function e(t,r,n){if(r.length===n)return r;var i="";if(!1===t._state){var o,a,s=t._value;null!=s?(o=s.name||"Error",a=s.message||s,i=ub(s,0)):(o=s,a=""),r.push(o+(a?": "+a:"")+i)}return um&&((i=ub(t._stackHolder,2))&&-1===r.indexOf(i)&&r.push(i),t._prev&&e(t._prev,r,n)),r})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{uG=!1}}},timeout:function(e,t){return e<1/0?new u9((r,n)=>{var i=setTimeout(()=>n(new uC.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,i))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&lQ(u9.prototype,Symbol.toStringTag,"Dexie.Promise"),u2.env=cS(),lJ(u9,{all:function(){var e=uf.apply(null,arguments).map(cw);return new u9(function(t,r){0===e.length&&t([]);var n=e.length;e.forEach((i,o)=>u9.resolve(i).then(r=>{e[o]=r,--n||t(e)},r))})},resolve:e=>{if(e instanceof u9)return e;if(e&&"function"==typeof e.then)return new u9((t,r)=>{e.then(t,r)});var t=new u9(uB,!0,e);return ci(t,u0),t},reject:cu,race:function(){var e=uf.apply(null,arguments).map(cw);return new u9((t,r)=>{e.map(e=>u9.resolve(e).then(t,r))})},PSD:{get:()=>u3,set:e=>u3=e},totalEchoes:{get:()=>cm},newPSD:cg,usePSD:cD,scheduler:{get:()=>uZ,set:e=>{uZ=e}},rejectionMapper:{get:()=>u1,set:e=>{u1=e}},follow:(e,t)=>new u9((r,n)=>cg((t,r)=>{var n=u3;n.unhandleds=[],n.onunhandled=r,n.finalize=uN(function(){var e;e=()=>{0===this.unhandleds.length?t():r(this.unhandleds[0])},u5.push(function t(){e(),u5.splice(u5.indexOf(t),1)}),++u6,uZ(()=>{0==--u6&&cl()},[])},n.finalize),e()},t,r,n))}),uK&&(uK.allSettled&&lQ(u9,"allSettled",function(){let e=uf.apply(null,arguments).map(cw);return new u9(t=>{0===e.length&&t([]);let r=e.length,n=Array(r);e.forEach((e,i)=>u9.resolve(e).then(e=>n[i]={status:"fulfilled",value:e},e=>n[i]={status:"rejected",reason:e}).then(()=>--r||t(n)))})}),uK.any&&"u">typeof AggregateError&&lQ(u9,"any",function(){let e=uf.apply(null,arguments).map(cw);return new u9((t,r)=>{0===e.length&&r(AggregateError([]));let n=e.length,i=Array(n);e.forEach((e,o)=>u9.resolve(e).then(e=>t(e),e=>{i[o]=e,--n||r(AggregateError(i))}))})}));let cd={awaits:0,echoes:0,id:0};var cp=0,cf=[],ch=0,cm=0,cy=0;function cg(e,t,r,n){var i=u3,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++cy;var a=u2.env;o.env=uH?{Promise:u9,PromiseProp:{value:u9,configurable:!0,writable:!0},all:u9.all,race:u9.race,allSettled:u9.allSettled,any:u9.any,resolve:u9.resolve,reject:u9.reject,nthen:cP(a.nthen,o),gthen:cP(a.gthen,o)}:{},t&&lG(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=cD(o,e,r,n);return 0===o.ref&&o.finalize(),s}function cv(){return cd.id||(cd.id=++cp),++cd.awaits,cd.echoes+=100,cd.id}function cb(){return!!cd.awaits&&(0==--cd.awaits&&(cd.id=0),cd.echoes=100*cd.awaits,!0)}function cw(e){return cd.echoes&&e&&e.constructor===uK?(cv(),e.then(e=>(cb(),e),e=>(cb(),cj(e)))):e}function c_(e){++cm,cd.echoes&&0!=--cd.echoes||(cd.echoes=cd.id=0),cf.push(u3),cE(e,!0)}function cx(){var e=cf[cf.length-1];cf.pop(),cE(e,!1)}function cE(e,t){var r,n=u3;if((t?!cd.echoes||ch++&&e===u3:!ch||--ch&&e===u3)||(r=t?c_.bind(null,e):cx,uz.call(uV,r)),e!==u3&&(u3=e,n===u2&&(u2.env=cS()),uH)){var i=u2.env.Promise,o=e.env;uU.then=o.nthen,i.prototype.then=o.gthen,(n.global||e.global)&&(Object.defineProperty(lz,"Promise",o.PromiseProp),i.all=o.all,i.race=o.race,i.resolve=o.resolve,i.reject=o.reject,o.allSettled&&(i.allSettled=o.allSettled),o.any&&(i.any=o.any))}}function cS(){var e=lz.Promise;return uH?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(lz,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:uU.then,gthen:e.prototype.then}:{}}function cD(e,t,r,n,i){var o=u3;try{return cE(e,!0),t(r,n,i)}finally{cE(o,!1)}}function cO(e,t,r,n){return"function"!=typeof e?e:function(){var i,o=u3;r&&cv(),cE(t,!0);try{return e.apply(this,arguments)}finally{cE(o,!1),n&&(i=cb,uz.call(uV,i))}}}function cP(e,t){return function(r,n){return e.call(this,cO(r,t),cO(n,t))}}-1===(""+uz).indexOf("[native code]")&&(cv=cb=uT);let cC="unhandledrejection";function ck(e,t){var r;try{r=t.onuncatched(e)}catch(e){}if(!1!==r)try{var n,i={promise:t,reason:e};if(lz.document&&document.createEvent?((n=document.createEvent("Event")).initEvent(cC,!0,!0),lG(n,i)):lz.CustomEvent&&lG(n=new CustomEvent(cC,{detail:i}),i),n&&lz.dispatchEvent&&(dispatchEvent(n),!lz.PromiseRejectionEvent&&lz.onunhandledrejection))try{lz.onunhandledrejection(n)}catch(e){}um&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var cj=u9.reject;let cT="3.2.7",cR=String.fromCharCode(65535),cA=-1/0,cN="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",cM="String expected.",cI=[],c$="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),cL=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),cF="__dbnames",cB="readonly",cV="readwrite";function cU(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let cW={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function cz(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=us(t))[e],t)}class cK{_trans(e,t,r){let n=this._tx||u3.trans,i=this.name;function o(e,r,n){if(!n.schema[i])throw new uC.NotFound("Table "+i+" not part of transaction");return t(n.idbtrans,n)}let a=ca();try{return n&&n.db===this.db?n===u3.trans?n._promise(e,o,r):cg(()=>n._promise(e,o,r),{trans:n,transless:u3.transless||u3}):function e(t,r,n,i){if(t.idbdb&&(t._state.openComplete||u3.letThrough||t._vip)){var o=t._createTransaction(r,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===uP.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,i))):cj(o)}return o._promise(r,(e,t)=>cg(()=>(u3.trans=o,i(e,t,o)))).then(e=>o._completion.then(()=>e))}if(t._state.openComplete)return cj(new uC.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return cj(new uC.DatabaseClosed);t.open().catch(uT)}return t._state.dbReadyPromise.then(()=>e(t,r,n,i))}(this.db,e,[this.name],o)}finally{a&&cs()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(lH(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=lK(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let r=this.schema.indexes.concat(this.schema.primKey).filter(e=>{if(e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)){for(let r=0;r<t.length;++r)if(-1===t.indexOf(e.keyPath[r]))return!1;return!0}return!1}).sort((e,t)=>e.keyPath.length-t.keyPath.length)[0];if(r&&this.db._maxKey!==cR){let n=r.keyPath.slice(0,t.length);return this.where(n).equals(n.map(t=>e[t]))}!r&&um&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:n}=this.schema,i=this.db._deps.indexedDB;function o(e,t){try{return 0===i.cmp(e,t)}catch(e){return!1}}let[a,s]=t.reduce(([t,r],i)=>{let a=n[i],s=e[i];return[t||a,t||!a?cU(r,a&&a.multi?e=>{let t=l8(e,i);return lH(t)&&t.some(e=>o(s,e))}:e=>o(s,l8(e,i))):r]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):r?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,lH(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let r=Object.create(e.prototype);for(var n in t)if(lY(t,n))try{r[n]=t[n]}catch(e){}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){lG(this,e)})}add(e,t){let{auto:r,keyPath:n}=this.schema.primKey,i=e;return n&&r&&(i=cz(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[i]})).then(e=>e.numFailures?u9.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{ue(e,n,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||lH(e))return this.where(":id").equals(e).modify(t);{let r=l8(e,this.schema.primKey.keyPath);if(void 0===r)return cj(new uC.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?lK(t).forEach(r=>{ue(e,r,t[r])}):t(e,{value:e,primKey:r})}catch(e){}return this.where(":id").equals(r).modify(t)}}put(e,t){let{auto:r,keyPath:n}=this.schema.primKey,i=e;return n&&r&&(i=cz(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[i],keys:null!=t?[t]:null})).then(e=>e.numFailures?u9.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{ue(e,n,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?u9.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:cW})).then(e=>e.numFailures?u9.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,r){let n=Array.isArray(t)?t:void 0,i=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:o}=this.schema.primKey;if(o&&n)throw new uC.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new uC.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&r?e.map(cz(o)):e;return this.core.mutate({trans:t,type:"add",keys:n,values:s,wantResults:i}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return i?t:r;throw new uO(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,n)})})}bulkPut(e,t,r){let n=Array.isArray(t)?t:void 0,i=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:o}=this.schema.primKey;if(o&&n)throw new uC.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new uC.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&r?e.map(cz(o)):e;return this.core.mutate({trans:t,type:"put",keys:n,values:s,wantResults:i}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return i?t:r;throw new uO(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,n)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:r,failures:n})=>{if(0===e)return r;throw new uO(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,n)})}}function cH(e){var t={},r=function(r,n){if(n){for(var i=arguments.length,o=Array(i-1);--i;)o[i-1]=arguments[i];return t[r].subscribe.apply(null,o),e}if("string"==typeof r)return t[r]};r.addEventType=o;for(var n=1,i=arguments.length;n<i;++n)o(arguments[n]);return r;function o(e,n,i){if("object"!=typeof e){n||(n=uL),i||(i=uT);var a={subscribers:[],fire:i,subscribe:function(e){-1===a.subscribers.indexOf(e)&&(a.subscribers.push(e),a.fire=n(a.fire,e))},unsubscribe:function(e){a.subscribers=a.subscribers.filter(function(t){return t!==e}),a.fire=a.subscribers.reduce(n,i)}};return t[e]=r[e]=a,a}lK(e).forEach(function(t){var r=e[t];if(lH(r))o(t,e[t][0],e[t][1]);else{if("asap"!==r)throw new uC.InvalidArgument("Invalid event config");var n=o(t,uR,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){l9(function(){e.apply(null,t)})})})}})}}function cG(e,t){return l0(t).from({prototype:e}),t}function cq(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function cZ(e,t){e.filter=cU(e.filter,t)}function cY(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>cU(n(),t()):t,e.justLimit=r&&!n}function cJ(e,t){if(e.isPrimKey)return t.primaryKey;let r=t.getIndexByKeyPath(e.index);if(!r)throw new uC.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function cX(e,t,r){let n=cJ(e,t.schema);return t.openCursor({trans:r,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:n,range:e.range}})}function cQ(e,t,r,n){let i=e.replayFilter?cU(e.filter,e.replayFilter()):e.filter;if(e.or){let o={},a=(e,r,n)=>{if(!i||i(r,n,e=>r.stop(e),e=>r.fail(e))){var a=r.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),lY(o,s)||(o[s]=!0,t(e,r,n))}};return Promise.all([e.or._iterate(a,r),c0(cX(e,n,r),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return c0(cX(e,n,r),cU(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function c0(e,t,r,n){var i=cc(n?(e,t,i)=>r(n(e),t,i):r);return e.then(e=>{if(e)return e.start(()=>{var r=()=>e.continue();t&&!t(e,e=>r=e,t=>{e.stop(t),r=uT},t=>{e.fail(t),r=uT})||i(e.value,e,e=>r=e),r()})})}function c1(e,t){try{let r=c2(e),n=c2(t);if(r!==n)return"Array"===r?1:"Array"===n?-1:"binary"===r?1:"binary"===n?-1:"string"===r?1:"string"===n?-1:"Date"===r?1:"Date"!==n?NaN:-1;switch(r){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let r=e.length,n=t.length,i=r<n?r:n;for(let r=0;r<i;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return r===n?0:r<n?-1:1}(c3(e),c3(t));case"Array":return function(e,t){let r=e.length,n=t.length,i=r<n?r:n;for(let r=0;r<i;++r){let n=c1(e[r],t[r]);if(0!==n)return n}return r===n?0:r<n?-1:1}(e,t)}}catch(e){}return NaN}function c2(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let r=uu(e);return"ArrayBuffer"===r?"binary":r}function c3(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class c4{_read(e,t){var r=this._ctx;return r.error?r.table._trans(null,cj.bind(null,r.error)):r.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,cj.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=cU(t.algorithm,e)}_iterate(e,t){return cQ(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&lG(r,e),t._ctx=r,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(r=>cQ(t,e,r,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,r=t.table.core;if(cq(t,!0))return r.count({trans:e,query:{index:cJ(t,r.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var n=0;return cQ(t,()=>(++n,!1),e,r).then(()=>n)}).then(e)}sortBy(e,t){let r=e.split(".").reverse(),n=r[0],i=r.length-1;function o(e,t){return t?o(e[r[t]],t-1):e[n]}var a="next"===this._ctx.dir?1:-1;function s(e,t){var r=o(e,i),n=o(t,i);return r<n?-a:r>n?a:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&cq(t,!0)&&t.limit>0){let{valueMapper:r}=t,n=cJ(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:n,range:t.range}}).then(({result:e})=>r?e.map(r):e)}{let r=[];return cQ(t,e=>r.push(e),e,t.table.core).then(()=>r)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,cq(t)?cY(t,()=>{var t=e;return(e,r)=>0===t||(1===t?--t:r(()=>{e.advance(t),t=0}),!1)}):cY(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),cY(this._ctx,()=>{var t=e;return function(e,r,n){return--t<=0&&r(n),t>=0}},!0),this}until(e,t){return cZ(this._ctx,function(r,n,i){return!e(r.value)||(n(i),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return cZ(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=cU(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.key,r)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.primaryKey,r)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.key)}).then(function(){return r}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&cq(t,!0)&&t.limit>0)return this._read(e=>{var r=cJ(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:r,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var r={};return cZ(this._ctx,function(e){var t=e.primaryKey.toString(),n=lY(r,t);return r[t]=!0,!n}),this}modify(e){var t=this._ctx;return this._write(r=>{var n;if("function"==typeof e)n=e;else{var i=lK(e),o=i.length;n=function(t){for(var r=!1,n=0;n<o;++n){var a=i[n],s=e[a];l8(t,a)!==s&&(ue(t,a,s),r=!0)}return r}}let a=t.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,u=this.db._options.modifyChunkSize||200,c=[],d=0,p=[],f=(e,t)=>{let{failures:r,numFailures:n}=t;for(let t of(d+=e-n,lK(r)))c.push(r[t])};return this.clone().primaryKeys().then(i=>{let o=c=>{let d=Math.min(u,i.length-c);return a.getMany({trans:r,keys:i.slice(c,c+d),cache:"immutable"}).then(p=>{let h=[],m=[],y=s?[]:null,g=[];for(let e=0;e<d;++e){let t=p[e],r={value:us(t),primKey:i[c+e]};!1!==n.call(r,r.value,r)&&(null==r.value?g.push(i[c+e]):s||0===c1(l(t),l(r.value))?(m.push(r.value),s&&y.push(i[c+e])):(g.push(i[c+e]),h.push(r.value)))}let v=cq(t)&&t.limit===1/0&&("function"!=typeof e||e===c6)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&a.mutate({trans:r,type:"add",values:h}).then(e=>{for(let t in e.failures)g.splice(parseInt(t),1);f(h.length,e)})).then(()=>(m.length>0||v&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:y,values:m,criteria:v,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(g.length>0||v&&e===c6)&&a.mutate({trans:r,type:"delete",keys:g,criteria:v}).then(e=>f(g.length,e))).then(()=>i.length>c+d&&o(c+u))})};return o(0).then(()=>{if(c.length>0)throw new uD("Error modifying one or more objects",c,d,p);return i.length})})})}delete(){var e=this._ctx,t=e.range;return cq(e)&&(e.isPrimKey&&!c$||3===t.type)?this._write(r=>{let{primaryKey:n}=e.table.core.schema;return e.table.core.count({trans:r,query:{index:n,range:t}}).then(n=>e.table.core.mutate({trans:r,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:r,numFailures:i})=>{if(i)throw new uD("Could not delete some values",Object.keys(e).map(t=>e[t]),n-i);return n-i}))}):this.modify(c6)}}let c6=(e,t)=>t.value=null;function c5(e,t){return e<t?-1:+(e!==t)}function c9(e,t){return e>t?-1:+(e!==t)}function c7(e,t,r){var n=e instanceof dn?new e.Collection(e):e;return n._ctx.error=r?new r(t):TypeError(t),n}function c8(e){return new e.Collection(e,()=>dr("")).limit(0)}function de(e,t,r,n){var i,o,a,s,l,u,c,d=r.length;if(!r.every(e=>"string"==typeof e))return c7(e,cM);function p(e){i="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),o="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?c5:c9;var t=r.map(function(e){return{lower:o(e),upper:i(e)}}).sort(function(e,t){return a(e.lower,t.lower)});s=t.map(function(e){return e.upper}),l=t.map(function(e){return e.lower}),u=e,c="next"===e?"":n}p("next");var f=new e.Collection(e,()=>dt(s[0],l[d-1]+n));f._ondirectionchange=function(e){p(e)};var h=0;return f._addAlgorithm(function(e,r,n){var i=e.key;if("string"!=typeof i)return!1;var p=o(i);if(t(p,l,h))return!0;for(var f=null,m=h;m<d;++m){var y=function(e,t,r,n,i,o){for(var a=Math.min(e.length,n.length),s=-1,l=0;l<a;++l){var u=t[l];if(u!==n[l])return 0>i(e[l],r[l])?e.substr(0,l)+r[l]+r.substr(l+1):0>i(e[l],n[l])?e.substr(0,l)+n[l]+r.substr(l+1):s>=0?e.substr(0,s)+t[s]+r.substr(s+1):null;0>i(e[l],u)&&(s=l)}return a<n.length&&"next"===o?e+r.substr(e.length):a<e.length&&"prev"===o?e.substr(0,r.length):s<0?null:e.substr(0,s)+n[s]+r.substr(s+1)}(i,p,s[m],l[m],a,u);null===y&&null===f?h=m+1:(null===f||a(f,y)>0)&&(f=y)}return r(null!==f?function(){e.continue(f+c)}:n),!1}),f}function dt(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function dr(e){return{type:1,lower:e,upper:e}}class dn{get Collection(){return this._ctx.table.db.Collection}between(e,t,r,n){r=!1!==r,n=!0===n;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(r||n)&&(!r||!n)?c8(this):new this.Collection(this,()=>dt(e,t,!r,!n))}catch(e){return c7(this,cN)}}equals(e){return null==e?c7(this,cN):new this.Collection(this,()=>dr(e))}above(e){return null==e?c7(this,cN):new this.Collection(this,()=>dt(e,void 0,!0))}aboveOrEqual(e){return null==e?c7(this,cN):new this.Collection(this,()=>dt(e,void 0,!1))}below(e){return null==e?c7(this,cN):new this.Collection(this,()=>dt(void 0,e,!1,!0))}belowOrEqual(e){return null==e?c7(this,cN):new this.Collection(this,()=>dt(void 0,e))}startsWith(e){return"string"!=typeof e?c7(this,cM):this.between(e,e+cR,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):de(this,(e,t)=>0===e.indexOf(t[0]),[e],cR)}equalsIgnoreCase(e){return de(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=uf.apply(up,arguments);return 0===e.length?c8(this):de(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=uf.apply(up,arguments);return 0===e.length?c8(this):de(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,cR)}anyOf(){let e=uf.apply(up,arguments),t=this._cmp;try{e.sort(t)}catch(e){return c7(this,cN)}if(0===e.length)return c8(this);let r=new this.Collection(this,()=>dt(e[0],e[e.length-1]));r._ondirectionchange=r=>{t="next"===r?this._ascending:this._descending,e.sort(t)};let n=0;return r._addAlgorithm((r,i,o)=>{let a=r.key;for(;t(a,e[n])>0;)if(++n===e.length)return i(o),!1;return 0===t(a,e[n])||(i(()=>{r.continue(e[n])}),!1)}),r}notEqual(e){return this.inAnyRange([[cA,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=uf.apply(up,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return c7(this,cN)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[cA,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let r=this._cmp,n=this._ascending,i=this._descending,o=this._min,a=this._max;if(0===e.length)return c8(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=n(e[0],e[1])))return c7(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",uC.InvalidArgument);let s=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,u,c=n;function d(e,t){return c(e[0],t[0])}try{(u=e.reduce(function(e,t){let n=0,i=e.length;for(;n<i;++n){let i=e[n];if(0>r(t[0],i[1])&&r(t[1],i[0])>0){i[0]=o(i[0],t[0]),i[1]=a(i[1],t[1]);break}}return n===i&&e.push(t),e},[])).sort(d)}catch(e){return c7(this,cN)}let p=0,f=l?e=>n(e,u[p][1])>0:e=>n(e,u[p][1])>=0,h=s?e=>i(e,u[p][0])>0:e=>i(e,u[p][0])>=0,m=f,y=new this.Collection(this,()=>dt(u[0][0],u[u.length-1][1],!s,!l));return y._ondirectionchange=e=>{"next"===e?(m=f,c=n):(m=h,c=i),u.sort(d)},y._addAlgorithm((e,t,r)=>{for(var i=e.key;m(i);)if(++p===u.length)return t(r),!1;return!!(!f(i)&&!h(i))||(0===this._cmp(i,u[p][1])||0===this._cmp(i,u[p][0])||t(()=>{c===n?e.continue(u[p][0]):e.continue(u[p][1])}),!1)}),y}startsWithAnyOf(){let e=uf.apply(up,arguments);return e.every(e=>"string"==typeof e)?0===e.length?c8(this):this.inAnyRange(e.map(e=>[e,e+cR])):c7(this,"startsWithAnyOf() only works with strings")}}function di(e){return cc(function(t){return da(t),e(t.target.error),!1})}function da(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let ds="storagemutated",dl="x-storagemutated-1",du=cH(null,ds);class dc{_lock(){return l5(!u3.global),++this._reculock,1!==this._reculock||u3.global||(u3.lockOwnerFor=this),this}_unlock(){if(l5(!u3.global),0==--this._reculock)for(u3.global||(u3.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{cD(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&u3.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,r=this.db._state.dbOpenError;if(l5(!this.idbtrans),!e&&!t)switch(r&&r.name){case"DatabaseClosedError":throw new uC.DatabaseClosed(r);case"MissingAPIError":throw new uC.MissingAPI(r.message,r);default:throw new uC.OpenFailed(r)}if(!this.active)throw new uC.TransactionInactive;return l5(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=cc(t=>{da(t),this._reject(e.error)}),e.onabort=cc(t=>{da(t),this.active&&this._reject(new uC.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=cc(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&du.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,r){if("readwrite"===e&&"readwrite"!==this.mode)return cj(new uC.ReadOnly("Transaction is readonly"));if(!this.active)return cj(new uC.TransactionInactive);if(this._locked())return new u9((n,i)=>{this._blockedFuncs.push([()=>{this._promise(e,t,r).then(n,i)},u3])});if(r)return cg(()=>{var e=new u9((e,r)=>{this._lock();let n=t(e,r,this);n&&n.then&&n.then(e,r)});return e.finally(()=>this._unlock()),e._lib=!0,e});var n=new u9((e,r)=>{var n=t(e,r,this);n&&n.then&&n.then(e,r)});return n._lib=!0,n}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let r=u9.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>r);else{t._waitingFor=r,t._waitingQueue=[];var n=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(n.get(-1/0).onsuccess=e)}()}var i=t._waitingFor;return new u9((e,n)=>{r.then(r=>t._waitingQueue.push(cc(e.bind(null,r))),e=>t._waitingQueue.push(cc(n.bind(null,e)))).finally(()=>{t._waitingFor===i&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new uC.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(lY(t,e))return t[e];let r=this.schema[e];if(!r)throw new uC.NotFound("Table "+e+" not part of transaction");let n=new this.db.Table(e,r,this);return n.core=this.db.core.table(e),t[e]=n,n}}function dd(e,t,r,n,i,o,a){return{name:e,keyPath:t,unique:r,multi:n,auto:i,compound:o,src:(r&&!a?"&":"")+(n?"*":"")+(i?"++":"")+dp(t)}}function dp(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function df(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:l7(r,e=>[e.name,e])}}let dh=e=>{try{return e.only([[]]),dh=()=>[[]],[[]]}catch(e){return dh=()=>cR,cR}};function dm(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>l8(t,e):t=>l8(t,e)}function dy(e){return[].slice.call(e)}let dg=0;function dv(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function db({_novip:e},t){let r=t.db,n=function(e,t,{IDBKeyRange:r,indexedDB:n},i){var o;return{dbcore:(o=function(e,t,r){let n;function i(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:r,upper:n,lowerOpen:i,upperOpen:o}=e;return void 0===r?void 0===n?null:t.upperBound(n,!!o):void 0===n?t.lowerBound(r,!!i):t.bound(r,n,!!i,!!o)}let{schema:o,hasGetAll:a}=(n=dy(e.objectStoreNames),{schema:{name:e.name,tables:n.map(e=>r.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:r}=e,n=lH(t),i=null==t,o={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:i,compound:n,keyPath:t,autoIncrement:r,unique:!0,extractKey:dm(t)},indexes:dy(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:r,multiEntry:n,keyPath:i}=e,a={name:t,compound:lH(i),keyPath:i,unique:r,multiEntry:n,extractKey:dm(i)};return o[dv(i)]=a,a}),getIndexByKeyPath:e=>o[dv(e)]};return o[":id"]=a.primaryKey,null!=t&&(o[dv(t)]=a.primaryKey),a})},hasGetAll:n.length>0&&"getAll"in r.objectStore(n[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=o.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:r,keys:n,values:o,range:a}){return new Promise((s,l)=>{let u;s=cc(s);let c=e.objectStore(t),d=null==c.keyPath,p="put"===r||"add"===r;if(!p&&"delete"!==r&&"deleteRange"!==r)throw Error("Invalid operation type: "+r);let{length:f}=n||o||{length:1};if(n&&o&&n.length!==o.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=[],y=0,g=e=>{++y,da(e)};if("deleteRange"===r){if(4===a.type)return s({numFailures:y,failures:m,results:[],lastResult:void 0});3===a.type?h.push(u=c.clear()):h.push(u=c.delete(i(a)))}else{let[e,t]=p?d?[o,n]:[o,null]:[n,null];if(p)for(let n=0;n<f;++n)h.push(u=t&&void 0!==t[n]?c[r](e[n],t[n]):c[r](e[n])),u.onerror=g;else for(let t=0;t<f;++t)h.push(u=c[r](e[t])),u.onerror=g}let v=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:y,failures:m,results:"delete"===r?n:h.map(e=>e.result),lastResult:t})};u.onerror=e=>{g(e),v(e)},u.onsuccess=v})},getMany:({trans:e,keys:r})=>new Promise((n,i)=>{n=cc(n);let o=e.objectStore(t),a=r.length,s=Array(a),l,u=0,c=0,d=e=>{let t=e.target;s[t._pos]=t.result,++c===u&&n(s)},p=di(i);for(let e=0;e<a;++e)null!=r[e]&&((l=o.get(r[e]))._pos=e,l.onsuccess=d,l.onerror=p,++u);0===u&&n(s)}),get:({trans:e,key:r})=>new Promise((n,i)=>{n=cc(n);let o=e.objectStore(t).get(r);o.onsuccess=e=>n(e.target.result),o.onerror=di(i)}),query:e=>new Promise((r,n)=>{r=cc(r);let{trans:o,values:s,limit:l,query:u}=e,c=l===1/0?void 0:l,{index:d,range:p}=u,f=o.objectStore(t),h=d.isPrimaryKey?f:f.index(d.name),m=i(p);if(0===l)return r({result:[]});if(a){let e=s?h.getAll(m,c):h.getAllKeys(m,c);e.onsuccess=e=>r({result:e.target.result}),e.onerror=di(n)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),i=[];t.onsuccess=n=>{let o=t.result;return o?(i.push(s?o.value:o.primaryKey),++e===l?r({result:i}):void o.continue()):r({result:i})},t.onerror=di(n)}}),openCursor:function({trans:e,values:r,query:n,reverse:o,unique:a}){return new Promise((s,l)=>{s=cc(s);let{index:u,range:c}=n,d=e.objectStore(t),p=u.isPrimaryKey?d:d.index(u.name),f=o?a?"prevunique":"prev":a?"nextunique":"next",h=!r&&"openKeyCursor"in p?p.openKeyCursor(i(c),f):p.openCursor(i(c),f);h.onerror=di(l),h.onsuccess=cc(t=>{let r=h.result;if(!r)return void s(null);r.___id=++dg,r.done=!1;let n=r.continue.bind(r),i=r.continuePrimaryKey;i&&(i=i.bind(r));let o=r.advance.bind(r),a=()=>{throw Error("Cursor not stopped")};r.trans=e,r.stop=r.continue=r.continuePrimaryKey=r.advance=()=>{throw Error("Cursor not started")},r.fail=cc(l),r.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},r.start=e=>{let t=new Promise((e,t)=>{e=cc(e),h.onerror=di(t),r.fail=t,r.stop=t=>{r.stop=r.continue=r.continuePrimaryKey=r.advance=a,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){r.fail(e)}else r.done=!0,r.start=()=>{throw Error("Cursor behind last entry")},r.stop()};return h.onsuccess=cc(e=>{h.onsuccess=s,s()}),r.continue=n,r.continuePrimaryKey=i,r.advance=o,s(),t},s(r)},l)})},count({query:e,trans:r}){let{index:n,range:o}=e;return new Promise((e,a)=>{let s=r.objectStore(t),l=n.isPrimaryKey?s:s.index(n.name),u=i(o),c=u?l.count(u):l.count();c.onsuccess=cc(t=>e(t.target.result)),c.onerror=di(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:dh(t),schema:o}}(t,r,i),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),o))}}(e._middlewares,r,e._deps,t);e.core=n.dbcore,e.tables.forEach(t=>{let r=t.name;e.core.schema.tables.some(e=>e.name===r)&&(t.core=e.core.table(r),e[r]instanceof e.Table&&(e[r].core=t.core))})}function dw({_novip:e},t,r,n){r.forEach(r=>{let i=n[r];t.forEach(t=>{let n=l2(t,r);(!n||"value"in n&&void 0===n.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?lQ(t,r,{get(){return this.table(r)},set(e){lX(this,r,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[r]=new e.Table(r,i))})})}function d_({_novip:e},t){t.forEach(t=>{for(let r in t)t[r]instanceof e.Table&&delete t[r]})}function dx(e,t){return e._cfg.version-t._cfg.version}function dE(e,t){let r,n={del:[],add:[],change:[]};for(r in e)t[r]||n.del.push(r);for(r in t){let i=e[r],o=t[r];if(i){let e={name:r,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")==""+(o.primKey.keyPath||"")&&(i.primKey.auto===o.primKey.auto||c$)){let t,r=i.idxByName,a=o.idxByName;for(t in r)a[t]||e.del.push(t);for(t in a){let n=r[t],i=a[t];n?n.src!==i.src&&e.change.push(i):e.add.push(i)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}else e.recreate=!0,n.change.push(e)}else n.add.push([r,o])}return n}function dS(e,t,r,n){let i=e.db.createObjectStore(t,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(e=>dD(i,e)),i}function dD(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function dO(e,t,r){let n={};return l4(t.objectStoreNames,0).forEach(e=>{let t=r.objectStore(e),i=t.keyPath,o=dd(dp(i),i||"",!1,!1,!!t.autoIncrement,i&&"string"!=typeof i,!0),a=[];for(let e=0;e<t.indexNames.length;++e){let r=t.index(t.indexNames[e]);i=r.keyPath;var s=dd(r.name,i,!!r.unique,!!r.multiEntry,!1,i&&"string"!=typeof i,!1);a.push(s)}n[e]=df(e,o,a)}),n}function dP({_novip:e},t,r){let n=r.db.objectStoreNames;for(let i=0;i<n.length;++i){let o=n[i],a=r.objectStore(o);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let r=a.indexNames[e],n=a.index(r).keyPath,i="string"==typeof n?n:"["+l4(n).join("+")+"]";if(t[o]){let e=t[o].idxByName[i];e&&(e.name=r,delete t[o].idxByName[i],t[o].idxByName[r]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&lz.WorkerGlobalScope&&lz instanceof lz.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class dC{_parseStoresSpec(e,t){lK(e).forEach(r=>{if(null!==e[r]){var n=e[r].split(",").map((e,t)=>{let r=(e=e.trim()).replace(/([&*]|\+\+)/g,""),n=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return dd(r,n||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),lH(n),0===t)}),i=n.shift();if(i.multi)throw new uC.Schema("Primary key cannot be multi-valued");n.forEach(e=>{if(e.auto)throw new uC.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new uC.Schema("Index must have a name and cannot be an empty string")}),t[r]=df(r,i,n)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?lG(this._cfg.storesSource,e):e;let r=t._versions,n={},i={};return r.forEach(e=>{lG(n,e._cfg.storesSource),i=e._cfg.dbschema={},e._parseStoresSpec(n,i)}),t._dbSchema=i,d_(t,[t._allTables,t,t.Transaction.prototype]),dw(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],lK(i),i),t._storeNames=lK(i),this}upgrade(e){return this._cfg.contentUpgrade=uF(this._cfg.contentUpgrade||uT,e),this}}function dk(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new dq(cF,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),r.table("dbnames")}function dj(e){return e&&"function"==typeof e.databases}function dT(e){return cg(function(){return u3.letThrough=!0,e()})}function dR(e){var t=t=>e.next(t),r=i(t),n=i(t=>e.throw(t));function i(e){return t=>{var i=e(t),o=i.value;return i.done?o:o&&"function"==typeof o.then?o.then(r,n):lH(o)?Promise.all(o).then(r,n):r(o)}}return i(t)()}function dA(e,t,r){var n=arguments.length;if(n<2)throw new uC.InvalidArgument("Too few arguments");for(var i=Array(n-1);--n;)i[n-1]=arguments[n];return r=i.pop(),[e,un(i),r]}function dN(e,t,r){let n=lH(e)?e.slice():[e];for(let e=0;e<r;++e)n.push(t);return n}let dM={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let r=e.table(t),{schema:n}=r,i={},o=[];function a(e,t,r){let n=dv(e),s=i[n]=i[n]||[],l=null==e?0:"string"==typeof e?1:e.length,u=t>0,c={...r,isVirtual:u,keyTail:t,keyLength:l,extractKey:dm(e),unique:!u&&r.unique};return s.push(c),c.isPrimaryKey||o.push(c),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,r),s.sort((e,t)=>e.keyTail-t.keyTail),c}let s=a(n.primaryKey.keyPath,0,n.primaryKey);for(let e of(i[":id"]=[s],n.indexes))a(e.keyPath,0,e);function l(t){var r,n;let i=t.query.index;return i.isVirtual?{...t,query:{index:i,range:(r=t.query.range,n=i.keyTail,{type:1===r.type?2:r.type,lower:dN(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,n),lowerOpen:!0,upper:dN(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,n),upperOpen:!0})}}:t}return{...r,schema:{...n,primaryKey:s,indexes:o,getIndexByKeyPath:function(e){let t=i[dv(e)];return t&&t[0]}},count:e=>r.count(l(e)),query:e=>r.query(l(e)),openCursor(t){let{keyTail:n,isVirtual:i,keyLength:o}=t.query.index;return i?r.openCursor(l(t)).then(r=>r&&Object.create(r,{continue:{value:function(i){null!=i?r.continue(dN(i,t.reverse?e.MAX_KEY:e.MIN_KEY,n)):t.unique?r.continue(r.key.slice(0,o).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,n)):r.continue()}},continuePrimaryKey:{value(t,i){r.continuePrimaryKey(dN(t,e.MAX_KEY,n),i)}},primaryKey:{get:()=>r.primaryKey},key:{get(){let e=r.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:()=>r.value}})):r.openCursor(t)}}}}}};function dI(e,t,r,n){return r=r||{},n=n||"",lK(e).forEach(i=>{if(lY(t,i)){var o=e[i],a=t[i];if("object"==typeof o&&"object"==typeof a&&o&&a){let e=uu(o);e!==uu(a)?r[n+i]=t[i]:"Object"===e?dI(o,a,r,n+i+"."):o!==a&&(r[n+i]=t[i])}else o!==a&&(r[n+i]=t[i])}else r[n+i]=void 0}),lK(t).forEach(i=>{lY(e,i)||(r[n+i]=t[i])}),r}let d$={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let r=e.table(t),{primaryKey:n}=r.schema;return{...r,mutate(e){let i=u3.trans,{deleting:o,creating:a,updating:s}=i.table(t).hook;switch(e.type){case"add":if(a.fire===uT)break;return i._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===uT&&s.fire===uT)break;return i._promise("readwrite",()=>l(e),!0);case"delete":if(o.fire===uT)break;return i._promise("readwrite",()=>l(e),!0);case"deleteRange":if(o.fire===uT)break;return i._promise("readwrite",()=>(function e(t,i,o){return r.query({trans:t,values:!1,query:{index:n,range:i},limit:o}).then(({result:r})=>l({type:"delete",keys:r,trans:t}).then(n=>n.numFailures>0?Promise.reject(n.failures[0]):r.length<o?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...i,lower:r[r.length-1],lowerOpen:!0},o)))})(e.trans,e.range,1e4),!0)}return r.mutate(e);function l(e){var t,i;let l=u3.trans,u=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(n.extractKey));if(!u)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:u}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(i=e).type?Promise.resolve([]):r.getMany({trans:i.trans,keys:u,cache:"immutable"})).then(t=>{let i=u.map((r,i)=>{let u=t[i],c={onerror:null,onsuccess:null};if("delete"===e.type)o.fire.call(c,r,u,l);else if("add"===e.type||void 0===u){let t=a.fire.call(c,r,e.values[i],l);null==r&&null!=t&&(r=t,e.keys[i]=r,n.outbound||ue(e.values[i],n.keyPath,r))}else{let t=dI(u,e.values[i]),n=s.fire.call(c,t,r,u,l);if(n){let t=e.values[i];Object.keys(n).forEach(e=>{lY(t,e)?t[e]=n[e]:ue(t,e,n[e])})}}return c});return r.mutate(e).then(({failures:r,results:n,numFailures:o,lastResult:a})=>{for(let o=0;o<u.length;++o){let a=n?n[o]:u[o],s=i[o];null==a?s.onerror&&s.onerror(r[o]):s.onsuccess&&s.onsuccess("put"===e.type&&t[o]?e.values[o]:a)}return{failures:r,results:n,numFailures:o,lastResult:a}}).catch(e=>(i.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function dL(e,t,r){try{if(!t||t.keys.length<e.length)return null;let n=[];for(let i=0,o=0;i<t.keys.length&&o<e.length;++i)0===c1(t.keys[i],e[o])&&(n.push(r?us(t.values[i]):t.values[i]),++o);return n.length===e.length?n:null}catch(e){return null}}let dF={stack:"dbcore",level:-1,create:e=>({table:t=>{let r=e.table(t);return{...r,getMany:e=>{if(!e.cache)return r.getMany(e);let t=dL(e.keys,e.trans._cache,"clone"===e.cache);return t?u9.resolve(t):r.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?us(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),r.mutate(e))}}})};function dB(e){return!("from"in e)}let dV=function(e,t){if(!this){let t=new dV;return e&&"d"in e&&lG(t,e),t}lG(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function dU(e,t,r){let n=c1(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(dB(e))return lG(e,{from:t,to:r,d:1});let i=e.l,o=e.r;if(0>c1(r,e.from))return i?dU(i,t,r):e.l={from:t,to:r,d:1,l:null,r:null},dK(e);if(c1(t,e.to)>0)return o?dU(o,t,r):e.r={from:t,to:r,d:1,l:null,r:null},dK(e);0>c1(t,e.from)&&(e.from=t,e.l=null,e.d=o?o.d+1:1),c1(r,e.to)>0&&(e.to=r,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;i&&!e.l&&dW(e,i),o&&a&&dW(e,o)}function dW(e,t){dB(t)||function e(t,{from:r,to:n,l:i,r:o}){dU(t,r,n),i&&e(t,i),o&&e(t,o)}(e,t)}function dz(e){let t=dB(e)?null:{s:0,n:e};return{next(e){let r=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&0>c1(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||0>=c1(e,t.n.to))return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function dK(e){var t,r;let n=((null==(t=e.r)?void 0:t.d)||0)-((null==(r=e.l)?void 0:r.d)||0),i=n>1?"r":n<-1?"l":"";if(i){let t="r"===i?"l":"r",r={...e},n=e[i];e.from=n.from,e.to=n.to,e[i]=n[i],r[i]=n[t],e[t]=r,r.d=dH(r)}e.d=dH(e)}function dH({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}lJ(dV.prototype,{add(e){return dW(this,e),this},addKey(e){return dU(this,e,e),this},addKeys(e){return e.forEach(e=>dU(this,e,e)),this},[uc](){return dz(this)}});let dG={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,r=new dV(e.MIN_KEY,e.MAX_KEY);return{...e,table:n=>{let i=e.table(n),{schema:o}=i,{primaryKey:a}=o,{extractKey:s,outbound:l}=a,u={...i,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),l=e=>{let r=`idb://${t}/${n}/${e}`;return s[r]||(s[r]=new dV)},u=l(""),c=l(":dels"),{type:d}=e,[p,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return i.mutate(e).then(e=>{if(lH(p)){"delete"!==d&&(p=e.results),u.addKeys(p);let t=dL(p,h);t||"add"===d||c.addKeys(p),(t||f)&&o.indexes.forEach(function(e){let r=l(e.name||"");function n(t){return null!=t?e.extractKey(t):null}let i=t=>e.multiEntry&&lH(t)?t.forEach(e=>r.addKey(e)):r.addKey(t);(t||f).forEach((e,r)=>{let o=t&&n(t[r]),a=f&&n(f[r]);0!==c1(o,a)&&(null!=o&&i(o),null!=a&&i(a))})})}else if(p){let e={from:p.lower,to:p.upper};c.add(e),u.add(e)}else u.add(r),c.add(r),o.indexes.forEach(e=>l(e.name).add(r));return e})}},c=({query:{index:t,range:r}})=>{var n,i;return[t,new dV(null!=(n=r.lower)?n:e.MIN_KEY,null!=(i=r.upper)?i:e.MAX_KEY)]},d={get:e=>[a,new dV(e.key)],getMany:e=>[a,(new dV).addKeys(e.keys)],count:c,query:c,openCursor:c};return lK(d).forEach(e=>{u[e]=function(o){let{subscr:a}=u3;if(a){let u=e=>{let r=`idb://${t}/${n}/${e}`;return a[r]||(a[r]=new dV)},c=u(""),p=u(":dels"),[f,h]=d[e](o);if(u(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&o.values&&i.query({...o,values:!1});return i[e].apply(this,arguments).then(r=>{if("query"===e){if(l&&o.values)return t.then(({result:e})=>(c.addKeys(e),r));let e=o.values?r.result.map(s):r.result;o.values?c.addKeys(e):p.addKeys(e)}else if("openCursor"===e){let e=o.values;return r&&Object.create(r,{key:{get:()=>(p.addKey(r.primaryKey),r.key)},primaryKey:{get(){let e=r.primaryKey;return p.addKey(e),e}},value:{get:()=>(e&&c.addKey(r.primaryKey),r.value)}})}return r})}p.add(r)}}return i[e].apply(this,arguments)}}),u}}}};class dq{constructor(e,t){var r;this._middlewares={},this.verno=0;const n=dq.dependencies;this._options=t={addons:dq.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:i}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:uT,dbReadyPromise:null,cancelOpen:uT,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new u9(e=>{o.dbReadyResolve=e}),o.openCanceller=new u9((e,t)=>{o.cancelOpen=t}),this._state=o,this.name=e,this.on=cH(this,"populate","blocked","versionchange","close",{ready:[uF,uT]}),this.on.ready.subscribe=l6(this.on.ready.subscribe,e=>(t,r)=>{dq.vip(()=>{let n=this._state;if(n.openComplete)n.dbOpenError||u9.resolve().then(t),r&&e(t);else if(n.onReadyBeingFired)n.onReadyBeingFired.push(t),r&&e(t);else{e(t);let n=this;r||e(function e(){n.on.ready.unsubscribe(t),n.on.ready.unsubscribe(e)})}})}),this.Collection=(r=this,cG(c4.prototype,function(e,t){this.db=r;let n=cW,i=null;if(t)try{n=t()}catch(e){i=e}let o=e._ctx,a=o.table,s=a.hook.reading.fire;this._ctx={table:a,index:o.index,isPrimKey:!o.index||a.schema.primKey.keyPath&&o.index===a.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:i,or:o.or,valueMapper:s!==uR?s:null}})),this.Table=function(e){return cG(cK.prototype,function(t,r,n){this.db=e,this._tx=n,this.name=t,this.schema=r,this.hook=e._allTables[t]?e._allTables[t].hook:cH(null,{creating:[uM,uT],reading:[uA,uR],updating:[u$,uT],deleting:[uI,uT]})})}(this),this.Transaction=function(e){return cG(dc.prototype,function(t,r,n,i,o){this.db=e,this.mode=t,this.storeNames=r,this.schema=n,this.chromeTransactionDurability=i,this.idbtrans=null,this.on=cH(this,"complete","error","abort"),this.parent=o||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 u9((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),cj(e)})})}(this),this.Version=function(e){return cG(dC.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return cG(dn.prototype,function(t,r,n){this.db=e,this._ctx={table:t,index:":id"===r?null:r,or:n};let i=e._deps.indexedDB;if(!i)throw new uC.MissingAPI;this._cmp=this._ascending=i.cmp.bind(i),this._descending=(e,t)=>i.cmp(t,e),this._max=(e,t)=>i.cmp(e,t)>0?e:t,this._min=(e,t)=>0>i.cmp(e,t)?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=dh(t.IDBKeyRange),this._createTransaction=(e,t,r,n)=>new this.Transaction(e,t,r,this._options.chromeTransactionDurability,n),this._fireOnBlocked=e=>{this.on("blocked").fire(e),cI.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(dM),this.use(d$),this.use(dG),this.use(dF),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new uC.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new uC.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let t=this._versions;var r=t.filter(t=>t._cfg.version===e)[0];return r||(r=new this.Version(e),t.push(r),t.sort(dx),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||u3.letThrough||this._vip)?e():new u9((e,t)=>{if(this._state.openComplete)return t(new uC.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new uC.DatabaseClosed);this.open().catch(uT)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:r,name:n}){n&&this.unuse({stack:e,name:n});let i=this._middlewares[e]||(this._middlewares[e]=[]);return i.push({stack:e,create:t,level:null==r?10:r,name:n}),i.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>r?e.create!==r:!!t&&e.name!==t)),this}open(){return function(e){var t;let r=e._state,{indexedDB:n}=e._deps;if(r.isBeingOpened||e.idbdb)return r.dbReadyPromise.then(()=>r.dbOpenError?cj(r.dbOpenError):e);um&&(r.openCanceller._stackHolder=uv()),r.isBeingOpened=!0,r.dbOpenError=null,r.openComplete=!1;let i=r.openCanceller;function o(){if(r.openCanceller!==i)throw new uC.DatabaseClosed("db.open() was cancelled")}let a=r.dbReadyResolve,s=null,l=!1,u=()=>new u9((t,i)=>{if(o(),!n)throw new uC.MissingAPI;let a=e.name,u=r.autoSchema?n.open(a):n.open(a,Math.round(10*e.verno));if(!u)throw new uC.MissingAPI;u.onerror=di(i),u.onblocked=cc(e._fireOnBlocked),u.onupgradeneeded=cc(t=>{if(s=u.transaction,r.autoSchema&&!e._options.allowEmptyDB){u.onerror=da,s.abort(),u.result.close();let e=n.deleteDatabase(a);e.onsuccess=e.onerror=cc(()=>{i(new uC.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let r,n,a,p;s.onerror=di(i);var o,c,d=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=d<1,e._novip.idbdb=u.result,o=d/10,c=s,r=e._dbSchema,(n=e._createTransaction("readwrite",e._storeNames,r)).create(c),n._completion.catch(i),a=n._reject.bind(n),p=u3.transless||u3,cg(()=>{u3.trans=n,u3.transless=p,0===o?(lK(r).forEach(e=>{dS(c,e,r[e].primKey,r[e].indexes)}),db(e,c),u9.follow(()=>e.on.populate.fire(n)).catch(a)):(function({_novip:e},t,r,n){let i=[],o=e._versions,a=e._dbSchema=dO(e,e.idbdb,n),s=!1;return o.filter(e=>e._cfg.version>=t).forEach(o=>{i.push(()=>{let i=a,l=o._cfg.dbschema;dP(e,i,n),dP(e,l,n),a=e._dbSchema=l;let u=dE(i,l);u.add.forEach(e=>{dS(n,e[0],e[1].primKey,e[1].indexes)}),u.change.forEach(e=>{if(e.recreate)throw new uC.Upgrade("Not yet support for changing primary key");{let t=n.objectStore(e.name);e.add.forEach(e=>dD(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),dD(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=o._cfg.contentUpgrade;if(c&&o._cfg.version>t){let t;db(e,n),r._memoizedTables={},s=!0;let o=ut(l);u.del.forEach(e=>{o[e]=i[e]}),d_(e,[e.Transaction.prototype]),dw(e,[e.Transaction.prototype],lK(o),o),r.schema=o;let a=uh(c);a&&cv();let d=u9.follow(()=>{if((t=c(r))&&a){var e=cb.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?u9.resolve(t):d.then(()=>t)}}),i.push(t=>{var n;s&&c$||(n=o._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==n[e]&&t.db.deleteObjectStore(e))),d_(e,[e.Transaction.prototype]),dw(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema})}),(function e(){return i.length?u9.resolve(i.shift()(r.idbtrans)).then(e):u9.resolve()})().then(()=>{var e;lK(e=a).forEach(t=>{n.db.objectStoreNames.contains(t)||dS(n,t,e[t].primKey,e[t].indexes)})})})(e,o,n,c).catch(a)})}},i),u.onsuccess=cc(()=>{s=null;let n=e._novip.idbdb=u.result,i=l4(n.objectStoreNames);if(i.length>0)try{let t,o=n.transaction(1===i.length?i[0]:i,"readonly");r.autoSchema?function({_novip:e},t,r){e.verno=t.version/10;let n=e._dbSchema=dO(0,t,r);e._storeNames=l4(t.objectStoreNames,0),dw(e,[e._allTables],lK(n),n)}(e,n,o):(dP(e,e._dbSchema,o),((t=dE(dO(0,e.idbdb,o),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),db(e,o)}catch(e){}cI.push(e),n.onversionchange=cc(t=>{r.vcFired=!0,e.on("versionchange").fire(t)}),n.onclose=cc(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},r){dj(e)||r===cF||dk(e,t).put({name:r}).catch(uT)}(e._deps,a),t()},i)}).catch(e=>e&&"UnknownError"===e.name&&r.PR1398_maxLoop>0?(r.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),u()):u9.reject(e));return u9.race([i,("u"<typeof navigator?u9.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var r=function(){return indexedDB.databases().finally(e)};t=setInterval(r,100),r()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(u)]).then(()=>(o(),r.onReadyBeingFired=[],u9.resolve(dT(()=>e.on.ready.fire(e.vip))).then(function t(){if(r.onReadyBeingFired.length>0){let n=r.onReadyBeingFired.reduce(uF,uT);return r.onReadyBeingFired=[],u9.resolve(dT(()=>n(e.vip))).then(t)}}))).finally(()=>{r.onReadyBeingFired=null,r.isBeingOpened=!1}).then(()=>e).catch(t=>{r.dbOpenError=t;try{s&&s.abort()}catch(e){}return i===r.openCanceller&&e._close(),cj(t)}).finally(()=>{r.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=cI.indexOf(this);if(t>=0&&cI.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new u9(t=>{e.dbReadyResolve=t}),e.openCanceller=new u9((t,r)=>{e.cancelOpen=r})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new uC.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new u9((r,n)=>{let i=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=cc(()=>{!function({indexedDB:e,IDBKeyRange:t},r){dj(e)||r===cF||dk(e,t).delete(r).catch(uT)}(this._deps,this.name),r()}),e.onerror=di(n),e.onblocked=this._fireOnBlocked};if(e)throw new uC.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(i):i()})}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 lK(this._allTables).map(e=>this._allTables[e])}transaction(){let e=dA.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,r){let n,i,o=u3.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(i=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||e===cB)n=cB;else{if("rw"!=e&&e!=cV)throw new uC.InvalidArgument("Invalid transaction mode: "+e);n=cV}if(o){if(o.mode===cB&&n===cV){if(!a)throw new uC.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&i.forEach(e=>{if(o&&-1===o.storeNames.indexOf(e)){if(!a)throw new uC.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),a&&o&&!o.active&&(o=null)}}catch(e){return o?o._promise(null,(t,r)=>{r(e)}):cj(e)}let s=(function e(t,r,n,i,o){return u9.resolve().then(()=>{let a,s=u3.transless||u3,l=t._createTransaction(r,n,t._dbSchema,i);if(i)l.idbtrans=i.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===uP.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,null,o))):cj(i)}let u=uh(o);u&&cv();let c=u9.follow(()=>{if(a=o.call(l,l))if(u){var e=cb.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=dR(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?u9.resolve(a).then(e=>l.active?e:cj(new uC.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>a)).then(e=>(i&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),cj(e)))})}).bind(null,this,n,i,o,r);return o?o._promise(n,s,"lock"):u3.trans?cD(u3.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!lY(this._allTables,e))throw new uC.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let dZ="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class dY{constructor(e){this._subscribe=e}subscribe(e,t,r){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:r})}[dZ](){return this}}function dJ(e,t){return lK(t).forEach(r=>{dW(e[r]||(e[r]=new dV),t[r])}),e}try{o={indexedDB:lz.indexedDB||lz.mozIndexedDB||lz.webkitIndexedDB||lz.msIndexedDB,IDBKeyRange:lz.IDBKeyRange||lz.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function dX(e){let t=dQ;try{dQ=!0,du.storagemutated.fire(e)}finally{dQ=t}}lJ(dq,{...uj,delete:e=>new dq(e,{addons:[]}).delete(),exists:e=>new dq(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return dj(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==cF)):dk(e,t).toCollection().primaryKeys()})(dq.dependencies).then(e)}catch(e){return cj(new uC.MissingAPI)}},defineClass:()=>function(e){lG(this,e)},ignoreTransaction:e=>u3.trans?cD(u3.transless,e):e(),vip:dT,async:function(e){return function(){try{var t=dR(e.apply(this,arguments));return t&&"function"==typeof t.then?t:u9.resolve(t)}catch(e){return cj(e)}}},spawn:function(e,t,r){try{var n=dR(e.apply(r,t||[]));return n&&"function"==typeof n.then?n:u9.resolve(n)}catch(e){return cj(e)}},currentTransaction:{get:()=>u3.trans||null},waitFor:function(e,t){let r=u9.resolve("function"==typeof e?dq.ignoreTransaction(e):e).timeout(t||6e4);return u3.trans?u3.trans.waitFor(r):r},Promise:u9,debug:{get:()=>um,set:e=>{um=e,uy="dexie"===e?()=>!0:cL}},derive:l0,extend:lG,props:lJ,override:l6,Events:cH,on:du,liveQuery:function(e){let t,r=!1,n=new dY(n=>{let i=uh(e),o=!1,a={},s={},l={get closed(){return o},unsubscribe:()=>{o=!0,du.storagemutated.unsubscribe(p)}};n.start&&n.start(l);let u=!1,c=!1;function d(){return lK(s).some(e=>a[e]&&function(e,t){let r=dz(t),n=r.next();if(n.done)return!1;let i=n.value,o=dz(e),a=o.next(i.from),s=a.value;for(;!n.done&&!a.done;){if(0>=c1(s.from,i.to)&&c1(s.to,i.from)>=0)return!0;0>c1(i.from,s.from)?i=(n=r.next(s.from)).value:s=(a=o.next(i.from)).value}return!1}(a[e],s[e]))}let p=e=>{dJ(a,e),d()&&f()},f=()=>{let h,m;if(u||o)return;a={};let y={},g=(i&&cv(),h=()=>cg(e,{subscr:y,trans:null}),m=u3.trans?cD(u3.transless,h):h(),i&&m.then(cb,cb),m);c||(du(ds,p),c=!0),u=!0,Promise.resolve(g).then(e=>{r=!0,t=e,u=!1,o||(d()?f():(a={},s=y,n.next&&n.next(e)))},e=>{u=!1,r=!1,n.error&&n.error(e),l.unsubscribe()})};return f(),l});return n.hasValue=()=>r,n.getValue=()=>t,n},extendObservabilitySet:dJ,getByKeyPath:l8,setByKeyPath:ue,delByKeyPath:function(e,t){"string"==typeof t?ue(e,t,void 0):"length"in t&&[].map.call(t,function(t){ue(e,t,void 0)})},shallowClone:ut,deepClone:us,getObjectDiff:dI,cmp:c1,asap:l9,minKey:cA,addons:[],connections:cI,errnames:uP,dependencies:o,semVer:cT,version:cT.split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),dq.maxKey=dh(dq.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(du(ds,e=>{if(!dQ){let t;c$?(t=document.createEvent("CustomEvent")).initCustomEvent(dl,!0,!0,e):t=new CustomEvent(dl,{detail:e}),dQ=!0,dispatchEvent(t),dQ=!1}}),addEventListener(dl,({detail:e})=>{dQ||dX(e)}));let dQ=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(dl);"function"==typeof e.unref&&e.unref(),du(ds,t=>{dQ||e.postMessage(t)}),e.onmessage=e=>{e.data&&dX(e.data)}}else if("u">typeof self&&"u">typeof navigator){du(ds,e=>{try{dQ||("u">typeof localStorage&&localStorage.setItem(dl,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:dl,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===dl){let t=JSON.parse(e.newValue);t&&dX(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===dl&&dX(e.changedParts)})}function d0(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}u9.rejectionMapper=function(e,t){if(!e||e instanceof uE||e instanceof TypeError||e instanceof SyntaxError||!e.name||!uk[e.name])return e;var r=new uk[e.name](t||e.message,e);return"stack"in e&&lQ(r,"stack",{get:function(){return this.inner.stack}}),r},uy=cL;class d1 extends dq{constructor(){super("EsmOffline"),d0(this,"syncQueue",void 0),d0(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 d2(){return new d1}let d3=new d1,d4={},d6=Z("offline-synchronization",{});function d5(){return d6}async function d9(){if(d6.getState().synchronization)return;let e=await d3.syncQueue.count(),t={},r=Object.entries(d4),n=r.length,i={},o=new AbortController,a=()=>{let e=d6.getState().synchronization;d6.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{d6.setState({synchronization:{totalCount:e,pendingCount:e,abortController:o}});for(let e=0;e<n&&r.length>0;e++)for(let e=r.length;e--;){let[n,s]=r[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(i[n]={},await Promise.all(l),t[n]=d7(s,i,o,a),r.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{d6.setState({synchronization:void 0})}}async function d7({type:e,dependsOn:t,process:r},n,i,o){let a=[],s=[],l=await d8();await d3.syncQueue.where({type:e,userId:l}).each((e,t)=>{a.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let u=0;u<a.length;u++){let[c,d,{id:p,dependencies:f=[]}]=a[u];try{let o=await r(d,{abort:i,index:u,items:s,userId:l,dependencies:f.map(({id:e,type:r})=>t.includes(r)?n[r][e]:void 0)});void 0!==p&&(n[e][p]=o),await d3.syncQueue.delete(c)}catch(e){await d3.syncQueue.update(c,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{o()}}}async function d8(){let e=await aF();return e?.uuid||"*"}async function pe(e,t,r,n){let i=n&&n.id;return void 0!==i&&await d3.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===i).delete().catch(dq.errnames.DatabaseClosed),await d3.syncQueue.add({type:t,content:r,userId:e,descriptor:n||{},createdOn:new Date}).catch(dq.errnames.DatabaseClosed,()=>-1)}async function pt(e,t,r){let n=await d8();return await pe(n,e,t,r)}async function pr(e,t){return(await pn(e,t)).map(e=>e.content)}async function pn(e,t){return await d3.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(dq.errnames.DatabaseClosed,()=>[])}async function pi(e){let t=await d8();return await pr(t,e)}async function po(e){let t=await d8();return await pn(t,e)}async function pa(e){return await d3.syncQueue.get(e).catch(dq.errnames.DatabaseClosed,()=>void 0)}function ps(e){return!!d4[e]?.options.onBeginEditSyncItem}async function pl(e){let t=await pa(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let r=d4[t.type]?.options.onBeginEditSyncItem;if(!r)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);r(t)}async function pu(e){await d3.syncQueue.delete(e).catch(dq.errnames.DatabaseClosed)}function pc(e,t,r,n={}){d4[e]={type:e,dependsOn:t,process:r,options:n}}let pd="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pp=new Uint8Array(16),pf=[];for(let e=0;e<256;++e)pf.push((e+256).toString(16).slice(1));let ph=function(e,t,r){if(pd&&!t&&!e)return pd();let n=(e=e||{}).random||(e.rng||function(){if(!a&&!(a="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 a(pp)})();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return pf[e[t+0]]+pf[e[t+1]]+pf[e[t+2]]+pf[e[t+3]]+"-"+pf[e[t+4]]+pf[e[t+5]]+"-"+pf[e[t+6]]+pf[e[t+7]]+"-"+pf[e[t+8]]+pf[e[t+9]]+"-"+pf[e[t+10]]+pf[e[t+11]]+pf[e[t+12]]+pf[e[t+13]]+pf[e[t+14]]+pf[e[t+15]]}(n)},pm="OFFLINE+";function py(){return pm+ph()}function pg(e){return e.startsWith(pm)}let pv={};function pb(){return Object.values(pv)}function pw(e){pv[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.`),pv[e.id]=e}async function p_(e){let t=await pk();return await px(t,e)}async function px(e,t){let r=new d1;return await r.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(dq.errnames.DatabaseClosed,()=>[])}async function pE(e,t){let r=await pk();return await pS(r,e,t)}async function pS(e,t,r){let n=new d1,i=await n.dynamicOfflineData.get({type:t,identifier:r}).catch(dq.errnames.DatabaseClosed,()=>void 0);i?i.users.includes(e)||await n.dynamicOfflineData.update(i.id,{users:[...i.users,e]}).catch(dq.errnames.DatabaseClosed):await n.dynamicOfflineData.add({users:[e],type:t,identifier:r}).catch(dq.errnames.DatabaseClosed)}async function pD(e,t){let r=await pk();return await pO(r,e,t)}async function pO(e,t,r){let n=new d1,i=await n.dynamicOfflineData.get({type:t,identifier:r,users:e}).catch(dq.errnames.DatabaseClosed,()=>void 0);i&&(i.users.length>1?await n.dynamicOfflineData.update(i.id,{users:i.users.filter(t=>t!==e)}).catch(dq.errnames.DatabaseClosed):await n.dynamicOfflineData.delete(i.id).catch(dq.errnames.DatabaseClosed))}async function pP(e,t){let r=await p_(e);await Promise.all(r.map(async e=>pC(e.type,e.identifier,t)))}async function pC(e,t,r){await pE(e,t);let n=new d1,i=await pk(),o=await n.dynamicOfflineData.get({type:e,identifier:t}).catch(dq.errnames.DatabaseClosed,()=>void 0),a=pb().filter(t=>t.type===e);if(!o)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,r),{id:e.id,error:void 0}}catch(r){let t=r.message?.toString()??r.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),d={syncedOn:new Date,syncedBy:i,succeededHandlers:l,erroredHandlers:u,errors:c};o.id&&await n.dynamicOfflineData.update(o.id,{syncState:d}).catch(dq.errnames.DatabaseClosed)}async function pk(){let e=(await aF()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let pj=Z("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function pT(){return pN(),pj}function pR(e,t){pN(),pw({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,r)=>t.onOfflinePatientAdded({patientUuid:e,signal:r??new AbortController().signal})})}async function pA(e){pN(),await pC("patient",e)}function pN(){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 pM(e,t,r=!0){if(e){let n=null,[i,o]=await Promise.all([aC(`${aD}/Patient/${e}`,t).catch(e=>n=e),r?pI(e):Promise.resolve(null)]);if(i.ok)return i.data;if(o)return o;if(n)throw n}return null}async function pI(e){let t=(await pi("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function p$(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function pL(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}var pF=r(9549);function pB(e){return{uuid:e.uuid,display:e.display}}function pV(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return ak(`${aS}/location${n?"?"+n:""}`).pipe((0,pF.map)(e=>e.data.results.map(pB))).pipe((0,pF.take)(1))}function pU(e){return{uuid:e.uuid,display:e.display,name:e.name}}function pW(){return ak(`${aS}/visittype`).pipe((0,pF.map)(e=>e.data.results.map(pU))).pipe((0,pF.take)(1))}var pz=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),pK=function(e){function t(t,r){var n=e.call(this)||this;return n.subject=t,n.subscriber=r,n.closed=!1,n}return eS(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var r=t.indexOf(this.subscriber);-1!==r&&t.splice(r,1)}}},t}(eR),pH=function(e){function t(t){var r=e.call(this,t)||this;return r.destination=t,r}return eS(t,e),t}(eM),pG=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return eS(t,e),t.prototype[eN]=function(){return new pH(this)},t.prototype.lift=function(e){var t=new pq(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new pz;if(!this.isStopped)for(var t=this.observers,r=t.length,n=t.slice(),i=0;i<r;i++)n[i].next(e)},t.prototype.error=function(e){if(this.closed)throw new pz;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,r=t.length,n=t.slice(),i=0;i<r;i++)n[i].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new pz;this.isStopped=!0;for(var e=this.observers,t=e.length,r=e.slice(),n=0;n<t;n++)r[n].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new pz},t.prototype._subscribe=function(e){if(this.closed)throw new pz;return this.hasError?(e.error(this.thrownError),eR.EMPTY):this.isStopped?(e.complete(),eR.EMPTY):(this.observers.push(e),new pK(this,e))},t.prototype.asObservable=function(){var e=new eL;return e.source=this,e},t.create=function(e,t){return new pq(e,t)},t}(eL),pq=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return eS(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):eR.EMPTY},t}(pG),pZ=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return eS(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return r&&!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new pz},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(pG),pY=((eu={}).NEWVISIT="startVisit",eu.EDITVISIT="editVisit",eu.LOADING="loadingVisit",eu),pJ=((ec={}).NOTSTARTED="notStarted",ec.ONGOING="ongoing",ec);let pX="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))",pQ=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function p0(){return J("visit",pQ)}function p1(e,t){p0().setState({patientUuid:e,manuallySetVisitUuid:t})}function p2(e,t){return aC(`${aS}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function p3(e,t,r){return aC(`${aS}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function p4(e,t,r){return aC(`${aS}/visit?patient=${e}&v=${r??pX}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}p0().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let p6=new pZ(null);class p5{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+p5.version}static addUnaryOp(e){return p5.max_unop_len=Math.max(e.length,p5.max_unop_len),p5.unary_ops[e]=1,p5}static addBinaryOp(e,t,r){return p5.max_binop_len=Math.max(e.length,p5.max_binop_len),p5.binary_ops[e]=t,r?p5.right_associative.add(e):p5.right_associative.delete(e),p5}static addIdentifierChar(e){return p5.additional_identifier_chars.add(e),p5}static addLiteral(e,t){return p5.literals[e]=t,p5}static removeUnaryOp(e){return delete p5.unary_ops[e],e.length===p5.max_unop_len&&(p5.max_unop_len=p5.getMaxKeyLen(p5.unary_ops)),p5}static removeAllUnaryOps(){return p5.unary_ops={},p5.max_unop_len=0,p5}static removeIdentifierChar(e){return p5.additional_identifier_chars.delete(e),p5}static removeBinaryOp(e){return delete p5.binary_ops[e],e.length===p5.max_binop_len&&(p5.max_binop_len=p5.getMaxKeyLen(p5.binary_ops)),p5.right_associative.delete(e),p5}static removeAllBinaryOps(){return p5.binary_ops={},p5.max_binop_len=0,p5}static removeLiteral(e){return delete p5.literals[e],p5}static removeAllLiterals(){return p5.literals={},p5}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 p5(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 p5.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!p5.binary_ops[String.fromCharCode(e)]||p5.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return p5.isIdentifierStart(e)||p5.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(p5.hooks[e]){let r={context:this,node:t};return p5.hooks.run(e,r),r.node}return t}searchHook(e){if(p5.hooks[e]){let t={context:this};return p5.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===p5.SPACE_CODE||e===p5.TAB_CODE||e===p5.LF_CODE||e===p5.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:p5.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===p5.SEMCOL_CODE||r===p5.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,p5.max_binop_len),t=e.length;for(;t>0;){if(p5.binary_ops.hasOwnProperty(e)&&(!p5.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!p5.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,i,o,a,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(i={value:t,prec:p5.binaryPrecedence(t),right_a:p5.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,i,a];t=this.gobbleBinaryOp();){if(0===(r=p5.binaryPrecedence(t))){this.index-=t.length;break}i={value:t,prec:r,right_a:p5.right_associative.has(t)},l=t;let s=e=>i.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)a=n.pop(),t=n.pop().value,o=n.pop(),e={type:p5.BINARY_EXP,operator:t,left:o,right:a},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(i,e)}for(s=n.length-1,e=n[s];s>1;)e={type:p5.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,p5.isDecimalDigit(e)||e===p5.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===p5.SQUOTE_CODE||e===p5.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===p5.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,p5.max_unop_len)).length;r>0;){if(p5.unary_ops.hasOwnProperty(t)&&(!p5.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!p5.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:p5.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}p5.isIdentifierStart(e)?(n=this.gobbleIdentifier(),p5.literals.hasOwnProperty(n.name)?n={type:p5.LITERAL,value:p5.literals[n.name],raw:n.name}:n.name===p5.this_str&&(n={type:p5.THIS_EXP})):e===p5.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===p5.PERIOD_CODE||t===p5.OBRACK_CODE||t===p5.OPAREN_CODE||t===p5.QUMARK_CODE;){let r;if(t===p5.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==p5.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===p5.OBRACK_CODE?((e={type:p5.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==p5.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===p5.OPAREN_CODE?e={type:p5.CALL_EXP,arguments:this.gobbleArguments(p5.CPAREN_CODE),callee:e}:(t===p5.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:p5.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;p5.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===p5.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);p5.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));p5.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);p5.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,p5.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===p5.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===p5.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:p5.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:p5.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(p5.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,p5.isIdentifierPart(e))this.index++;else break;return{type:p5.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let i=this.code;if(i===e){r=!0,this.index++,e===p5.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(i===p5.COMMA_CODE){if(this.index++,++n!==t.length){if(e===p5.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===p5.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==p5.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(p5.CPAREN_CODE);if(this.code===p5.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:p5.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:p5.ARRAY_EXP,elements:this.gobbleArguments(p5.CBRACK_CODE)}}}Object.assign(p5,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(p5),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"}),p5.max_unop_len=p5.getMaxKeyLen(p5.unary_ops),p5.max_binop_len=p5.getMaxKeyLen(p5.binary_ops);let p9=e=>new p5(e).parse(),p7=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(p5).filter(e=>!p7.includes(e)&&void 0===p9[e]).forEach(e=>{p9[e]=p5[e]}),p9.Jsep=p5,p9.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let p8="ArrowFunctionExpression",fe={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)}},ft={...fe,Promise};function fr(e,t={}){return fl(e,t,fd)}async function fn(e,t={}){return fu(e,t,fd)}function fi(e,t={}){return fl(e,t,fp)}function fo(e,t={}){return fu(e,t,fp)}function fa(e,t={}){return fl(e,t,ff)}function fs(e,t={}){return fu(e,t,ff)}function fl(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=fv(t,fe),i=fh("string"==typeof e?p9(e):e,n);if(r(i))return i;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 fu(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=fv(t,ft);return Promise.resolve(fh("string"==typeof e?p9(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function fc(e){return p9(e)}function fd(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function fp(e){return"boolean"==typeof e}function ff(e){return"number"==typeof e}function fh(e,t){switch(e.type){case"UnaryExpression":var r,n,i,o,a,s,l,u,c,d,p,f,h,m=e,y=t;let g=fh(m.argument,y);switch(m.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${m.operator}''`}case"BinaryExpression":var v=e,b=t;switch(v.operator){case"&&":return fh(v.left,b)&&fh(v.right,b);case"||":return fh(v.left,b)||fh(v.right,b);case"??":return fh(v.left,b)??fh(v.right,b)}let w=fh(v.left,b),x=fh(v.right,b);switch(v.operator){case"+":return w+x;case"-":return w-x;case"*":return w*x;case"/":return w/x;case"%":return w%x;case"**":return w**x;case"==":return w==x;case"===":return w===x;case"!=":return w!=x;case"!==":return w!==x;case">":return w>x;case">=":return w>=x;case"<":return w<x;case"<=":return w<=x;case"in":return w in x;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,fh(r.test,n)?fh(r.consequent,n):fh(r.alternate,n);case"CallExpression":return f_(fy(e,t));case"ArrowFunctionExpression":let E;return i=e,o=t,E=i.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<E.length)throw`Required argument(s) ${E.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(E.reduce((t,r,n)=>{let i=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(i)&&t.push([r,i]),t},[]));return fh(i.body,o.addVariables(t))}).bind(null);case"MemberExpression":return f_(fg(e,t));case"ArrayExpression":return a=e,s=t,a.elements?.map(fx(s));case"SequenceExpression":let S;return l=e,u=t,(S=l.expressions.map(fx(u)))[S.length-1];case"NewExpression":var D=e,O=t;if(D.callee&&"Identifier"===D.callee.type){let e=D.arguments?.map(fx(O));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 e.value;case"Identifier":return c=e,d=t,(fE(c.name),d.variables&&Object.hasOwn(d.variables,c.name))?d.variables[c.name]:Object.hasOwn(d.globals,c.name)?d.globals[c.name]:void 0;case"TemplateLiteral":let P,C;return p=e,f=t,P=p.expressions?.map(fx(f))??[],(C=p.quasis?.map(fx(f))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.join("")+C.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(h=e).cooked,tail:h.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function fm(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return fm(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function fy(e,t){let r=fw(e.callee,t);if(r===fb||e.optional&&null==r)return fb;let n=e.arguments?.map(fx(t));if(r){if("function"!=typeof r)throw`${fO(e.callee)} is not a function`}else throw`No function named ${fO(e.callee)} is defined in this context`;return r(...n)}function fg(e,t){let r=fw(e.object,t);if(r===fb||e.optional&&null==r)return fb;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${fD(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=fm(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${fD(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof r&&"function"!=typeof r&&"string"!=typeof r&&"number"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;let n=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(fh(e.property,t)):function(e){if("Identifier"!==e.type)throw`VisitMemberExpression does not support a property of type '${e.type}'`;return e.name}(e.property);fE(n),function(e,t){if(fS.has(String(t)))return;let r=Object(e);for(;null!==r;){if(Object.hasOwn(r,t)){if(r===Object.prototype||r===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}r=Object.getPrototypeOf(r)}}(r,n);let i=r[n];return"function"==typeof i?i.bind(r):i}function fv(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}p9.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:p8,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=p8,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),p9.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),p9.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",i=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};i(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),i());let o=this.char;("e"===o||"E"===o)&&(n+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(n+=this.expr.charAt(this.index++)),i(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(a===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var i,o,a;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;i=this.code,o=u,95===i||o.some(([e,t])=>i>=e&&i<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(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)&&r.call(this,n)})}}),p9.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,i=this.expr.slice(r,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{n=new RegExp(i,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),p9.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),p9.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",i="",o=!1,a=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:i,cooked:n},tail:o});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,o=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),i="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(i+=a,a=this.expr.charAt(++this.index),i+=a,a){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=a}else n+=a,i+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),p9.addBinaryOp("in",7),p9.addBinaryOp("??",1);let fb=Symbol("optional chain short-circuited");function fw(e,t){switch(e.type){case"MemberExpression":return fg(e,t);case"CallExpression":return fy(e,t);default:return fh(e,t)}}function f_(e){return e===fb?void 0:e}function fx(e){return function(t){return null===t?null:fh(t,e)}}function fE(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let fS=new Set(["toString","valueOf","hasOwnProperty"]);function fD(e,t){try{return fm(e,t)}catch{return"<computed>"}}function fO(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function fP(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...ft},isLocalExpression:!1,variables:new Set};return fC("string"==typeof e?p9(e):e,t),[...t.variables]}function fC(e,t){switch(e.type){case"UnaryExpression":return n=e,i=t,fC(n.argument,i);case"BinaryExpression":return o=e,a=t,[fC(o.left,a),fC(o.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[fC(s.consequent,l),fC(s.test,l),fC(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=fC(u.callee,c),u.arguments?.map(fk(c)),r;case"ArrowFunctionExpression":var n,i,o,a,s,l,u,c,d,p,f,h,m,y,g,v,b=e,w=t;let x={...w};x.isLocalExpression=!0;let E=b.params?.map(fk(x))??[],S=fC(b.body,x)??[];if(S&&Array.isArray(S))for(let e of S)E.includes(e)||w.variables.add(e);return;case"MemberExpression":var D=e,O=t;if(fC(D.object,O),D.computed)return void fC(D.property,O);let P={...O};P.isLocalExpression=!0,fC(D.property,P);return;case"ArrayExpression":return d=e,p=t,void d.elements?.map(fk(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(fk(h));case"NewExpression":return m=e,y=t,void m.arguments?.map(fk(y));case"Literal":case"TemplateElement":return;case"Identifier":var C=e,k=t;if(!(C.name in k.globals))if(k.isLocalExpression)return C.name;else k.variables.add(C.name);return;case"TemplateLiteral":return g=e,v=t,void(g.expressions?.map(fk(v)),g.quasis?.map(fk(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function fk(e){return function(t){return null===t?null:fC(t,e)}}let fj=J("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function fT(e,t,r){fj.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function fR(){let e=fj.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function fA(e){return fj.getState().flags[e].enabled}function fN(e,t){fj.subscribe(r=>{t(r.flags[e].enabled)})}function fM(e,t){fj.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}function fI(e){return!window.offlineEnabled||(e??navigator.onLine)}fj.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var f$=ru(function(e,t,r){rt(e,t,r)});function fL(e=!0,t=!1){return fF(fI(),e,t)}function fF(e,t=!0,r=!1){return!!(e?t:r)}let fB=Z("extensionsInternal",{slots:{},extensions:{}}),fV=Z("extensionRenderings",{renderings:new Map}),fU=()=>J("extensionsInternal",{slots:{},extensions:{}}),fW=()=>J("extensionRenderings",{renderings:new Map});function fz(e){let t=fB.getState(),r=e(t);r!==t&&fB.setState(r)}let fK=null,fH=null;function fG(){let e=fV.getState();return fK&&e===fH||(fK=new Map(e.renderings),fH=e,function(e){for(let t of(f3.clear(),e.values()))f6(t,1);f4=!0}(fK)),fK}function fq(e){fH={renderings:e},fV.setState(fH,!0)}function fZ(e){let t=fG();t.has(e.renderingId)||(t.set(e.renderingId,e),f6(e,1),fq(t))}function fY(e){let t=fG(),r=t.get(e);r&&(t.delete(e),f6(r,-1),fq(t))}let fJ=()=>J("extensions",{slots:{}}),fX=0,fQ=new Set;function f0(e){fX++;try{return e()}finally{if(0==--fX&&fQ.size>0){let e=Array.from(fQ);for(let t of(fQ.clear(),e))f1(t)}}}function f1(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function f2(e){fX>0?fQ.add(e):f1(e)}let f3=new Map,f4=!1;function f6(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=f3.get(r);if(!n){if(t<0)return;f3.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),f4=!0;return}n.count+=t,n.count<1&&(f3.delete(r),f4=!0)}function f5(){var e,t;if(fG(),!f4)return;f4=!1;let r=Array.from(f3.values(),({record:e})=>e);r.sort(f9),e=nz.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===f9(e,t[r]))||nz.setState({mountedExtensions:r})}function f9(e,t){return f7(e.slotName,t.slotName)||f7(e.extensionId,t.extensionId)||f7(e.slotModuleName,t.slotModuleName)||f7(e.extensionModuleName,t.extensionModuleName)}function f7(e,t){return e===t?0:e<t?-1:1}f5(),fV.subscribe(()=>f2(f5));let f8=fU(),he=fJ(),ht=nH(),hr=nZ(),hn=new Set,hi=!1;function ho(e){if(null===e)hn=null;else if(null!==hn)for(let t of e)hn.add(t);f2(ha)}function ha(){if(!hi){hi=!0;try{for(let e=1;;e++){let t=hn;if(null!==t&&0===t.size)return;hn=new Set;try{!function(e,t,r,n,i,o=null){let a=he.getState().slots,s={},l=!1,u=fI(),c=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,d]of Object.entries(e.slots)){let p=a[n];if(p&&o&&!o.has(n)){s[n]=p;continue}let{config:f}=nq(t,d.name),h=function(e,t,r,n,i,o,a){let s=function(e,t){let r=e.add||[],n=e.remove||[],i=e.order||[],{extensions:o}=f8.getState();return[...t,...r].filter(e=>!n.includes(e)).sort((e,r)=>hg(e,i,o[hc(e)]?.order,t)-hg(r,i,o[hc(r)]?.order,t))}(r,t.slots[e].attachedIds),l=[];for(let u of s){let{config:s}=nJ(n,e,u),c=nX(r,e,u),d=c?f$({},s,c):s,p=hc(u),f=t.extensions[p];if(f){let e=d?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!aL(e,a.user))||f.featureFlag&&!i.includes(f.featureFlag)||window.offlineEnabled&&!fF(o,f.online,f.offline))continue;l.push({id:u,name:p,moduleName:f.moduleName,config:d,featureFlag:f.featureFlag,meta:f.meta,online:d?.["Display conditions"]?.online??f.online??!0,offline:d?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||f.displayExpression})}}return l}(n,e,f,r,c,u,i.session);p&&p.moduleName===d.moduleName&&r1(p.candidateExtensions,h)?s[n]=p:(s[n]={moduleName:d.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&he.setState({slots:s})}(f8.getState(),ht.getState(),hr.getState(),fj.getState(),aT.getState(),t)}catch(e){throw hn=null===t||null===hn?null:new Set([...t,...hn]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{hi=!1}}}function hs(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function hl(){ho(null)}function hu(e,t){return{moduleName:t,name:e,attachedIds:[]}}function hc(e){let[t]=e.split("#");return t}function hd(e,t){let r=hc(t);return e.extensions[r]}function hp(e){return hd(f8.getState(),e)}f8.subscribe((e,t)=>{ho(e.extensions!==t.extensions?null:hs(e.slots,t.slots))}),ht.subscribe((e,t)=>{ho(hs(e.slots,t.slots))}),hr.subscribe((e,t)=>{ho(hs(e.configs,t.configs))}),fj.subscribe(()=>ho(null)),aT.subscribe(()=>ho(null)),hl(),v(hl);let hf=e=>fz(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function hh(e,t){fz(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...hu(e),attachedIds:[t]}}}})}function hm(e,t){fz(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function hy(e){fz(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function hg(e,t,r,n){let i=t.indexOf(e);if(-1!==i)return i;{if(void 0!==r)return 1e3+r;let t=n.indexOf(e);return -1!==t?2e3+t:3e3}}function hv(e,t){return function(e,t,r=null,n){let i;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;i??(i=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!fi(o,i)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(hb(e),t,aT.getState().session,e)}function hb(e){return he.getState().slots[e]?.candidateExtensions??[]}let hw=(e,t)=>f8.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let i=hu(t,e);return{...r,slots:{...r.slots,[t]:{...i}}}}),h_=()=>{hn=null,fz(()=>({slots:{},extensions:{}})),fW().setState({renderings:new Map}),he.setState({slots:{}})},hx=Z("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function hE({name:e,basePath:t,mode:r,componentContext:n,state:i}){hx.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:i})}function hS(e){hx.getState().slotName===e&&hx.setState(hx.getInitialState(),!0)}let hD=Z("modalRegistry",{modals:{}});function hO(e){hD.setState(t=>(t.modals[e.name]=e,t))}function hP(e){let t=hD.getState().modals[e];if(!t){let r=hp(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),hO(t))}return t}let hC=Z("workspaceRegistrations",{workspaces:{}}),hk=Z("workspaceGroups",{workspaceGroups:{}});function hj(e){hC.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function hT(e){hk.setState(t=>{let r=t.workspaceGroups[e.name];return r?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...r,members:Array.from(new Set([...r.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let hR=new Set;function hA(e){let t=hC.getState().workspaces;if(t[e])return t[e];{let t=hp(e);if(t){var r;let n;return hR.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.`),hR.add(e)),{name:t.name,title:(r=t,"string"==typeof(n=r?.meta?.title)?n:n&&"object"==typeof n?sP(r.moduleName,n.key,n.default):r.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function hN(e){let t=hk.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let hM=Z("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function hI(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=hM.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function h$(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=hM.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function hL(e){let{openedWindows:t}=hM.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function hF(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=hM.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}hM.setState({registeredGroupsByName:n})}function hB(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=hM.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}hM.setState({registeredWindowsByName:n})}function hV(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=hM.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}hM.setState({registeredWorkspacesByName:n})}let hU=0,hW=null,hz={bootstrap:15e3,mount:15e3,unmount:15e3};function hK(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(hz).filter(t=>e[t]).map(n=>{var i,o;let a,s;return[n,(i=e[n],o=hz[n],a=Array.isArray(i)?i:[i],s=e=>a.reduce((t,i,o)=>t.then(()=>{let t=i(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${o} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let i,a=new Promise((e,t)=>{i=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${o}ms`)),o)});return Promise.race([s(e),a]).finally(()=>clearTimeout(i)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function hH(e,t){var r,n;let i,o,a,s,l,u=await (hW??(hW=new Promise((e,t)=>{oO({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),oO))),hW),c={...t},d=(i=c,o=!1,{retarget:e=>i={...e},release:a=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(i),onSettled(e,t){switch(e){case"bootstrap":t&&a();return;case"mount":o||(o=t);return;case"unmount":(t||o)&&a();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>hK(e,r)):hK(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function hG(){return hq}function hq(e,t){let r,n=hH(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function hZ(e,t,r,n,i=e=>e,o={}){let a=hc(n),s=hp(n),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:u,moduleName:c,online:d,offline:p,load:f}=s;if(fL(d,p)){let s,d=hU++,p=`${t}/${n}-${d}`;e.dataset.extensionRenderingId=p;let h=e=>{try{fY(p)}catch(t){console.error(e,t)}};try{fZ({renderingId:p,extensionName:a,extensionModuleName:c,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{s=await f()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await hH(i({...s,name:`${t}/${a}-${d}`}),{...o,_meta:u,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var hY=r(7125),hJ=r.n(hY);let hX=(0,hY.createContext)({moduleName:"",featureName:""});function hQ({to:e,templateParams:t,onBeforeNavigate:r,children:n,...i}){return(0,hY.useEffect)(()=>{i.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${i.href}'`),i.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),hJ().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),ah({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:ap(e,t),...i},n)}let h0=({state:e,children:t,...r})=>{let{extension:n}=(0,hY.useContext)(hX),i=(0,hY.useRef)(null),o=(0,hY.useRef)(Promise.resolve()),a=(0,hY.useRef)(!1),s=(0,hY.useRef)(!1),l=(0,hY.useRef)(e),u=(0,hY.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,hY.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(i.current?.getStatus()==="MOUNTED"&&i.current.update)return i.current.update({...t})}).catch(e=>{let t=i.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,hY.useCallback)(t=>{t&&!i.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,hZ(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,i.current=t,a.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,hY.useEffect)(()=>(a.current=!1,()=>{a.current=!0,u(i.current)}),[]),(0,hY.useEffect)(()=>{l.current=e,i.current&&c(i.current,e)},[e]),n?hJ().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function h1(e){let t=(0,hY.useRef)(e);return F(t.current,e)||(t.current=e),t.current}function h2(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,i]of Object.entries(t)){let t=function(...t){e.setState(e=>i(e,...t))};r[n]=t}return r}let h3=e=>e;function h4(e,t=h3,r){let n=(0,hY.useCallback)(t=>e.subscribe(t),[e]),i=(0,hY.useCallback)(()=>t(e.getState()),[e,t]),o=(0,hY.useSyncExternalStore)(n,i,i),a=(0,hY.useMemo)(()=>r?h2(e,r):null,[e,r]);return(0,hY.useMemo)(()=>a?{...o,...a}:o,[o,a])}function h6(e,t){return h4(e,h3,t)}function h5(e){return function(t){let r=(0,hY.useCallback)(t=>e.subscribe(t),[]),n=(0,hY.useCallback)(()=>e.getState(),[]),i=(0,hY.useSyncExternalStore)(r,n,n),o=(0,hY.useMemo)(()=>t?h2(e,t):null,[t]);return(0,hY.useMemo)(()=>o?{...i,...o}:i,[i,o])}}let h9=[];Object.freeze(h9);let h7={candidateExtensions:h9};Object.freeze(h7);let h8=e=>{let t=(0,hY.useCallback)(t=>t.slots?.[e]??h7,[e]);return h4(fJ(),t)},me=e=>e.session;function mt(e,t){let{candidateExtensions:r}=h8(e),n=h4(aT,me),i=h1(t);return(0,hY.useMemo)(()=>hv(e,i),[e,i,n,r])}function mr(e,t){let{moduleName:r}=(0,hY.useContext)(hX);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,hY.useEffect)(()=>{hw(r,e)},[r,e]),{extensions:mt(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function mn(e){return e}function mi({name:e,extensionSlotName:t,select:r=mn,children:n,state:i,style:o,...a}){if(n&&i)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,hY.useRef)(null),{extensions:u,extensionSlotModuleName:c}=mr(s,i),d=(0,hY.useMemo)(()=>r(u),[r,u]),p=(0,hY.useMemo)(()=>{if("function"==typeof n&&!hJ().isValidElement(n))return d.map(e=>n(e,i))},[n,d]);return hJ().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...a},s&&d?.map((e,t)=>hJ().createElement(hX.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},p?.[t]??("function"!=typeof n?n:null)??hJ().createElement(h0,{state:i}))))}var mo=r(5873);function ma(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ms(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ma(Object(r),!0).forEach(function(t){var n,i,o;n=e,i=t,o=r[t],i in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ma(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ml(e){return(ml="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 mu(e){return(mu="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 mc(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(mu(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(mu(e)));return e}}var md=null;try{md=require("react").createContext()}catch(e){}var mp={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 mf(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function mh(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var i,o=mv(e,t,function(){r(this)}),a=mc(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,i=e.domElement,o=t[r];if("function"!=typeof o)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=o(i);return a.render(n),a;case"hydrateRoot":return o(i,n);default:return o(n,i),null}}({elementToRender:o,domElement:a,reactDom:mg(e),renderType:"function"==typeof(i=e).renderType?i.renderType():i.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function mm(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():mg(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function my(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=mv(e,t,null),i=e.renderResults[t.name];if(i&&i.render)i.render(n);else{var o=mc(e,t)();mg(e).render(n,o)}})}function mg(e){return e.ReactDOMClient||e.ReactDOM}function mv(e,t,r){var n=e.React.createElement(e.rootComponent,t),i=md?e.React.createElement(md.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),i=e.React.createElement(e.errorBoundaryClass,t,i)),i=e.React.createElement(e.SingleSpaRoot,ms(ms({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),i)}var mb=r(5921),mw=r(8909),m_=r.n(mw),mx=r(9106);let mE={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},mS=new Map;(0,mx.initCache)(mS);let mD={errorRetryCount:3,fetcher:aC,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof aj){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>mS};function mO(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},mE,e),r={...mD,...t.swrConfig};return function(e){var n,i,o,a,s;return o=i=class extends(n=hJ().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return hJ().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=hJ().createElement(hY.Suspense,{fallback:null},hJ().createElement(mw.SWRConfig,{value:r},hJ().createElement(hX.Provider,{value:this.state.config},t.disableTranslations?hJ().createElement(e,this.props):hJ().createElement(mb.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},hJ().createElement(e,this.props)))));return t.strictMode&&hJ().StrictMode?hJ().createElement(hJ().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in o?Object.defineProperty(o,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[a]=s,i}}function mP(e,t){return function(e){if("object"!==ml(e))throw Error("single-spa-react requires a configuration object");var t,r=ms(ms({},mp),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!md&&r.React.createContext&&(md=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:mf.bind(null,r),mount:mh.bind(null,r),unmount:mm.bind(null,r)};return r.parcelCanUpdate&&(n.update=my.bind(null,r)),n}({React:hJ(),ReactDOMClient:mo,rootComponent:mO(t)(e)})}function mC(e,t){return()=>e().then(({default:e})=>mP(e,t))}function mk(e,t){return()=>Promise.resolve(mP(e,t))}let mj=mC,mT=W()(()=>({}));Y("openmrs-app-context",mT);let mR={};function mA(e,t=e=>e){let r=mT.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function mN(e,t){mT.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function mM(e){return null===e?null:Object.freeze(Object.assign({},e))}let mI=new Map;function m$(e,t){let r=(0,hY.useRef)(t??{}),n=(0,hY.useRef)(t=>mN(e,t)),i=(0,hY.useRef)(Symbol());return(0,hY.useEffect)(()=>{let r=t??{},n=i.current;return null===mA(e)?!function(e,t=mR){mT.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===mR?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),mN(e,()=>r)),mI.set(e,n),()=>{mI.get(e)===n&&(mT.setState(t=>(e in t&&delete t[e],t)),mI.delete(e))}},[e]),(0,hY.useEffect)(()=>{let n=t??{};F(r.current,n)||(mN(e,()=>n),r.current=n)},[t]),n.current}function mL({namespace:e,value:t}){return m$(e,t),null}let mF=({children:e,value:t,fallback:r})=>t?hJ().createElement(hJ().Fragment,null,e):r?hJ().createElement(hJ().Fragment,null,r):null;function mB(){let e=(0,hY.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,hY.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function mV(e,t=e=>e??{}){let[r,n]=(0,hY.useState)(()=>{if(mU(e))return;let r=mA(e);if(null!==r)return t?t(r):r});return(0,hY.useEffect)(()=>{if(mU(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,hY.useEffect)(()=>{var r;let i;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>F(e,r)?e:r)})(mM(i=mA(e))),mT.subscribe(t=>{let n=e in t?t[e]:null;n!==i&&(i=n,r(mM(n)))})},[e,t]),r}function mU(e){return"string"!=typeof e||0===e.trim().length}function mW(e){let t=mt(e);return(0,hY.useMemo)(()=>t.map(e=>e.id),[t])}function mz(e){return h8(e).candidateExtensions}function mK(e,t,r){let{data:n,error:i,mutate:o,isLoading:a,isValidating:s}=m_()(e?lm(e,t,r):null,aC);return(0,hY.useMemo)(()=>({isLoading:a,data:n?.data.results??[],error:i,mutate:o,isValidating:s}),[n,i,a,s,o])}function mH(e){(0,hY.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let mG={},mq=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function mZ(e){let{moduleName:t,extension:r}=(0,hY.useContext)(hX),n=e?.externalModuleName??t;if(!n&&!r)throw Error(mq);let i=function(e){let t=(0,hY.useMemo)(()=>nK(e),[e]),r=function(e){let[t,r]=(0,hY.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,hY.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw mG[e]||(mG[e]=new Promise(e=>{let r=t.subscribe(t=>{t.loaded&&t.config&&(e(t.config),r())})})),mG[e];return r}(n),o=function(e){let t=(0,hY.useMemo)(nZ,[]),r=function(e,t){let[r,n]=(0,hY.useState)(t?()=>{let r=nJ(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,hY.useEffect)(()=>{if(t)return e.subscribe(e=>{let i=nJ(e,t.extensionSlotName,t.extensionId);i.loaded&&i.config&&!r1(i.config,r)&&n(i.config)})},[e,t,r]),r}(t,e);if(!r&&e){let r=`${e.extensionSlotName}-${e.extensionId}`;throw!mG[r]&&t&&(mG[r]=new Promise(r=>{let n=t.subscribe(t=>{let i=nJ(t,e.extensionSlotName,e.extensionId);i.loaded&&i.config&&(r(i.config),n())})})),mG[r]}return r||{}}(r);return(0,hY.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...i}:{...i,...o},[n,e?.externalModuleName,i,o])}let mY=mt;function mJ(){let[e,t]=(0,hY.useState)(fI());return(0,hY.useEffect)(()=>v(({online:e})=>t(e)),[]),e}function mX(e,t=300){let[r,n]=(0,hY.useState)(e);return(0,hY.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var mQ=r(4498),m0=r.n(mQ);let m1=`custom:${[["admissionDecisionConcept","ref"],["admissionEncounterType","ref"],["admissionForm","ref"],["atFacilityVisitType","ref"],["bedAssignmentEncounterType","ref"],["cancelADTRequestEncounterType","ref"],["checkInClerkEncounterRole","ref"],["checkInEncounterType","ref"],["clinicianEncounterRole","ref"],["conceptSourcesForDiagnosisSearch","ref"],["consultEncounterType","ref"],["consultFreeTextCommentsConcept","ref"],["denyAdmissionConcept","ref"],["diagnosisMetadata","ref"],["diagnosisSets","ref"],["dischargeForm","ref"],["dispositionDescriptor","ref"],["dispositions","ref"],["emrApiConceptSource","ref"],["exitFromInpatientEncounterType","ref"],["extraPatientIdentifierTypes","ref"],["fullPrivilegeLevel","ref"],["highPrivilegeLevel","ref"],["identifierTypesToSearch","ref"],["inpatientNoteEncounterType","ref"],["lastViewedPatientSizeLimit","ref"],["metadataSourceName","ref"],["motherChildRelationshipType","ref"],["narrowerThanConceptMapType","ref"],["nonDiagnosisConceptSets","ref"],["orderingProviderEncounterRole","ref"],["patientDiedConcept","ref"],["personImageDirectory","ref"],["primaryIdentifierType","ref"],["sameAsConceptMapType","ref"],["suppressedDiagnosisConcepts","ref"],["supportsAdmissionLocationTag","(uuid,display,name,links)"],["supportsLoginLocationTag","(uuid,display,name,links)"],["supportsTransferLocationTag","(uuid,display,name,links)"],["supportsVisitsLocationTag","(uuid,display,name,links)"],["telephoneAttributeType","ref"],["testPatientPersonAttributeType","ref"],["transferForm","ref"],["transferRequestEncounterType","ref"],["transferWithinHospitalEncounterType","ref"],["unknownCauseOfDeathConcept","ref"],["unknownLocation","ref"],["unknownPatientPersonAttributeType","ref"],["unknownProvider","ref"],["visitAssignmentHandlerAdjustEncounterTimeOfDayIfNecessary","ref"],["visitExpireHours","ref"],["visitNoteEncounterType","ref"]].map(([e,t])=>`${e}:${t}`).join(",")}`;function m2(){let e=`${aS}/emrapi/configuration?v=${m1}`,t=m0()(e,aC);return(0,hY.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}let m3=h5(fU());function m4(e){let t=mt(e);return(0,hY.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let m6=h5(fJ());function m5(e){let{flags:t}=h4(fj);return t[e]?.enabled??!1}function m9(){let[,e]=(0,hY.useState)(0);return(0,hY.useCallback)(()=>{e(e=>e+1)},[])}function m7(e,t,r={}){return ye(e,t,m8,r)}let m8={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(aP(e.toString()),window.location.toString());return n.searchParams.set("limit",""+t),n.searchParams.set("startIndex",""+r),n.searchParams.set("totalCount","true"),n.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function ye(e,t,r,n={}){let{getPaginatedUrl:i,getTotalCount:o,getCurrentPageSize:a,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??aC,[d,p]=(0,hY.useState)(1),f=(0,hY.useRef)(NaN),h=(0,hY.useRef)(NaN),m=(0,hY.useRef)(d),y=(0,hY.useRef)(!1),g=(0,hY.useRef)(!1),v=e?.toString()??"",[b,w]=(0,hY.useState)(v);v!==b&&(w(v),p(1),m.current=1,f.current=NaN,h.current=NaN,y.current=!1,g.current=!1);let x=(d-1)*t,E=(0,hY.useMemo)(()=>i(e,t,x),[e,t,x]),{data:S,...D}=(l?m0():m_())(E,c,u);S?.data&&(f.current=o(S?.data),h.current=a(S?.data),y.current=!0);let O=Math.ceil(f.current/t),P=(0,hY.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(f.current/t);!y.current||Number.isNaN(r)||e<=r?(m.current=e,p(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,hY.useEffect)(()=>{if(!y.current)return;if(Number.isNaN(f.current)){g.current||(g.current=!0,console.warn(`useServerPagination: ${v} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(f.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),m.current=e,p(e))},[d,t,v,S]);let C=(0,hY.useCallback)(()=>{P(m.current+1)},[P]),k=(0,hY.useCallback)(()=>{P(m.current-1)},[P]);return{data:s(S?.data),totalPages:O,totalCount:f.current,currentPage:d,currentPageSize:h.current,paginated:O>1,showNextButton:d<O,showPreviousButton:d>1,goTo:P,goToNext:C,goToPrevious:k,...D}}function yt(e,t,r={}){return ye(e,t,yr(),r)}function yr(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(aP(e.toString()),window.location.toString());return n.searchParams.set("_count",""+t),n.searchParams.set("_getpagesoffset",""+r),n.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var yn=r(5292),yi=r.n(yn);function yo(e,t={}){return ya(e,m8,t)}function ya(e,t,r={}){let{swrInfiniteConfig:n,immutable:i}=r,{getNextUrl:o,getTotalCount:a,getData:s}=t,l=r.fetcher??aC,u=(0,hY.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:p,...f}=yi()(u,l,{...n,...i?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),h=o(c?.[c.length-1].data),m=a(c?.[0]?.data);return{data:c?.flatMap(e=>s(e.data)),totalCount:m,hasMore:null!=h,loadMore:()=>{p((c?.length??0)+1)},nextUri:h,...f}}function ys(e,t={}){return yl(e,m8,t)}function yl(e,t,r={}){let n=ya(e,t,r),{hasMore:i,error:o,data:a,loadMore:s,isLoading:l,nextUri:u}=n;return((0,hY.useEffect)(()=>{i&&!o&&s()},[i,u]),r.partialData)?n:{...n,data:i||o?void 0:a,isLoading:l||i}}function yu(e,t={}){return yl(e,yr(),t)}function yc(e,t={}){return ya(e,yr(),t)}function yd(){let e="tablet";return document.body.classList.forEach(t=>{switch(t){case"omrs-breakpoint-lt-tablet":e="phone";break;case"omrs-breakpoint-gt-small-desktop":e="large-desktop";break;case"omrs-breakpoint-gt-tablet":e="small-desktop"}}),e}function yp(){let[e,t]=(0,hY.useState)(yd);return(0,hY.useEffect)(()=>{let e=()=>{t(yd())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let yf=e=>"small-desktop"===e||"large-desktop"===e;function yh(e){let t=(0,hY.useContext)(hX);(0,hY.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),hE(e),()=>{hS(e.name)}),[t,e])}function ym(){return h4(hx)}function yy(e=null,t=null){let[r,n]=(0,hY.useState)([]);return(0,hY.useEffect)(()=>{let r=pV(e,t).subscribe(e=>{n(e)},e=>{console.error(e)});return()=>r.unsubscribe()},[e,t]),r}function yg(e,t=!0){let r=(0,hY.useRef)(null);return(0,hY.useEffect)(()=>{let n=n=>{t&&r.current&&n.target&&n.target instanceof Node&&(r.current.contains(n.target)||e(n))};return window.addEventListener("mousedown",n),window.addEventListener("touchstart",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("touchstart",n)}},[e,t]),r}function yv(e){let t=(0,hY.useRef)();return(0,hY.useEffect)(()=>{let r=new IntersectionObserver(t=>{for(let r of t)if(r.isIntersecting)return void e()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t.current,e]),t}function yb(e,t={}){let{abortController:r,fetchInit:n,url:i,swrConfig:o}=t,a=mB(),s=(0,hY.useMemo)(()=>n?.signal??r?.signal??a.signal,[r?.signal,n?.signal,a.signal]),l=(0,hY.useCallback)(e=>aC(function(e,t){if(t)return"function"==typeof t?t(e):t;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,i),{...n,signal:s}),[s,n,i]);return m_()(e,l,o)}function yw(e=[],t=10){let[r,n]=(0,hY.useState)(1),i=(0,hY.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);r>i&&n(i);let o=Math.min(Math.max(1,r),i),a=(0,hY.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,hY.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,hY.useCallback)(()=>{n(e=>e+1)},[]),u=(0,hY.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,hY.useMemo)(()=>({results:a,totalPages:i,currentPage:o,paginated:e.length>t,showNextButton:o<i,showPreviousButton:o>1,goTo:s,goToNext:l,goToPrevious:u}),[a,i,e.length,t,o,s,l,u])}function y_(e,t,r,n){return{pageSizes:(0,hY.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,hY.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function yx(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function yE(e){let[t,r]=(0,hY.useState)(e??yx()),{data:n,error:i,isValidating:o}=m_()(t?["patient",t]:null,()=>pM(t,{}));return(0,hY.useEffect)(()=>{let e=()=>{let e=yx();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,hY.useMemo)(()=>({isLoading:o&&!i&&!n,patient:n,patientUuid:t,error:i}),[o,i,n,t])}function yS(){let e=`${aS}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=m_()(e,aC);return(0,hY.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function yD(e){let{extensions:t,extensionSlotModuleName:r}=mr(e);return e?t.map(t=>({state:n})=>hJ().createElement(hX.Provider,{value:{moduleName:r,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:r}}},hJ().createElement(h0,{state:n}))):[]}function yO(){let e=(0,hY.useRef)(),[t,r]=(0,hY.useState)(null),n=null;if(!t){if(s){let e=aN().getState();e.loaded&&(n=e.session)}else s=new Promise(t=>{let r=({loaded:r,session:i})=>{r&&(t(i),n=i,e.current&&(e.current(),e.current=void 0))};r(aN().getState()),n||(e.current=aN().subscribe(r))});if(n)r(n);else throw s}(0,hY.useEffect)(()=>(e.current||(e.current=aN().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let i=t||n;if(!i)if(s)throw console.warn("useSession is in an unexpected state. Attempting to recover."),s;else throw Error("useSession is in an invalid state.");return i}let yP=({privilege:e,fallback:t,children:r})=>{let[n,i]=(0,hY.useState)(null);return((0,hY.useEffect)(()=>{let e=aA({includeAuthStatus:!1}).subscribe(i);return()=>e.unsubscribe()},[]),n&&aL(e,n))?hJ().createElement(hJ().Fragment,null,r):t?hJ().createElement(hJ().Fragment,null,t):null};var yC=r(7248),yk=r.n(yC),yj=r(5602);let yT=new Map;function yR(){for(let e of Array.from(yT.values()))e()}let yA={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function yN(e){let t=(0,hY.useId)();return(0,hY.useEffect)(()=>{if(e)return yT.set(t,e),()=>{yT.delete(t)}},[t,e]),{...h6(p0(),yA),mutateVisit:yR}}function yM(e,t=pX){let r=(0,hY.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:i,setVisitContext:o}=yN((0,hY.useCallback)(()=>r.current?.(),[])),a=e&&n==e?i:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${a}?v=${t}`,{data:u,error:c,mutate:d,isValidating:p}=m_()(e?`${aS}/visit${s}`:null,aC),{data:f,error:h,mutate:m,isValidating:y}=m_()(e&&a?`${aS}/visit${l}`:null,aC),g=(0,hY.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,hY.useMemo)(()=>a&&f?f.data:null,[f,a]),b=(0,hY.useRef)(null);(0,hY.useEffect)(()=>{!p&&g&&n===e&&null===i&&o(g),y||(b.current&&v&&b.current.uuid===v.uuid&&!b.current.stopDatetime&&v.stopDatetime&&o(null),b.current=v)},[v,i,g,p,y,n]);let w=(0,hY.useCallback)(()=>{d(),m()},[d,m]);(0,hY.useEffect)(()=>{r.current=w},[w]);let x=!!(!u||a&&!f),E=!!(a?h:c);return{error:c||h,mutate:w,isValidating:p||y,activeVisit:g,currentVisit:v,currentVisitIsRetrospective:!!a,isLoading:x&&!E}}function yI(){let[e,t]=(0,hY.useState)([]);return(0,hY.useEffect)(()=>{let e=pW().subscribe(e=>{t(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}yk().extend(yj);let y$=new Map;async function yL(e,t){let r=t.indexOf("#"),n=r>=0,i=n?t.substring(0,r):e,o=n?t.substring(r+1):t,a=await sX(i);return a&&Object.hasOwn(a,o)&&"function"==typeof a[o]?yB(i,a).then(()=>a[o]()):(a?a&&Object.hasOwn(a,o)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${i} does not define a component called "${o}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${i} for ${t} defined in ${e}'s routes.json`),yF)}let yF={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function yB(e,t){if(e in y$)await y$[e];else{let r=t??await sX(e);await (y$[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let i=r.startupApp;if("function"==typeof i)return Promise.resolve(i()).then(()=>{iu(e),t(null)}).catch(n)}iu(e),t(null)}))}}function yV(e,t){let r=t.name;if(!r)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
|
|
17
17
|
registered. To fix this, ensure that you define the "name" field inside the
|
|
18
18
|
extension definition.`,t);t.slots&&t.slot&&console.warn(`The extension ${r} from ${e} declares both a 'slots' property and
|