@openmrs/esm-form-builder-app 3.5.2-pre.3765 → 3.5.2-pre.3768
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/8398.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 ra=(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&&rs(e)){if(i._type===tC.Array&&Array.isArray(n)){let i=n.map(t=>ra(e,t));r[t]=i}else if(i._type===tC.Object)for(let t of Object.keys(n))n[t]=ra(e,n[t])}}else if(rl(i)){let e=n??{};rl(e)&&(r[t]=ra(i,e))}}return r};function rs(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function rl(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let ru=new Set;function rc(e,t){let r=`${e}:::${t}`;ru||(ru=new Set),ru.has(r)||(console.error(t),ru.add(r))}let rd={"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:tC.Object,_default:{},_validators:[tk(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(", ")}.`})]}},rf={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:tC.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:tC.String,_default:void 0}},...rd},rp=(e,t)=>tk(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),rh=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return tk(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(", "))},rm=rh([]),ry=e=>tk(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),rg={inRange:rp,isUrl:rm,isUrlWithTemplateParameters:rh,oneOf:ry};var rb=r(48067);let rv=K("breadcrumbs",[]);function r_(e){return rw([e])}function rw(e){let t=[...rx(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,rb.pathToRegexp)(e.matcher).regexp:(0,rb.pathToRegexp)(e.path).regexp,settings:e}))];rv.setState(t,!0)}function rx(){return rv.getState()}function rE(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=rE(e,r.join("/"));if(t)return t}}(e,t)}function rS(e,t){if(e.length>0){let r=rE(e,t);if(r){let t=[r],n=rE(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=rE(e,n.settings.parent);return t.reverse()}}return[]}function rD(e){return rS(rx(),e)}var rO=Object.freeze({__proto__:null,get start(){return nY},get ensureJQuerySupport(){return nD},get setBootstrapMaxTime(){return na},get setMountMaxTime(){return ns},get setUnmountMaxTime(){return nl},get setUnloadMaxTime(){return nu},get registerApplication(){return nI},get unregisterApplication(){return nL},get getMountedApps(){return nR},get getAppStatus(){return nM},get unloadApplication(){return nF},get checkActivityFunctions(){return n$},get getAppNames(){return nA},get pathToActiveWhen(){return nU},get navigateToUrl(){return ny},get patchHistoryApi(){return nx},get triggerAppChange(){return nz},get addErrorHandler(){return rT},get removeErrorHandler(){return rR},get mountRootParcel(){return nt},get NOT_LOADED(){return rN},get LOADING_SOURCE_CODE(){return rI},get NOT_BOOTSTRAPPED(){return r$},get BOOTSTRAPPING(){return rL},get NOT_MOUNTED(){return rF},get MOUNTING(){return rB},get UPDATING(){return rU},get LOAD_ERROR(){return rH},get MOUNTED(){return rV},get UNLOADING(){return rK},get UNMOUNTING(){return rW},get SKIP_BECAUSE_BROKEN(){return rz}}),rP=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,rC=!function(){try{var e=new rP("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}:rP;let rk=[];function rj(e,t,r){let n=rM(e,t,r);rk.length?rk.forEach(e=>e(n)):setTimeout(()=>{throw n})}function rT(e){if("function"!=typeof e)throw Error(rA(28,!1));rk.push(e)}function rR(e){if("function"!=typeof e)throw Error(rA(29,!1));let t=!1;return rk=rk.filter(r=>{let n=r===e;return t=t||n,!n}),t}function rA(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 rM(e,t,r){let n,i=`${rJ(t)} '${rZ(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=i+e.message}catch(e){}n=e}else{console.warn(rA(30,!1,t.status,rZ(t)));try{n=Error(i+JSON.stringify(e))}catch(t){n=e}}return n.appOrParcelName=rZ(t),t.status=r,n}let rN="NOT_LOADED",rI="LOADING_SOURCE_CODE",r$="NOT_BOOTSTRAPPED",rL="BOOTSTRAPPING",rF="NOT_MOUNTED",rB="MOUNTING",rV="MOUNTED",rU="UPDATING",rW="UNMOUNTING",rK="UNLOADING",rH="LOAD_ERROR",rz="SKIP_BECAUSE_BROKEN";function rq(e){return e.status===rV}function rG(e){try{return e.activeWhen(window.location)}catch(t){return rj(t,e,rz),!1}}function rZ(e){return e.name}function rY(e){return!!e.unmountThisParcel}function rJ(e){return rY(e)?"parcel":"application"}function rQ(){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 rX(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r];return null}function r0(e){return e&&("function"==typeof e||Array.isArray(e)&&!rX(e,e=>"function"!=typeof e))}function r1(e,t){let r=e[t]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[()=>Promise.resolve()]);let n=rJ(e),i=rZ(e);return function(e){return r.reduce((r,o,a)=>r.then(()=>{let r=o(e);return r3(r)?r:Promise.reject(rA(15,!1,n,i,t,a))}),Promise.resolve())}}function r3(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let r4=[];function r2(e,t){return Promise.resolve().then(()=>e.status!==r$?e:(e.status=rL,e.bootstrap?nc(e,"bootstrap").then(r).catch(r=>{if(t)throw rM(r,e,rz);return rj(r,e,rz),e}):Promise.resolve().then(r)));function r(){return e.status=rF,e}}function r6(e,t){return Promise.resolve().then(()=>{if(e.status!==rV)return e;return e.status=rW,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 rM(r,e,rz);rj(r,e,rz)})).then(()=>e);function r(){return nc(e,"unmount").then(()=>{e.status=rF},r=>{if(t)throw rM(r,e,rz);rj(r,e,rz)})}})}let r5=!1,r8=!1;function r9(e,t){return Promise.resolve().then(()=>e.status!==rF?e:(r5||(window.dispatchEvent(new rC("single-spa:before-first-mount")),r5=!0),e.status=rB,nc(e,"mount").then(()=>(e.status=rV,r8||(window.dispatchEvent(new rC("single-spa:first-mount")),r8=!0),e)).catch(r=>{return e.status=rV,r6(e,!0).then(n,n);function n(){if(t)throw rM(r,e,rz);return rj(r,e,rz),e}})))}let r7=0,ne={parcels:{}};function nt(){return nr.apply(ne,arguments)}function nr(e,t){let r,n,i,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(rA(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(rA(3,!1,typeof e.name));let a=r7++,s=e.name||`parcel-${a}`;if("object"!=typeof t)throw Error(rA(4,!1,s,typeof t));if(!t.domElement)throw Error(rA(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:a,parcels:{},status:l?rI:r$,customProps:t,parentName:rZ(o),unmountThisParcel:()=>p.then(()=>{if(c.status!==rV)throw Error(rA(6,!1,s,c.status));return r6(c,!0)}).then(e=>(c.parentName&&delete o.parcels[c.id],e)).then(e=>(n(e),e)).catch(e=>{throw c.status=rz,i(e),e})};o.parcels[a]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(rA(7,!1));let f=(d=d.then(e=>{if(!e)throw Error(rA(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!r0(e.bootstrap))throw Error(rA(9,!1,s));if(!r0(e.mount))throw Error(rA(10,!1,s));if(!r0(e.unmount))throw Error(rA(11,!1,s));if(e.update&&!r0(e.update))throw Error(rA(12,!1,s));let t=r1(e,"bootstrap"),n=r1(e,"mount"),i=r1(e,"unmount");c.status=r$,c.name=s,c.bootstrap=t,c.mount=n,c.unmount=i,c.timeouts=nd(e.timeouts),e.update&&(c.update=r1(e,"update"),r.update=function(e){return c.customProps=e,nn(Promise.resolve().then(()=>{if(c.status!==rV)throw Error(rA(32,!1,rZ(c)));return c.status=rU,nc(c,"update").then(()=>(c.status=rV,c)).catch(e=>{throw rM(e,c,rz)})}))})})).then(()=>r2(c,!0)),p=f.then(()=>r9(c,!0)),h=new Promise((e,t)=>{n=e,i=t});return r={mount:()=>nn(Promise.resolve().then(()=>{if(c.status!==rF)throw Error(rA(13,!1,s,c.status));return o.parcels[a]=c,r9(c)})),unmount:()=>nn(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:nn(d),bootstrapPromise:nn(f),mountPromise:nn(p),unmountPromise:nn(h)}}function nn(e){return e.then(()=>null)}function ni(e){let t=rZ(e),r="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(rA(40,!1),t,r));let n=rQ({},r,{name:t,mountParcel:nr.bind(e),singleSpa:rO});return rY(e)&&(n.unmountSelf=e.unmountThisParcel),n}let no={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 na(e,t,r){if("number"!=typeof e||e<=0)throw Error(rA(16,!1));no.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function ns(e,t,r){if("number"!=typeof e||e<=0)throw Error(rA(17,!1));no.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nl(e,t,r){if("number"!=typeof e||e<=0)throw Error(rA(18,!1));no.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nu(e,t,r){if("number"!=typeof e||e<=0)throw Error(rA(19,!1));no.unload={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nc(e,t){let r=e.timeouts[t],n=r.warningMillis,i=rJ(e);return new Promise((o,a)=>{let s=!1,l=!1;e[t](ni(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>c(1),n),setTimeout(()=>c(!0),r.millis);let u=rA(31,!1,t,i,rZ(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 nd(e){let t={};for(let r in no)t[r]=rQ({},no[r],e&&e[r]||{});return t}function nf(e){return Promise.resolve().then(()=>{let t,r;return e.loadPromise?e.loadPromise:e.status!==rN&&e.status!==rH?e:(e.status=rI,e.loadPromise=Promise.resolve().then(()=>{let n=e.loadApp(ni(e));if(!r3(n))throw r=!0,Error(rA(33,!1,rZ(e)));return n.then(r=>{let n;e.loadErrorTime=null,"object"!=typeof(t=r)&&(n=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!r0(t.bootstrap)&&(n=35),r0(t.mount)||(n=36),r0(t.unmount)||(n=37);let i=rJ(t);if(n){let r;try{r=JSON.stringify(t)}catch(e){}return console.error(rA(n,!1,i,rZ(e),r),t),rj(void 0,e,rz),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=rQ({},e.devtools.overlays,t.devtools.overlays)),e.status=r$,e.bootstrap=r1(t,"bootstrap"),e.mount=r1(t,"mount"),e.unmount=r1(t,"unmount"),e.unload=r1(t,"unload"),e.timeouts=nd(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let n;return delete e.loadPromise,r?n=rz:(n=rH,e.loadErrorTime=(new Date).getTime()),rj(t,e,n),e}))})}let np="u">typeof window,nh={hashchange:[],popstate:[]},nm=["hashchange","popstate"];function ny(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(rA(14,!1));t=e.currentTarget.href,e.preventDefault()}let r=nE(window.location.href),n=nE(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 ng(e){if(e){let t=e[0].type;nm.indexOf(t)>=0&&nh[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function nb(){nq([],arguments)}function nv(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 n_=null,nw=!1;function nx(e){if(nw)throw Error(rA(43,!1));i=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,nw=!0,n_=window.history.replaceState,window.addEventListener("hashchange",nb),window.addEventListener("popstate",nb);let t=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(e,r){if(!("function"==typeof r&&nm.indexOf(e)>=0)||rX(nh[e],e=>e===r))return t.apply(this,arguments);nh[e].push(r)},window.removeEventListener=function(e,t){return"function"==typeof t&&nm.indexOf(e)>=0&&(nh[e]=nh[e].filter(e=>e!==t)),r.apply(this,arguments)},window.history.pushState=nv(window.history.pushState,"pushState"),window.history.replaceState=nv(n_,"replaceState")}function nE(e){let t=document.createElement("a");return t.href=e,t}np&&(window.singleSpaNavigate?console.warn(rA(41,!1)):window.singleSpaNavigate=ny);let nS=!1;function nD(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!nS){let t=e.fn.on,r=e.fn.off;e.fn.on=function(e,r){return nO.call(this,t,window.addEventListener,e,r,arguments)},e.fn.off=function(e,t){return nO.call(this,r,window.removeEventListener,e,t,arguments)},nS=!0}}function nO(e,t,r,n,i){return"string"!=typeof r?e.apply(this,i):(r.split(/\s+/).forEach(e=>{nm.indexOf(e)>=0&&(t(e,n),r=r.replace(e,""))}),""===r.trim()?this:e.apply(this,i))}let nP={};function nC(e){return Promise.resolve().then(()=>{let t=nP[rZ(e)];if(!t)return e;if(e.status===rN)return nk(e,t),e;if(e.status===rK)return t.promise.then(()=>e);if(e.status!==rF&&e.status!==rH)return e;let r=e.status===rH?Promise.resolve():nc(e,"unload");return e.status=rK,r.then(()=>(nk(e,t),e)).catch(r=>(delete nP[rZ(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,rj(r,e,rz),t.reject(r),e))})}function nk(e,t){delete nP[rZ(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=rN,t.resolve()}function nj(e,t,r,n){nP[rZ(e)]={app:e,resolve:r,reject:n},Object.defineProperty(nP[rZ(e)],"promise",{get:t})}let nT=[];function nR(){return nT.filter(rq).map(rZ)}function nA(){return nT.map(rZ)}function nM(e){let t=rX(nT,t=>rZ(t)===e);return t?t.status:null}let nN=!1;function nI(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(rA(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(rA(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(rA(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(rA(24,!1));if(!nV(e.customProps))throw Error(rA(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(rA(20,!1));if(!t)throw Error(rA(23,!1));if("function"!=typeof r)throw Error(rA(24,!1));if(!nV(n))throw Error(rA(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:nU(e)),a.activeWhen=e=>s.some(t=>t(e)),a);if(nZ||nN||(nN=!0,setTimeout(()=>{nZ||console.warn(rA(1,!1))},5e3)),-1!==nA().indexOf(l.name))throw Error(rA(21,!1,l.name));nT.push(rQ({loadErrorTime:null,status:rN,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),np&&(nD(),nq())}function n$(e=window.location){return nT.filter(t=>t.activeWhen(e)).map(rZ)}function nL(e){if(0===nT.filter(t=>rZ(t)===e).length)throw Error(rA(25,!1,e));return(np?nF(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=nT.map(rZ).indexOf(e);nT.splice(t,1)})}function nF(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(rA(26,!1));let r=rX(nT,t=>rZ(t)===e);if(!r)throw Error(rA(27,!1,e));let n=nP[rZ(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{nj(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,nB(r,n.resolve,n.reject)):e=new Promise((t,n)=>{nj(r,()=>e,t,n),nB(r,t,n)}),e}}function nB(e,t,r){Promise.resolve().then(()=>{if(rX(n$(),t=>t===rZ(e)))return nz()}).then(()=>r6(e).then(nC).then(()=>{t(),setTimeout(()=>{nq()})})).catch(r)}function nV(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function nU(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 nW=!1,nK=[],nH=np&&window.location.href;function nz(){return nq()}function nq(e=[],t,r=!1){let n,i,o,a,s;if(nW)return new Promise((e,r)=>{nK.push({resolve:e,reject:r,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(n=[],i=[],o=[],a=[],s=(new Date).getTime(),nT.forEach(e=>{let t=e.status!==rz&&rG(e);switch(e.status){case rH:t&&s-e.loadErrorTime>=200&&o.push(e);break;case rN:case rI:t&&o.push(e);break;case r$:case rF:!t&&nP[rZ(e)]?n.push(e):t&&a.push(e);break;case rV:t||i.push(e)}}),{appsToUnload:n,appsToUnmount:i,appsToLoad:o,appsToMount:a}),f,p=[],h=nH,m=nH=window.location.href;return nZ?(nW=!0,f=l.concat(c,u,d),Promise.resolve().then(()=>(w(0===f.length?"before-no-app-change":"before-app-change",v(!0)),w("before-routing-event",v(!0,{cancelNavigation:y})),Promise.all(p).then(r=>{if(r.some(e=>e))return n_.call(window.history,history.state,"",h.substring(location.origin.length)),nH=location.href,nW=!1,nq(e,t,!0);let n=l.map(nC),i=Promise.all(u.map(r6).map(e=>e.then(nC)).concat(n));i.then(()=>{w("before-mount-routing-event",v(!0))},e=>{throw e});let o=c.map(e=>nf(e).then(e=>nG(e,i))),a=d.filter(e=>0>c.indexOf(e)).map(e=>nG(e,i));return i.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(o.concat(a)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(g).then(()=>{},e=>{throw e})))})))):(f=c,Promise.resolve().then(()=>Promise.all(c.map(nf)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function y(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);p.push(t.catch(e=>(console.warn(Error(rA(42,!1))),console.warn(e),!1)))}function g(){let t=nR();e.forEach(e=>e.resolve(t));try{w(0===f.length?"no-app-change":"app-change",v()),w("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(nW=!1,nK.length>0){let e=nK;nK=[],nq(e)}return t}function b(){r||(e.forEach(e=>{ng(e.eventArguments)}),ng(t))}function v(e=!1,r){let n={},i={[rV]:[],[rF]:[],[rN]:[],[rz]:[]};e?(c.concat(d).forEach((e,t)=>{a(e,rV)}),l.forEach(e=>{a(e,rN)}),u.forEach(e=>{a(e,rF)})):f.forEach(e=>{a(e)});let o={detail:{newAppStatuses:n,appsByNewStatus:i,totalAppChanges:f.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return r&&rQ(o.detail,r),o;function a(e,t){let r=rZ(e);t=t||nM(r),n[r]=t,(i[t]=i[t]||[]).push(r)}}function w(e,t){r||window.dispatchEvent(new rC(`single-spa:${e}`,t))}}function nG(e,t){return rG(e)?r2(e).then(e=>t.then(()=>rG(e)?r9(e):e)):t.then(()=>e)}let nZ=!1;function nY(e){nZ=!0,np&&(nx(e),nq())}function nJ(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,"");return nQ(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t}).replace(/^\/\//,"/")}function nQ(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function nX({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=nJ(e,t).replace(window.location.origin,"");n.startsWith(r)?ny(n):window.location.assign(n)}np&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...nT]},reroute:nq,NOT_LOADED:rN,toLoadPromise:nf,toBootstrapPromise:r2,unregisterApplication:nL,getProfilerData:function(){return r4}});let n0="openmrs:history";function n1(){return JSON.parse(sessionStorage.getItem(n0)??"[]")}function n3({toUrl:e}){let t=n1(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);nX({to:t[r]}),sessionStorage.setItem(n0,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function n4(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}tC.Boolean,tC.String,rg.isUrl,tC.Array,tC.Number,rg.inRange(100,600),tC.Boolean,tC.Boolean;let n2="/ws/rest/v1",n6="/ws/fhir2/R4",n5=`${n2}/session`;function n8(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function n9(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=n8(e);if(t.headers||(t.headers={}),eh(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(n2)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(n6)){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 t2("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(i&&t&&(r===n8(n5)||204===e.status)&&nX({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===n8(n5)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(sessionStorage.removeItem(n0),nX({to:t.url||e.headers.get("location")||"${openmrsSpaBase}/login"}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let i=t;try{i=JSON.parse(t)}catch(e){}throw new ie(r,e,i,n)},t=>{throw new ie(r,e,null,n)})})}function n7(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 ea.Observable(n=>{let i=!1;return n9(e,t).then(e=>{i=!0,n.next(e),n.complete()},e=>{i=!0,n.error(e)}),()=>{i||r.abort()}})}class ie extends Error{constructor(e,t,r,n){super(),n4(this,"response",void 0),n4(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 it=K("session",{loaded:!1,session:null}),ir=0;function ii(e={includeAuthStatus:!0}){return(ir<Date.now()-6e4||!it.getState().loaded)&&is(),new ea.Observable(t=>{let r=r=>{r.loaded&&(e.includeAuthStatus?t.next(r.session):t.next(r.session?.user))};return r(it.getState()),it.subscribe(r)})}function io(){return(ir<Date.now()-6e4||!it.getState().loaded)&&is(),it}function ia(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 is(e,t){ir=Date.now();let r={};return e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),im(n9(n5,{headers:r}))}function il(){it.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function iu(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!Z(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!Z(n.privileges.find(t=>e===t.display))):(Z(r)||console.error(`Could not understand privileges "${r}"`),!0))||!Z(t.roles.find(e=>"System Developer"===e.display))}function ic(){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(it.getState()),e||(t=it.subscribe(n))})}function id(){return new Promise((e,t)=>{ii().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function ip(e,t){return im(n9(n5,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function ih(e,t,r){return r||(r=new AbortController),await n9(`${n2}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),is()}function im(e){return new Promise((t,r)=>{e.then(e=>{let n;"object"==typeof e?.data?(n={loaded:!0,session:e.data},it.setState(n),t(n)):(n={loaded:!1,session:null},it.setState(n),r(n))}).catch(e=>{T(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};it.setState(t),r(t)})})}function iy(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}it.subscribe(e=>{e.loaded&&e.session&&ia(e.session)});let ig={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"},ib=L()(()=>({}));H("openmrs-app-context",ib);let iv={};function i_(e,t=iv){ib.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===iv?{}:t})})}function iw(e){ib.setState(t=>(e in t&&delete t[e],t))}function ix(e,t=e=>e){let r=ib.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function iE(e,t){ib.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function iS(e,t){let r=ix(e);return t(iD(r)),ib.subscribe(n=>{let i=e in n?n[e]:null;i!==r&&(r=i,t(iD(i)))})}function iD(e){return null===e?null:Object.freeze(Object.assign({},e))}let iO={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"},iP=e=>"string"==typeof e,iC=()=>{let e,t,r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r},ik=e=>null==e?"":""+e,ij=/###/g,iT=e=>e&&e.indexOf("###")>-1?e.replace(ij,"."):e,iR=e=>!e||iP(e),iA=(e,t,r)=>{let n=iP(t)?t.split("."):t,i=0;for(;i<n.length-1;){if(iR(e))return{};let t=iT(n[i]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return iR(e)?{}:{obj:e,k:iT(n[i])}},iM=(e,t,r)=>{let{obj:n,k:i}=iA(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=iA(e,a,Object);for(;void 0===s.obj&&a.length;)o=`${a[a.length-1]}.${o}`,s=iA(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},iN=(e,t)=>{let{obj:r,k:n}=iA(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},iI=(e,t,r)=>{for(let n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?iP(e[n])||e[n]instanceof String||iP(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):iI(e[n],t[n],r):e[n]=t[n]);return e};var i$={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let iL=e=>iP(e)?e.replace(/[&<>"'\/]/g,e=>i$[e]):e,iF=[" ",",","?","!",";"],iB=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),iV=(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},iU=e=>e?.replace("_","-"),iW={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 iK{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||iW,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:(iP(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new iK(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new iK(this.logger,e)}}var iH=new iK;class iz{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 iq extends iz{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):iP(r)&&o?i.push(...r.split(o)):i.push(r)));let s=iN(this.data,i);return(!s&&!t&&!r&&e.indexOf(".")>-1&&(e=i[0],t=i[1],r=i.slice(2).join(".")),!s&&a&&iP(r))?iV(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),iM(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)(iP(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=iN(this.data,a)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),n?iI(s,r,i):s={...s,...r},iM(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 iG={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 iZ=Symbol("i18next/PATH_KEY");function iY(e,t){let r,n,i,{[iZ]:o}=e((n=[],(i=Object.create(null)).get=(e,t)=>(r?.revoke?.(),t===iZ)?n:(n.push(t),(r=Proxy.revocable(e,i)).proxy),Proxy.revocable(Object.create(null),i).proxy));return o.join(t?.keySeparator??".")}let iJ={},iQ=e=>!iP(e)&&"boolean"!=typeof e&&"number"!=typeof e;class iX extends iz{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=iH.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=iQ(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=iF.filter(e=>0>t.indexOf(e)&&0>r.indexOf(e));if(0===n.length)return!0;let i=iB.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:iP(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:iP(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=iY(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 f=this.resolve(e,n),p=f?.res,h=f?.usedKey||a,m=f?.exactUsedKey||a,y=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,g=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==n.count&&!iP(n.count),v=iX.hasDefaultValue(n),w=b?this.pluralResolver.getSuffix(c,n.count,n):"",x=n.ordinal&&b?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",E=b&&!n.ordinal&&0===n.count,S=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${w}`]||n[`defaultValue${x}`]||n.defaultValue,D=p;g&&!p&&v&&(D=S);let O=iQ(D),P=Object.prototype.toString.apply(D);if(g&&D&&O&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(P)&&!(iP(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?(f.res=e,f.usedParams=this.getUsedParamsDetails(n),f):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}`;v&&!p?t[e]=this.translate(i,{...n,defaultValue:iQ(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])}p=t}}else if(g&&iP(y)&&Array.isArray(p))(p=p.join(y))&&(p=this.extendTranslation(p,e,n,r));else{let t=!1,i=!1;!this.isValidLookup(p)&&v&&(t=!0,p=S),this.isValidLookup(p)||(i=!0,p=a);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&i?void 0:p,d=v&&S!==p&&this.options.updateMissing;if(i||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,a,d?S:p),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=v&&r!==p?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,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?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))}p=this.extendTranslation(p,e,n,f,r),i&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${a}`),(i||t)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,t?p:void 0,n))}return i?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}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=iP(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&&!iP(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=iP(o)?[o]:o;return null!=e&&a?.length&&!1!==r.applyPostProcessor&&(e=iG.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 iP(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&&!iP(t.count),d=c&&!t.ordinal&&0===t.count,f=void 0!==t.context&&(iP(t.context)||"number"==typeof t.context)&&""!==t.context,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(a=e,!iJ[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(iJ[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${n}" for languages "${p.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!!!")),p.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)),f){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&&!iP(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 i0{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=iH.create("languageUtils")}getScriptPartFromCode(e){if(!(e=iU(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=iU(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(iP(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)),iP(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 iP(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))):iP(e)&&i(this.formatLanguageCode(e)),r.forEach(e=>{0>n.indexOf(e)&&i(this.formatLanguageCode(e))}),n}}let i1={zero:0,one:1,two:2,few:3,many:4,other:5},i3={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class i4{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=iH.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let r,n=iU("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!"),i3;if(!e.match(/-|_/))return i3;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)=>i1[e]-i1[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 i2=(e,t,r,n=".",i=!0)=>{let o,a=void 0!==(o=iN(e,r))?o:iN(t,r);return!a&&i&&iP(r)&&void 0===(a=iV(e,r,n))&&(a=iV(t,r,n)),a};class i6{constructor(e={}){this.logger=iH.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:f,nestingSuffix:p,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:y,alwaysFormat:g}=e.interpolation;this.escape=void 0!==t?t:iL,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,"\\$&"):f||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=p?p.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=i2(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(i2(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=iP(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 iP(o)||this.useRawValueToEscape||(o=ik(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&&!iP(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&&!iP(i))return i;iP(i)||(i=ik(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 i5=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(iU(n),i),t[a]=s),s(r)}},i8=e=>(t,r,n)=>e(iU(r),n)(t);class i9{constructor(e={}){this.logger=iH.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let r=t.cacheInBuiltFormats?i5:i8;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()]=i5(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 i7 extends iz{constructor(e,t,r,n={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=n,this.logger=iH.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}=iA(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();iP(e)&&(e=this.languageUtils.toResolveHierarchy(e)),iP(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 oe=()=>({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]),iP(e[1])&&(t.defaultValue=e[1]),iP(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}),ot=e=>(iP(e.ns)&&(e.ns=[e.ns]),iP(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),iP(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),or=()=>{};class on extends iz{constructor(e={},t){if(super(),this.options=ot(e),this.services={},this.logger=iH,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&&(iP(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let r=oe();this.options={...r,...this.options,...ot(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?iH.init(n(this.modules.logger),this.options):iH.init(null,this.options),e=this.modules.formatter?this.modules.formatter:i9;let t=new i0(this.options);this.store=new iq(this.options.resources,this.options);let i=this.services;i.logger=iH,i.resourceStore=this.store,i.languageUtils=t,i.pluralResolver=new i4(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 i6(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new i7(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 iX(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=or),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=iC(),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=or){let r=t,n=iP(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=iC();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=or),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&&iG.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=iC();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=iP(t)?t:t&&t[0],o=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(iP(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=iY(e,{...this.options,...t})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=iY(e,{...this.options,...t})),a=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(a,o)};return iP(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=iC();return this.options.ns?(iP(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=iC();iP(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 i0(oe());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 on(e,t)}cloneInstance(e={},t=or){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let n={...this.options,...e,isClone:!0},i=new on(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 iq(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 iX(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 oi=on.createInstance();oi.createInstance=on.createInstance,oi.createInstance,oi.dir,oi.init,oi.loadResources,oi.reloadResources,oi.use,oi.changeLanguage,oi.getFixedT,oi.t,oi.exists,oi.setDefaultNamespace,oi.hasLoadedNamespace,oi.loadNamespaces,oi.loadLanguages;let oo=oi.default||oi;function oa(e,t,r,n){return oo.t(t,{ns:e,defaultValue:r,...n})}function os(e,t,r){return iO[e]?oa("core",e,t??iO[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}oo.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let ol=null;async function ou(){return ol??(ol=oc().then(({map:e,complete:t})=>(t||(ol=null),e))),ol}async function oc(){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:function(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}(t),complete:r}}async function od(){return await ou()}function of(e){return e.replace(/[\/\-@]/g,"_")}async function op(e,t="./start",n){var i;let o,a=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([oh(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=of(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 oh(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=of(e);if(!window[r]){let r=t??await om();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let i=e in{};try{return await function(e){var t;let r=(t=window)[oy]??(t[oy]=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&&O({kind:"error",title:os("scriptLoadingFailed","Error: Script failed to load"),description:os("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:os("resetOverrides","Reset overrides"),onActionButtonClick(){console.warn("[Security] Import map overrides are disabled in production mode."),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function om(){return od()}let oy=Symbol.for("__openmrs_script_loading"),og=`${n2}/attachment`;function ob(e,t){return n9(`${og}/${e}`,{signal:t.signal})}function ov(e,t,r){return n9(`${og}?patient=${e}&includeEncounterless=${t}`,{signal:r.signal})}async function o_(e,t){let r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),n9(`${og}`,{method:"POST",body:r})}function ow(e,t){return n9(`${og}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function ox(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 oE(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 oS(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 oD=function(){var e=this;this.promise=new Promise(function(t,r){e.resolve=t,e.reject=r})};function oO(e,t){var r=location.href;return new URL(e,r).href===new URL(t,r).href}var oP=function(e,t){this.type=e,Object.assign(this,t)};function oC(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function ok(){}var oj={type:"SKIP_WAITING"};function oT(e,t){if(!t)return e&&e.then?e.then(ok):Promise.resolve()}async function oR(e){let t=await (f??Promise.resolve(void 0));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."}}!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 oD,n.en=new oD,n.on=new oD,n.un=0,n.an=new Set,n.cn=function(){var e=n.fn,t=e.installing;n.tn>0||!oO(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 oP(i,a)),"installed"===i?n.wn=self.setTimeout(function(){"installed"===i&&t.waiting===r&&n.dispatchEvent(new oP("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 oP("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 oC(n.getSW(),function(){n.an.has(i)&&n.dispatchEvent(new oP("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=t.prototype;n.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 oT(new Promise(function(e){return window.addEventListener("load",e)}))},i=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),oC(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&&oO(t.scriptURL,a.sn.toString())&&(a.hn=t,Promise.resolve().then(function(){a.dispatchEvent(new oP("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)}},n.update=function(){try{return this.fn?oT(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},n.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},n.messageSW=function(e){try{return oC(this.getSW(),function(t){return ox(t,e)})}catch(e){return Promise.reject(e)}},n.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&ox(this.fn.waiting,oj)},n.pn=function(){var e=navigator.serviceWorker.controller;return e&&oO(e.scriptURL,this.sn.toString())?e:void 0},n.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 oC(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)}},oE(t.prototype,[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}]),r&&oE(t,r)}(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 oS(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)?oS(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}());let oA="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,oM=Object.keys,oN=Array.isArray;function oI(e,t){return"object"!=typeof t||oM(t).forEach(function(r){e[r]=t[r]}),e}"u"<typeof Promise||oA.Promise||(oA.Promise=Promise);let o$=Object.getPrototypeOf,oL={}.hasOwnProperty;function oF(e,t){return oL.call(e,t)}function oB(e,t){"function"==typeof t&&(t=t(o$(e))),("u"<typeof Reflect?oM:Reflect.ownKeys)(t).forEach(r=>{oU(e,r,t[r])})}let oV=Object.defineProperty;function oU(e,t,r,n){oV(e,t,oI(r&&oF(r,"get")&&"function"==typeof r.get?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function oW(e){return{from:function(t){return e.prototype=Object.create(t.prototype),oU(e.prototype,"constructor",e),{extend:oB.bind(null,e.prototype)}}}}let oK=Object.getOwnPropertyDescriptor;function oH(e,t){let r;return oK(e,t)||(r=o$(e))&&oH(r,t)}let oz=[].slice;function oq(e,t,r){return oz.call(e,t,r)}function oG(e,t){return t(e)}function oZ(e){if(!e)throw Error("Assertion Failed")}function oY(e){oA.setImmediate?setImmediate(e):setTimeout(e,0)}function oJ(e,t){return e.reduce((e,r,n)=>{var i=t(r,n);return i&&(e[i[0]]=i[1]),e},{})}function oQ(e,t){if("string"==typeof t&&oF(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=oQ(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:oQ(s,t.substr(a+1))}}function oX(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){oZ("string"!=typeof r&&"length"in r);for(var n=0,i=t.length;n<i;++n)oX(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?oN(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=r;else{var l=e[a];l&&oF(e,a)||(l=e[a]={}),oX(l,s,r)}}else void 0===r?oN(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function o0(e){var t={};for(var r in e)oF(e,r)&&(t[r]=e[r]);return t}let o1=[].concat;function o3(e){return o1.apply([],e)}let o4="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(o3([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>oA[e]),o2=o4.map(e=>oA[e]);oJ(o4,e=>[e,!0]);let o6=null;function o5(e){o6="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let r=o6&&o6.get(t);if(r)return r;if(oN(t)){r=[],o6&&o6.set(t,r);for(var n=0,i=t.length;n<i;++n)r.push(e(t[n]))}else if(o2.indexOf(t.constructor)>=0)r=t;else{let n=o$(t);for(var o in r=n===Object.prototype?{}:Object.create(n),o6&&o6.set(t,r),t)oF(t,o)&&(r[o]=e(t[o]))}return r}(e);return o6=null,t}let{toString:o8}={};function o9(e){return o8.call(e).slice(8,-1)}let o7="u">typeof Symbol?Symbol.iterator:"@@iterator",ae="symbol"==typeof o7?function(e){var t;return null!=e&&(t=e[o7])&&t.apply(e)}:function(){return null},at={};function ar(e){var t,r,n,i;if(1==arguments.length){if(oN(e))return e.slice();if(this===at&&"string"==typeof e)return[e];if(i=ae(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 an="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var ai="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),ao=()=>!0;let aa=!Error("").stack;function as(){if(aa)try{throw as.arguments,Error()}catch(e){return e}return Error()}function al(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(ao).map(e=>"\n"+e).join("")):""}var au=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],ac=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(au),ad={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 af(e,t){this._e=as(),this.name=e,this.message=t}function ap(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,r)=>r.indexOf(e)===t).join("\n")}function ah(e,t,r,n){this._e=as(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=ap(e,t)}function am(e,t){this._e=as(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=ap(e,t)}oW(af).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+al(this._e,2))}},toString:function(){return this.name+": "+this.message}}),oW(ah).from(af),oW(am).from(af);var ay=ac.reduce((e,t)=>(e[t]=t+"Error",e),{}),ag=ac.reduce((e,t)=>{var r=t+"Error";function n(e,n){this._e=as(),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=ad[t]||r,this.inner=null)}return oW(n).from(af),e[t]=n,e},{});ag.Syntax=SyntaxError,ag.Type=TypeError,ag.Range=RangeError;var ab=au.reduce((e,t)=>(e[t+"Error"]=ag[t],e),{}),av=ac.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=ag[t]),e),{});function a_(){}function aw(e){return e}function ax(e,t){return null==e||e===aw?t:function(r){return t(e(r))}}function aE(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function aS(e,t){return e===a_?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?aE(n,this.onsuccess):n),i&&(this.onerror=this.onerror?aE(i,this.onerror):i),void 0!==o?o:r}}function aD(e,t){return e===a_?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?aE(r,this.onsuccess):r),n&&(this.onerror=this.onerror?aE(n,this.onerror):n)}}function aO(e,t){return e===a_?t:function(r){var n=e.apply(this,arguments);oI(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?aE(i,this.onsuccess):i),o&&(this.onerror=this.onerror?aE(o,this.onerror):o),void 0===n?void 0===a?void 0:a:oI(n,a)}}function aP(e,t){return e===a_?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function aC(e,t){return e===a_?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)}}av.ModifyError=ah,av.DexieError=af,av.BulkError=am;var ak={};let[aj,aT,aR]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,o$(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,o$(t),e]})(),aA=aT&&aT.then,aM=aj&&aj.constructor,aN=!!aR;var aI=!1,a$=aR?()=>{aR.then(a2)}:oA.setImmediate?setImmediate.bind(null,a2):oA.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{a2(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(a2,0)},aL=function(e,t){aq.push([e,t]),aB&&(a$(),aB=!1)},aF=!0,aB=!0,aV=[],aU=[],aW=null,aK=aw,aH={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:sb,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{sb(e[0],e[1])}catch(e){}})}},az=aH,aq=[],aG=0,aZ=[];function aY(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=a_,this._lib=!1;var t=this._PSD=az;if(ai&&(this._stackHolder=as(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==ak)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&aX(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&&a6();r&&"function"==typeof r.then?e(t,(e,t)=>{r instanceof aY?r._then(e,t):r.then(e,t)}):(t._state=!0,t._value=r,a0(t)),n&&a5()}},aX.bind(null,t))}catch(e){aX(t,e)}}(this,e)}let aJ={get:function(){var e=az,t=si;function r(r,n){var i=!e.global&&(e!==az||t!==si);let o=i&&!sl();var a=new aY((t,a)=>{a1(this,new aQ(sm(r,e,i,o),sm(n,e,i,o),t,a,e))});return ai&&a4(a,this),a}return r.prototype=ak,r},set:function(e){oU(this,"then",e&&e.prototype===ak?aJ:{get:function(){return e},set:aJ.set})}};function aQ(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 aX(e,t){if(aU.push(t),null===e._state){var r=e._lib&&a6();t=aK(t),e._state=!1,e._value=t,ai&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var r=oH(t,"stack");t._promise=e,oU(t,"stack",{get:()=>aI?r&&(r.get?r.get.apply(t):r.value):e.stack})}),aV.some(t=>t._value===e._value)||aV.push(e),a0(e),r&&a5()}}function a0(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)a1(e,t[r]);var i=e._PSD;--i.ref||i.finalize(),0===aG&&(++aG,aL(()=>{0==--aG&&a8()},[]))}function a1(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,++aG,aL(a3,[r,e,t])}else e._listeners.push(t)}function a3(e,t,r){try{aW=t;var n,i=t._value;t._state?n=e(i):(aU.length&&(aU=[]),n=e(i),-1===aU.indexOf(i)&&function(e){for(var t=aV.length;t;)if(aV[--t]._value===e._value)return void aV.splice(t,1)}(t)),r.resolve(n)}catch(e){r.reject(e)}finally{aW=null,0==--aG&&a8(),--r.psd.ref||r.psd.finalize()}}function a4(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function a2(){a6()&&a5()}function a6(){var e=aF;return aF=!1,aB=!1,e}function a5(){var e,t,r;do for(;aq.length>0;)for(e=aq,aq=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(aq.length>0);aF=!0,aB=!0}function a8(){var e=aV;aV=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=aZ.slice(0),r=t.length;r;)t[--r]()}function a9(e){return new aY(ak,!1,e)}function a7(e,t){var r=az;return function(){var n=a6(),i=az;try{return sf(r,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{sf(i,!1),n&&a5()}}}oB(aY.prototype,{then:aJ,_then:function(e,t){a1(this,new aQ(null,null,e,t,az))},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):a9(e)):this.then(null,e=>e&&e.name===t?r(e):a9(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),a9(t)))},stack:{get:function(){if(this._stack)return this._stack;try{aI=!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=al(s,0)):(o=s,a=""),r.push(o+(a?": "+a:"")+i)}return ai&&((i=al(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{aI=!1}}},timeout:function(e,t){return e<1/0?new aY((r,n)=>{var i=setTimeout(()=>n(new ag.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,i))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&oU(aY.prototype,Symbol.toStringTag,"Dexie.Promise"),aH.env=sp(),oB(aY,{all:function(){var e=ar.apply(null,arguments).map(su);return new aY(function(t,r){0===e.length&&t([]);var n=e.length;e.forEach((i,o)=>aY.resolve(i).then(r=>{e[o]=r,--n||t(e)},r))})},resolve:e=>{if(e instanceof aY)return e;if(e&&"function"==typeof e.then)return new aY((t,r)=>{e.then(t,r)});var t=new aY(ak,!0,e);return a4(t,aW),t},reject:a9,race:function(){var e=ar.apply(null,arguments).map(su);return new aY((t,r)=>{e.map(e=>aY.resolve(e).then(t,r))})},PSD:{get:()=>az,set:e=>az=e},totalEchoes:{get:()=>si},newPSD:sa,usePSD:sh,scheduler:{get:()=>aL,set:e=>{aL=e}},rejectionMapper:{get:()=>aK,set:e=>{aK=e}},follow:(e,t)=>new aY((r,n)=>sa((t,r)=>{var n=az;n.unhandleds=[],n.onunhandled=r,n.finalize=aE(function(){var e;e=()=>{0===this.unhandleds.length?t():r(this.unhandleds[0])},aZ.push(function t(){e(),aZ.splice(aZ.indexOf(t),1)}),++aG,aL(()=>{0==--aG&&a8()},[])},n.finalize),e()},t,r,n))}),aM&&(aM.allSettled&&oU(aY,"allSettled",function(){let e=ar.apply(null,arguments).map(su);return new aY(t=>{0===e.length&&t([]);let r=e.length,n=Array(r);e.forEach((e,i)=>aY.resolve(e).then(e=>n[i]={status:"fulfilled",value:e},e=>n[i]={status:"rejected",reason:e}).then(()=>--r||t(n)))})}),aM.any&&"u">typeof AggregateError&&oU(aY,"any",function(){let e=ar.apply(null,arguments).map(su);return new aY((t,r)=>{0===e.length&&r(AggregateError([]));let n=e.length,i=Array(n);e.forEach((e,o)=>aY.resolve(e).then(e=>t(e),e=>{i[o]=e,--n||r(AggregateError(i))}))})}));let se={awaits:0,echoes:0,id:0};var st=0,sr=[],sn=0,si=0,so=0;function sa(e,t,r,n){var i=az,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++so;var a=aH.env;o.env=aN?{Promise:aY,PromiseProp:{value:aY,configurable:!0,writable:!0},all:aY.all,race:aY.race,allSettled:aY.allSettled,any:aY.any,resolve:aY.resolve,reject:aY.reject,nthen:sy(a.nthen,o),gthen:sy(a.gthen,o)}:{},t&&oI(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=sh(o,e,r,n);return 0===o.ref&&o.finalize(),s}function ss(){return se.id||(se.id=++st),++se.awaits,se.echoes+=100,se.id}function sl(){return!!se.awaits&&(0==--se.awaits&&(se.id=0),se.echoes=100*se.awaits,!0)}function su(e){return se.echoes&&e&&e.constructor===aM?(ss(),e.then(e=>(sl(),e),e=>(sl(),sv(e)))):e}function sc(e){++si,se.echoes&&0!=--se.echoes||(se.echoes=se.id=0),sr.push(az),sf(e,!0)}function sd(){var e=sr[sr.length-1];sr.pop(),sf(e,!1)}function sf(e,t){var r,n=az;if((t?!se.echoes||sn++&&e===az:!sn||--sn&&e===az)||(r=t?sc.bind(null,e):sd,aA.call(aj,r)),e!==az&&(az=e,n===aH&&(aH.env=sp()),aN)){var i=aH.env.Promise,o=e.env;aT.then=o.nthen,i.prototype.then=o.gthen,(n.global||e.global)&&(Object.defineProperty(oA,"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 sp(){var e=oA.Promise;return aN?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(oA,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:aT.then,gthen:e.prototype.then}:{}}function sh(e,t,r,n,i){var o=az;try{return sf(e,!0),t(r,n,i)}finally{sf(o,!1)}}function sm(e,t,r,n){return"function"!=typeof e?e:function(){var i,o=az;r&&ss(),sf(t,!0);try{return e.apply(this,arguments)}finally{sf(o,!1),n&&(i=sl,aA.call(aj,i))}}}function sy(e,t){return function(r,n){return e.call(this,sm(r,t),sm(n,t))}}-1===(""+aA).indexOf("[native code]")&&(ss=sl=a_);let sg="unhandledrejection";function sb(e,t){var r;try{r=t.onuncatched(e)}catch(e){}if(!1!==r)try{var n,i={promise:t,reason:e};if(oA.document&&document.createEvent?((n=document.createEvent("Event")).initEvent(sg,!0,!0),oI(n,i)):oA.CustomEvent&&oI(n=new CustomEvent(sg,{detail:i}),i),n&&oA.dispatchEvent&&(dispatchEvent(n),!oA.PromiseRejectionEvent&&oA.onunhandledrejection))try{oA.onunhandledrejection(n)}catch(e){}ai&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var sv=aY.reject;let s_="3.2.7",sw=String.fromCharCode(65535),sx=-1/0,sE="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",sS="String expected.",sD=[],sO="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),sP=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),sC="__dbnames",sk="readonly",sj="readwrite";function sT(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let sR={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function sA(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=o5(t))[e],t)}class sM{_trans(e,t,r){let n=this._tx||az.trans,i=this.name;function o(e,r,n){if(!n.schema[i])throw new ag.NotFound("Table "+i+" not part of transaction");return t(n.idbtrans,n)}let a=a6();try{return n&&n.db===this.db?n===az.trans?n._promise(e,o,r):sa(()=>n._promise(e,o,r),{trans:n,transless:az.transless||az}):function e(t,r,n,i){if(t.idbdb&&(t._state.openComplete||az.letThrough||t._vip)){var o=t._createTransaction(r,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===ay.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))):sv(o)}return o._promise(r,(e,t)=>sa(()=>(az.trans=o,i(e,t,o)))).then(e=>o._completion.then(()=>e))}if(t._state.openComplete)return sv(new ag.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return sv(new ag.DatabaseClosed);t.open().catch(a_)}return t._state.dbReadyPromise.then(()=>e(t,r,n,i))}(this.db,e,[this.name],o)}finally{a&&a5()}}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(oN(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=oM(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!==sw){let n=r.keyPath.slice(0,t.length);return this.where(n).equals(n.map(t=>e[t]))}!r&&ai&&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?sT(r,a&&a.multi?e=>{let t=oQ(e,i);return oN(t)&&t.some(e=>o(s,e))}:e=>o(s,oQ(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,oN(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(oF(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){oI(this,e)})}add(e,t){let{auto:r,keyPath:n}=this.schema.primKey,i=e;return n&&r&&(i=sA(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[i]})).then(e=>e.numFailures?aY.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{oX(e,n,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||oN(e))return this.where(":id").equals(e).modify(t);{let r=oQ(e,this.schema.primKey.keyPath);if(void 0===r)return sv(new ag.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?oM(t).forEach(r=>{oX(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=sA(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[i],keys:null!=t?[t]:null})).then(e=>e.numFailures?aY.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{oX(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?aY.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:sR})).then(e=>e.numFailures?aY.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 ag.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new ag.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&r?e.map(sA(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 am(`${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 ag.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new ag.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&r?e.map(sA(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 am(`${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 am(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,n)})}}function sN(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=aP),i||(i=a_);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}oM(e).forEach(function(t){var r=e[t];if(oN(r))o(t,e[t][0],e[t][1]);else{if("asap"!==r)throw new ag.InvalidArgument("Invalid event config");var n=o(t,aw,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){oY(function(){e.apply(null,t)})})})}})}}function sI(e,t){return oW(t).from({prototype:e}),t}function s$(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function sL(e,t){e.filter=sT(e.filter,t)}function sF(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>sT(n(),t()):t,e.justLimit=r&&!n}function sB(e,t){if(e.isPrimKey)return t.primaryKey;let r=t.getIndexByKeyPath(e.index);if(!r)throw new ag.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function sV(e,t,r){let n=sB(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 sU(e,t,r,n){let i=e.replayFilter?sT(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)),oF(o,s)||(o[s]=!0,t(e,r,n))}};return Promise.all([e.or._iterate(a,r),sW(sV(e,n,r),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return sW(sV(e,n,r),sT(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function sW(e,t,r,n){var i=a7(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=a_},t=>{e.fail(t),r=a_})||i(e.value,e,e=>r=e),r()})})}function sK(e,t){try{let r=sH(e),n=sH(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}(sz(e),sz(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=sK(e[r],t[r]);if(0!==n)return n}return r===n?0:r<n?-1:1}(e,t)}}catch(e){}return NaN}function sH(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let r=o9(e);return"ArrayBuffer"===r?"binary":r}function sz(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class sq{_read(e,t){var r=this._ctx;return r.error?r.table._trans(null,sv.bind(null,r.error)):r.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,sv.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=sT(t.algorithm,e)}_iterate(e,t){return sU(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&oI(r,e),t._ctx=r,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(r=>sU(t,e,r,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,r=t.table.core;if(s$(t,!0))return r.count({trans:e,query:{index:sB(t,r.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var n=0;return sU(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&&s$(t,!0)&&t.limit>0){let{valueMapper:r}=t,n=sB(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 sU(t,e=>r.push(e),e,t.table.core).then(()=>r)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,s$(t)?sF(t,()=>{var t=e;return(e,r)=>0===t||(1===t?--t:r(()=>{e.advance(t),t=0}),!1)}):sF(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),sF(this._ctx,()=>{var t=e;return function(e,r,n){return--t<=0&&r(n),t>=0}},!0),this}until(e,t){return sL(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 sL(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=sT(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&&s$(t,!0)&&t.limit>0)return this._read(e=>{var r=sB(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 sL(this._ctx,function(e){var t=e.primaryKey.toString(),n=oF(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=oM(e),o=i.length;n=function(t){for(var r=!1,n=0;n<o;++n){var a=i[n],s=e[a];oQ(t,a)!==s&&(oX(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,f=[],p=(e,t)=>{let{failures:r,numFailures:n}=t;for(let t of(d+=e-n,oM(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(f=>{let h=[],m=[],y=s?[]:null,g=[];for(let e=0;e<d;++e){let t=f[e],r={value:o5(t),primKey:i[c+e]};!1!==n.call(r,r.value,r)&&(null==r.value?g.push(i[c+e]):s||0===sK(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 b=s$(t)&&t.limit===1/0&&("function"!=typeof e||e===sG)&&{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);p(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:y,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>p(m.length,e))).then(()=>(g.length>0||b&&e===sG)&&a.mutate({trans:r,type:"delete",keys:g,criteria:b}).then(e=>p(g.length,e))).then(()=>i.length>c+d&&o(c+u))})};return o(0).then(()=>{if(c.length>0)throw new ah("Error modifying one or more objects",c,d,f);return i.length})})})}delete(){var e=this._ctx,t=e.range;return s$(e)&&(e.isPrimKey&&!sO||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 ah("Could not delete some values",Object.keys(e).map(t=>e[t]),n-i);return n-i}))}):this.modify(sG)}}let sG=(e,t)=>t.value=null;function sZ(e,t){return e<t?-1:+(e!==t)}function sY(e,t){return e>t?-1:+(e!==t)}function sJ(e,t,r){var n=e instanceof s3?new e.Collection(e):e;return n._ctx.error=r?new r(t):TypeError(t),n}function sQ(e){return new e.Collection(e,()=>s1("")).limit(0)}function sX(e,t,r,n){var i,o,a,s,l,u,c,d=r.length;if(!r.every(e=>"string"==typeof e))return sJ(e,sS);function f(e){i="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),o="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?sZ:sY;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}f("next");var p=new e.Collection(e,()=>s0(s[0],l[d-1]+n));p._ondirectionchange=function(e){f(e)};var h=0;return p._addAlgorithm(function(e,r,n){var i=e.key;if("string"!=typeof i)return!1;var f=o(i);if(t(f,l,h))return!0;for(var p=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,f,s[m],l[m],a,u);null===y&&null===p?h=m+1:(null===p||a(p,y)>0)&&(p=y)}return r(null!==p?function(){e.continue(p+c)}:n),!1}),p}function s0(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function s1(e){return{type:1,lower:e,upper:e}}class s3{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)?sQ(this):new this.Collection(this,()=>s0(e,t,!r,!n))}catch(e){return sJ(this,sE)}}equals(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s1(e))}above(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s0(e,void 0,!0))}aboveOrEqual(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s0(e,void 0,!1))}below(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s0(void 0,e,!1,!0))}belowOrEqual(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s0(void 0,e))}startsWith(e){return"string"!=typeof e?sJ(this,sS):this.between(e,e+sw,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):sX(this,(e,t)=>0===e.indexOf(t[0]),[e],sw)}equalsIgnoreCase(e){return sX(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=ar.apply(at,arguments);return 0===e.length?sQ(this):sX(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=ar.apply(at,arguments);return 0===e.length?sQ(this):sX(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,sw)}anyOf(){let e=ar.apply(at,arguments),t=this._cmp;try{e.sort(t)}catch(e){return sJ(this,sE)}if(0===e.length)return sQ(this);let r=new this.Collection(this,()=>s0(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([[sx,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=ar.apply(at,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return sJ(this,sE)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[sx,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 sQ(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=n(e[0],e[1])))return sJ(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",ag.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 sJ(this,sE)}let f=0,p=l?e=>n(e,u[f][1])>0:e=>n(e,u[f][1])>=0,h=s?e=>i(e,u[f][0])>0:e=>i(e,u[f][0])>=0,m=p,y=new this.Collection(this,()=>s0(u[0][0],u[u.length-1][1],!s,!l));return y._ondirectionchange=e=>{"next"===e?(m=p,c=n):(m=h,c=i),u.sort(d)},y._addAlgorithm((e,t,r)=>{for(var i=e.key;m(i);)if(++f===u.length)return t(r),!1;return!!(!p(i)&&!h(i))||(0===this._cmp(i,u[f][1])||0===this._cmp(i,u[f][0])||t(()=>{c===n?e.continue(u[f][0]):e.continue(u[f][1])}),!1)}),y}startsWithAnyOf(){let e=ar.apply(at,arguments);return e.every(e=>"string"==typeof e)?0===e.length?sQ(this):this.inAnyRange(e.map(e=>[e,e+sw])):sJ(this,"startsWithAnyOf() only works with strings")}}function s4(e){return a7(function(t){return s2(t),e(t.target.error),!1})}function s2(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let s6="storagemutated",s5="x-storagemutated-1",s8=sN(null,s6);class s9{_lock(){return oZ(!az.global),++this._reculock,1!==this._reculock||az.global||(az.lockOwnerFor=this),this}_unlock(){if(oZ(!az.global),0==--this._reculock)for(az.global||(az.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{sh(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&az.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,r=this.db._state.dbOpenError;if(oZ(!this.idbtrans),!e&&!t)switch(r&&r.name){case"DatabaseClosedError":throw new ag.DatabaseClosed(r);case"MissingAPIError":throw new ag.MissingAPI(r.message,r);default:throw new ag.OpenFailed(r)}if(!this.active)throw new ag.TransactionInactive;return oZ(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=a7(t=>{s2(t),this._reject(e.error)}),e.onabort=a7(t=>{s2(t),this.active&&this._reject(new ag.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=a7(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&s8.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,r){if("readwrite"===e&&"readwrite"!==this.mode)return sv(new ag.ReadOnly("Transaction is readonly"));if(!this.active)return sv(new ag.TransactionInactive);if(this._locked())return new aY((n,i)=>{this._blockedFuncs.push([()=>{this._promise(e,t,r).then(n,i)},az])});if(r)return sa(()=>{var e=new aY((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 aY((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=aY.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 aY((e,n)=>{r.then(r=>t._waitingQueue.push(a7(e.bind(null,r))),e=>t._waitingQueue.push(a7(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 ag.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(oF(t,e))return t[e];let r=this.schema[e];if(!r)throw new ag.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 s7(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?"++":"")+le(t)}}function le(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function lt(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:oJ(r,e=>[e.name,e])}}let lr=e=>{try{return e.only([[]]),lr=()=>[[]],[[]]}catch(e){return lr=()=>sw,sw}};function ln(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>oQ(t,e):t=>oQ(t,e)}function li(e){return[].slice.call(e)}let lo=0;function la(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function ls({_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=li(e.objectStoreNames),{schema:{name:e.name,tables:n.map(e=>r.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:r}=e,n=oN(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:ln(t)},indexes:li(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:r,multiEntry:n,keyPath:i}=e,a={name:t,compound:oN(i),keyPath:i,unique:r,multiEntry:n,extractKey:ln(i)};return o[la(i)]=a,a}),getIndexByKeyPath:e=>o[la(e)]};return o[":id"]=a.primaryKey,null!=t&&(o[la(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=a7(s);let c=e.objectStore(t),d=null==c.keyPath,f="put"===r||"add"===r;if(!f&&"delete"!==r&&"deleteRange"!==r)throw Error("Invalid operation type: "+r);let{length:p}=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===p)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],y=0,g=e=>{++y,s2(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]=f?d?[o,n]:[o,null]:[n,null];if(f)for(let n=0;n<p;++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<p;++t)h.push(u=c[r](e[t])),u.onerror=g}let b=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),b(e)},u.onsuccess=b})},getMany:({trans:e,keys:r})=>new Promise((n,i)=>{n=a7(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)},f=s4(i);for(let e=0;e<a;++e)null!=r[e]&&((l=o.get(r[e]))._pos=e,l.onsuccess=d,l.onerror=f,++u);0===u&&n(s)}),get:({trans:e,key:r})=>new Promise((n,i)=>{n=a7(n);let o=e.objectStore(t).get(r);o.onsuccess=e=>n(e.target.result),o.onerror=s4(i)}),query:e=>new Promise((r,n)=>{r=a7(r);let{trans:o,values:s,limit:l,query:u}=e,c=l===1/0?void 0:l,{index:d,range:f}=u,p=o.objectStore(t),h=d.isPrimaryKey?p:p.index(d.name),m=i(f);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=s4(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=s4(n)}}),openCursor:function({trans:e,values:r,query:n,reverse:o,unique:a}){return new Promise((s,l)=>{s=a7(s);let{index:u,range:c}=n,d=e.objectStore(t),f=u.isPrimaryKey?d:d.index(u.name),p=o?a?"prevunique":"prev":a?"nextunique":"next",h=!r&&"openKeyCursor"in f?f.openKeyCursor(i(c),p):f.openCursor(i(c),p);h.onerror=s4(l),h.onsuccess=a7(t=>{let r=h.result;if(!r)return void s(null);r.___id=++lo,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=a7(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=a7(e),h.onerror=s4(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=a7(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=a7(t=>e(t.target.result)),c.onerror=s4(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:lr(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 ll({_novip:e},t,r,n){r.forEach(r=>{let i=n[r];t.forEach(t=>{let n=oH(t,r);(!n||"value"in n&&void 0===n.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?oU(t,r,{get(){return this.table(r)},set(e){oV(this,r,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[r]=new e.Table(r,i))})})}function lu({_novip:e},t){t.forEach(t=>{for(let r in t)t[r]instanceof e.Table&&delete t[r]})}function lc(e,t){return e._cfg.version-t._cfg.version}function ld(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||sO)){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 lf(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=>lp(i,e)),i}function lp(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function lh(e,t,r){let n={};return oq(t.objectStoreNames,0).forEach(e=>{let t=r.objectStore(e),i=t.keyPath,o=s7(le(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=s7(r.name,i,!!r.unique,!!r.multiEntry,!1,i&&"string"!=typeof i,!1);a.push(s)}n[e]=lt(e,o,a)}),n}function lm({_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:"["+oq(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)&&oA.WorkerGlobalScope&&oA instanceof oA.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class ly{_parseStoresSpec(e,t){oM(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 s7(r,n||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),oN(n),0===t)}),i=n.shift();if(i.multi)throw new ag.Schema("Primary key cannot be multi-valued");n.forEach(e=>{if(e.auto)throw new ag.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new ag.Schema("Index must have a name and cannot be an empty string")}),t[r]=lt(r,i,n)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?oI(this._cfg.storesSource,e):e;let r=t._versions,n={},i={};return r.forEach(e=>{oI(n,e._cfg.storesSource),i=e._cfg.dbschema={},e._parseStoresSpec(n,i)}),t._dbSchema=i,lu(t,[t._allTables,t,t.Transaction.prototype]),ll(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],oM(i),i),t._storeNames=oM(i),this}upgrade(e){return this._cfg.contentUpgrade=aC(this._cfg.contentUpgrade||a_,e),this}}function lg(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new lI(sC,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),r.table("dbnames")}function lb(e){return e&&"function"==typeof e.databases}function lv(e){return sa(function(){return az.letThrough=!0,e()})}function l_(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):oN(o)?Promise.all(o).then(r,n):r(o)}}return i(t)()}function lw(e,t,r){var n=arguments.length;if(n<2)throw new ag.InvalidArgument("Too few arguments");for(var i=Array(n-1);--n;)i[n-1]=arguments[n];return r=i.pop(),[e,o3(i),r]}function lx(e,t,r){let n=oN(e)?e.slice():[e];for(let e=0;e<r;++e)n.push(t);return n}let lE={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=la(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:ln(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:lx(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,n),lowerOpen:!0,upper:lx(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[la(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(lx(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(lx(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 lS(e,t,r,n){return r=r||{},n=n||"",oM(e).forEach(i=>{if(oF(t,i)){var o=e[i],a=t[i];if("object"==typeof o&&"object"==typeof a&&o&&a){let e=o9(o);e!==o9(a)?r[n+i]=t[i]:"Object"===e?lS(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}),oM(t).forEach(i=>{oF(e,i)||(r[n+i]=t[i])}),r}let lD={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=az.trans,{deleting:o,creating:a,updating:s}=i.table(t).hook;switch(e.type){case"add":if(a.fire===a_)break;return i._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===a_&&s.fire===a_)break;return i._promise("readwrite",()=>l(e),!0);case"delete":if(o.fire===a_)break;return i._promise("readwrite",()=>l(e),!0);case"deleteRange":if(o.fire===a_)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=az.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||oX(e.values[i],n.keyPath,r))}else{let t=lS(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=>{oF(t,e)?t[e]=n[e]:oX(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 lO(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===sK(t.keys[i],e[o])&&(n.push(r?o5(t.values[i]):t.values[i]),++o);return n.length===e.length?n:null}catch(e){return null}}let lP={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=lO(e.keys,e.trans._cache,"clone"===e.cache);return t?aY.resolve(t):r.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?o5(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),r.mutate(e))}}})};function lC(e){return!("from"in e)}let lk=function(e,t){if(!this){let t=new lk;return e&&"d"in e&&oI(t,e),t}oI(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function lj(e,t,r){let n=sK(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(lC(e))return oI(e,{from:t,to:r,d:1});let i=e.l,o=e.r;if(0>sK(r,e.from))return i?lj(i,t,r):e.l={from:t,to:r,d:1,l:null,r:null},lA(e);if(sK(t,e.to)>0)return o?lj(o,t,r):e.r={from:t,to:r,d:1,l:null,r:null},lA(e);0>sK(t,e.from)&&(e.from=t,e.l=null,e.d=o?o.d+1:1),sK(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&&lT(e,i),o&&a&&lT(e,o)}function lT(e,t){lC(t)||function e(t,{from:r,to:n,l:i,r:o}){lj(t,r,n),i&&e(t,i),o&&e(t,o)}(e,t)}function lR(e){let t=lC(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>sK(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>=sK(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 lA(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=lM(r)}e.d=lM(e)}function lM({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}oB(lk.prototype,{add(e){return lT(this,e),this},addKey(e){return lj(this,e,e),this},addKeys(e){return e.forEach(e=>lj(this,e,e)),this},[o7](){return lR(this)}});let lN={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,r=new lk(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 lk)},u=l(""),c=l(":dels"),{type:d}=e,[f,p]="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(oN(f)){"delete"!==d&&(f=e.results),u.addKeys(f);let t=lO(f,h);t||"add"===d||c.addKeys(f),(t||p)&&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&&oN(t)?t.forEach(e=>r.addKey(e)):r.addKey(t);(t||p).forEach((e,r)=>{let o=t&&n(t[r]),a=p&&n(p[r]);0!==sK(o,a)&&(null!=o&&i(o),null!=a&&i(a))})})}else if(f){let e={from:f.lower,to:f.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 lk(null!=(n=r.lower)?n:e.MIN_KEY,null!=(i=r.upper)?i:e.MAX_KEY)]},d={get:e=>[a,new lk(e.key)],getMany:e=>[a,(new lk).addKeys(e.keys)],count:c,query:c,openCursor:c};return oM(d).forEach(e=>{u[e]=function(o){let{subscr:a}=az;if(a){let u=e=>{let r=`idb://${t}/${n}/${e}`;return a[r]||(a[r]=new lk)},c=u(""),f=u(":dels"),[p,h]=d[e](o);if(u(p.name||"").add(h),!p.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):f.addKeys(e)}else if("openCursor"===e){let e=o.values;return r&&Object.create(r,{key:{get:()=>(f.addKey(r.primaryKey),r.key)},primaryKey:{get(){let e=r.primaryKey;return f.addKey(e),e}},value:{get:()=>(e&&c.addKey(r.primaryKey),r.value)}})}return r})}f.add(r)}}return i[e].apply(this,arguments)}}),u}}}};class lI{constructor(e,t){var r;this._middlewares={},this.verno=0;const n=lI.dependencies;this._options=t={addons:lI.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:a_,dbReadyPromise:null,cancelOpen:a_,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new aY(e=>{o.dbReadyResolve=e}),o.openCanceller=new aY((e,t)=>{o.cancelOpen=t}),this._state=o,this.name=e,this.on=sN(this,"populate","blocked","versionchange","close",{ready:[aC,a_]}),this.on.ready.subscribe=oG(this.on.ready.subscribe,e=>(t,r)=>{lI.vip(()=>{let n=this._state;if(n.openComplete)n.dbOpenError||aY.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,sI(sq.prototype,function(e,t){this.db=r;let n=sR,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!==aw?s:null}})),this.Table=function(e){return sI(sM.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:sN(null,{creating:[aS,a_],reading:[ax,aw],updating:[aO,a_],deleting:[aD,a_]})})}(this),this.Transaction=function(e){return sI(s9.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=sN(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 aY((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(),sv(e)})})}(this),this.Version=function(e){return sI(ly.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return sI(s3.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 ag.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=lr(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),sD.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(lE),this.use(lD),this.use(lN),this.use(lP),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new ag.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new ag.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(lc),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||az.letThrough||this._vip)?e():new aY((e,t)=>{if(this._state.openComplete)return t(new ag.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new ag.DatabaseClosed);this.open().catch(a_)}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?sv(r.dbOpenError):e);ai&&(r.openCanceller._stackHolder=as()),r.isBeingOpened=!0,r.dbOpenError=null,r.openComplete=!1;let i=r.openCanceller;function o(){if(r.openCanceller!==i)throw new ag.DatabaseClosed("db.open() was cancelled")}let a=r.dbReadyResolve,s=null,l=!1,u=()=>new aY((t,i)=>{if(o(),!n)throw new ag.MissingAPI;let a=e.name,u=r.autoSchema?n.open(a):n.open(a,Math.round(10*e.verno));if(!u)throw new ag.MissingAPI;u.onerror=s4(i),u.onblocked=a7(e._fireOnBlocked),u.onupgradeneeded=a7(t=>{if(s=u.transaction,r.autoSchema&&!e._options.allowEmptyDB){u.onerror=s2,s.abort(),u.result.close();let e=n.deleteDatabase(a);e.onsuccess=e.onerror=a7(()=>{i(new ag.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let r,n,a,f;s.onerror=s4(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),f=az.transless||az,sa(()=>{az.trans=n,az.transless=f,0===o?(oM(r).forEach(e=>{lf(c,e,r[e].primKey,r[e].indexes)}),ls(e,c),aY.follow(()=>e.on.populate.fire(n)).catch(a)):(function({_novip:e},t,r,n){let i=[],o=e._versions,a=e._dbSchema=lh(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;lm(e,i,n),lm(e,l,n),a=e._dbSchema=l;let u=ld(i,l);u.add.forEach(e=>{lf(n,e[0],e[1].primKey,e[1].indexes)}),u.change.forEach(e=>{if(e.recreate)throw new ag.Upgrade("Not yet support for changing primary key");{let t=n.objectStore(e.name);e.add.forEach(e=>lp(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),lp(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=o._cfg.contentUpgrade;if(c&&o._cfg.version>t){let t;ls(e,n),r._memoizedTables={},s=!0;let o=o0(l);u.del.forEach(e=>{o[e]=i[e]}),lu(e,[e.Transaction.prototype]),ll(e,[e.Transaction.prototype],oM(o),o),r.schema=o;let a=an(c);a&&ss();let d=aY.follow(()=>{if((t=c(r))&&a){var e=sl.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?aY.resolve(t):d.then(()=>t)}}),i.push(t=>{var n;s&&sO||(n=o._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==n[e]&&t.db.deleteObjectStore(e))),lu(e,[e.Transaction.prototype]),ll(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema})}),(function e(){return i.length?aY.resolve(i.shift()(r.idbtrans)).then(e):aY.resolve()})().then(()=>{var e;oM(e=a).forEach(t=>{n.db.objectStoreNames.contains(t)||lf(n,t,e[t].primKey,e[t].indexes)})})})(e,o,n,c).catch(a)})}},i),u.onsuccess=a7(()=>{s=null;let n=e._novip.idbdb=u.result,i=oq(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=lh(0,t,r);e._storeNames=oq(t.objectStoreNames,0),ll(e,[e._allTables],oM(n),n)}(e,n,o):(lm(e,e._dbSchema,o),((t=ld(lh(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.")),ls(e,o)}catch(e){}sD.push(e),n.onversionchange=a7(t=>{r.vcFired=!0,e.on("versionchange").fire(t)}),n.onclose=a7(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},r){lb(e)||r===sC||lg(e,t).put({name:r}).catch(a_)}(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()):aY.reject(e));return aY.race([i,("u"<typeof navigator?aY.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=[],aY.resolve(lv(()=>e.on.ready.fire(e.vip))).then(function t(){if(r.onReadyBeingFired.length>0){let n=r.onReadyBeingFired.reduce(aC,a_);return r.onReadyBeingFired=[],aY.resolve(lv(()=>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(),sv(t)}).finally(()=>{r.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=sD.indexOf(this);if(t>=0&&sD.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new aY(t=>{e.dbReadyResolve=t}),e.openCanceller=new aY((t,r)=>{e.cancelOpen=r})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new ag.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new aY((r,n)=>{let i=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=a7(()=>{!function({indexedDB:e,IDBKeyRange:t},r){lb(e)||r===sC||lg(e,t).delete(r).catch(a_)}(this._deps,this.name),r()}),e.onerror=s4(n),e.onblocked=this._fireOnBlocked};if(e)throw new ag.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 oM(this._allTables).map(e=>this._allTables[e])}transaction(){let e=lw.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,r){let n,i,o=az.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===sk)n=sk;else{if("rw"!=e&&e!=sj)throw new ag.InvalidArgument("Invalid transaction mode: "+e);n=sj}if(o){if(o.mode===sk&&n===sj){if(!a)throw new ag.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 ag.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)}):sv(e)}let s=(function e(t,r,n,i,o){return aY.resolve().then(()=>{let a,s=az.transless||az,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===ay.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))):sv(i)}let u=an(o);u&&ss();let c=aY.follow(()=>{if(a=o.call(l,l))if(u){var e=sl.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=l_(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?aY.resolve(a).then(e=>l.active?e:sv(new ag.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),sv(e)))})}).bind(null,this,n,i,o,r);return o?o._promise(n,s,"lock"):az.trans?sh(az.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!oF(this._allTables,e))throw new ag.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let l$="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class lL{constructor(e){this._subscribe=e}subscribe(e,t,r){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:r})}[l$](){return this}}function lF(e,t){return oM(t).forEach(r=>{lT(e[r]||(e[r]=new lk),t[r])}),e}try{o={indexedDB:oA.indexedDB||oA.mozIndexedDB||oA.webkitIndexedDB||oA.msIndexedDB,IDBKeyRange:oA.IDBKeyRange||oA.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function lB(e){let t=lV;try{lV=!0,s8.storagemutated.fire(e)}finally{lV=t}}oB(lI,{...av,delete:e=>new lI(e,{addons:[]}).delete(),exists:e=>new lI(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return lb(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==sC)):lg(e,t).toCollection().primaryKeys()})(lI.dependencies).then(e)}catch(e){return sv(new ag.MissingAPI)}},defineClass:()=>function(e){oI(this,e)},ignoreTransaction:e=>az.trans?sh(az.transless,e):e(),vip:lv,async:function(e){return function(){try{var t=l_(e.apply(this,arguments));return t&&"function"==typeof t.then?t:aY.resolve(t)}catch(e){return sv(e)}}},spawn:function(e,t,r){try{var n=l_(e.apply(r,t||[]));return n&&"function"==typeof n.then?n:aY.resolve(n)}catch(e){return sv(e)}},currentTransaction:{get:()=>az.trans||null},waitFor:function(e,t){let r=aY.resolve("function"==typeof e?lI.ignoreTransaction(e):e).timeout(t||6e4);return az.trans?az.trans.waitFor(r):r},Promise:aY,debug:{get:()=>ai,set:e=>{ai=e,ao="dexie"===e?()=>!0:sP}},derive:oW,extend:oI,props:oB,override:oG,Events:sN,on:s8,liveQuery:function(e){let t,r=!1,n=new lL(n=>{let i=an(e),o=!1,a={},s={},l={get closed(){return o},unsubscribe:()=>{o=!0,s8.storagemutated.unsubscribe(f)}};n.start&&n.start(l);let u=!1,c=!1;function d(){return oM(s).some(e=>a[e]&&function(e,t){let r=lR(t),n=r.next();if(n.done)return!1;let i=n.value,o=lR(e),a=o.next(i.from),s=a.value;for(;!n.done&&!a.done;){if(0>=sK(s.from,i.to)&&sK(s.to,i.from)>=0)return!0;0>sK(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 f=e=>{lF(a,e),d()&&p()},p=()=>{let h,m;if(u||o)return;a={};let y={},g=(i&&ss(),h=()=>sa(e,{subscr:y,trans:null}),m=az.trans?sh(az.transless,h):h(),i&&m.then(sl,sl),m);c||(s8(s6,f),c=!0),u=!0,Promise.resolve(g).then(e=>{r=!0,t=e,u=!1,o||(d()?p():(a={},s=y,n.next&&n.next(e)))},e=>{u=!1,r=!1,n.error&&n.error(e),l.unsubscribe()})};return p(),l});return n.hasValue=()=>r,n.getValue=()=>t,n},extendObservabilitySet:lF,getByKeyPath:oQ,setByKeyPath:oX,delByKeyPath:function(e,t){"string"==typeof t?oX(e,t,void 0):"length"in t&&[].map.call(t,function(t){oX(e,t,void 0)})},shallowClone:o0,deepClone:o5,getObjectDiff:lS,cmp:sK,asap:oY,minKey:sx,addons:[],connections:sD,errnames:ay,dependencies:o,semVer:s_,version:s_.split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),lI.maxKey=lr(lI.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(s8(s6,e=>{if(!lV){let t;sO?(t=document.createEvent("CustomEvent")).initCustomEvent(s5,!0,!0,e):t=new CustomEvent(s5,{detail:e}),lV=!0,dispatchEvent(t),lV=!1}}),addEventListener(s5,({detail:e})=>{lV||lB(e)}));let lV=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(s5);"function"==typeof e.unref&&e.unref(),s8(s6,t=>{lV||e.postMessage(t)}),e.onmessage=e=>{e.data&&lB(e.data)}}else if("u">typeof self&&"u">typeof navigator){s8(s6,e=>{try{lV||("u">typeof localStorage&&localStorage.setItem(s5,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:s5,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===s5){let t=JSON.parse(e.newValue);t&&lB(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===s5&&lB(e.changedParts)})}function lU(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}aY.rejectionMapper=function(e,t){if(!e||e instanceof af||e instanceof TypeError||e instanceof SyntaxError||!e.name||!ab[e.name])return e;var r=new ab[e.name](t||e.message,e);return"stack"in e&&oU(r,"stack",{get:function(){return this.inner.stack}}),r},ao=sP;class lW extends lI{constructor(){super("EsmOffline"),lU(this,"syncQueue",void 0),lU(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 lK(){return new lW}let lH=new lW,lz={};async function lq(){let e=await ic();return e?.uuid||"*"}async function lG(e,t,r,n){let i=n&&n.id;return void 0!==i&&await lH.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===i).delete().catch(lI.errnames.DatabaseClosed),await lH.syncQueue.add({type:t,content:r,userId:e,descriptor:n||{},createdOn:new Date}).catch(lI.errnames.DatabaseClosed,()=>-1)}async function lZ(e,t,r){let n=await lq();return await lG(n,e,t,r)}async function lY(e,t){return(await lJ(e,t)).map(e=>e.content)}async function lJ(e,t){return await lH.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(lI.errnames.DatabaseClosed,()=>[])}async function lQ(e){let t=await lq();return await lY(t,e)}async function lX(e){let t=await lq();return await lJ(t,e)}async function l0(e){return await lH.syncQueue.get(e).catch(lI.errnames.DatabaseClosed,()=>void 0)}function l1(e){return!!lz[e]?.options.onBeginEditSyncItem}async function l3(e){let t=await l0(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let r=lz[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 l4(e){await lH.syncQueue.delete(e).catch(lI.errnames.DatabaseClosed)}function l2(e,t,r,n={}){lz[e]={type:e,dependsOn:t,process:r,options:n}}K("offline-synchronization",{});let l6={};function l5(){return Object.values(l6)}function l8(e){l6[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.`),l6[e.id]=e}async function l9(e){let t=await ua();return await l7(t,e)}async function l7(e,t){let r=new lW;return await r.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(lI.errnames.DatabaseClosed,()=>[])}async function ue(e,t){let r=await ua();return await ut(r,e,t)}async function ut(e,t,r){let n=new lW,i=await n.dynamicOfflineData.get({type:t,identifier:r}).catch(lI.errnames.DatabaseClosed,()=>void 0);i?i.users.includes(e)||await n.dynamicOfflineData.update(i.id,{users:[...i.users,e]}).catch(lI.errnames.DatabaseClosed):await n.dynamicOfflineData.add({users:[e],type:t,identifier:r}).catch(lI.errnames.DatabaseClosed)}async function ur(e,t){let r=await ua();return await un(r,e,t)}async function un(e,t,r){let n=new lW,i=await n.dynamicOfflineData.get({type:t,identifier:r,users:e}).catch(lI.errnames.DatabaseClosed,()=>void 0);i&&(i.users.length>1?await n.dynamicOfflineData.update(i.id,{users:i.users.filter(t=>t!==e)}).catch(lI.errnames.DatabaseClosed):await n.dynamicOfflineData.delete(i.id).catch(lI.errnames.DatabaseClosed))}async function ui(e,t){let r=await l9(e);await Promise.all(r.map(async e=>uo(e.type,e.identifier,t)))}async function uo(e,t,r){await ue(e,t);let n=new lW,i=await ua(),o=await n.dynamicOfflineData.get({type:e,identifier:t}).catch(lI.errnames.DatabaseClosed,()=>void 0),a=l5().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(lI.errnames.DatabaseClosed)}async function ua(){let e=(await ic()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let us=K("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function ul(){return ud(),us}function uu(e,t){ud(),l8({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 uc(e){ud(),await uo("patient",e)}function ud(){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 uf(e,t,r=!0){if(e){let n=null,[i,o]=await Promise.all([n9(`${n6}/Patient/${e}`,t).catch(e=>n=e),r?up(e):Promise.resolve(null)]);if(i.ok)return i.data;if(o)return o;if(n)throw n}return null}async function up(e){let t=(await lQ("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function uh(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 um=((er={}).NEWVISIT="startVisit",er.EDITVISIT="editVisit",er.LOADING="loadingVisit",er),uy=((en={}).NOTSTARTED="notStarted",en.ONGOING="ongoing",en);let ug="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))",ub=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function uv(){return z("visit",ub)}function u_(e,t){uv().setState({patientUuid:e,manuallySetVisitUuid:t})}function uw(e,t){return n9(`${n2}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function ux(e,t,r){return n9(`${n2}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function uE(e,t,r){return n9(`${n2}/visit?patient=${e}&v=${r??ug}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}uv().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let uS=new ea.BehaviorSubject(null);var uD=r(56170);function uO(e){return{uuid:e.uuid,display:e.display,name:e.name}}function uP(){return n7(`${n2}/visittype`).pipe((0,uD.map)(e=>e.data.results.map(uO))).pipe((0,uD.take)(1))}function uC(e){return{uuid:e.uuid,display:e.display}}function uk(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return n7(`${n2}/location${n?"?"+n:""}`).pipe((0,uD.map)(e=>e.data.results.map(uC))).pipe((0,uD.take)(1))}class uj{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+uj.version}static addUnaryOp(e){return uj.max_unop_len=Math.max(e.length,uj.max_unop_len),uj.unary_ops[e]=1,uj}static addBinaryOp(e,t,r){return uj.max_binop_len=Math.max(e.length,uj.max_binop_len),uj.binary_ops[e]=t,r?uj.right_associative.add(e):uj.right_associative.delete(e),uj}static addIdentifierChar(e){return uj.additional_identifier_chars.add(e),uj}static addLiteral(e,t){return uj.literals[e]=t,uj}static removeUnaryOp(e){return delete uj.unary_ops[e],e.length===uj.max_unop_len&&(uj.max_unop_len=uj.getMaxKeyLen(uj.unary_ops)),uj}static removeAllUnaryOps(){return uj.unary_ops={},uj.max_unop_len=0,uj}static removeIdentifierChar(e){return uj.additional_identifier_chars.delete(e),uj}static removeBinaryOp(e){return delete uj.binary_ops[e],e.length===uj.max_binop_len&&(uj.max_binop_len=uj.getMaxKeyLen(uj.binary_ops)),uj.right_associative.delete(e),uj}static removeAllBinaryOps(){return uj.binary_ops={},uj.max_binop_len=0,uj}static removeLiteral(e){return delete uj.literals[e],uj}static removeAllLiterals(){return uj.literals={},uj}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 uj(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 uj.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!uj.binary_ops[String.fromCharCode(e)]||uj.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return uj.isIdentifierStart(e)||uj.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(uj.hooks[e]){let r={context:this,node:t};return uj.hooks.run(e,r),r.node}return t}searchHook(e){if(uj.hooks[e]){let t={context:this};return uj.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===uj.SPACE_CODE||e===uj.TAB_CODE||e===uj.LF_CODE||e===uj.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:uj.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)===uj.SEMCOL_CODE||r===uj.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,uj.max_binop_len),t=e.length;for(;t>0;){if(uj.binary_ops.hasOwnProperty(e)&&(!uj.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!uj.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:uj.binaryPrecedence(t),right_a:uj.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,i,a];t=this.gobbleBinaryOp();){if(0===(r=uj.binaryPrecedence(t))){this.index-=t.length;break}i={value:t,prec:r,right_a:uj.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:uj.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:uj.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,uj.isDecimalDigit(e)||e===uj.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===uj.SQUOTE_CODE||e===uj.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===uj.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,uj.max_unop_len)).length;r>0;){if(uj.unary_ops.hasOwnProperty(t)&&(!uj.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!uj.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:uj.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}uj.isIdentifierStart(e)?(n=this.gobbleIdentifier(),uj.literals.hasOwnProperty(n.name)?n={type:uj.LITERAL,value:uj.literals[n.name],raw:n.name}:n.name===uj.this_str&&(n={type:uj.THIS_EXP})):e===uj.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===uj.PERIOD_CODE||t===uj.OBRACK_CODE||t===uj.OPAREN_CODE||t===uj.QUMARK_CODE;){let r;if(t===uj.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==uj.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===uj.OBRACK_CODE?((e={type:uj.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==uj.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===uj.OPAREN_CODE?e={type:uj.CALL_EXP,arguments:this.gobbleArguments(uj.CPAREN_CODE),callee:e}:(t===uj.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:uj.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(;uj.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===uj.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);uj.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++));uj.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);uj.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,uj.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===uj.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===uj.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:uj.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:uj.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(uj.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,uj.isIdentifierPart(e))this.index++;else break;return{type:uj.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===uj.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(i===uj.COMMA_CODE){if(this.index++,++n!==t.length){if(e===uj.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===uj.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!==uj.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(uj.CPAREN_CODE);if(this.code===uj.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:uj.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:uj.ARRAY_EXP,elements:this.gobbleArguments(uj.CBRACK_CODE)}}}Object.assign(uj,{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)})}}(uj),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"}),uj.max_unop_len=uj.getMaxKeyLen(uj.unary_ops),uj.max_binop_len=uj.getMaxKeyLen(uj.binary_ops);let uT=e=>new uj(e).parse(),uR=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(uj).filter(e=>!uR.includes(e)&&void 0===uT[e]).forEach(e=>{uT[e]=uj[e]}),uT.Jsep=uj,uT.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 uA="ArrowFunctionExpression",uM={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)}},uN={...uM,Promise};function uI(e,t={}){return uU(e,t,uH)}async function u$(e,t={}){return uW(e,t,uH)}function uL(e,t={}){return uU(e,t,uz)}function uF(e,t={}){return uW(e,t,uz)}function uB(e,t={}){return uU(e,t,uq)}function uV(e,t={}){return uW(e,t,uq)}function uU(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=uY(t,uM),i=uG("string"==typeof e?uT(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 uW(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=uY(t,uN);return Promise.resolve(uG("string"==typeof e?uT(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 uK(e){return uT(e)}function uH(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function uz(e){return"boolean"==typeof e}function uq(e){return"number"==typeof e}function uG(e,t){switch(e.type){case"UnaryExpression":var r,n,i,o,a,s,l,u,c,d,f,p,h=e,m=t;let y=uG(h.argument,m);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var g=e,b=t;let v=uG(g.left,b),w=uG(g.right,b);switch(g.operator){case"+":return v+w;case"-":return v-w;case"*":return v*w;case"/":return v/w;case"%":return v%w;case"**":return v**w;case"==":return v==w;case"===":return v===w;case"!=":return v!=w;case"!==":return v!==w;case">":return v>w;case">=":return v>=w;case"<":return v<w;case"<=":return v<=w;case"in":return v in w;case"&&":return v&&w;case"||":return v||w;case"??":return v??w;default:throw`Expression evaluator does not support operator '${g.operator}' operator`}case"ConditionalExpression":return r=e,n=t,uG(r.test,n)?uG(r.consequent,n):uG(r.alternate,n);case"CallExpression":var x=e,E=t;let S=x.arguments?.map(uJ(E)),D=uG(x.callee,E);if(D){if("function"!=typeof D)throw`${uX(x.callee)} is not a function`}else throw`No function named ${uX(x.callee)} is defined in this context`;return D(...S);case"ArrowFunctionExpression":let O;return i=e,o=t,O=i.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<O.length)throw`Required argument(s) ${O.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(O.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 uG(i.body,o.addVariables(t))}).bind(o.thisObj??null);case"MemberExpression":return function(e,t){let r,n=uG(e.object,t);if(void 0===n)switch(e.object.type){case"Identifier":{let r=uZ(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":{let r=uZ(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${r}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let i=n;if("string"==typeof n)i=String.prototype;else if("number"==typeof n)i=Number.prototype;else if("function"==typeof n);else if("object"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;switch(t.thisObj=i,e.property.type){case"Identifier":case"MemberExpression":r=uG(e.property,t);break;default:{let i=uG(e.property,t);if(void 0===i)throw{type:"Illegal property access",message:"No property was supplied to the property access"};uQ(i),r=n[i]}}return"function"==typeof r?r.bind(n):r}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(uJ(s));case"SequenceExpression":let P;return l=e,u=t,(P=l.expressions.map(uJ(u)))[P.length-1];case"NewExpression":var C=e,k=t;if(C.callee&&"Identifier"===C.callee.type){let e=C.arguments?.map(uJ(k));switch(C.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${C.callee.name}`}}if(C.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return uQ((c=e).value),c.value;case"Identifier":var j=e,T=t;uQ(j.name);let R=T.thisObj;if(R&&("object"==typeof R||"function"==typeof R)&&j.name in R){let e=R[j.name];return uQ(e),e}if(T.variables&&j.name in T.variables){let e=T.variables[j.name];return uQ(e),e}return j.name in T.globals?T.globals[j.name]:void 0;case"TemplateLiteral":let A,M;return d=e,f=t,A=d.expressions?.map(uJ(f))??[],(M=d.quasis?.map(uJ(f))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+A.join("")+M.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function uZ(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return uZ(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function uY(e,t){let r={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}function uJ(e){return function(t){return null===t?null:uG(t,e)}}function uQ(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function uX(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function u0(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:{...uN},isLocalExpression:!1,variables:new Set};return u1("string"==typeof e?uT(e):e,t),[...t.variables]}function u1(e,t){switch(e.type){case"UnaryExpression":return n=e,i=t,u1(n.argument,i);case"BinaryExpression":return o=e,a=t,[u1(o.left,a),u1(o.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[u1(s.consequent,l),u1(s.test,l),u1(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=u1(u.callee,c),u.arguments?.map(u3(c)),r;case"ArrowFunctionExpression":var n,i,o,a,s,l,u,c,d,f,p,h,m,y,g,b,v,w,x=e,E=t;let S={...E};S.isLocalExpression=!0;let D=x.params?.map(u3(S))??[],O=u1(x.body,S)??[];if(O&&Array.isArray(O))for(let e of O)D.includes(e)||E.variables.add(e);return;case"MemberExpression":let P;return d=e,f=t,u1(d.object,f),void((P={...f}).isLocalExpression=!0,u1(d.property,P));case"ArrayExpression":return p=e,h=t,void p.elements?.map(u3(h));case"SequenceExpression":return m=e,y=t,void m.expressions?.map(u3(y));case"NewExpression":return g=e,b=t,void g.arguments?.map(u3(b));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 v=e,w=t,void(v.expressions?.map(u3(w)),v.quasis?.map(u3(w)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function u3(e){return function(t){return null===t?null:u1(t,e)}}uT.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:uA,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=uA,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)})}}),uT.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"}})}}),uT.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)})}}),uT.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")}})}}),uT.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 :")}})}}),uT.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})}}),uT.addBinaryOp("in",7),uT.addBinaryOp("??",1);let u4=z("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 u2(e,t,r){u4.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function u6(e){return u4.getState().flags[e].enabled}function u5(e){return!window.offlineEnabled||(e??navigator.onLine)}u4.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 u8=ez(function(e,t,r){eN(e,t,r)});function u9(e,t=!0,r=!1){return!!(e?t:r)}let u7=K("extensionsInternal",{slots:{},extensions:{}}),ce=K("extensionRenderings",{renderings:new Map}),ct=()=>z("extensionsInternal",{slots:{},extensions:{}});function cr(e){let t=u7.getState(),r=e(t);r!==t&&u7.setState(r)}let cn=null,ci=null;function co(){let e=ce.getState();return cn&&e===ci||(cn=new Map(e.renderings),ci=e,function(e){for(let t of(cu.clear(),e.values()))cd(t,1);cc=!0}(cn)),cn}function ca(e){ci={renderings:e},ce.setState(ci,!0)}let cs=()=>z("extensions",{slots:{}});function cl(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}let cu=new Map,cc=!1;function cd(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=cu.get(r);if(!n){if(t<0)return;cu.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),cc=!0;return}n.count+=t,n.count<1&&(cu.delete(r),cc=!0)}function cf(){var e,t;if(co(),!cc)return;cc=!1;let r=Array.from(cu.values(),({record:e})=>e);r.sort(cp),e=tL.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===cp(e,t[r]))||tL.setState({mountedExtensions:r})}function cp(e,t){return ch(e.slotName,t.slotName)||ch(e.extensionId,t.extensionId)||ch(e.slotModuleName,t.slotModuleName)||ch(e.extensionModuleName,t.extensionModuleName)}function ch(e,t){return e===t?0:e<t?-1:1}cf(),ce.subscribe(()=>cl(cf));let cm=ct(),cy=cs(),cg=tB(),cb=tV(),cv=new Set,c_=!1;function cw(e){if(null===e)cv=null;else if(null!==cv)for(let t of e)cv.add(t);cl(cx)}function cx(){if(!c_){c_=!0;try{for(let e=1;;e++){let t=cv;if(null!==t&&0===t.size)return;cv=new Set;try{!function(e,t,r,n,i,o=null){let a=cy.getState().slots,s={},l=!1,u=u5(),c=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,f]of Object.entries(e.slots)){var d;let p=a[n];if(p&&o&&!o.has(n)){s[n]=p;continue}let{config:h}=(d=f.name,t.slots[d]??{loaded:!1,config:{}}),m=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}=cm.getState();return[...t,...r].filter(e=>!n.includes(e)).sort((e,r)=>cR(e,i,o[cO(e)]?.order,t)-cR(r,i,o[cO(r)]?.order,t))}(r,t.slots[e].attachedIds),l=[];for(let u of s){let{config:s}=tU(n,e,u),c=r.configure?.[u]??null,d=c?u8({},s,c):s,f=cO(u),p=t.extensions[f];if(p){let e=d?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!iu(e,a.user))||p.featureFlag&&!i.includes(p.featureFlag)||window.offlineEnabled&&!u9(o,p.online,p.offline))continue;l.push({id:u,name:f,moduleName:p.moduleName,config:d,featureFlag:p.featureFlag,meta:p.meta,online:d?.["Display conditions"]?.online??p.online??!0,offline:d?.["Display conditions"]?.offline??p.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||p.displayExpression})}}return l}(n,e,h,r,c,u,i.session);p&&p.moduleName===f.moduleName&&ti(p.candidateExtensions,m)?s[n]=p:(s[n]={moduleName:f.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&cy.setState({slots:s})}(cm.getState(),cg.getState(),cb.getState(),u4.getState(),it.getState(),t)}catch(e){throw cv=null===t||null===cv?null:new Set([...t,...cv]),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{c_=!1}}}function cE(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 cS(){cw(null)}function cD(e,t){return{moduleName:t,name:e,attachedIds:[]}}function cO(e){let[t]=e.split("#");return t}function cP(e){var t;let r;return t=cm.getState(),r=cO(e),t.extensions[r]}cm.subscribe((e,t)=>{cw(e.extensions!==t.extensions?null:cE(e.slots,t.slots))}),cg.subscribe((e,t)=>{cw(cE(e.slots,t.slots))}),cb.subscribe((e,t)=>{cw(cE(e.configs,t.configs))}),u4.subscribe(()=>cw(null)),it.subscribe(()=>cw(null)),cS(),g(cS);let cC=e=>cr(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function ck(e,t){cr(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...cD(e),attachedIds:[t]}}}})}function cj(e,t){cr(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 cT(e){cr(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function cR(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 cA(e,t){var r;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!!uL(o,i)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}((r=e,cy.getState().slots[r]?.candidateExtensions??[]),t,it.getState().session,e)}let cM=(e,t)=>cm.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=cD(t,e);return{...r,slots:{...r.slots,[t]:{...i}}}}),cN=K("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function cI({name:e,basePath:t,mode:r,componentContext:n,state:i}){cN.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:i})}function c$(e){cN.getState().slotName===e&&cN.setState(cN.getInitialState(),!0)}let cL=0,cF=null,cB={bootstrap:15e3,mount:15e3,unmount:15e3};function cV(e){if(e.timeouts)return e;let t=e.name??"parcel",r=Object.fromEntries(Object.keys(cB).filter(t=>e[t]).map(r=>{var n,i;let o,a;return[r,(n=e[r],i=cB[r],o=Array.isArray(n)?n:[n],a=e=>o.reduce((n,i,o)=>n.then(()=>{let n=i(e);return"function"==typeof n?.then&&"function"==typeof n?.catch?n:Promise.reject(Error(`Lifecycle function ${r} at array index ${o} for parcel ${t} did not return a promise`))}),Promise.resolve(void 0)),e=>{let n,o=new Promise((e,o)=>{n=setTimeout(()=>o(Error(`Lifecycle function ${r} for parcel ${t} did not settle within ${i}ms`)),i)});return Promise.race([a(e),o]).finally(()=>clearTimeout(n))})]}));return{...e,...r}}async function cU(e,t){return(await (cF??(cF=new Promise((e,t)=>{nt({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),nt))),cF))("function"==typeof e?()=>e().then(cV):cV(e),t)}function cW(e,t){let r,n=cU(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 cK(e,t,r,n,i=e=>e,o={}){let a=cO(n),s=cP(n),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:c,moduleName:d,online:f,offline:p,load:h}=s;if(function(e=!0,t=!1){return u9(u5(),e,t)}(f,p)){let s,f=cL++,p=`${t}/${n}-${f}`;e.dataset.extensionRenderingId=p;let m=e=>{try{let e,t;(t=(e=co()).get(p))&&(e.delete(p),cd(t,-1),ca(e))}catch(t){console.error(e,t)}};try{var u;let e;u={renderingId:p,extensionName:a,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r},(e=co()).has(u.renderingId)||(e.set(u.renderingId,u),cd(u,1),ca(e))}catch(e){throw m(`Recomputing configuration after registering '${n}' failed also failed`),e}try{s=await h()}catch(e){throw m(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await cU(i({...s,name:`${t}/${a}-${f}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d},domElement:e})}catch(e){throw m(`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),m(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>m(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),m(`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}function cH(){return{current:"unavailable",notAvailable:!0,active:!1}}let cz="x-omrs-offline-response-body",cq="x-omrs-offline-response-status",cG="x-omrs-offline-caching-strategy",cZ="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cY=new Uint8Array(16),cJ=[];for(let e=0;e<256;++e)cJ.push((e+256).toString(16).slice(1));let cQ=function(e,t,r){if(cZ&&!t&&!e)return cZ();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(cY)})();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 cJ[e[t+0]]+cJ[e[t+1]]+cJ[e[t+2]]+cJ[e[t+3]]+"-"+cJ[e[t+4]]+cJ[e[t+5]]+"-"+cJ[e[t+6]]+cJ[e[t+7]]+"-"+cJ[e[t+8]]+cJ[e[t+9]]+"-"+cJ[e[t+10]]+cJ[e[t+11]]+cJ[e[t+12]]+cJ[e[t+13]]+cJ[e[t+14]]+cJ[e[t+15]]}(n)},cX="OFFLINE+";function c0(){return cX+cQ()}function c1(e){return e.startsWith(cX)}var c3=r(47499),c4=r.n(c3);function c2({to:e,templateParams:t,onBeforeNavigate:r,children:n,...i}){return(0,c3.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}`)},[]),c4().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),nX({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:nJ(e,t),...i},n)}let c6=K("modalRegistry",{modals:{}}),c5=K("workspaceRegistrations",{workspaces:{}}),c8=K("workspaceGroups",{workspaceGroups:{}}),c9=new Set;function c7(e){let t=c5.getState().workspaces;if(t[e])return t[e];{let t=cP(e);if(t){var r;let n;return c9.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.`),c9.add(e)),{name:t.name,title:(r=t,"string"==typeof(n=r?.meta?.title)?n:n&&"object"==typeof n?oa(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.`)}}let de=K("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function dt(e){let{openedWindows:t}=de.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}let dr=(0,c3.createContext)({moduleName:"",featureName:""});function dn(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 di=e=>e;function da(e,t=di,r){let n=(0,c3.useCallback)(t=>e.subscribe(t),[e]),i=(0,c3.useCallback)(()=>t(e.getState()),[e,t]),o=(0,c3.useSyncExternalStore)(n,i,i),a=(0,c3.useMemo)(()=>r?dn(e,r):null,[e,r]);return(0,c3.useMemo)(()=>a?{...o,...a}:o,[o,a])}function ds(e,t){return da(e,di,t)}function dl(e){return function(t){let r=(0,c3.useCallback)(t=>e.subscribe(t),[]),n=(0,c3.useCallback)(()=>e.getState(),[]),i=(0,c3.useSyncExternalStore)(r,n,n),o=(0,c3.useMemo)(()=>t?dn(e,t):null,[t]);return(0,c3.useMemo)(()=>o?{...i,...o}:i,[i,o])}}let du=[];Object.freeze(du);let dc={candidateExtensions:du};Object.freeze(dc);let dd=e=>{let t=(0,c3.useCallback)(t=>t.slots?.[e]??dc,[e]);return da(cs(),t)},df=e=>e.session;function dp(e,t){let r,{candidateExtensions:n}=dd(e),i=da(it,df),o=(M((r=(0,c3.useRef)(t)).current,t)||(r.current=t),r.current);return(0,c3.useMemo)(()=>cA(e,o),[e,o,i,n])}function dh(e,t){let{moduleName:r}=(0,c3.useContext)(dr);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,c3.useEffect)(()=>{cM(r,e)},[r,e]),{extensions:dp(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function dm(e){return e}function dy({name:e,extensionSlotName:t,select:r=dm,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,c3.useRef)(null),{extensions:u,extensionSlotModuleName:c}=dh(s,i),d=(0,c3.useMemo)(()=>r(u),[r,u]),f=(0,c3.useMemo)(()=>{if("function"==typeof n&&!c4().isValidElement(n))return d.map(e=>n(e,i))},[n,d]);return c4().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)=>c4().createElement(dr.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},f?.[t]??("function"!=typeof n?n:null)??c4().createElement(fW,{state:i}))))}var dg=r(5338);function db(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 dv(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?db(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)):db(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function d_(e){return(d_="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 dw(e){return(dw="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 dx(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(dw(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(dw(e)));return e}}var dE=null;try{dE=require("react").createContext()}catch(e){}var dS={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 dD(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function dO(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=dj(e,t,function(){r(this)}),a=dx(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:dk(e),renderType:"function"==typeof(i=e).renderType?i.renderType():i.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function dP(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():dk(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function dC(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=dj(e,t,null),i=e.renderResults[t.name];if(i&&i.render)i.render(n);else{var o=dx(e,t)();dk(e).render(n,o)}})}function dk(e){return e.ReactDOMClient||e.ReactDOM}function dj(e,t,r){var n=e.React.createElement(e.rootComponent,t),i=dE?e.React.createElement(dE.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,dv(dv({},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 dT=r(58779),dR=r(59324),dA=r(14993);let dM={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},dN=new Map;(0,dA.r2)(dN);let dI={errorRetryCount:3,fetcher:n9,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof ie){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>dN};function d$(e,t){return function(e){if("object"!==d_(e))throw Error("single-spa-react requires a configuration object");var t,r=dv(dv({},dS),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");!dE&&r.React.createContext&&(dE=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:dD.bind(null,r),mount:dO.bind(null,r),unmount:dP.bind(null,r)};return r.parcelCanUpdate&&(n.update=dC.bind(null,r)),n}({React:c4(),ReactDOMClient:dg,rootComponent:(function(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},dM,e),r={...dI,...t.swrConfig};return function(e){var n,i,o,a,s;return o=i=class extends(n=c4().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 c4().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=c4().createElement(c3.Suspense,{fallback:null},c4().createElement(dR.BE,{value:r},c4().createElement(dr.Provider,{value:this.state.config},t.disableTranslations?c4().createElement(e,this.props):c4().createElement(dT.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},c4().createElement(e,this.props)))));return t.strictMode&&c4().StrictMode?c4().createElement(c4().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}})(t)(e)})}function dL(e,t){return()=>e().then(({default:e})=>d$(e,t))}function dF(e,t){return()=>Promise.resolve(d$(e,t))}let dB=dL,dV=new Map;function dU(e,t){let r=(0,c3.useRef)(t??{}),n=(0,c3.useRef)(t=>iE(e,t)),i=(0,c3.useRef)(Symbol());return(0,c3.useEffect)(()=>{let r=t??{},n=i.current;return null===ix(e)?i_(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.`),iE(e,()=>r)),dV.set(e,n),()=>{dV.get(e)===n&&(iw(e),dV.delete(e))}},[e]),(0,c3.useEffect)(()=>{let n=t??{};M(r.current,n)||(iE(e,()=>n),r.current=n)},[t]),n.current}function dW({namespace:e,value:t}){return dU(e,t),null}let dK=({children:e,value:t,fallback:r})=>t?c4().createElement(c4().Fragment,null,e):r?c4().createElement(c4().Fragment,null,r):null;function dH(){let e=(0,c3.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,c3.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function dz(e,t=e=>e??{}){let[r,n]=(0,c3.useState)(()=>{if(dq(e))return;let r=ix(e);if(null!==r)return t?t(r):r});return(0,c3.useEffect)(()=>{if(dq(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,c3.useEffect)(()=>iS(e,e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>M(e,r)?e:r)}),[e,t]),r}function dq(e){return"string"!=typeof e||0===e.trim().length}function dG(e){let t=dp(e);return(0,c3.useMemo)(()=>t.map(e=>e.id),[t])}function dZ(e,t){let{data:r,error:n,mutate:i,isLoading:o,isValidating:a}=(0,dR.Ay)(`${og}?patient=${e}&includeEncounterless=${t}`,n9);return(0,c3.useMemo)(()=>({isLoading:o,data:r?.data.results??[],error:n,mutate:i,isValidating:a}),[r,n,o,a,i])}function dY(e){(0,c3.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let dJ={},dQ=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let it=K("session",{loaded:!1,session:null}),ir=0;function ii(e={includeAuthStatus:!0}){return(ir<Date.now()-6e4||!it.getState().loaded)&&is(),new ea.Observable(t=>{let r=r=>{r.loaded&&(e.includeAuthStatus?t.next(r.session):t.next(r.session?.user))};return r(it.getState()),it.subscribe(r)})}function io(){return(ir<Date.now()-6e4||!it.getState().loaded)&&is(),it}function ia(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 is(e,t){ir=Date.now();let r={};return e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),im(n9(n5,{headers:r}))}function il(){it.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function iu(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!Z(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!Z(n.privileges.find(t=>e===t.display))):(Z(r)||console.error(`Could not understand privileges "${r}"`),!0))||!Z(t.roles.find(e=>"System Developer"===e.display))}function ic(){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(it.getState()),e||(t=it.subscribe(n))})}function id(){return new Promise((e,t)=>{ii().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function ip(e,t){return im(n9(n5,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function ih(e,t,r){return r||(r=new AbortController),await n9(`${n2}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),is()}function im(e){return new Promise((t,r)=>{e.then(e=>{let n;"object"==typeof e?.data?(n={loaded:!0,session:e.data},it.setState(n),t(n)):(n={loaded:!1,session:null},it.setState(n),r(n))}).catch(e=>{T(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};it.setState(t),r(t)})})}function iy(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}it.subscribe(e=>{e.loaded&&e.session&&ia(e.session)});let ig={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"},ib=L()(()=>({}));H("openmrs-app-context",ib);let iv={};function i_(e,t=iv){ib.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===iv?{}:t})})}function iw(e){ib.setState(t=>(e in t&&delete t[e],t))}function ix(e,t=e=>e){let r=ib.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function iE(e,t){ib.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function iS(e,t){let r=ix(e);return t(iD(r)),ib.subscribe(n=>{let i=e in n?n[e]:null;i!==r&&(r=i,t(iD(i)))})}function iD(e){return null===e?null:Object.freeze(Object.assign({},e))}let iO={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"},iP=e=>"string"==typeof e,iC=()=>{let e,t,r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r},ik=e=>null==e?"":""+e,ij=/###/g,iT=e=>e&&e.indexOf("###")>-1?e.replace(ij,"."):e,iR=e=>!e||iP(e),iA=(e,t,r)=>{let n=iP(t)?t.split("."):t,i=0;for(;i<n.length-1;){if(iR(e))return{};let t=iT(n[i]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return iR(e)?{}:{obj:e,k:iT(n[i])}},iM=(e,t,r)=>{let{obj:n,k:i}=iA(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=iA(e,a,Object);for(;void 0===s.obj&&a.length;)o=`${a[a.length-1]}.${o}`,s=iA(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},iN=(e,t)=>{let{obj:r,k:n}=iA(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},iI=(e,t,r)=>{for(let n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?iP(e[n])||e[n]instanceof String||iP(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):iI(e[n],t[n],r):e[n]=t[n]);return e};var i$={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let iL=e=>iP(e)?e.replace(/[&<>"'\/]/g,e=>i$[e]):e,iF=[" ",",","?","!",";"],iB=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),iV=(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},iU=e=>e?.replace("_","-"),iW={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 iK{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||iW,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:(iP(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new iK(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new iK(this.logger,e)}}var iH=new iK;class iz{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 iq extends iz{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):iP(r)&&o?i.push(...r.split(o)):i.push(r)));let s=iN(this.data,i);return(!s&&!t&&!r&&e.indexOf(".")>-1&&(e=i[0],t=i[1],r=i.slice(2).join(".")),!s&&a&&iP(r))?iV(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),iM(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)(iP(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=iN(this.data,a)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),n?iI(s,r,i):s={...s,...r},iM(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 iG={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 iZ=Symbol("i18next/PATH_KEY");function iY(e,t){let r,n,i,{[iZ]:o}=e((n=[],(i=Object.create(null)).get=(e,t)=>(r?.revoke?.(),t===iZ)?n:(n.push(t),(r=Proxy.revocable(e,i)).proxy),Proxy.revocable(Object.create(null),i).proxy));return o.join(t?.keySeparator??".")}let iJ={},iQ=e=>!iP(e)&&"boolean"!=typeof e&&"number"!=typeof e;class iX extends iz{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=iH.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=iQ(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=iF.filter(e=>0>t.indexOf(e)&&0>r.indexOf(e));if(0===n.length)return!0;let i=iB.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:iP(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:iP(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=iY(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 f=this.resolve(e,n),p=f?.res,h=f?.usedKey||a,m=f?.exactUsedKey||a,y=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,g=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==n.count&&!iP(n.count),v=iX.hasDefaultValue(n),w=b?this.pluralResolver.getSuffix(c,n.count,n):"",x=n.ordinal&&b?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",E=b&&!n.ordinal&&0===n.count,S=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${w}`]||n[`defaultValue${x}`]||n.defaultValue,D=p;g&&!p&&v&&(D=S);let O=iQ(D),P=Object.prototype.toString.apply(D);if(g&&D&&O&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(P)&&!(iP(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?(f.res=e,f.usedParams=this.getUsedParamsDetails(n),f):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}`;v&&!p?t[e]=this.translate(i,{...n,defaultValue:iQ(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])}p=t}}else if(g&&iP(y)&&Array.isArray(p))(p=p.join(y))&&(p=this.extendTranslation(p,e,n,r));else{let t=!1,i=!1;!this.isValidLookup(p)&&v&&(t=!0,p=S),this.isValidLookup(p)||(i=!0,p=a);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&i?void 0:p,d=v&&S!==p&&this.options.updateMissing;if(i||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,a,d?S:p),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=v&&r!==p?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,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?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))}p=this.extendTranslation(p,e,n,f,r),i&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${a}`),(i||t)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,t?p:void 0,n))}return i?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}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=iP(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&&!iP(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=iP(o)?[o]:o;return null!=e&&a?.length&&!1!==r.applyPostProcessor&&(e=iG.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 iP(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&&!iP(t.count),d=c&&!t.ordinal&&0===t.count,f=void 0!==t.context&&(iP(t.context)||"number"==typeof t.context)&&""!==t.context,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(a=e,!iJ[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(iJ[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${n}" for languages "${p.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!!!")),p.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)),f){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&&!iP(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 i0{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=iH.create("languageUtils")}getScriptPartFromCode(e){if(!(e=iU(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=iU(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(iP(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)),iP(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 iP(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))):iP(e)&&i(this.formatLanguageCode(e)),r.forEach(e=>{0>n.indexOf(e)&&i(this.formatLanguageCode(e))}),n}}let i1={zero:0,one:1,two:2,few:3,many:4,other:5},i3={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class i4{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=iH.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let r,n=iU("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!"),i3;if(!e.match(/-|_/))return i3;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)=>i1[e]-i1[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 i2=(e,t,r,n=".",i=!0)=>{let o,a=void 0!==(o=iN(e,r))?o:iN(t,r);return!a&&i&&iP(r)&&void 0===(a=iV(e,r,n))&&(a=iV(t,r,n)),a};class i6{constructor(e={}){this.logger=iH.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:f,nestingSuffix:p,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:y,alwaysFormat:g}=e.interpolation;this.escape=void 0!==t?t:iL,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,"\\$&"):f||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=p?p.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=i2(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(i2(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=iP(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 iP(o)||this.useRawValueToEscape||(o=ik(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&&!iP(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&&!iP(i))return i;iP(i)||(i=ik(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 i5=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(iU(n),i),t[a]=s),s(r)}},i8=e=>(t,r,n)=>e(iU(r),n)(t);class i9{constructor(e={}){this.logger=iH.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let r=t.cacheInBuiltFormats?i5:i8;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()]=i5(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 i7 extends iz{constructor(e,t,r,n={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=n,this.logger=iH.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}=iA(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();iP(e)&&(e=this.languageUtils.toResolveHierarchy(e)),iP(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 oe=()=>({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]),iP(e[1])&&(t.defaultValue=e[1]),iP(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}),ot=e=>(iP(e.ns)&&(e.ns=[e.ns]),iP(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),iP(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),or=()=>{};class on extends iz{constructor(e={},t){if(super(),this.options=ot(e),this.services={},this.logger=iH,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&&(iP(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let r=oe();this.options={...r,...this.options,...ot(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?iH.init(n(this.modules.logger),this.options):iH.init(null,this.options),e=this.modules.formatter?this.modules.formatter:i9;let t=new i0(this.options);this.store=new iq(this.options.resources,this.options);let i=this.services;i.logger=iH,i.resourceStore=this.store,i.languageUtils=t,i.pluralResolver=new i4(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 i6(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new i7(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 iX(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=or),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=iC(),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=or){let r=t,n=iP(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=iC();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=or),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&&iG.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=iC();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=iP(t)?t:t&&t[0],o=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(iP(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=iY(e,{...this.options,...t})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=iY(e,{...this.options,...t})),a=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(a,o)};return iP(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=iC();return this.options.ns?(iP(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=iC();iP(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 i0(oe());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 on(e,t)}cloneInstance(e={},t=or){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let n={...this.options,...e,isClone:!0},i=new on(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 iq(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 iX(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 oi=on.createInstance();oi.createInstance=on.createInstance,oi.createInstance,oi.dir,oi.init,oi.loadResources,oi.reloadResources,oi.use,oi.changeLanguage,oi.getFixedT,oi.t,oi.exists,oi.setDefaultNamespace,oi.hasLoadedNamespace,oi.loadNamespaces,oi.loadLanguages;let oo=oi.default||oi;function oa(e,t,r,n){return oo.t(t,{ns:e,defaultValue:r,...n})}function os(e,t,r){return iO[e]?oa("core",e,t??iO[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}oo.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let ol=null;async function ou(){return ol??(ol=oc().then(({map:e,complete:t})=>(t||(ol=null),e))),ol}async function oc(){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:function(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}(t),complete:r}}async function od(){return await ou()}function of(e){return e.replace(/[\/\-@]/g,"_")}async function op(e,t="./start",n){var i;let o,a=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([oh(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=of(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 oh(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=of(e);if(!window[r]){let r=t??await om();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let i=e in{};try{return await function(e){var t;let r=(t=window)[oy]??(t[oy]=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&&O({kind:"error",title:os("scriptLoadingFailed","Error: Script failed to load"),description:os("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:os("resetOverrides","Reset overrides"),onActionButtonClick(){console.warn("[Security] Import map overrides are disabled in production mode."),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function om(){return od()}let oy=Symbol.for("__openmrs_script_loading"),og=`${n2}/attachment`;function ob(e,t){return n9(`${og}/${e}`,{signal:t.signal})}function ov(e,t,r){return n9(`${og}?patient=${e}&includeEncounterless=${t}`,{signal:r.signal})}async function o_(e,t){let r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),n9(`${og}`,{method:"POST",body:r})}function ow(e,t){return n9(`${og}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function ox(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 oE(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 oS(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 oD=function(){var e=this;this.promise=new Promise(function(t,r){e.resolve=t,e.reject=r})};function oO(e,t){var r=location.href;return new URL(e,r).href===new URL(t,r).href}var oP=function(e,t){this.type=e,Object.assign(this,t)};function oC(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function ok(){}var oj={type:"SKIP_WAITING"};function oT(e,t){if(!t)return e&&e.then?e.then(ok):Promise.resolve()}async function oR(e){let t=await (f??Promise.resolve(void 0));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."}}!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 oD,n.en=new oD,n.on=new oD,n.un=0,n.an=new Set,n.cn=function(){var e=n.fn,t=e.installing;n.tn>0||!oO(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 oP(i,a)),"installed"===i?n.wn=self.setTimeout(function(){"installed"===i&&t.waiting===r&&n.dispatchEvent(new oP("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 oP("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 oC(n.getSW(),function(){n.an.has(i)&&n.dispatchEvent(new oP("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=t.prototype;n.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 oT(new Promise(function(e){return window.addEventListener("load",e)}))},i=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),oC(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&&oO(t.scriptURL,a.sn.toString())&&(a.hn=t,Promise.resolve().then(function(){a.dispatchEvent(new oP("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)}},n.update=function(){try{return this.fn?oT(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},n.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},n.messageSW=function(e){try{return oC(this.getSW(),function(t){return ox(t,e)})}catch(e){return Promise.reject(e)}},n.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&ox(this.fn.waiting,oj)},n.pn=function(){var e=navigator.serviceWorker.controller;return e&&oO(e.scriptURL,this.sn.toString())?e:void 0},n.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 oC(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)}},oE(t.prototype,[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}]),r&&oE(t,r)}(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 oS(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)?oS(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}());let oA="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,oM=Object.keys,oN=Array.isArray;function oI(e,t){return"object"!=typeof t||oM(t).forEach(function(r){e[r]=t[r]}),e}"u"<typeof Promise||oA.Promise||(oA.Promise=Promise);let o$=Object.getPrototypeOf,oL={}.hasOwnProperty;function oF(e,t){return oL.call(e,t)}function oB(e,t){"function"==typeof t&&(t=t(o$(e))),("u"<typeof Reflect?oM:Reflect.ownKeys)(t).forEach(r=>{oU(e,r,t[r])})}let oV=Object.defineProperty;function oU(e,t,r,n){oV(e,t,oI(r&&oF(r,"get")&&"function"==typeof r.get?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function oW(e){return{from:function(t){return e.prototype=Object.create(t.prototype),oU(e.prototype,"constructor",e),{extend:oB.bind(null,e.prototype)}}}}let oK=Object.getOwnPropertyDescriptor;function oH(e,t){let r;return oK(e,t)||(r=o$(e))&&oH(r,t)}let oz=[].slice;function oq(e,t,r){return oz.call(e,t,r)}function oG(e,t){return t(e)}function oZ(e){if(!e)throw Error("Assertion Failed")}function oY(e){oA.setImmediate?setImmediate(e):setTimeout(e,0)}function oJ(e,t){return e.reduce((e,r,n)=>{var i=t(r,n);return i&&(e[i[0]]=i[1]),e},{})}function oQ(e,t){if("string"==typeof t&&oF(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=oQ(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:oQ(s,t.substr(a+1))}}function oX(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){oZ("string"!=typeof r&&"length"in r);for(var n=0,i=t.length;n<i;++n)oX(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?oN(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=r;else{var l=e[a];l&&oF(e,a)||(l=e[a]={}),oX(l,s,r)}}else void 0===r?oN(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function o0(e){var t={};for(var r in e)oF(e,r)&&(t[r]=e[r]);return t}let o1=[].concat;function o3(e){return o1.apply([],e)}let o4="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(o3([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>oA[e]),o2=o4.map(e=>oA[e]);oJ(o4,e=>[e,!0]);let o6=null;function o5(e){o6="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let r=o6&&o6.get(t);if(r)return r;if(oN(t)){r=[],o6&&o6.set(t,r);for(var n=0,i=t.length;n<i;++n)r.push(e(t[n]))}else if(o2.indexOf(t.constructor)>=0)r=t;else{let n=o$(t);for(var o in r=n===Object.prototype?{}:Object.create(n),o6&&o6.set(t,r),t)oF(t,o)&&(r[o]=e(t[o]))}return r}(e);return o6=null,t}let{toString:o8}={};function o9(e){return o8.call(e).slice(8,-1)}let o7="u">typeof Symbol?Symbol.iterator:"@@iterator",ae="symbol"==typeof o7?function(e){var t;return null!=e&&(t=e[o7])&&t.apply(e)}:function(){return null},at={};function ar(e){var t,r,n,i;if(1==arguments.length){if(oN(e))return e.slice();if(this===at&&"string"==typeof e)return[e];if(i=ae(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 an="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var ai="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),ao=()=>!0;let aa=!Error("").stack;function as(){if(aa)try{throw as.arguments,Error()}catch(e){return e}return Error()}function al(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(ao).map(e=>"\n"+e).join("")):""}var au=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],ac=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(au),ad={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 af(e,t){this._e=as(),this.name=e,this.message=t}function ap(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,r)=>r.indexOf(e)===t).join("\n")}function ah(e,t,r,n){this._e=as(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=ap(e,t)}function am(e,t){this._e=as(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=ap(e,t)}oW(af).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+al(this._e,2))}},toString:function(){return this.name+": "+this.message}}),oW(ah).from(af),oW(am).from(af);var ay=ac.reduce((e,t)=>(e[t]=t+"Error",e),{}),ag=ac.reduce((e,t)=>{var r=t+"Error";function n(e,n){this._e=as(),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=ad[t]||r,this.inner=null)}return oW(n).from(af),e[t]=n,e},{});ag.Syntax=SyntaxError,ag.Type=TypeError,ag.Range=RangeError;var ab=au.reduce((e,t)=>(e[t+"Error"]=ag[t],e),{}),av=ac.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=ag[t]),e),{});function a_(){}function aw(e){return e}function ax(e,t){return null==e||e===aw?t:function(r){return t(e(r))}}function aE(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function aS(e,t){return e===a_?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?aE(n,this.onsuccess):n),i&&(this.onerror=this.onerror?aE(i,this.onerror):i),void 0!==o?o:r}}function aD(e,t){return e===a_?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?aE(r,this.onsuccess):r),n&&(this.onerror=this.onerror?aE(n,this.onerror):n)}}function aO(e,t){return e===a_?t:function(r){var n=e.apply(this,arguments);oI(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?aE(i,this.onsuccess):i),o&&(this.onerror=this.onerror?aE(o,this.onerror):o),void 0===n?void 0===a?void 0:a:oI(n,a)}}function aP(e,t){return e===a_?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function aC(e,t){return e===a_?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)}}av.ModifyError=ah,av.DexieError=af,av.BulkError=am;var ak={};let[aj,aT,aR]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,o$(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,o$(t),e]})(),aA=aT&&aT.then,aM=aj&&aj.constructor,aN=!!aR;var aI=!1,a$=aR?()=>{aR.then(a2)}:oA.setImmediate?setImmediate.bind(null,a2):oA.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{a2(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(a2,0)},aL=function(e,t){aq.push([e,t]),aB&&(a$(),aB=!1)},aF=!0,aB=!0,aV=[],aU=[],aW=null,aK=aw,aH={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:sb,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{sb(e[0],e[1])}catch(e){}})}},az=aH,aq=[],aG=0,aZ=[];function aY(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=a_,this._lib=!1;var t=this._PSD=az;if(ai&&(this._stackHolder=as(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==ak)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&aX(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&&a6();r&&"function"==typeof r.then?e(t,(e,t)=>{r instanceof aY?r._then(e,t):r.then(e,t)}):(t._state=!0,t._value=r,a0(t)),n&&a5()}},aX.bind(null,t))}catch(e){aX(t,e)}}(this,e)}let aJ={get:function(){var e=az,t=si;function r(r,n){var i=!e.global&&(e!==az||t!==si);let o=i&&!sl();var a=new aY((t,a)=>{a1(this,new aQ(sm(r,e,i,o),sm(n,e,i,o),t,a,e))});return ai&&a4(a,this),a}return r.prototype=ak,r},set:function(e){oU(this,"then",e&&e.prototype===ak?aJ:{get:function(){return e},set:aJ.set})}};function aQ(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 aX(e,t){if(aU.push(t),null===e._state){var r=e._lib&&a6();t=aK(t),e._state=!1,e._value=t,ai&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var r=oH(t,"stack");t._promise=e,oU(t,"stack",{get:()=>aI?r&&(r.get?r.get.apply(t):r.value):e.stack})}),aV.some(t=>t._value===e._value)||aV.push(e),a0(e),r&&a5()}}function a0(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)a1(e,t[r]);var i=e._PSD;--i.ref||i.finalize(),0===aG&&(++aG,aL(()=>{0==--aG&&a8()},[]))}function a1(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,++aG,aL(a3,[r,e,t])}else e._listeners.push(t)}function a3(e,t,r){try{aW=t;var n,i=t._value;t._state?n=e(i):(aU.length&&(aU=[]),n=e(i),-1===aU.indexOf(i)&&function(e){for(var t=aV.length;t;)if(aV[--t]._value===e._value)return void aV.splice(t,1)}(t)),r.resolve(n)}catch(e){r.reject(e)}finally{aW=null,0==--aG&&a8(),--r.psd.ref||r.psd.finalize()}}function a4(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function a2(){a6()&&a5()}function a6(){var e=aF;return aF=!1,aB=!1,e}function a5(){var e,t,r;do for(;aq.length>0;)for(e=aq,aq=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(aq.length>0);aF=!0,aB=!0}function a8(){var e=aV;aV=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=aZ.slice(0),r=t.length;r;)t[--r]()}function a9(e){return new aY(ak,!1,e)}function a7(e,t){var r=az;return function(){var n=a6(),i=az;try{return sf(r,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{sf(i,!1),n&&a5()}}}oB(aY.prototype,{then:aJ,_then:function(e,t){a1(this,new aQ(null,null,e,t,az))},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):a9(e)):this.then(null,e=>e&&e.name===t?r(e):a9(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),a9(t)))},stack:{get:function(){if(this._stack)return this._stack;try{aI=!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=al(s,0)):(o=s,a=""),r.push(o+(a?": "+a:"")+i)}return ai&&((i=al(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{aI=!1}}},timeout:function(e,t){return e<1/0?new aY((r,n)=>{var i=setTimeout(()=>n(new ag.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,i))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&oU(aY.prototype,Symbol.toStringTag,"Dexie.Promise"),aH.env=sp(),oB(aY,{all:function(){var e=ar.apply(null,arguments).map(su);return new aY(function(t,r){0===e.length&&t([]);var n=e.length;e.forEach((i,o)=>aY.resolve(i).then(r=>{e[o]=r,--n||t(e)},r))})},resolve:e=>{if(e instanceof aY)return e;if(e&&"function"==typeof e.then)return new aY((t,r)=>{e.then(t,r)});var t=new aY(ak,!0,e);return a4(t,aW),t},reject:a9,race:function(){var e=ar.apply(null,arguments).map(su);return new aY((t,r)=>{e.map(e=>aY.resolve(e).then(t,r))})},PSD:{get:()=>az,set:e=>az=e},totalEchoes:{get:()=>si},newPSD:sa,usePSD:sh,scheduler:{get:()=>aL,set:e=>{aL=e}},rejectionMapper:{get:()=>aK,set:e=>{aK=e}},follow:(e,t)=>new aY((r,n)=>sa((t,r)=>{var n=az;n.unhandleds=[],n.onunhandled=r,n.finalize=aE(function(){var e;e=()=>{0===this.unhandleds.length?t():r(this.unhandleds[0])},aZ.push(function t(){e(),aZ.splice(aZ.indexOf(t),1)}),++aG,aL(()=>{0==--aG&&a8()},[])},n.finalize),e()},t,r,n))}),aM&&(aM.allSettled&&oU(aY,"allSettled",function(){let e=ar.apply(null,arguments).map(su);return new aY(t=>{0===e.length&&t([]);let r=e.length,n=Array(r);e.forEach((e,i)=>aY.resolve(e).then(e=>n[i]={status:"fulfilled",value:e},e=>n[i]={status:"rejected",reason:e}).then(()=>--r||t(n)))})}),aM.any&&"u">typeof AggregateError&&oU(aY,"any",function(){let e=ar.apply(null,arguments).map(su);return new aY((t,r)=>{0===e.length&&r(AggregateError([]));let n=e.length,i=Array(n);e.forEach((e,o)=>aY.resolve(e).then(e=>t(e),e=>{i[o]=e,--n||r(AggregateError(i))}))})}));let se={awaits:0,echoes:0,id:0};var st=0,sr=[],sn=0,si=0,so=0;function sa(e,t,r,n){var i=az,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++so;var a=aH.env;o.env=aN?{Promise:aY,PromiseProp:{value:aY,configurable:!0,writable:!0},all:aY.all,race:aY.race,allSettled:aY.allSettled,any:aY.any,resolve:aY.resolve,reject:aY.reject,nthen:sy(a.nthen,o),gthen:sy(a.gthen,o)}:{},t&&oI(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=sh(o,e,r,n);return 0===o.ref&&o.finalize(),s}function ss(){return se.id||(se.id=++st),++se.awaits,se.echoes+=100,se.id}function sl(){return!!se.awaits&&(0==--se.awaits&&(se.id=0),se.echoes=100*se.awaits,!0)}function su(e){return se.echoes&&e&&e.constructor===aM?(ss(),e.then(e=>(sl(),e),e=>(sl(),sv(e)))):e}function sc(e){++si,se.echoes&&0!=--se.echoes||(se.echoes=se.id=0),sr.push(az),sf(e,!0)}function sd(){var e=sr[sr.length-1];sr.pop(),sf(e,!1)}function sf(e,t){var r,n=az;if((t?!se.echoes||sn++&&e===az:!sn||--sn&&e===az)||(r=t?sc.bind(null,e):sd,aA.call(aj,r)),e!==az&&(az=e,n===aH&&(aH.env=sp()),aN)){var i=aH.env.Promise,o=e.env;aT.then=o.nthen,i.prototype.then=o.gthen,(n.global||e.global)&&(Object.defineProperty(oA,"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 sp(){var e=oA.Promise;return aN?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(oA,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:aT.then,gthen:e.prototype.then}:{}}function sh(e,t,r,n,i){var o=az;try{return sf(e,!0),t(r,n,i)}finally{sf(o,!1)}}function sm(e,t,r,n){return"function"!=typeof e?e:function(){var i,o=az;r&&ss(),sf(t,!0);try{return e.apply(this,arguments)}finally{sf(o,!1),n&&(i=sl,aA.call(aj,i))}}}function sy(e,t){return function(r,n){return e.call(this,sm(r,t),sm(n,t))}}-1===(""+aA).indexOf("[native code]")&&(ss=sl=a_);let sg="unhandledrejection";function sb(e,t){var r;try{r=t.onuncatched(e)}catch(e){}if(!1!==r)try{var n,i={promise:t,reason:e};if(oA.document&&document.createEvent?((n=document.createEvent("Event")).initEvent(sg,!0,!0),oI(n,i)):oA.CustomEvent&&oI(n=new CustomEvent(sg,{detail:i}),i),n&&oA.dispatchEvent&&(dispatchEvent(n),!oA.PromiseRejectionEvent&&oA.onunhandledrejection))try{oA.onunhandledrejection(n)}catch(e){}ai&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var sv=aY.reject;let s_="3.2.7",sw=String.fromCharCode(65535),sx=-1/0,sE="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",sS="String expected.",sD=[],sO="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),sP=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),sC="__dbnames",sk="readonly",sj="readwrite";function sT(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let sR={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function sA(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=o5(t))[e],t)}class sM{_trans(e,t,r){let n=this._tx||az.trans,i=this.name;function o(e,r,n){if(!n.schema[i])throw new ag.NotFound("Table "+i+" not part of transaction");return t(n.idbtrans,n)}let a=a6();try{return n&&n.db===this.db?n===az.trans?n._promise(e,o,r):sa(()=>n._promise(e,o,r),{trans:n,transless:az.transless||az}):function e(t,r,n,i){if(t.idbdb&&(t._state.openComplete||az.letThrough||t._vip)){var o=t._createTransaction(r,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===ay.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))):sv(o)}return o._promise(r,(e,t)=>sa(()=>(az.trans=o,i(e,t,o)))).then(e=>o._completion.then(()=>e))}if(t._state.openComplete)return sv(new ag.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return sv(new ag.DatabaseClosed);t.open().catch(a_)}return t._state.dbReadyPromise.then(()=>e(t,r,n,i))}(this.db,e,[this.name],o)}finally{a&&a5()}}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(oN(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=oM(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!==sw){let n=r.keyPath.slice(0,t.length);return this.where(n).equals(n.map(t=>e[t]))}!r&&ai&&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?sT(r,a&&a.multi?e=>{let t=oQ(e,i);return oN(t)&&t.some(e=>o(s,e))}:e=>o(s,oQ(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,oN(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(oF(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){oI(this,e)})}add(e,t){let{auto:r,keyPath:n}=this.schema.primKey,i=e;return n&&r&&(i=sA(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[i]})).then(e=>e.numFailures?aY.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{oX(e,n,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||oN(e))return this.where(":id").equals(e).modify(t);{let r=oQ(e,this.schema.primKey.keyPath);if(void 0===r)return sv(new ag.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?oM(t).forEach(r=>{oX(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=sA(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[i],keys:null!=t?[t]:null})).then(e=>e.numFailures?aY.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{oX(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?aY.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:sR})).then(e=>e.numFailures?aY.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 ag.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new ag.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&r?e.map(sA(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 am(`${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 ag.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new ag.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&r?e.map(sA(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 am(`${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 am(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,n)})}}function sN(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=aP),i||(i=a_);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}oM(e).forEach(function(t){var r=e[t];if(oN(r))o(t,e[t][0],e[t][1]);else{if("asap"!==r)throw new ag.InvalidArgument("Invalid event config");var n=o(t,aw,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){oY(function(){e.apply(null,t)})})})}})}}function sI(e,t){return oW(t).from({prototype:e}),t}function s$(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function sL(e,t){e.filter=sT(e.filter,t)}function sF(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>sT(n(),t()):t,e.justLimit=r&&!n}function sB(e,t){if(e.isPrimKey)return t.primaryKey;let r=t.getIndexByKeyPath(e.index);if(!r)throw new ag.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function sV(e,t,r){let n=sB(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 sU(e,t,r,n){let i=e.replayFilter?sT(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)),oF(o,s)||(o[s]=!0,t(e,r,n))}};return Promise.all([e.or._iterate(a,r),sW(sV(e,n,r),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return sW(sV(e,n,r),sT(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function sW(e,t,r,n){var i=a7(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=a_},t=>{e.fail(t),r=a_})||i(e.value,e,e=>r=e),r()})})}function sK(e,t){try{let r=sH(e),n=sH(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}(sz(e),sz(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=sK(e[r],t[r]);if(0!==n)return n}return r===n?0:r<n?-1:1}(e,t)}}catch(e){}return NaN}function sH(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let r=o9(e);return"ArrayBuffer"===r?"binary":r}function sz(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class sq{_read(e,t){var r=this._ctx;return r.error?r.table._trans(null,sv.bind(null,r.error)):r.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,sv.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=sT(t.algorithm,e)}_iterate(e,t){return sU(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&oI(r,e),t._ctx=r,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(r=>sU(t,e,r,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,r=t.table.core;if(s$(t,!0))return r.count({trans:e,query:{index:sB(t,r.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var n=0;return sU(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&&s$(t,!0)&&t.limit>0){let{valueMapper:r}=t,n=sB(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 sU(t,e=>r.push(e),e,t.table.core).then(()=>r)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,s$(t)?sF(t,()=>{var t=e;return(e,r)=>0===t||(1===t?--t:r(()=>{e.advance(t),t=0}),!1)}):sF(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),sF(this._ctx,()=>{var t=e;return function(e,r,n){return--t<=0&&r(n),t>=0}},!0),this}until(e,t){return sL(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 sL(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=sT(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&&s$(t,!0)&&t.limit>0)return this._read(e=>{var r=sB(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 sL(this._ctx,function(e){var t=e.primaryKey.toString(),n=oF(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=oM(e),o=i.length;n=function(t){for(var r=!1,n=0;n<o;++n){var a=i[n],s=e[a];oQ(t,a)!==s&&(oX(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,f=[],p=(e,t)=>{let{failures:r,numFailures:n}=t;for(let t of(d+=e-n,oM(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(f=>{let h=[],m=[],y=s?[]:null,g=[];for(let e=0;e<d;++e){let t=f[e],r={value:o5(t),primKey:i[c+e]};!1!==n.call(r,r.value,r)&&(null==r.value?g.push(i[c+e]):s||0===sK(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 b=s$(t)&&t.limit===1/0&&("function"!=typeof e||e===sG)&&{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);p(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:y,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>p(m.length,e))).then(()=>(g.length>0||b&&e===sG)&&a.mutate({trans:r,type:"delete",keys:g,criteria:b}).then(e=>p(g.length,e))).then(()=>i.length>c+d&&o(c+u))})};return o(0).then(()=>{if(c.length>0)throw new ah("Error modifying one or more objects",c,d,f);return i.length})})})}delete(){var e=this._ctx,t=e.range;return s$(e)&&(e.isPrimKey&&!sO||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 ah("Could not delete some values",Object.keys(e).map(t=>e[t]),n-i);return n-i}))}):this.modify(sG)}}let sG=(e,t)=>t.value=null;function sZ(e,t){return e<t?-1:+(e!==t)}function sY(e,t){return e>t?-1:+(e!==t)}function sJ(e,t,r){var n=e instanceof s3?new e.Collection(e):e;return n._ctx.error=r?new r(t):TypeError(t),n}function sQ(e){return new e.Collection(e,()=>s1("")).limit(0)}function sX(e,t,r,n){var i,o,a,s,l,u,c,d=r.length;if(!r.every(e=>"string"==typeof e))return sJ(e,sS);function f(e){i="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),o="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?sZ:sY;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}f("next");var p=new e.Collection(e,()=>s0(s[0],l[d-1]+n));p._ondirectionchange=function(e){f(e)};var h=0;return p._addAlgorithm(function(e,r,n){var i=e.key;if("string"!=typeof i)return!1;var f=o(i);if(t(f,l,h))return!0;for(var p=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,f,s[m],l[m],a,u);null===y&&null===p?h=m+1:(null===p||a(p,y)>0)&&(p=y)}return r(null!==p?function(){e.continue(p+c)}:n),!1}),p}function s0(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function s1(e){return{type:1,lower:e,upper:e}}class s3{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)?sQ(this):new this.Collection(this,()=>s0(e,t,!r,!n))}catch(e){return sJ(this,sE)}}equals(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s1(e))}above(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s0(e,void 0,!0))}aboveOrEqual(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s0(e,void 0,!1))}below(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s0(void 0,e,!1,!0))}belowOrEqual(e){return null==e?sJ(this,sE):new this.Collection(this,()=>s0(void 0,e))}startsWith(e){return"string"!=typeof e?sJ(this,sS):this.between(e,e+sw,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):sX(this,(e,t)=>0===e.indexOf(t[0]),[e],sw)}equalsIgnoreCase(e){return sX(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=ar.apply(at,arguments);return 0===e.length?sQ(this):sX(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=ar.apply(at,arguments);return 0===e.length?sQ(this):sX(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,sw)}anyOf(){let e=ar.apply(at,arguments),t=this._cmp;try{e.sort(t)}catch(e){return sJ(this,sE)}if(0===e.length)return sQ(this);let r=new this.Collection(this,()=>s0(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([[sx,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=ar.apply(at,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return sJ(this,sE)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[sx,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 sQ(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=n(e[0],e[1])))return sJ(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",ag.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 sJ(this,sE)}let f=0,p=l?e=>n(e,u[f][1])>0:e=>n(e,u[f][1])>=0,h=s?e=>i(e,u[f][0])>0:e=>i(e,u[f][0])>=0,m=p,y=new this.Collection(this,()=>s0(u[0][0],u[u.length-1][1],!s,!l));return y._ondirectionchange=e=>{"next"===e?(m=p,c=n):(m=h,c=i),u.sort(d)},y._addAlgorithm((e,t,r)=>{for(var i=e.key;m(i);)if(++f===u.length)return t(r),!1;return!!(!p(i)&&!h(i))||(0===this._cmp(i,u[f][1])||0===this._cmp(i,u[f][0])||t(()=>{c===n?e.continue(u[f][0]):e.continue(u[f][1])}),!1)}),y}startsWithAnyOf(){let e=ar.apply(at,arguments);return e.every(e=>"string"==typeof e)?0===e.length?sQ(this):this.inAnyRange(e.map(e=>[e,e+sw])):sJ(this,"startsWithAnyOf() only works with strings")}}function s4(e){return a7(function(t){return s2(t),e(t.target.error),!1})}function s2(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let s6="storagemutated",s5="x-storagemutated-1",s8=sN(null,s6);class s9{_lock(){return oZ(!az.global),++this._reculock,1!==this._reculock||az.global||(az.lockOwnerFor=this),this}_unlock(){if(oZ(!az.global),0==--this._reculock)for(az.global||(az.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{sh(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&az.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,r=this.db._state.dbOpenError;if(oZ(!this.idbtrans),!e&&!t)switch(r&&r.name){case"DatabaseClosedError":throw new ag.DatabaseClosed(r);case"MissingAPIError":throw new ag.MissingAPI(r.message,r);default:throw new ag.OpenFailed(r)}if(!this.active)throw new ag.TransactionInactive;return oZ(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=a7(t=>{s2(t),this._reject(e.error)}),e.onabort=a7(t=>{s2(t),this.active&&this._reject(new ag.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=a7(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&s8.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,r){if("readwrite"===e&&"readwrite"!==this.mode)return sv(new ag.ReadOnly("Transaction is readonly"));if(!this.active)return sv(new ag.TransactionInactive);if(this._locked())return new aY((n,i)=>{this._blockedFuncs.push([()=>{this._promise(e,t,r).then(n,i)},az])});if(r)return sa(()=>{var e=new aY((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 aY((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=aY.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 aY((e,n)=>{r.then(r=>t._waitingQueue.push(a7(e.bind(null,r))),e=>t._waitingQueue.push(a7(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 ag.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(oF(t,e))return t[e];let r=this.schema[e];if(!r)throw new ag.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 s7(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?"++":"")+le(t)}}function le(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function lt(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:oJ(r,e=>[e.name,e])}}let lr=e=>{try{return e.only([[]]),lr=()=>[[]],[[]]}catch(e){return lr=()=>sw,sw}};function ln(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>oQ(t,e):t=>oQ(t,e)}function li(e){return[].slice.call(e)}let lo=0;function la(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function ls({_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=li(e.objectStoreNames),{schema:{name:e.name,tables:n.map(e=>r.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:r}=e,n=oN(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:ln(t)},indexes:li(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:r,multiEntry:n,keyPath:i}=e,a={name:t,compound:oN(i),keyPath:i,unique:r,multiEntry:n,extractKey:ln(i)};return o[la(i)]=a,a}),getIndexByKeyPath:e=>o[la(e)]};return o[":id"]=a.primaryKey,null!=t&&(o[la(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=a7(s);let c=e.objectStore(t),d=null==c.keyPath,f="put"===r||"add"===r;if(!f&&"delete"!==r&&"deleteRange"!==r)throw Error("Invalid operation type: "+r);let{length:p}=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===p)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],y=0,g=e=>{++y,s2(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]=f?d?[o,n]:[o,null]:[n,null];if(f)for(let n=0;n<p;++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<p;++t)h.push(u=c[r](e[t])),u.onerror=g}let b=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),b(e)},u.onsuccess=b})},getMany:({trans:e,keys:r})=>new Promise((n,i)=>{n=a7(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)},f=s4(i);for(let e=0;e<a;++e)null!=r[e]&&((l=o.get(r[e]))._pos=e,l.onsuccess=d,l.onerror=f,++u);0===u&&n(s)}),get:({trans:e,key:r})=>new Promise((n,i)=>{n=a7(n);let o=e.objectStore(t).get(r);o.onsuccess=e=>n(e.target.result),o.onerror=s4(i)}),query:e=>new Promise((r,n)=>{r=a7(r);let{trans:o,values:s,limit:l,query:u}=e,c=l===1/0?void 0:l,{index:d,range:f}=u,p=o.objectStore(t),h=d.isPrimaryKey?p:p.index(d.name),m=i(f);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=s4(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=s4(n)}}),openCursor:function({trans:e,values:r,query:n,reverse:o,unique:a}){return new Promise((s,l)=>{s=a7(s);let{index:u,range:c}=n,d=e.objectStore(t),f=u.isPrimaryKey?d:d.index(u.name),p=o?a?"prevunique":"prev":a?"nextunique":"next",h=!r&&"openKeyCursor"in f?f.openKeyCursor(i(c),p):f.openCursor(i(c),p);h.onerror=s4(l),h.onsuccess=a7(t=>{let r=h.result;if(!r)return void s(null);r.___id=++lo,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=a7(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=a7(e),h.onerror=s4(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=a7(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=a7(t=>e(t.target.result)),c.onerror=s4(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:lr(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 ll({_novip:e},t,r,n){r.forEach(r=>{let i=n[r];t.forEach(t=>{let n=oH(t,r);(!n||"value"in n&&void 0===n.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?oU(t,r,{get(){return this.table(r)},set(e){oV(this,r,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[r]=new e.Table(r,i))})})}function lu({_novip:e},t){t.forEach(t=>{for(let r in t)t[r]instanceof e.Table&&delete t[r]})}function lc(e,t){return e._cfg.version-t._cfg.version}function ld(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||sO)){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 lf(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=>lp(i,e)),i}function lp(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function lh(e,t,r){let n={};return oq(t.objectStoreNames,0).forEach(e=>{let t=r.objectStore(e),i=t.keyPath,o=s7(le(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=s7(r.name,i,!!r.unique,!!r.multiEntry,!1,i&&"string"!=typeof i,!1);a.push(s)}n[e]=lt(e,o,a)}),n}function lm({_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:"["+oq(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)&&oA.WorkerGlobalScope&&oA instanceof oA.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class ly{_parseStoresSpec(e,t){oM(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 s7(r,n||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),oN(n),0===t)}),i=n.shift();if(i.multi)throw new ag.Schema("Primary key cannot be multi-valued");n.forEach(e=>{if(e.auto)throw new ag.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new ag.Schema("Index must have a name and cannot be an empty string")}),t[r]=lt(r,i,n)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?oI(this._cfg.storesSource,e):e;let r=t._versions,n={},i={};return r.forEach(e=>{oI(n,e._cfg.storesSource),i=e._cfg.dbschema={},e._parseStoresSpec(n,i)}),t._dbSchema=i,lu(t,[t._allTables,t,t.Transaction.prototype]),ll(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],oM(i),i),t._storeNames=oM(i),this}upgrade(e){return this._cfg.contentUpgrade=aC(this._cfg.contentUpgrade||a_,e),this}}function lg(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new lI(sC,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),r.table("dbnames")}function lb(e){return e&&"function"==typeof e.databases}function lv(e){return sa(function(){return az.letThrough=!0,e()})}function l_(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):oN(o)?Promise.all(o).then(r,n):r(o)}}return i(t)()}function lw(e,t,r){var n=arguments.length;if(n<2)throw new ag.InvalidArgument("Too few arguments");for(var i=Array(n-1);--n;)i[n-1]=arguments[n];return r=i.pop(),[e,o3(i),r]}function lx(e,t,r){let n=oN(e)?e.slice():[e];for(let e=0;e<r;++e)n.push(t);return n}let lE={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=la(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:ln(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:lx(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,n),lowerOpen:!0,upper:lx(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[la(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(lx(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(lx(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 lS(e,t,r,n){return r=r||{},n=n||"",oM(e).forEach(i=>{if(oF(t,i)){var o=e[i],a=t[i];if("object"==typeof o&&"object"==typeof a&&o&&a){let e=o9(o);e!==o9(a)?r[n+i]=t[i]:"Object"===e?lS(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}),oM(t).forEach(i=>{oF(e,i)||(r[n+i]=t[i])}),r}let lD={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=az.trans,{deleting:o,creating:a,updating:s}=i.table(t).hook;switch(e.type){case"add":if(a.fire===a_)break;return i._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===a_&&s.fire===a_)break;return i._promise("readwrite",()=>l(e),!0);case"delete":if(o.fire===a_)break;return i._promise("readwrite",()=>l(e),!0);case"deleteRange":if(o.fire===a_)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=az.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||oX(e.values[i],n.keyPath,r))}else{let t=lS(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=>{oF(t,e)?t[e]=n[e]:oX(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 lO(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===sK(t.keys[i],e[o])&&(n.push(r?o5(t.values[i]):t.values[i]),++o);return n.length===e.length?n:null}catch(e){return null}}let lP={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=lO(e.keys,e.trans._cache,"clone"===e.cache);return t?aY.resolve(t):r.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?o5(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),r.mutate(e))}}})};function lC(e){return!("from"in e)}let lk=function(e,t){if(!this){let t=new lk;return e&&"d"in e&&oI(t,e),t}oI(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function lj(e,t,r){let n=sK(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(lC(e))return oI(e,{from:t,to:r,d:1});let i=e.l,o=e.r;if(0>sK(r,e.from))return i?lj(i,t,r):e.l={from:t,to:r,d:1,l:null,r:null},lA(e);if(sK(t,e.to)>0)return o?lj(o,t,r):e.r={from:t,to:r,d:1,l:null,r:null},lA(e);0>sK(t,e.from)&&(e.from=t,e.l=null,e.d=o?o.d+1:1),sK(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&&lT(e,i),o&&a&&lT(e,o)}function lT(e,t){lC(t)||function e(t,{from:r,to:n,l:i,r:o}){lj(t,r,n),i&&e(t,i),o&&e(t,o)}(e,t)}function lR(e){let t=lC(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>sK(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>=sK(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 lA(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=lM(r)}e.d=lM(e)}function lM({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}oB(lk.prototype,{add(e){return lT(this,e),this},addKey(e){return lj(this,e,e),this},addKeys(e){return e.forEach(e=>lj(this,e,e)),this},[o7](){return lR(this)}});let lN={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,r=new lk(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 lk)},u=l(""),c=l(":dels"),{type:d}=e,[f,p]="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(oN(f)){"delete"!==d&&(f=e.results),u.addKeys(f);let t=lO(f,h);t||"add"===d||c.addKeys(f),(t||p)&&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&&oN(t)?t.forEach(e=>r.addKey(e)):r.addKey(t);(t||p).forEach((e,r)=>{let o=t&&n(t[r]),a=p&&n(p[r]);0!==sK(o,a)&&(null!=o&&i(o),null!=a&&i(a))})})}else if(f){let e={from:f.lower,to:f.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 lk(null!=(n=r.lower)?n:e.MIN_KEY,null!=(i=r.upper)?i:e.MAX_KEY)]},d={get:e=>[a,new lk(e.key)],getMany:e=>[a,(new lk).addKeys(e.keys)],count:c,query:c,openCursor:c};return oM(d).forEach(e=>{u[e]=function(o){let{subscr:a}=az;if(a){let u=e=>{let r=`idb://${t}/${n}/${e}`;return a[r]||(a[r]=new lk)},c=u(""),f=u(":dels"),[p,h]=d[e](o);if(u(p.name||"").add(h),!p.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):f.addKeys(e)}else if("openCursor"===e){let e=o.values;return r&&Object.create(r,{key:{get:()=>(f.addKey(r.primaryKey),r.key)},primaryKey:{get(){let e=r.primaryKey;return f.addKey(e),e}},value:{get:()=>(e&&c.addKey(r.primaryKey),r.value)}})}return r})}f.add(r)}}return i[e].apply(this,arguments)}}),u}}}};class lI{constructor(e,t){var r;this._middlewares={},this.verno=0;const n=lI.dependencies;this._options=t={addons:lI.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:a_,dbReadyPromise:null,cancelOpen:a_,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new aY(e=>{o.dbReadyResolve=e}),o.openCanceller=new aY((e,t)=>{o.cancelOpen=t}),this._state=o,this.name=e,this.on=sN(this,"populate","blocked","versionchange","close",{ready:[aC,a_]}),this.on.ready.subscribe=oG(this.on.ready.subscribe,e=>(t,r)=>{lI.vip(()=>{let n=this._state;if(n.openComplete)n.dbOpenError||aY.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,sI(sq.prototype,function(e,t){this.db=r;let n=sR,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!==aw?s:null}})),this.Table=function(e){return sI(sM.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:sN(null,{creating:[aS,a_],reading:[ax,aw],updating:[aO,a_],deleting:[aD,a_]})})}(this),this.Transaction=function(e){return sI(s9.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=sN(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 aY((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(),sv(e)})})}(this),this.Version=function(e){return sI(ly.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return sI(s3.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 ag.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=lr(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),sD.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(lE),this.use(lD),this.use(lN),this.use(lP),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new ag.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new ag.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(lc),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||az.letThrough||this._vip)?e():new aY((e,t)=>{if(this._state.openComplete)return t(new ag.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new ag.DatabaseClosed);this.open().catch(a_)}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?sv(r.dbOpenError):e);ai&&(r.openCanceller._stackHolder=as()),r.isBeingOpened=!0,r.dbOpenError=null,r.openComplete=!1;let i=r.openCanceller;function o(){if(r.openCanceller!==i)throw new ag.DatabaseClosed("db.open() was cancelled")}let a=r.dbReadyResolve,s=null,l=!1,u=()=>new aY((t,i)=>{if(o(),!n)throw new ag.MissingAPI;let a=e.name,u=r.autoSchema?n.open(a):n.open(a,Math.round(10*e.verno));if(!u)throw new ag.MissingAPI;u.onerror=s4(i),u.onblocked=a7(e._fireOnBlocked),u.onupgradeneeded=a7(t=>{if(s=u.transaction,r.autoSchema&&!e._options.allowEmptyDB){u.onerror=s2,s.abort(),u.result.close();let e=n.deleteDatabase(a);e.onsuccess=e.onerror=a7(()=>{i(new ag.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let r,n,a,f;s.onerror=s4(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),f=az.transless||az,sa(()=>{az.trans=n,az.transless=f,0===o?(oM(r).forEach(e=>{lf(c,e,r[e].primKey,r[e].indexes)}),ls(e,c),aY.follow(()=>e.on.populate.fire(n)).catch(a)):(function({_novip:e},t,r,n){let i=[],o=e._versions,a=e._dbSchema=lh(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;lm(e,i,n),lm(e,l,n),a=e._dbSchema=l;let u=ld(i,l);u.add.forEach(e=>{lf(n,e[0],e[1].primKey,e[1].indexes)}),u.change.forEach(e=>{if(e.recreate)throw new ag.Upgrade("Not yet support for changing primary key");{let t=n.objectStore(e.name);e.add.forEach(e=>lp(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),lp(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=o._cfg.contentUpgrade;if(c&&o._cfg.version>t){let t;ls(e,n),r._memoizedTables={},s=!0;let o=o0(l);u.del.forEach(e=>{o[e]=i[e]}),lu(e,[e.Transaction.prototype]),ll(e,[e.Transaction.prototype],oM(o),o),r.schema=o;let a=an(c);a&&ss();let d=aY.follow(()=>{if((t=c(r))&&a){var e=sl.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?aY.resolve(t):d.then(()=>t)}}),i.push(t=>{var n;s&&sO||(n=o._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==n[e]&&t.db.deleteObjectStore(e))),lu(e,[e.Transaction.prototype]),ll(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema})}),(function e(){return i.length?aY.resolve(i.shift()(r.idbtrans)).then(e):aY.resolve()})().then(()=>{var e;oM(e=a).forEach(t=>{n.db.objectStoreNames.contains(t)||lf(n,t,e[t].primKey,e[t].indexes)})})})(e,o,n,c).catch(a)})}},i),u.onsuccess=a7(()=>{s=null;let n=e._novip.idbdb=u.result,i=oq(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=lh(0,t,r);e._storeNames=oq(t.objectStoreNames,0),ll(e,[e._allTables],oM(n),n)}(e,n,o):(lm(e,e._dbSchema,o),((t=ld(lh(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.")),ls(e,o)}catch(e){}sD.push(e),n.onversionchange=a7(t=>{r.vcFired=!0,e.on("versionchange").fire(t)}),n.onclose=a7(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},r){lb(e)||r===sC||lg(e,t).put({name:r}).catch(a_)}(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()):aY.reject(e));return aY.race([i,("u"<typeof navigator?aY.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=[],aY.resolve(lv(()=>e.on.ready.fire(e.vip))).then(function t(){if(r.onReadyBeingFired.length>0){let n=r.onReadyBeingFired.reduce(aC,a_);return r.onReadyBeingFired=[],aY.resolve(lv(()=>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(),sv(t)}).finally(()=>{r.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=sD.indexOf(this);if(t>=0&&sD.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new aY(t=>{e.dbReadyResolve=t}),e.openCanceller=new aY((t,r)=>{e.cancelOpen=r})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new ag.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new aY((r,n)=>{let i=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=a7(()=>{!function({indexedDB:e,IDBKeyRange:t},r){lb(e)||r===sC||lg(e,t).delete(r).catch(a_)}(this._deps,this.name),r()}),e.onerror=s4(n),e.onblocked=this._fireOnBlocked};if(e)throw new ag.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 oM(this._allTables).map(e=>this._allTables[e])}transaction(){let e=lw.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,r){let n,i,o=az.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===sk)n=sk;else{if("rw"!=e&&e!=sj)throw new ag.InvalidArgument("Invalid transaction mode: "+e);n=sj}if(o){if(o.mode===sk&&n===sj){if(!a)throw new ag.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 ag.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)}):sv(e)}let s=(function e(t,r,n,i,o){return aY.resolve().then(()=>{let a,s=az.transless||az,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===ay.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))):sv(i)}let u=an(o);u&&ss();let c=aY.follow(()=>{if(a=o.call(l,l))if(u){var e=sl.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=l_(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?aY.resolve(a).then(e=>l.active?e:sv(new ag.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),sv(e)))})}).bind(null,this,n,i,o,r);return o?o._promise(n,s,"lock"):az.trans?sh(az.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!oF(this._allTables,e))throw new ag.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let l$="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class lL{constructor(e){this._subscribe=e}subscribe(e,t,r){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:r})}[l$](){return this}}function lF(e,t){return oM(t).forEach(r=>{lT(e[r]||(e[r]=new lk),t[r])}),e}try{o={indexedDB:oA.indexedDB||oA.mozIndexedDB||oA.webkitIndexedDB||oA.msIndexedDB,IDBKeyRange:oA.IDBKeyRange||oA.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function lB(e){let t=lV;try{lV=!0,s8.storagemutated.fire(e)}finally{lV=t}}oB(lI,{...av,delete:e=>new lI(e,{addons:[]}).delete(),exists:e=>new lI(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return lb(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==sC)):lg(e,t).toCollection().primaryKeys()})(lI.dependencies).then(e)}catch(e){return sv(new ag.MissingAPI)}},defineClass:()=>function(e){oI(this,e)},ignoreTransaction:e=>az.trans?sh(az.transless,e):e(),vip:lv,async:function(e){return function(){try{var t=l_(e.apply(this,arguments));return t&&"function"==typeof t.then?t:aY.resolve(t)}catch(e){return sv(e)}}},spawn:function(e,t,r){try{var n=l_(e.apply(r,t||[]));return n&&"function"==typeof n.then?n:aY.resolve(n)}catch(e){return sv(e)}},currentTransaction:{get:()=>az.trans||null},waitFor:function(e,t){let r=aY.resolve("function"==typeof e?lI.ignoreTransaction(e):e).timeout(t||6e4);return az.trans?az.trans.waitFor(r):r},Promise:aY,debug:{get:()=>ai,set:e=>{ai=e,ao="dexie"===e?()=>!0:sP}},derive:oW,extend:oI,props:oB,override:oG,Events:sN,on:s8,liveQuery:function(e){let t,r=!1,n=new lL(n=>{let i=an(e),o=!1,a={},s={},l={get closed(){return o},unsubscribe:()=>{o=!0,s8.storagemutated.unsubscribe(f)}};n.start&&n.start(l);let u=!1,c=!1;function d(){return oM(s).some(e=>a[e]&&function(e,t){let r=lR(t),n=r.next();if(n.done)return!1;let i=n.value,o=lR(e),a=o.next(i.from),s=a.value;for(;!n.done&&!a.done;){if(0>=sK(s.from,i.to)&&sK(s.to,i.from)>=0)return!0;0>sK(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 f=e=>{lF(a,e),d()&&p()},p=()=>{let h,m;if(u||o)return;a={};let y={},g=(i&&ss(),h=()=>sa(e,{subscr:y,trans:null}),m=az.trans?sh(az.transless,h):h(),i&&m.then(sl,sl),m);c||(s8(s6,f),c=!0),u=!0,Promise.resolve(g).then(e=>{r=!0,t=e,u=!1,o||(d()?p():(a={},s=y,n.next&&n.next(e)))},e=>{u=!1,r=!1,n.error&&n.error(e),l.unsubscribe()})};return p(),l});return n.hasValue=()=>r,n.getValue=()=>t,n},extendObservabilitySet:lF,getByKeyPath:oQ,setByKeyPath:oX,delByKeyPath:function(e,t){"string"==typeof t?oX(e,t,void 0):"length"in t&&[].map.call(t,function(t){oX(e,t,void 0)})},shallowClone:o0,deepClone:o5,getObjectDiff:lS,cmp:sK,asap:oY,minKey:sx,addons:[],connections:sD,errnames:ay,dependencies:o,semVer:s_,version:s_.split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),lI.maxKey=lr(lI.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(s8(s6,e=>{if(!lV){let t;sO?(t=document.createEvent("CustomEvent")).initCustomEvent(s5,!0,!0,e):t=new CustomEvent(s5,{detail:e}),lV=!0,dispatchEvent(t),lV=!1}}),addEventListener(s5,({detail:e})=>{lV||lB(e)}));let lV=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(s5);"function"==typeof e.unref&&e.unref(),s8(s6,t=>{lV||e.postMessage(t)}),e.onmessage=e=>{e.data&&lB(e.data)}}else if("u">typeof self&&"u">typeof navigator){s8(s6,e=>{try{lV||("u">typeof localStorage&&localStorage.setItem(s5,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:s5,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===s5){let t=JSON.parse(e.newValue);t&&lB(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===s5&&lB(e.changedParts)})}function lU(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}aY.rejectionMapper=function(e,t){if(!e||e instanceof af||e instanceof TypeError||e instanceof SyntaxError||!e.name||!ab[e.name])return e;var r=new ab[e.name](t||e.message,e);return"stack"in e&&oU(r,"stack",{get:function(){return this.inner.stack}}),r},ao=sP;class lW extends lI{constructor(){super("EsmOffline"),lU(this,"syncQueue",void 0),lU(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 lK(){return new lW}let lH=new lW,lz={};async function lq(){let e=await ic();return e?.uuid||"*"}async function lG(e,t,r,n){let i=n&&n.id;return void 0!==i&&await lH.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===i).delete().catch(lI.errnames.DatabaseClosed),await lH.syncQueue.add({type:t,content:r,userId:e,descriptor:n||{},createdOn:new Date}).catch(lI.errnames.DatabaseClosed,()=>-1)}async function lZ(e,t,r){let n=await lq();return await lG(n,e,t,r)}async function lY(e,t){return(await lJ(e,t)).map(e=>e.content)}async function lJ(e,t){return await lH.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(lI.errnames.DatabaseClosed,()=>[])}async function lQ(e){let t=await lq();return await lY(t,e)}async function lX(e){let t=await lq();return await lJ(t,e)}async function l0(e){return await lH.syncQueue.get(e).catch(lI.errnames.DatabaseClosed,()=>void 0)}function l1(e){return!!lz[e]?.options.onBeginEditSyncItem}async function l3(e){let t=await l0(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let r=lz[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 l4(e){await lH.syncQueue.delete(e).catch(lI.errnames.DatabaseClosed)}function l2(e,t,r,n={}){lz[e]={type:e,dependsOn:t,process:r,options:n}}K("offline-synchronization",{});let l6={};function l5(){return Object.values(l6)}function l8(e){l6[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.`),l6[e.id]=e}async function l9(e){let t=await ua();return await l7(t,e)}async function l7(e,t){let r=new lW;return await r.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(lI.errnames.DatabaseClosed,()=>[])}async function ue(e,t){let r=await ua();return await ut(r,e,t)}async function ut(e,t,r){let n=new lW,i=await n.dynamicOfflineData.get({type:t,identifier:r}).catch(lI.errnames.DatabaseClosed,()=>void 0);i?i.users.includes(e)||await n.dynamicOfflineData.update(i.id,{users:[...i.users,e]}).catch(lI.errnames.DatabaseClosed):await n.dynamicOfflineData.add({users:[e],type:t,identifier:r}).catch(lI.errnames.DatabaseClosed)}async function ur(e,t){let r=await ua();return await un(r,e,t)}async function un(e,t,r){let n=new lW,i=await n.dynamicOfflineData.get({type:t,identifier:r,users:e}).catch(lI.errnames.DatabaseClosed,()=>void 0);i&&(i.users.length>1?await n.dynamicOfflineData.update(i.id,{users:i.users.filter(t=>t!==e)}).catch(lI.errnames.DatabaseClosed):await n.dynamicOfflineData.delete(i.id).catch(lI.errnames.DatabaseClosed))}async function ui(e,t){let r=await l9(e);await Promise.all(r.map(async e=>uo(e.type,e.identifier,t)))}async function uo(e,t,r){await ue(e,t);let n=new lW,i=await ua(),o=await n.dynamicOfflineData.get({type:e,identifier:t}).catch(lI.errnames.DatabaseClosed,()=>void 0),a=l5().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(lI.errnames.DatabaseClosed)}async function ua(){let e=(await ic()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let us=K("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function ul(){return ud(),us}function uu(e,t){ud(),l8({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 uc(e){ud(),await uo("patient",e)}function ud(){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 uf(e,t,r=!0){if(e){let n=null,[i,o]=await Promise.all([n9(`${n6}/Patient/${e}`,t).catch(e=>n=e),r?up(e):Promise.resolve(null)]);if(i.ok)return i.data;if(o)return o;if(n)throw n}return null}async function up(e){let t=(await lQ("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function uh(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 um=((er={}).NEWVISIT="startVisit",er.EDITVISIT="editVisit",er.LOADING="loadingVisit",er),uy=((en={}).NOTSTARTED="notStarted",en.ONGOING="ongoing",en);let ug="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))",ub=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function uv(){return z("visit",ub)}function u_(e,t){uv().setState({patientUuid:e,manuallySetVisitUuid:t})}function uw(e,t){return n9(`${n2}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function ux(e,t,r){return n9(`${n2}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function uE(e,t,r){return n9(`${n2}/visit?patient=${e}&v=${r??ug}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}uv().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let uS=new ea.BehaviorSubject(null);var uD=r(56170);function uO(e){return{uuid:e.uuid,display:e.display,name:e.name}}function uP(){return n7(`${n2}/visittype`).pipe((0,uD.map)(e=>e.data.results.map(uO))).pipe((0,uD.take)(1))}function uC(e){return{uuid:e.uuid,display:e.display}}function uk(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return n7(`${n2}/location${n?"?"+n:""}`).pipe((0,uD.map)(e=>e.data.results.map(uC))).pipe((0,uD.take)(1))}class uj{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+uj.version}static addUnaryOp(e){return uj.max_unop_len=Math.max(e.length,uj.max_unop_len),uj.unary_ops[e]=1,uj}static addBinaryOp(e,t,r){return uj.max_binop_len=Math.max(e.length,uj.max_binop_len),uj.binary_ops[e]=t,r?uj.right_associative.add(e):uj.right_associative.delete(e),uj}static addIdentifierChar(e){return uj.additional_identifier_chars.add(e),uj}static addLiteral(e,t){return uj.literals[e]=t,uj}static removeUnaryOp(e){return delete uj.unary_ops[e],e.length===uj.max_unop_len&&(uj.max_unop_len=uj.getMaxKeyLen(uj.unary_ops)),uj}static removeAllUnaryOps(){return uj.unary_ops={},uj.max_unop_len=0,uj}static removeIdentifierChar(e){return uj.additional_identifier_chars.delete(e),uj}static removeBinaryOp(e){return delete uj.binary_ops[e],e.length===uj.max_binop_len&&(uj.max_binop_len=uj.getMaxKeyLen(uj.binary_ops)),uj.right_associative.delete(e),uj}static removeAllBinaryOps(){return uj.binary_ops={},uj.max_binop_len=0,uj}static removeLiteral(e){return delete uj.literals[e],uj}static removeAllLiterals(){return uj.literals={},uj}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 uj(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 uj.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!uj.binary_ops[String.fromCharCode(e)]||uj.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return uj.isIdentifierStart(e)||uj.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(uj.hooks[e]){let r={context:this,node:t};return uj.hooks.run(e,r),r.node}return t}searchHook(e){if(uj.hooks[e]){let t={context:this};return uj.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===uj.SPACE_CODE||e===uj.TAB_CODE||e===uj.LF_CODE||e===uj.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:uj.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)===uj.SEMCOL_CODE||r===uj.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,uj.max_binop_len),t=e.length;for(;t>0;){if(uj.binary_ops.hasOwnProperty(e)&&(!uj.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!uj.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:uj.binaryPrecedence(t),right_a:uj.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,i,a];t=this.gobbleBinaryOp();){if(0===(r=uj.binaryPrecedence(t))){this.index-=t.length;break}i={value:t,prec:r,right_a:uj.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:uj.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:uj.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,uj.isDecimalDigit(e)||e===uj.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===uj.SQUOTE_CODE||e===uj.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===uj.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,uj.max_unop_len)).length;r>0;){if(uj.unary_ops.hasOwnProperty(t)&&(!uj.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!uj.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:uj.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}uj.isIdentifierStart(e)?(n=this.gobbleIdentifier(),uj.literals.hasOwnProperty(n.name)?n={type:uj.LITERAL,value:uj.literals[n.name],raw:n.name}:n.name===uj.this_str&&(n={type:uj.THIS_EXP})):e===uj.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===uj.PERIOD_CODE||t===uj.OBRACK_CODE||t===uj.OPAREN_CODE||t===uj.QUMARK_CODE;){let r;if(t===uj.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==uj.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===uj.OBRACK_CODE?((e={type:uj.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==uj.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===uj.OPAREN_CODE?e={type:uj.CALL_EXP,arguments:this.gobbleArguments(uj.CPAREN_CODE),callee:e}:(t===uj.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:uj.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(;uj.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===uj.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);uj.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++));uj.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);uj.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,uj.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===uj.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===uj.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:uj.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:uj.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(uj.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,uj.isIdentifierPart(e))this.index++;else break;return{type:uj.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===uj.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(i===uj.COMMA_CODE){if(this.index++,++n!==t.length){if(e===uj.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===uj.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!==uj.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(uj.CPAREN_CODE);if(this.code===uj.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:uj.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:uj.ARRAY_EXP,elements:this.gobbleArguments(uj.CBRACK_CODE)}}}Object.assign(uj,{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)})}}(uj),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"}),uj.max_unop_len=uj.getMaxKeyLen(uj.unary_ops),uj.max_binop_len=uj.getMaxKeyLen(uj.binary_ops);let uT=e=>new uj(e).parse(),uR=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(uj).filter(e=>!uR.includes(e)&&void 0===uT[e]).forEach(e=>{uT[e]=uj[e]}),uT.Jsep=uj,uT.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 uA="ArrowFunctionExpression",uM={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)}},uN={...uM,Promise};function uI(e,t={}){return uU(e,t,uH)}async function u$(e,t={}){return uW(e,t,uH)}function uL(e,t={}){return uU(e,t,uz)}function uF(e,t={}){return uW(e,t,uz)}function uB(e,t={}){return uU(e,t,uq)}function uV(e,t={}){return uW(e,t,uq)}function uU(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=uY(t,uM),i=uG("string"==typeof e?uT(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 uW(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=uY(t,uN);return Promise.resolve(uG("string"==typeof e?uT(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 uK(e){return uT(e)}function uH(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function uz(e){return"boolean"==typeof e}function uq(e){return"number"==typeof e}function uG(e,t){switch(e.type){case"UnaryExpression":var r,n,i,o,a,s,l,u,c,d,f,p,h=e,m=t;let y=uG(h.argument,m);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var g=e,b=t;let v=uG(g.left,b),w=uG(g.right,b);switch(g.operator){case"+":return v+w;case"-":return v-w;case"*":return v*w;case"/":return v/w;case"%":return v%w;case"**":return v**w;case"==":return v==w;case"===":return v===w;case"!=":return v!=w;case"!==":return v!==w;case">":return v>w;case">=":return v>=w;case"<":return v<w;case"<=":return v<=w;case"in":return v in w;case"&&":return v&&w;case"||":return v||w;case"??":return v??w;default:throw`Expression evaluator does not support operator '${g.operator}' operator`}case"ConditionalExpression":return r=e,n=t,uG(r.test,n)?uG(r.consequent,n):uG(r.alternate,n);case"CallExpression":var x=e,E=t;let S=x.arguments?.map(uJ(E)),D=uG(x.callee,E);if(D){if("function"!=typeof D)throw`${uX(x.callee)} is not a function`}else throw`No function named ${uX(x.callee)} is defined in this context`;return D(...S);case"ArrowFunctionExpression":let O;return i=e,o=t,O=i.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<O.length)throw`Required argument(s) ${O.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(O.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 uG(i.body,o.addVariables(t))}).bind(o.thisObj??null);case"MemberExpression":return function(e,t){let r,n=uG(e.object,t);if(void 0===n)switch(e.object.type){case"Identifier":{let r=uZ(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":{let r=uZ(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${r}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let i=n;if("string"==typeof n)i=String.prototype;else if("number"==typeof n)i=Number.prototype;else if("function"==typeof n);else if("object"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;switch(t.thisObj=i,e.property.type){case"Identifier":case"MemberExpression":r=uG(e.property,t);break;default:{let i=uG(e.property,t);if(void 0===i)throw{type:"Illegal property access",message:"No property was supplied to the property access"};uQ(i),r=n[i]}}return"function"==typeof r?r.bind(n):r}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(uJ(s));case"SequenceExpression":let P;return l=e,u=t,(P=l.expressions.map(uJ(u)))[P.length-1];case"NewExpression":var C=e,k=t;if(C.callee&&"Identifier"===C.callee.type){let e=C.arguments?.map(uJ(k));switch(C.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${C.callee.name}`}}if(C.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return uQ((c=e).value),c.value;case"Identifier":var j=e,T=t;uQ(j.name);let R=T.thisObj;if(R&&("object"==typeof R||"function"==typeof R)&&j.name in R){let e=R[j.name];return uQ(e),e}if(T.variables&&j.name in T.variables){let e=T.variables[j.name];return uQ(e),e}return j.name in T.globals?T.globals[j.name]:void 0;case"TemplateLiteral":let A,M;return d=e,f=t,A=d.expressions?.map(uJ(f))??[],(M=d.quasis?.map(uJ(f))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+A.join("")+M.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function uZ(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return uZ(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function uY(e,t){let r={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}function uJ(e){return function(t){return null===t?null:uG(t,e)}}function uQ(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function uX(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function u0(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:{...uN},isLocalExpression:!1,variables:new Set};return u1("string"==typeof e?uT(e):e,t),[...t.variables]}function u1(e,t){switch(e.type){case"UnaryExpression":return n=e,i=t,u1(n.argument,i);case"BinaryExpression":return o=e,a=t,[u1(o.left,a),u1(o.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[u1(s.consequent,l),u1(s.test,l),u1(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=u1(u.callee,c),u.arguments?.map(u3(c)),r;case"ArrowFunctionExpression":var n,i,o,a,s,l,u,c,d,f,p,h,m,y,g,b,v,w,x=e,E=t;let S={...E};S.isLocalExpression=!0;let D=x.params?.map(u3(S))??[],O=u1(x.body,S)??[];if(O&&Array.isArray(O))for(let e of O)D.includes(e)||E.variables.add(e);return;case"MemberExpression":let P;return d=e,f=t,u1(d.object,f),void((P={...f}).isLocalExpression=!0,u1(d.property,P));case"ArrayExpression":return p=e,h=t,void p.elements?.map(u3(h));case"SequenceExpression":return m=e,y=t,void m.expressions?.map(u3(y));case"NewExpression":return g=e,b=t,void g.arguments?.map(u3(b));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 v=e,w=t,void(v.expressions?.map(u3(w)),v.quasis?.map(u3(w)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function u3(e){return function(t){return null===t?null:u1(t,e)}}uT.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:uA,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=uA,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)})}}),uT.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"}})}}),uT.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)})}}),uT.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")}})}}),uT.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 :")}})}}),uT.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})}}),uT.addBinaryOp("in",7),uT.addBinaryOp("??",1);let u4=z("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 u2(e,t,r){u4.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function u6(e){return u4.getState().flags[e].enabled}function u5(e){return!window.offlineEnabled||(e??navigator.onLine)}u4.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 u8=ez(function(e,t,r){eN(e,t,r)});function u9(e,t=!0,r=!1){return!!(e?t:r)}let u7=K("extensionsInternal",{slots:{},extensions:{}}),ce=K("extensionRenderings",{renderings:new Map}),ct=()=>z("extensionsInternal",{slots:{},extensions:{}});function cr(e){let t=u7.getState(),r=e(t);r!==t&&u7.setState(r)}let cn=null,ci=null;function co(){let e=ce.getState();return cn&&e===ci||(cn=new Map(e.renderings),ci=e,function(e){for(let t of(cu.clear(),e.values()))cd(t,1);cc=!0}(cn)),cn}function ca(e){ci={renderings:e},ce.setState(ci,!0)}let cs=()=>z("extensions",{slots:{}});function cl(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}let cu=new Map,cc=!1;function cd(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=cu.get(r);if(!n){if(t<0)return;cu.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),cc=!0;return}n.count+=t,n.count<1&&(cu.delete(r),cc=!0)}function cf(){var e,t;if(co(),!cc)return;cc=!1;let r=Array.from(cu.values(),({record:e})=>e);r.sort(cp),e=tL.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===cp(e,t[r]))||tL.setState({mountedExtensions:r})}function cp(e,t){return ch(e.slotName,t.slotName)||ch(e.extensionId,t.extensionId)||ch(e.slotModuleName,t.slotModuleName)||ch(e.extensionModuleName,t.extensionModuleName)}function ch(e,t){return e===t?0:e<t?-1:1}cf(),ce.subscribe(()=>cl(cf));let cm=ct(),cy=cs(),cg=tB(),cb=tV(),cv=new Set,c_=!1;function cw(e){if(null===e)cv=null;else if(null!==cv)for(let t of e)cv.add(t);cl(cx)}function cx(){if(!c_){c_=!0;try{for(let e=1;;e++){let t=cv;if(null!==t&&0===t.size)return;cv=new Set;try{!function(e,t,r,n,i,o=null){let a=cy.getState().slots,s={},l=!1,u=u5(),c=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,f]of Object.entries(e.slots)){var d;let p=a[n];if(p&&o&&!o.has(n)){s[n]=p;continue}let{config:h}=(d=f.name,t.slots[d]??{loaded:!1,config:{}}),m=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}=cm.getState();return[...t,...r].filter(e=>!n.includes(e)).sort((e,r)=>cR(e,i,o[cO(e)]?.order,t)-cR(r,i,o[cO(r)]?.order,t))}(r,t.slots[e].attachedIds),l=[];for(let u of s){let{config:s}=tU(n,e,u),c=r.configure?.[u]??null,d=c?u8({},s,c):s,f=cO(u),p=t.extensions[f];if(p){let e=d?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!iu(e,a.user))||p.featureFlag&&!i.includes(p.featureFlag)||window.offlineEnabled&&!u9(o,p.online,p.offline))continue;l.push({id:u,name:f,moduleName:p.moduleName,config:d,featureFlag:p.featureFlag,meta:p.meta,online:d?.["Display conditions"]?.online??p.online??!0,offline:d?.["Display conditions"]?.offline??p.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||p.displayExpression})}}return l}(n,e,h,r,c,u,i.session);p&&p.moduleName===f.moduleName&&ti(p.candidateExtensions,m)?s[n]=p:(s[n]={moduleName:f.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&cy.setState({slots:s})}(cm.getState(),cg.getState(),cb.getState(),u4.getState(),it.getState(),t)}catch(e){throw cv=null===t||null===cv?null:new Set([...t,...cv]),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{c_=!1}}}function cE(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 cS(){cw(null)}function cD(e,t){return{moduleName:t,name:e,attachedIds:[]}}function cO(e){let[t]=e.split("#");return t}function cP(e){var t;let r;return t=cm.getState(),r=cO(e),t.extensions[r]}cm.subscribe((e,t)=>{cw(e.extensions!==t.extensions?null:cE(e.slots,t.slots))}),cg.subscribe((e,t)=>{cw(cE(e.slots,t.slots))}),cb.subscribe((e,t)=>{cw(cE(e.configs,t.configs))}),u4.subscribe(()=>cw(null)),it.subscribe(()=>cw(null)),cS(),g(cS);let cC=e=>cr(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function ck(e,t){cr(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...cD(e),attachedIds:[t]}}}})}function cj(e,t){cr(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 cT(e){cr(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function cR(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 cA(e,t){var r;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!!uL(o,i)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}((r=e,cy.getState().slots[r]?.candidateExtensions??[]),t,it.getState().session,e)}let cM=(e,t)=>cm.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=cD(t,e);return{...r,slots:{...r.slots,[t]:{...i}}}}),cN=K("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function cI({name:e,basePath:t,mode:r,componentContext:n,state:i}){cN.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:i})}function c$(e){cN.getState().slotName===e&&cN.setState(cN.getInitialState(),!0)}let cL=0,cF=null,cB={bootstrap:15e3,mount:15e3,unmount:15e3};function cV(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(cB).filter(t=>e[t]).map(n=>{var i,o;let a,s;return[n,(i=e[n],o=cB[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 cU(e,t){var r,n;let i,o,a,s,l,u=await (cF??(cF=new Promise((e,t)=>{nt({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),nt))),cF),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=>cV(e,r)):cV(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 cW(e,t){let r,n=cU(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 cK(e,t,r,n,i=e=>e,o={}){let a=cO(n),s=cP(n),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:c,moduleName:d,online:f,offline:p,load:h}=s;if(function(e=!0,t=!1){return u9(u5(),e,t)}(f,p)){let s,f=cL++,p=`${t}/${n}-${f}`;e.dataset.extensionRenderingId=p;let m=e=>{try{let e,t;(t=(e=co()).get(p))&&(e.delete(p),cd(t,-1),ca(e))}catch(t){console.error(e,t)}};try{var u;let e;u={renderingId:p,extensionName:a,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r},(e=co()).has(u.renderingId)||(e.set(u.renderingId,u),cd(u,1),ca(e))}catch(e){throw m(`Recomputing configuration after registering '${n}' failed also failed`),e}try{s=await h()}catch(e){throw m(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await cU(i({...s,name:`${t}/${a}-${f}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d},domElement:e})}catch(e){throw m(`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),m(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>m(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),m(`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}function cH(){return{current:"unavailable",notAvailable:!0,active:!1}}let cz="x-omrs-offline-response-body",cq="x-omrs-offline-response-status",cG="x-omrs-offline-caching-strategy",cZ="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cY=new Uint8Array(16),cJ=[];for(let e=0;e<256;++e)cJ.push((e+256).toString(16).slice(1));let cQ=function(e,t,r){if(cZ&&!t&&!e)return cZ();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(cY)})();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 cJ[e[t+0]]+cJ[e[t+1]]+cJ[e[t+2]]+cJ[e[t+3]]+"-"+cJ[e[t+4]]+cJ[e[t+5]]+"-"+cJ[e[t+6]]+cJ[e[t+7]]+"-"+cJ[e[t+8]]+cJ[e[t+9]]+"-"+cJ[e[t+10]]+cJ[e[t+11]]+cJ[e[t+12]]+cJ[e[t+13]]+cJ[e[t+14]]+cJ[e[t+15]]}(n)},cX="OFFLINE+";function c0(){return cX+cQ()}function c1(e){return e.startsWith(cX)}var c3=r(47499),c4=r.n(c3);function c2({to:e,templateParams:t,onBeforeNavigate:r,children:n,...i}){return(0,c3.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}`)},[]),c4().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),nX({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:nJ(e,t),...i},n)}let c6=K("modalRegistry",{modals:{}}),c5=K("workspaceRegistrations",{workspaces:{}}),c8=K("workspaceGroups",{workspaceGroups:{}}),c9=new Set;function c7(e){let t=c5.getState().workspaces;if(t[e])return t[e];{let t=cP(e);if(t){var r;let n;return c9.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.`),c9.add(e)),{name:t.name,title:(r=t,"string"==typeof(n=r?.meta?.title)?n:n&&"object"==typeof n?oa(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.`)}}let de=K("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function dt(e){let{openedWindows:t}=de.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}let dr=(0,c3.createContext)({moduleName:"",featureName:""});function dn(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 di=e=>e;function da(e,t=di,r){let n=(0,c3.useCallback)(t=>e.subscribe(t),[e]),i=(0,c3.useCallback)(()=>t(e.getState()),[e,t]),o=(0,c3.useSyncExternalStore)(n,i,i),a=(0,c3.useMemo)(()=>r?dn(e,r):null,[e,r]);return(0,c3.useMemo)(()=>a?{...o,...a}:o,[o,a])}function ds(e,t){return da(e,di,t)}function dl(e){return function(t){let r=(0,c3.useCallback)(t=>e.subscribe(t),[]),n=(0,c3.useCallback)(()=>e.getState(),[]),i=(0,c3.useSyncExternalStore)(r,n,n),o=(0,c3.useMemo)(()=>t?dn(e,t):null,[t]);return(0,c3.useMemo)(()=>o?{...i,...o}:i,[i,o])}}let du=[];Object.freeze(du);let dc={candidateExtensions:du};Object.freeze(dc);let dd=e=>{let t=(0,c3.useCallback)(t=>t.slots?.[e]??dc,[e]);return da(cs(),t)},df=e=>e.session;function dp(e,t){let r,{candidateExtensions:n}=dd(e),i=da(it,df),o=(M((r=(0,c3.useRef)(t)).current,t)||(r.current=t),r.current);return(0,c3.useMemo)(()=>cA(e,o),[e,o,i,n])}function dh(e,t){let{moduleName:r}=(0,c3.useContext)(dr);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,c3.useEffect)(()=>{cM(r,e)},[r,e]),{extensions:dp(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function dm(e){return e}function dy({name:e,extensionSlotName:t,select:r=dm,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,c3.useRef)(null),{extensions:u,extensionSlotModuleName:c}=dh(s,i),d=(0,c3.useMemo)(()=>r(u),[r,u]),f=(0,c3.useMemo)(()=>{if("function"==typeof n&&!c4().isValidElement(n))return d.map(e=>n(e,i))},[n,d]);return c4().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)=>c4().createElement(dr.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},f?.[t]??("function"!=typeof n?n:null)??c4().createElement(fW,{state:i}))))}var dg=r(5338);function db(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 dv(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?db(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)):db(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function d_(e){return(d_="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 dw(e){return(dw="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 dx(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(dw(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(dw(e)));return e}}var dE=null;try{dE=require("react").createContext()}catch(e){}var dS={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 dD(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function dO(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=dj(e,t,function(){r(this)}),a=dx(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:dk(e),renderType:"function"==typeof(i=e).renderType?i.renderType():i.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function dP(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():dk(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function dC(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=dj(e,t,null),i=e.renderResults[t.name];if(i&&i.render)i.render(n);else{var o=dx(e,t)();dk(e).render(n,o)}})}function dk(e){return e.ReactDOMClient||e.ReactDOM}function dj(e,t,r){var n=e.React.createElement(e.rootComponent,t),i=dE?e.React.createElement(dE.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,dv(dv({},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 dT=r(58779),dR=r(59324),dA=r(14993);let dM={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},dN=new Map;(0,dA.r2)(dN);let dI={errorRetryCount:3,fetcher:n9,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof ie){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>dN};function d$(e,t){return function(e){if("object"!==d_(e))throw Error("single-spa-react requires a configuration object");var t,r=dv(dv({},dS),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");!dE&&r.React.createContext&&(dE=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:dD.bind(null,r),mount:dO.bind(null,r),unmount:dP.bind(null,r)};return r.parcelCanUpdate&&(n.update=dC.bind(null,r)),n}({React:c4(),ReactDOMClient:dg,rootComponent:(function(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},dM,e),r={...dI,...t.swrConfig};return function(e){var n,i,o,a,s;return o=i=class extends(n=c4().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 c4().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=c4().createElement(c3.Suspense,{fallback:null},c4().createElement(dR.BE,{value:r},c4().createElement(dr.Provider,{value:this.state.config},t.disableTranslations?c4().createElement(e,this.props):c4().createElement(dT.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},c4().createElement(e,this.props)))));return t.strictMode&&c4().StrictMode?c4().createElement(c4().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}})(t)(e)})}function dL(e,t){return()=>e().then(({default:e})=>d$(e,t))}function dF(e,t){return()=>Promise.resolve(d$(e,t))}let dB=dL,dV=new Map;function dU(e,t){let r=(0,c3.useRef)(t??{}),n=(0,c3.useRef)(t=>iE(e,t)),i=(0,c3.useRef)(Symbol());return(0,c3.useEffect)(()=>{let r=t??{},n=i.current;return null===ix(e)?i_(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.`),iE(e,()=>r)),dV.set(e,n),()=>{dV.get(e)===n&&(iw(e),dV.delete(e))}},[e]),(0,c3.useEffect)(()=>{let n=t??{};M(r.current,n)||(iE(e,()=>n),r.current=n)},[t]),n.current}function dW({namespace:e,value:t}){return dU(e,t),null}let dK=({children:e,value:t,fallback:r})=>t?c4().createElement(c4().Fragment,null,e):r?c4().createElement(c4().Fragment,null,r):null;function dH(){let e=(0,c3.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,c3.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function dz(e,t=e=>e??{}){let[r,n]=(0,c3.useState)(()=>{if(dq(e))return;let r=ix(e);if(null!==r)return t?t(r):r});return(0,c3.useEffect)(()=>{if(dq(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,c3.useEffect)(()=>iS(e,e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>M(e,r)?e:r)}),[e,t]),r}function dq(e){return"string"!=typeof e||0===e.trim().length}function dG(e){let t=dp(e);return(0,c3.useMemo)(()=>t.map(e=>e.id),[t])}function dZ(e,t){let{data:r,error:n,mutate:i,isLoading:o,isValidating:a}=(0,dR.Ay)(`${og}?patient=${e}&includeEncounterless=${t}`,n9);return(0,c3.useMemo)(()=>({isLoading:o,data:r?.data.results??[],error:n,mutate:i,isValidating:a}),[r,n,o,a,i])}function dY(e){(0,c3.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let dJ={},dQ=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function dX(e){let{moduleName:t,extension:r}=(0,c3.useContext)(dr),n=e?.externalModuleName??t;if(!n&&!r)throw Error(dQ);let i=function(e){let t=(0,c3.useMemo)(()=>tF(e),[e]),r=function(e){let[t,r]=(0,c3.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,c3.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw dJ[e]||(dJ[e]=new Promise(e=>{let r=t.subscribe(t=>{t.loaded&&t.config&&(e(t.config),r())})})),dJ[e];return r}(n),o=function(e){let t=(0,c3.useMemo)(tV,[]),r=function(e,t){let[r,n]=(0,c3.useState)(t?()=>{let r=tU(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,c3.useEffect)(()=>{if(t)return e.subscribe(e=>{let i=tU(e,t.extensionSlotName,t.extensionId);i.loaded&&i.config&&!ti(i.config,r)&&n(i.config)})},[e,t,r]),r}(t,e);if(!r&&e){let r=`${e.extensionSlotName}-${e.extensionId}`;throw!dJ[r]&&t&&(dJ[r]=new Promise(r=>{let n=t.subscribe(t=>{let i=tU(t,e.extensionSlotName,e.extensionId);i.loaded&&i.config&&(r(i.config),n())})})),dJ[r]}return r||{}}(r);return(0,c3.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...i}:{...i,...o},[n,e?.externalModuleName,i,o])}let d0=dp;function d1(){let[e,t]=(0,c3.useState)(u5());return(0,c3.useEffect)(()=>g(({online:e})=>t(e)),[]),e}function d3(e,t=300){let[r,n]=(0,c3.useState)(e);return(0,c3.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var d4=r(54225);let d2=`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 d6(){let e=`${n2}/emrapi/configuration?v=${d2}`,t=(0,d4.A)(e,n9);return(0,c3.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function d5(e){let t=dp(e);return(0,c3.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}dl(ct());let d8=dl(cs());function d9(e){let{flags:t}=da(u4);return t[e]?.enabled??!1}function d7(){let[,e]=(0,c3.useState)(0);return(0,c3.useCallback)(()=>{e(e=>e+1)},[])}function fe(e,t,r={}){return fr(e,t,ft,r)}let ft={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(n8(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 fr(e,t,r,n={}){let{getPaginatedUrl:i,getTotalCount:o,getCurrentPageSize:a,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??n9,[d,f]=(0,c3.useState)(1),p=(0,c3.useRef)(NaN),h=(0,c3.useRef)(NaN),m=(0,c3.useRef)(d),y=(0,c3.useRef)(!1),g=(0,c3.useRef)(!1),b=e?.toString()??"",[v,w]=(0,c3.useState)(b);b!==v&&(w(b),f(1),m.current=1,p.current=NaN,h.current=NaN,y.current=!1,g.current=!1);let x=(d-1)*t,E=(0,c3.useMemo)(()=>i(e,t,x),[e,t,x]),{data:S,...D}=(l?d4.A:dR.Ay)(E,c,u);S?.data&&(p.current=o(S?.data),h.current=a(S?.data),y.current=!0);let O=Math.ceil(p.current/t),P=(0,c3.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(p.current/t);!y.current||Number.isNaN(r)||e<=r?(m.current=e,f(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,c3.useEffect)(()=>{if(!y.current)return;if(Number.isNaN(p.current)){g.current||(g.current=!0,console.warn(`useServerPagination: ${b} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(p.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),m.current=e,f(e))},[d,t,b,S]);let C=(0,c3.useCallback)(()=>{P(m.current+1)},[P]),k=(0,c3.useCallback)(()=>{P(m.current-1)},[P]);return{data:s(S?.data),totalPages:O,totalCount:p.current,currentPage:d,currentPageSize:h.current,paginated:O>1,showNextButton:d<O,showPreviousButton:d>1,goTo:P,goToNext:C,goToPrevious:k,...D}}function fn(e,t,r={}){return fr(e,t,fi(),r)}function fi(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(n8(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 fo=r(19888);let fa=c4().use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;if("rejected"===e.status)throw e.reason;throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}),fs={dedupe:!0};dA.qv.defineProperty(dA.BE,"defaultValue",{value:dA.sb});let fl=(0,dA.qm)((e,t,r)=>{let{cache:n,compare:i,suspense:o,fallbackData:a,revalidateOnMount:s,revalidateIfStale:l,refreshInterval:u,refreshWhenHidden:c,refreshWhenOffline:d,keepPreviousData:f}=r,[p,h,m,y]=dA.bZ.get(n),[g,b]=(0,dA.lK)(e),v=(0,c3.useRef)(!1),w=(0,c3.useRef)(!1),x=(0,c3.useRef)(g),E=(0,c3.useRef)(t),S=(0,c3.useRef)(r),D=()=>S.current.isVisible()&&S.current.isOnline(),[O,P,C,k]=(0,dA.r9)(n,g),j=(0,c3.useRef)({}).current,T=(0,dA.b0)(a)?r.fallback[g]:a,R=(e,t)=>{for(let r in j)if("data"===r){if(!i(e[r],t[r])&&(!(0,dA.b0)(e[r])||!i(V,t[r])))return!1}else if(t[r]!==e[r])return!1;return!0},A=(0,c3.useMemo)(()=>{let e=!!g&&!!t&&((0,dA.b0)(s)?!S.current.isPaused()&&!o&&(!!(0,dA.b0)(l)||l):s),r=t=>{let r=(0,dA.rL)(t);return(delete r._k,e)?{isValidating:!0,isLoading:!0,...r}:r},n=O(),i=k(),a=r(n),u=n===i?a:r(i),c=a;return[()=>{let e=r(O());return R(e,c)?(c.data=e.data,c.isLoading=e.isLoading,c.isValidating=e.isValidating,c.error=e.error,c):(c=e,e)},()=>u]},[n,g]),M=(0,fo.useSyncExternalStore)((0,c3.useCallback)(e=>C(g,(t,r)=>{R(r,t)||e()}),[n,g]),A[0],A[1]),N=!v.current,I=p[g]&&p[g].length>0,$=M.data,L=(0,dA.b0)($)?T:$,F=M.error,B=(0,c3.useRef)(L),V=f?(0,dA.b0)($)?B.current:$:L,U=(!I||!!(0,dA.b0)(F))&&(N&&!(0,dA.b0)(s)?s:!S.current.isPaused()&&(o?!(0,dA.b0)(L)&&l:(0,dA.b0)(L)||l)),W=!!(g&&t&&N&&U),K=(0,dA.b0)(M.isValidating)?W:M.isValidating,H=(0,dA.b0)(M.isLoading)?W:M.isLoading,z=(0,c3.useCallback)(async e=>{let t,n,o=E.current;if(!g||!o||w.current||S.current.isPaused())return!1;let a=!0,s=e||{},l=!m[g]||!s.dedupe,u=()=>dA.dO?!w.current&&g===x.current&&v.current:g===x.current,c={isValidating:!1,isLoading:!1},d=()=>{P(c)},f=()=>{let e=m[g];e&&e[1]===n&&delete m[g]},y={isValidating:!0};(0,dA.b0)(O().data)&&(y.isLoading=!0);try{if(l&&(P(y),r.loadingTimeout&&(0,dA.b0)(O().data)&&setTimeout(()=>{a&&u()&&S.current.onLoadingSlow(g,r)},r.loadingTimeout),m[g]=[o(b),(0,dA.lg)()]),[t,n]=m[g],t=await t,l&&setTimeout(f,r.dedupingInterval),!m[g]||m[g][1]!==n)return l&&u()&&S.current.onDiscarded(g),!1;c.error=dA.ZH;let e=h[g];if(!(0,dA.b0)(e)&&(n<=e[0]||n<=e[1]||0===e[1]))return d(),l&&u()&&S.current.onDiscarded(g),!1;let s=O().data;c.data=i(s,t)?s:t,l&&u()&&S.current.onSuccess(t,g,r)}catch(r){f();let e=S.current,{shouldRetryOnError:t}=e;!e.isPaused()&&(c.error=r,l&&u()&&(e.onError(r,g,e),(!0===t||(0,dA.Tn)(t)&&t(r))&&(!S.current.revalidateOnFocus||!S.current.revalidateOnReconnect||D())&&e.onErrorRetry(r,g,e,e=>{let t=p[g];t&&t[0]&&t[0](dA.bu.ERROR_REVALIDATE_EVENT,e)},{retryCount:(s.retryCount||0)+1,dedupe:!0})))}return a=!1,d(),!0},[g,n]),q=(0,c3.useCallback)((...e)=>(0,dA.mF)(n,x.current,...e),[]);if((0,dA.Es)(()=>{E.current=t,S.current=r,(0,dA.b0)($)||(B.current=$)}),(0,dA.Es)(()=>{if(!g)return;let e=z.bind(dA.ZH,fs),t=0,r=(0,dA.aw)(g,p,(r,n={})=>{if(r==dA.bu.FOCUS_EVENT){let r=Date.now();S.current.revalidateOnFocus&&r>t&&D()&&(t=r+S.current.focusThrottleInterval,e())}else if(r==dA.bu.RECONNECT_EVENT)S.current.revalidateOnReconnect&&D()&&e();else if(r==dA.bu.MUTATE_EVENT)return z();else if(r==dA.bu.ERROR_REVALIDATE_EVENT)return z(n)});return w.current=!1,x.current=g,v.current=!0,P({_k:b}),U&&((0,dA.b0)(L)||dA.X3?e():(0,dA.mf)(e)),()=>{w.current=!0,r()}},[g]),(0,dA.Es)(()=>{let e;function t(){let t=(0,dA.Tn)(u)?u(O().data):u;t&&-1!==e&&(e=setTimeout(r,t))}function r(){!O().error&&(c||S.current.isVisible())&&(d||S.current.isOnline())?z(fs).then(t):t()}return t(),()=>{e&&(clearTimeout(e),e=-1)}},[u,c,d,g]),(0,c3.useDebugValue)(V),o&&(0,dA.b0)(L)&&g){if(!dA.dO&&dA.X3)throw Error("Fallback data is required when using suspense in SSR.");E.current=t,S.current=r,w.current=!1;let e=y[g];if((0,dA.b0)(e)||fa(q(e)),(0,dA.b0)(F)){let e=z(fs);(0,dA.b0)(V)||(e.status="fulfilled",e.value=!0),fa(e)}else throw F}return{mutate:q,get data(){return j.data=!0,V},get error(){return j.error=!0,F},get isValidating(){return j.isValidating=!0,K},get isLoading(){return j.isLoading=!0,H}}}),fu=Promise.resolve(),fc=(0,dA.Ht)(fl,e=>(t,r,n)=>{let i,o=(0,c3.useRef)(!1),{cache:a,initialSize:s=1,revalidateAll:l=!1,persistSize:u=!1,revalidateFirstPage:c=!0,revalidateOnMount:d=!1,parallel:f=!1}=n,[,,,p]=dA.bZ.get(dA.PP);try{(i=(0,dA.lK)(t?t(0,null):null)[0])&&(i=dA.q9+i)}catch(e){}let[h,m,y]=(0,dA.r9)(a,i),g=(0,c3.useCallback)(()=>(0,dA.b0)(h()._l)?s:h()._l,[a,i,s]);(0,fo.useSyncExternalStore)((0,c3.useCallback)(e=>i?y(i,()=>{e()}):()=>{},[a,i]),g,g);let b=(0,c3.useCallback)(()=>{let e=h()._l;return(0,dA.b0)(e)?s:e},[i,s]),v=(0,c3.useRef)(b());(0,dA.Es)(()=>{if(!o.current){o.current=!0;return}i&&m({_l:u?v.current:b()})},[i,a]);let w=d&&!o.current,x=e(i,async e=>{let i=h()._i,o=h()._r;m({_r:dA.ZH});let s=[],u=b(),[d]=(0,dA.r9)(a,e),y=d().data,g=[],v=null;for(let e=0;e<u;++e){let[u,d]=(0,dA.lK)(t(e,f?null:v));if(!u)break;let[h,m]=(0,dA.r9)(a,u),b=h().data,x=l||i||(0,dA.b0)(b)||c&&!e&&!(0,dA.b0)(y)||w||y&&!(0,dA.b0)(y[e])&&!n.compare(y[e],b);if(r&&("function"==typeof o?o(b,d):x)){let t=async()=>{if(u in p){let e=p[u];delete p[u],b=await e}else b=await r(d);m({data:b,_k:d}),s[e]=b};f?g.push(t):await t()}else s[e]=b;f||(v=b)}return f&&await Promise.all(g.map(e=>e())),m({_i:dA.ZH}),s},n),E=(0,c3.useCallback)(function(e,t){let r="boolean"==typeof t?{revalidate:t}:t||{},n=!1!==r.revalidate;return i?(n&&((0,dA.b0)(e)?m({_i:!0,_r:r.revalidate}):m({_i:!1,_r:r.revalidate})),arguments.length?x.mutate(e,{...r,revalidate:n}):x.mutate()):fu},[i,a]),S=(0,c3.useCallback)(e=>{let r;if(!i)return fu;let[,n]=(0,dA.r9)(a,i);if((0,dA.Tn)(e)?r=e(b()):"number"==typeof e&&(r=e),"number"!=typeof r)return fu;n({_l:r}),v.current=r;let o=[],[s]=(0,dA.r9)(a,i),l=null;for(let e=0;e<r;++e){let[r]=(0,dA.lK)(t(e,l)),[n]=(0,dA.r9)(a,r),i=r?n().data:dA.ZH;if((0,dA.b0)(i))return E(s().data);o.push(i),l=i}return E(o)},[i,a,E,b]);return{size:b(),setSize:S,mutate:E,get data(){return x.data},get error(){return x.error},get isValidating(){return x.isValidating},get isLoading(){return x.isLoading}}});function fd(e,t={}){return ff(e,ft,t)}function ff(e,t,r={}){let{swrInfiniteConfig:n,immutable:i}=r,{getNextUrl:o,getTotalCount:a,getData:s}=t,l=r.fetcher??n9,{data:u,size:c,setSize:d,...f}=fc((0,c3.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),l,{...n,...i?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),p=o(u?.[u.length-1].data),h=a(u?.[0]?.data);return{data:u?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=p,loadMore:()=>{d((u?.length??0)+1)},nextUri:p,...f}}function fp(e,t={}){return fh(e,ft,t)}function fh(e,t,r={}){let n=ff(e,t,r),{hasMore:i,error:o,data:a,loadMore:s,isLoading:l,nextUri:u}=n;return((0,c3.useEffect)(()=>{i&&!o&&s()},[i,u]),r.partialData)?n:{...n,data:i||o?void 0:a,isLoading:l||i}}function fm(e,t={}){return fh(e,fi(),t)}function fy(e,t={}){return ff(e,fi(),t)}function fg(){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 fb(){let[e,t]=(0,c3.useState)(fg);return(0,c3.useEffect)(()=>{let e=()=>{t(fg())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let fv=e=>"small-desktop"===e||"large-desktop"===e;function f_(e){let t=(0,c3.useContext)(dr);(0,c3.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),cI(e),()=>{c$(e.name)}),[t,e])}function fw(){return da(cN)}function fx(e=null,t=null){let[r,n]=(0,c3.useState)([]);return(0,c3.useEffect)(()=>{let r=uk(e,t).subscribe(e=>{n(e)},e=>{console.error(e)});return()=>r.unsubscribe()},[e,t]),r}function fE(e,t=!0){let r=(0,c3.useRef)(null);return(0,c3.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 fS(e){let t=(0,c3.useRef)();return(0,c3.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 fD(e,t={}){let{abortController:r,fetchInit:n,url:i,swrConfig:o}=t,a=dH(),s=(0,c3.useMemo)(()=>n?.signal??r?.signal??a.signal,[r?.signal,n?.signal,a.signal]),l=(0,c3.useCallback)(e=>n9(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(0,dR.Ay)(e,l,o)}function fO(e=[],t=10){let[r,n]=(0,c3.useState)(1),i=(0,c3.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,c3.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,c3.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,c3.useCallback)(()=>{n(e=>e+1)},[]),u=(0,c3.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,c3.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 fP(e,t,r,n){return{pageSizes:(0,c3.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,c3.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function fC(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function fk(e){let[t,r]=(0,c3.useState)(e??fC()),{data:n,error:i,isValidating:o}=(0,dR.Ay)(t?["patient",t]:null,()=>uf(t,{}));return(0,c3.useEffect)(()=>{let e=()=>{let e=fC();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,c3.useMemo)(()=>({isLoading:o&&!i&&!n,patient:n,patientUuid:t,error:i}),[o,i,n,t])}function fj(){let e=`${n2}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=(0,dR.Ay)(e,n9);return(0,c3.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function fT(e){let{extensions:t,extensionSlotModuleName:r}=dh(e);return e?t.map(t=>({state:n})=>c4().createElement(dr.Provider,{value:{moduleName:r,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:r}}},c4().createElement(fW,{state:n}))):[]}function fR(){let e=(0,c3.useRef)(),[t,r]=(0,c3.useState)(null),n=null;if(!t){if(s){let e=io().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(io().getState()),n||(e.current=io().subscribe(r))});if(n)r(n);else throw s}(0,c3.useEffect)(()=>(e.current||(e.current=io().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 fA=({privilege:e,fallback:t,children:r})=>{let[n,i]=(0,c3.useState)(null);return((0,c3.useEffect)(()=>{let e=ii({includeAuthStatus:!1}).subscribe(i);return()=>e.unsubscribe()},[]),n&&iu(e,n))?c4().createElement(c4().Fragment,null,r):t?c4().createElement(c4().Fragment,null,t):null};var fM=r(74353),fN=r.n(fM),fI=r(47581);let f$=new Map;function fL(){for(let e of Array.from(f$.values()))e()}let fF={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function fB(e){let t=(0,c3.useId)();return(0,c3.useEffect)(()=>{if(e)return f$.set(t,e),()=>{f$.delete(t)}},[t,e]),{...ds(uv(),fF),mutateVisit:fL}}function fV(e,t=ug){let r=(0,c3.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:i,setVisitContext:o}=fB((0,c3.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:f}=(0,dR.Ay)(e?`${n2}/visit${s}`:null,n9),{data:p,error:h,mutate:m,isValidating:y}=(0,dR.Ay)(e&&a?`${n2}/visit${l}`:null,n9),g=(0,c3.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),b=(0,c3.useMemo)(()=>a&&p?p.data:null,[p,a]),v=(0,c3.useRef)(null);(0,c3.useEffect)(()=>{!f&&g&&n===e&&null===i&&o(g),y||(v.current&&b&&v.current.uuid===b.uuid&&!v.current.stopDatetime&&b.stopDatetime&&o(null),v.current=b)},[b,i,g,f,y,n]);let w=(0,c3.useCallback)(()=>{d(),m()},[d,m]);(0,c3.useEffect)(()=>{r.current=w},[w]);let x=!!(!u||a&&!p),E=!!(a?h:c);return{error:c||h,mutate:w,isValidating:f||y,activeVisit:g,currentVisit:b,currentVisitIsRetrospective:!!a,isLoading:x&&!E}}function fU(){let[e,t]=(0,c3.useState)([]);return(0,c3.useEffect)(()=>{let e=uP().subscribe(e=>{t(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}fM.extend(fI);let fW=({state:e,children:t,...r})=>{let{extension:n}=(0,c3.useContext)(dr),i=(0,c3.useRef)(null),o=(0,c3.useRef)(Promise.resolve()),a=(0,c3.useRef)(!1),s=(0,c3.useRef)(!1),l=(0,c3.useRef)(e),u=(0,c3.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,c3.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,c3.useCallback)(t=>{t&&!i.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,cK(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,c3.useEffect)(()=>(a.current=!1,()=>{a.current=!0,u(i.current)}),[]),(0,c3.useEffect)(()=>{l.current=e,i.current&&c(i.current,e)},[e]),n?c4().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};var fK=r(74848),fH=r(46942),fz=r.n(fH);function fq({title:e,children:t}){let r="tablet"===fb();return(0,fK.jsxs)("div",{className:fz()({"-esm-form-builder__card-header-module__tabletHeader___rUYi0":r,"-esm-form-builder__card-header-module__desktopHeader___CDa37":!r}),children:[(0,fK.jsx)("h4",{children:e}),t]})}var fG=r(68108);let fZ="-esm-form-builder__custom-overflow-menu-module__container___lY3iq",fY="-esm-form-builder__custom-overflow-menu-module__menu___dReHr",fJ="-esm-form-builder__custom-overflow-menu-module__show___48R0e",fQ="-esm-form-builder__custom-overflow-menu-module__overflowMenuButton___tsY8r",fX=(0,c3.createContext)(null);function f0(){let e=(0,c3.useContext)(fX);if(!e)throw Error("useCustomOverflowMenu must be used within a CustomOverflowMenu");return e}function f1({menuTitle:e,children:t}){let[r,n]=c4().useState(!1),i=fE(()=>n(!1),r),o="tablet"===fb(),a=(0,c3.useCallback)(()=>n(e=>!e),[]),s=(0,c3.useRef)(null),l=(0,c3.useRef)(null),u=(0,c3.useId)(),c=`custom-overflow-menu-trigger-${u}`,d=`custom-overflow-menu-${u}`,f=(0,c3.useCallback)(()=>{n(!1),s.current?.focus()},[]),p=(0,c3.useMemo)(()=>({closeMenu:f}),[f]),h=(0,c3.useCallback)(e=>{"Escape"===e.key&&r&&(e.stopPropagation(),f())},[f,r]),m=c3.Children.toArray(t);(0,c3.useEffect)(()=>{if(r&&l.current){let e=l.current.querySelector('[role="menuitem"]:not([disabled])');e?.focus()}},[r]);let y=(0,c3.useCallback)(({currentIndex:e,direction:t})=>{let r=l.current?.querySelectorAll('[role="menuitem"]:not([disabled])');if(!r?.length)return;let n=document.activeElement?.closest?.('[role="menuitem"]')??document.activeElement,i=Array.from(r).indexOf(n);if(-1===i)return void r[t>0?0:r.length-1]?.focus();let o=i+t,a=o<0?r.length-1:o>=r.length?0:o;r[a]?.focus()},[]),g=m.map((e,t)=>(0,c3.isValidElement)(e)?(0,c3.cloneElement)(e,{closeMenu:f,handleOverflowMenuItemFocus:y,index:t}):e);return(0,fK.jsxs)("div",{"data-overflow-menu":!0,className:fz()("cds--overflow-menu",fZ),ref:i,children:[(0,fK.jsx)("button",{className:fz()("cds--btn","cds--btn--ghost","cds--overflow-menu__trigger",{"cds--overflow-menu--open":r},fQ),"aria-controls":d,"aria-expanded":r,"aria-haspopup":"true",id:c,onClick:a,onKeyDown:h,ref:s,children:e}),(0,fK.jsxs)("div",{className:fz()("cds--overflow-menu-options","cds--overflow-menu--flip",fY,{[fJ]:r}),"aria-labelledby":c,"data-floating-menu-direction":"bottom",id:d,onKeyDown:h,ref:l,role:"menu",tabIndex:-1,children:[(0,fK.jsx)("ul",{className:fz()("cds--overflow-menu-options__content",{"cds--overflow-menu-options--lg":o}),children:(0,fK.jsx)(fX.Provider,{value:p,children:g})}),(0,fK.jsx)("span",{})]})]})}function f3(e){let t=(0,c3.useContext)(fX);return(0,fK.jsx)(fG.XSD,{...e,closeMenu:t?.closeMenu})}let f4={"carbon.table.batch.cancel":"cancel","carbon.table.batch.items.selected":"batchActionsItemsSelected","carbon.table.batch.item.selected":"batchActionItemSelected","carbon.table.batch.selectAll":"selectAll"},f2=e=>(0,fK.jsx)(fG.GGC,{translateWithId:(e,t)=>{let r=f4[e];return r?os(r,e,t):e},...e});var f6=r(47767),f5=r(84976);let f8=["omrs-icon-activity","omrs-icon-add","omrs-icon-arrow-down","omrs-icon-arrow-left","omrs-icon-arrow-right","omrs-icon-arrow-up","omrs-icon-baby","omrs-icon-calendar-heat-map","omrs-icon-calendar","omrs-icon-caret-down","omrs-icon-caret-left","omrs-icon-caret-right","omrs-icon-caret-up","omrs-icon-chart-average","omrs-icon-chart-line","omrs-icon-checkmark-filled","omrs-icon-checkmark-outline","omrs-icon-chemistry","omrs-icon-chevron-down","omrs-icon-chevron-left","omrs-icon-chevron-right","omrs-icon-chevron-up","omrs-icon-close","omrs-icon-close-filled","omrs-icon-close-outline","omrs-icon-document","omrs-icon-document-attachment","omrs-icon-download","omrs-icon-drug-order","omrs-icon-edit","omrs-icon-event-schedule","omrs-icon-events","omrs-icon-gender-female","omrs-icon-gender-male","omrs-icon-gender-other","omrs-icon-gender-unknown","omrs-icon-generic-order-type","omrs-icon-group","omrs-icon-group-access","omrs-icon-hospital-bed","omrs-icon-image-medical","omrs-icon-information","omrs-icon-information-filled","omrs-icon-information-square","omrs-icon-inventory-management","omrs-icon-lab-order","omrs-icon-list-checked","omrs-icon-location","omrs-icon-material-order","omrs-icon-maximize","omrs-icon-medication","omrs-icon-message-queue","omrs-icon-microscope","omrs-icon-mobile-check","omrs-icon-money","omrs-icon-mother","omrs-icon-movement","omrs-icon-overflow-menu--horizontal","omrs-icon-overflow-menu--vertical","omrs-icon-password","omrs-icon-pedestrian-family","omrs-icon-pen","omrs-icon-printer","omrs-icon-procedure-order","omrs-icon-programs","omrs-icon-renew","omrs-icon-referral-order","omrs-icon-report","omrs-icon-reset","omrs-icon-save","omrs-icon-search","omrs-icon-settings","omrs-icon-shopping-cart","omrs-icon-shopping-cart--arrow-down","omrs-icon-sticky-note-add","omrs-icon-switcher","omrs-icon-syringe","omrs-icon-table-of-contents","omrs-icon-table","omrs-icon-time","omrs-icon-tools","omrs-icon-translate","omrs-icon-trash-can","omrs-icon-tree-view--alt","omrs-icon-two-factor-authentication","omrs-icon-user-avatar","omrs-icon-user-follow","omrs-icon-user-xray","omrs-icon-user","omrs-icon-view-off","omrs-icon-view","omrs-icon-warning"],f9=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-activity",iconProps:e})})),f7=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-add",iconProps:e})})),pe=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-arrow-down",iconProps:e})})),pt=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-arrow-left",iconProps:e})})),pr=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-arrow-right",iconProps:e})})),pn=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-arrow-up",iconProps:e})})),pi=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-baby",iconProps:e})})),po=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-calendar-heat-map",iconProps:e})})),pa=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-calendar",iconProps:e})})),ps=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-caret-down",iconProps:e})})),pl=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-caret-left",iconProps:e})})),pu=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-caret-right",iconProps:e})})),pc=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-caret-up",iconProps:e})})),pd=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-chart-average",iconProps:e})})),pf=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-chart-line",iconProps:e})})),pp=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-checkmark-filled",iconProps:e})})),ph=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-checkmark-outline",iconProps:e})})),pm=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-chemistry",iconProps:e})})),py=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-chevron-down",iconProps:e})})),pg=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-chevron-left",iconProps:e})})),pb=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-chevron-right",iconProps:e})})),pv=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-chevron-up",iconProps:e})})),p_=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-close",iconProps:e})})),pw=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-close-filled",iconProps:e})})),px=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-close-outline",iconProps:e})})),pE=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-document",iconProps:e})})),pS=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-document-attachment",iconProps:e})})),pD=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-download",iconProps:e})})),pO=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-drug-order",iconProps:e})})),pP=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-edit",iconProps:e})})),pC=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-event-schedule",iconProps:e})})),pk=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-events",iconProps:e})})),pj=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-gender-female",iconProps:e})})),pT=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-gender-male",iconProps:e})})),pR=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-gender-other",iconProps:e})})),pA=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-gender-unknown",iconProps:e})})),pM=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-generic-order-type",iconProps:e})})),pN=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-group",iconProps:e})})),pI=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-group-access",iconProps:e})})),p$=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-hospital-bed",iconProps:e})})),pL=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-image-medical",iconProps:e})})),pF=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-information",iconProps:e})})),pB=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-information-filled",iconProps:e})})),pV=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-information-square",iconProps:e})})),pU=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-inventory-management",iconProps:e})})),pW=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-lab-order",iconProps:e})})),pK=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-list-checked",iconProps:e})})),pH=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-location",iconProps:e})})),pz=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-material-order",iconProps:e})})),pq=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-maximize",iconProps:e})})),pG=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-medication",iconProps:e})})),pZ=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-message-queue",iconProps:e})})),pY=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-microscope",iconProps:e})})),pJ=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-mobile-check",iconProps:e})})),pQ=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-money",iconProps:e})})),pX=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-mother",iconProps:e})})),p0=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-movement",iconProps:e})})),p1=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-overflow-menu--horizontal",iconProps:e})})),p3=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-overflow-menu--horizontal",iconProps:e})})),p4=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-password",iconProps:e})})),p2=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-pedestrian-family",iconProps:e})})),p6=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-pen",iconProps:e})})),p5=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-printer",iconProps:e})})),p8=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-procedure-order",iconProps:e})})),p9=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-programs",iconProps:e})})),p7=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-referral-order",iconProps:e})})),he=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-renew",iconProps:e})})),ht=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-report",iconProps:e})})),hr=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-reset",iconProps:e})})),hn=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-save",iconProps:e})})),hi=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-search",iconProps:e})})),ho=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-settings",iconProps:e})})),ha=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-switcher",iconProps:e})})),hs=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-shopping-cart",iconProps:e})})),hl=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-shopping-cart--arrow-down",iconProps:e})})),hu=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-sticky-note-add",iconProps:e})})),hc=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-syringe",iconProps:e})})),hd=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-table-of-contents",iconProps:e})})),hf=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-table",iconProps:e})})),hp=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-time",iconProps:e})})),hh=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-tools",iconProps:e})})),hm=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-translate",iconProps:e})})),hy=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-trash-can",iconProps:e})})),hg=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-tree-view--alt",iconProps:e})})),hb=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-two-factor-authentication",iconProps:e})})),hv=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-user-avatar",iconProps:e})})),h_=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-user-follow",iconProps:e})})),hw=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-user-xray",iconProps:e})})),hx=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-user",iconProps:e})})),hE=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-view-off",iconProps:e})})),hS=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-view",iconProps:e})})),hD=(0,c3.memo)((0,c3.forwardRef)(function(e,t){return(0,fK.jsx)(hR,{ref:t,icon:"omrs-icon-warning",iconProps:e})})),hO=hD,hP=pS,hC=pK,hk=pL,hj=hl,hT=(0,c3.memo)((0,c3.forwardRef)(function({icon:e,fallback:t,...r},n){let i=(0,c3.useRef)(e?document.getElementById(e):void 0);return(0,c3.useEffect)(()=>{let t=document.getElementById("omrs-svgs-container"),r=new MutationObserver(t=>{for(let r of t)"childList"===r.type&&(i.current=e?document.getElementById(e):void 0)});return t&&r.observe(t,{childList:!0}),()=>r.disconnect()},[e]),(0,fK.jsx)(dK,{value:i.current,fallback:t,children:(0,fK.jsx)(hR,{ref:n,icon:e,iconProps:r})})})),hR=(0,c3.memo)((0,c3.forwardRef)(function({icon:e,iconProps:t},r){let{className:n,fill:i,size:o}=Object.assign({},{fill:"currentColor",size:20},t);(o<=0||o>72)&&(console.error(`Invalid size '${o}' specified for ${e}. Defaulting to 20.`),o=20);let a=(0,c3.useRef)(null);return(0,c3.useImperativeHandle)(r,()=>a.current),(0,c3.useEffect)(()=>{a.current&&"currentColor"!==i&&a.current.style.setProperty("--omrs-icon-fill",i)},[]),(0,fK.jsx)("svg",{ref:a,className:fz()("omrs-icon","-esm-form-builder__icons-module__icon___sq7Qp",n),height:o,width:o,viewBox:"0 0 16 16",children:(0,fK.jsx)("use",{href:`#${e}`})})})),hA=({path:e,title:t,basePath:r,icon:n})=>{let{t:i}=(0,dT.useTranslation)(),o=(0,f6.zy)(),a=(0,c3.useMemo)(()=>{if(!e)return!1;let t=e.startsWith("/")?e.slice(1):e;if(t.startsWith("http"))return t===window.location.href;let r=t.split("/").map(e=>decodeURIComponent(e)),n=(o.pathname??"").split("/").slice(1).map(e=>decodeURIComponent(e));return n.some((e,t)=>r.every((e,r)=>n[t+r]===e))},[o.pathname,e]);return(0,fK.jsx)("div",{children:(0,fK.jsx)(c2,{className:fz()("cds--side-nav__link",{"active-left-nav-link":a}),to:`${r}/${encodeURIComponent(e)}`,children:(0,fK.jsxs)("span",{className:"-esm-form-builder__dashboard-module__menu___Lg1M+",children:[(0,fK.jsx)(hT,{icon:n,className:"-esm-form-builder__dashboard-module__icon___Y2DxK",size:16}),(0,fK.jsx)("span",{children:i(t)})]})})},e)};function hM(e){return function({basePath:t}){return(0,fK.jsx)(f5.Kd,{children:(0,fK.jsx)(hA,{basePath:t,...e})})}}function hN(e){let t=(0,c3.useRef)(null),r=(0,c3.useRef)(void 0),n=(0,c3.useCallback)(t=>{if("function"==typeof e){let r=e(t);return()=>{"function"==typeof r?r():e(null)}}if(e)return e.current=t,()=>{e.current=null}},[e]);return(0,c3.useMemo)(()=>({get current(){return t.current},set current(value){t.current=value,r.current&&(r.current(),r.current=void 0),null!=value&&(r.current=n(value))}}),[n])}function hI(...e){return 1===e.length&&e[0]?e[0]:t=>{let r=!1,n=e.map(e=>{let n=h$(e,t);return r||="function"==typeof n,n});if(r)return()=>{n.forEach((t,r)=>{"function"==typeof t?t():h$(e[r],null)})}}}function h$(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function hL(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}let hF="u">typeof document?c4().useLayoutEffect:()=>{},hB={prefix:String(Math.round(1e10*Math.random())),current:0},hV=c4().createContext(hB),hU=c4().createContext(!1),hW=("u">typeof window&&window.document&&window.document.createElement,new WeakMap),hK="function"==typeof c4().useId?function(e){let t=c4().useId(),[r]=(0,c3.useState)(hG()),n=r?"react-aria":`react-aria${hB.prefix}`;return e||`${n}-${t}`}:function(e){let t=(0,c3.useContext)(hV),r=function(e=!1){let t=(0,c3.useContext)(hV),r=(0,c3.useRef)(null);if(null===r.current&&!e){let e=c4().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentOwner?.current;if(e){let r=hW.get(e);null==r?hW.set(e,{id:t.current,state:e.memoizedState}):e.memoizedState!==r.state&&(t.current=r.id,hW.delete(e))}r.current=++t.current}return r.current}(!!e),n=`react-aria${t.prefix}`;return e||`${n}-${r}`};function hH(){return!1}function hz(){return!0}function hq(e){return()=>{}}function hG(){return"function"==typeof c4().useSyncExternalStore?c4().useSyncExternalStore(hq,hH,hz):(0,c3.useContext)(hU)}let hZ=!!("u">typeof window&&window.document&&window.document.createElement),hY=new Map;function hJ(e){let[t,r]=(0,c3.useState)(e),n=(0,c3.useRef)(null),i=hK(t),o=(0,c3.useRef)(null);if(l&&l.register(o,i),hZ){let e=hY.get(i);e&&!e.includes(n)?e.push(n):hY.set(i,[n])}return hF(()=>()=>{l&&l.unregister(o),hY.delete(i)},[i]),(0,c3.useEffect)(()=>{let e=n.current;return e&&r(e),()=>{e&&(n.current=null)}}),i}function hQ(e=[]){let t=hJ(),[r,n]=function(e){let[t,r]=(0,c3.useState)(e),n=(0,c3.useRef)(t),i=(0,c3.useRef)(null),o=(0,c3.useRef)(()=>{if(!i.current)return;let e=i.current.next();if(e.done){i.current=null;return}n.current===e.value?o.current():r(e.value)});return hF(()=>{n.current=t,i.current&&o.current()}),[t,(0,c3.useCallback)(e=>{i.current=e(n.current),o.current()},[o])]}(t),i=(0,c3.useCallback)(()=>{n(function*(){yield t,yield document.getElementById(t)?t:void 0})},[t,n]);return hF(i,[t,i,...e]),r}"u">typeof FinalizationRegistry&&(l=new FinalizationRegistry(e=>{hY.delete(e)}));let hX=function(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=function e(t){var r,n,i="";if("string"==typeof t||"number"==typeof t)i+=t;else if("object"==typeof t)if(Array.isArray(t)){var o=t.length;for(r=0;r<o;r++)t[r]&&(n=e(t[r]))&&(i&&(i+=" "),i+=n)}else for(n in t)t[n]&&(i&&(i+=" "),i+=n);return i}(e))&&(n&&(n+=" "),n+=t);return n};function h0(...e){let t={...e[0]};for(let r=1;r<e.length;r++){let n=e[r];for(let e in n){let r=t[e],i=n[e];"function"==typeof r&&"function"==typeof i&&"o"===e[0]&&"n"===e[1]&&e.charCodeAt(2)>=65&&90>=e.charCodeAt(2)?t[e]=hL(r,i):("className"===e||"UNSAFE_className"===e)&&"string"==typeof r&&"string"==typeof i?t[e]=hX(r,i):"id"===e&&r&&i?t.id=function(e,t){if(e===t)return e;let r=hY.get(e);if(r)return r.forEach(e=>e.current=t),t;let n=hY.get(t);return n?(n.forEach(t=>t.current=e),e):t}(r,i):"ref"===e&&r&&i?t.ref=hI(r,i):t[e]=void 0!==i?i:r}}return t}let h1=Symbol("default");function h3({values:e,children:t}){for(let[r,n]of e)t=c4().createElement(r.Provider,{value:n},t);return t}function h4(e){let{className:t,style:r,children:n,defaultClassName:i,defaultChildren:o,defaultStyle:a,values:s}=e;return(0,c3.useMemo)(()=>{let e,l,u;return e="function"==typeof t?t({...s,defaultClassName:i}):t,l="function"==typeof r?r({...s,defaultStyle:a||{}}):r,u="function"==typeof n?n({...s,defaultChildren:o}):null==n?o:n,{className:null!=e?e:i,style:l||a?{...a,...l}:void 0,children:null!=u?u:o,"data-rac":""}},[t,r,n,i,o,a,s])}function h2(e,t){let r=(0,c3.useContext)(e);if(null===t)return null;if(r&&"object"==typeof r&&"slots"in r&&r.slots){let e=t||h1;if(!r.slots[e]){let e=new Intl.ListFormat().format(Object.keys(r.slots).map(e=>`"${e}"`)),n=t?`Invalid slot "${t}".`:"A slot prop is required.";throw Error(`${n} Valid slot names are ${e}.`)}return r.slots[e]}return r}function h6(e,t,r){let{ref:n,...i}=h2(r,e.slot)||{},o=hN((0,c3.useMemo)(()=>hI(t,n),[t,n])),a=h0(i,e);return"style"in i&&i.style&&"style"in e&&e.style&&("function"==typeof i.style||"function"==typeof e.style?a.style=t=>{let r="function"==typeof i.style?i.style(t):i.style,n={...t.defaultStyle,...r},o="function"==typeof e.style?e.style({...t,defaultStyle:n}):e.style;return{...n,...o}}:a.style={...i.style,...e.style}),[a,o]}function h5(e=!0){let[t,r]=(0,c3.useState)(e),n=(0,c3.useRef)(!1),i=(0,c3.useCallback)(e=>{n.current=!0,r(!!e)},[]);return hF(()=>{n.current||r(!1)},[]),[i,t]}function h8(e){let t=/^(data-.*)$/,r={};for(let n in e)t.test(n)||(r[n]=e[n]);return r}let h9=(0,c3.createContext)(null),h7=null;function me(e,t="assertive",r=7e3){h7?h7.announce(e,t,r):(h7=new mt,("boolean"==typeof IS_REACT_ACT_ENVIRONMENT?IS_REACT_ACT_ENVIRONMENT:"u">typeof jest)?h7.announce(e,t,r):setTimeout(()=>{(null==h7?void 0:h7.isAttached())&&(null==h7||h7.announce(e,t,r))},100))}class mt{isAttached(){var e;return null==(e=this.node)?void 0:e.isConnected}createLog(e){let t=document.createElement("div");return t.setAttribute("role","log"),t.setAttribute("aria-live",e),t.setAttribute("aria-relevant","additions"),t}destroy(){this.node&&(document.body.removeChild(this.node),this.node=null)}announce(e,t="assertive",r=7e3){var n,i;if(!this.node)return;let o=document.createElement("div");"object"==typeof e?(o.setAttribute("role","img"),o.setAttribute("aria-labelledby",e["aria-labelledby"])):o.textContent=e,"assertive"===t?null==(n=this.assertiveLog)||n.appendChild(o):null==(i=this.politeLog)||i.appendChild(o),""!==e&&setTimeout(()=>{o.remove()},r)}clear(e){this.node&&((!e||"assertive"===e)&&this.assertiveLog&&(this.assertiveLog.innerHTML=""),(!e||"polite"===e)&&this.politeLog&&(this.politeLog.innerHTML=""))}constructor(){this.node=null,this.assertiveLog=null,this.politeLog=null,"u">typeof document&&(this.node=document.createElement("div"),this.node.dataset.liveAnnouncer="true",Object.assign(this.node.style,{border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"}),this.assertiveLog=this.createLog("assertive"),this.node.appendChild(this.assertiveLog),this.politeLog=this.createLog("polite"),this.node.appendChild(this.politeLog),document.body.prepend(this.node))}}let mr=new Set(["id"]),mn=new Set(["aria-label","aria-labelledby","aria-describedby","aria-details"]),mi=new Set(["href","hrefLang","target","rel","download","ping","referrerPolicy"]),mo=new Set(["dir","lang","hidden","inert","translate"]),ma=new Set(["onClick","onAuxClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onGotPointerCapture","onLostPointerCapture","onScroll","onWheel","onAnimationStart","onAnimationEnd","onAnimationIteration","onTransitionCancel","onTransitionEnd","onTransitionRun","onTransitionStart"]),ms=/^(data-.*)$/;function ml(e,t={}){let{labelable:r,isLink:n,global:i,events:o=i,propNames:a}=t,s={};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(mr.has(t)||r&&mn.has(t)||n&&mi.has(t)||i&&mo.has(t)||o&&(ma.has(t)||t.endsWith("Capture")&&ma.has(t.slice(0,-7)))||a?.has(t)||ms.test(t))&&(s[t]=e[t]);return s}function mu(e){if(function(){if(null==mc){mc=!1;try{document.createElement("div").focus({get preventScroll(){return mc=!0,!0}})}catch{}}return mc}())e.focus({preventScroll:!0});else{let t=function(e){let t=e.parentNode,r=[],n=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==n;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&r.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return n instanceof HTMLElement&&r.push({element:n,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft}),r}(e);e.focus(),function(e){for(let{element:t,scrollTop:r,scrollLeft:n}of e)t.scrollTop=r,t.scrollLeft=n}(t)}}let mc=null,md=e=>e?.ownerDocument??document,mf=e=>e&&"window"in e&&e.window===e?e:md(e).defaultView||window;function mp(e,t){return!!t&&!!e&&e.contains(t)}function mh(e){return e.target}function mm(e){if(!e)return!1;let t=e.getRootNode(),r=mf(e);if(!(t instanceof r.Document||t instanceof r.ShadowRoot))return!1;let n=t.activeElement;return null!=n&&e.contains(n)}let my="u">typeof Element&&"checkVisibility"in Element.prototype;function mg(e,t){return my?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):"#comment"!==e.nodeName&&function(e){let t=mf(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:r,visibility:n}=e.style,i="none"!==r&&"hidden"!==n&&"collapse"!==n;if(i){let{getComputedStyle:t}=e.ownerDocument.defaultView,{display:r,visibility:n}=t(e);i="none"!==r&&"hidden"!==n&&"collapse"!==n}return i}(e)&&!e.hasAttribute("hidden")&&!e.hasAttribute("data-react-aria-prevent-focus")&&("DETAILS"!==e.nodeName||!t||"SUMMARY"===t.nodeName||e.hasAttribute("open"))&&(!e.parentElement||mg(e.parentElement,e))}let mb=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable^="false"])',"permission"],mv=mb.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";mb.push('[tabindex]:not([tabindex="-1"]):not([disabled])');let m_=mb.join(':not([hidden]):not([tabindex="-1"]),');function mw(e,t){return e.matches(mv)&&!mE(e)&&(t?.skipVisibilityCheck||mg(e))}function mx(e){return e.matches(m_)&&mg(e)&&!mE(e)}function mE(e){let t=e;for(;null!=t;){if(t instanceof t.ownerDocument.defaultView.HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}function mS(e){return e.nativeEvent=e,e.isDefaultPrevented=()=>e.defaultPrevented,e.isPropagationStopped=()=>e.cancelBubble,e.persist=()=>{},e}function mD(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function mO(e){let t=(0,c3.useRef)({isFocused:!1,observer:null});return hF(()=>{let e=t.current;return()=>{e.observer&&(e.observer.disconnect(),e.observer=null)}},[]),(0,c3.useCallback)(r=>{let n=mh(r);(n instanceof HTMLButtonElement||n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement)&&(t.current.isFocused=!0,n.addEventListener("focusout",r=>{if(t.current.isFocused=!1,n.disabled){let t=mS(r);e?.(t)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)},{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&n.disabled){t.current.observer?.disconnect();let e=n===((e=document)=>e.activeElement)()?null:((e=document)=>e.activeElement)();n.dispatchEvent(new FocusEvent("blur",{relatedTarget:e})),n.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:e}))}}),t.current.observer.observe(n,{attributes:!0,attributeFilter:["disabled"]}))},[e])}let mP=!1;function mC(e){if("u"<typeof window||null==window.navigator)return!1;let t=window.navigator.userAgentData?.brands;return Array.isArray(t)&&t.some(t=>e.test(t.brand))||e.test(window.navigator.userAgent)}function mk(e){return"u">typeof window&&null!=window.navigator&&e.test(window.navigator.userAgentData?.platform||window.navigator.platform)}function mj(e){let t=null;return()=>(null==t&&(t=e()),t)}let mT=mj(function(){return mk(/^Mac/i)}),mR=mj(function(){return mk(/^iPhone/i)}),mA=mj(function(){return mk(/^iPad/i)||mT()&&navigator.maxTouchPoints>1}),mM=mj(function(){return mR()||mA()});mj(function(){return mT()||mM()});let mN=mj(function(){return mC(/AppleWebKit/i)&&!mI()}),mI=mj(function(){return mC(/Chrome/i)}),m$=mj(function(){return mC(/Android/i)}),mL=mj(function(){return mC(/Firefox/i)});function mF(e){return""===e.pointerType&&!!e.isTrusted||(m$()&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType)}function mB(e,t,r=!0){let{metaKey:n,ctrlKey:i,altKey:o,shiftKey:a}=t;mL()&&window.event?.type?.startsWith("key")&&"_blank"===e.target&&(mT()?n=!0:i=!0);let s=mN()&&mT()&&!mA()&&1?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:n,ctrlKey:i,altKey:o,shiftKey:a}):new MouseEvent("click",{metaKey:n,ctrlKey:i,altKey:o,shiftKey:a,detail:1,bubbles:!0,cancelable:!0});mB.isOpening=r,mu(e),e.dispatchEvent(s),mB.isOpening=!1}mB.isOpening=!1;let mV=null,mU=new Set,mW=new Map,mK=!1,mH=!1,mz={Tab:!0,Escape:!0};function mq(e,t){for(let r of mU)r(e,t)}function mG(e){mK=!0,mB.isOpening||e.metaKey||!mT()&&e.altKey||e.ctrlKey||"Control"===e.key||"Shift"===e.key||"Meta"===e.key||(mV="keyboard",mq("keyboard",e))}function mZ(e){mV="pointer","pointerType"in e&&e.pointerType,("mousedown"===e.type||"pointerdown"===e.type)&&(mK=!0,mq("pointer",e))}function mY(e){!mB.isOpening&&mF(e)&&(mK=!0,mV="virtual")}function mJ(e){let t=mf(mh(e)),r=md(mh(e));mh(e)!==t&&mh(e)!==r&&!mP&&e.isTrusted&&(mK||mH||(mV="virtual",mq("virtual",e)),mK=!1,mH=!1)}function mQ(){mP||(mK=!1,mH=!0)}function mX(e){if("u"<typeof window||"u"<typeof document)return;let t=mf(e),r=md(e);if(mW.get(t))return;let n=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){mK=!0,n.apply(this,arguments)},r.addEventListener("keydown",mG,!0),r.addEventListener("keyup",mG,!0),r.addEventListener("click",mY,!0),t.addEventListener("focus",mJ,!0),t.addEventListener("blur",mQ,!1),"u">typeof PointerEvent&&(r.addEventListener("pointerdown",mZ,!0),r.addEventListener("pointermove",mZ,!0),r.addEventListener("pointerup",mZ,!0)),t.addEventListener("beforeunload",()=>{m0(e)},{once:!0}),mW.set(t,{focus:n})}let m0=(e,t)=>{let r=mf(e),n=md(e);t&&n.removeEventListener("DOMContentLoaded",t),mW.has(r)&&(r.HTMLElement.prototype.focus=mW.get(r).focus,n.removeEventListener("keydown",mG,!0),n.removeEventListener("keyup",mG,!0),n.removeEventListener("click",mY,!0),r.removeEventListener("focus",mJ,!0),r.removeEventListener("blur",mQ,!1),"u">typeof PointerEvent&&(n.removeEventListener("pointerdown",mZ,!0),n.removeEventListener("pointermove",mZ,!0),n.removeEventListener("pointerup",mZ,!0)),mW.delete(r))};function m1(){return"pointer"!==mV}"u">typeof document&&("loading"!==(p=md(void 0)).readyState?mX(void 0):p.addEventListener("DOMContentLoaded",()=>{mX(void 0)}));let m3=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),m4=new Map,m2=new Set;function m6(){if("u"<typeof window)return;function e(e){return"propertyName"in e}let t=r=>{let n=mh(r);if(!e(r)||!n)return;let i=m4.get(n);if(i&&(i.delete(r.propertyName),0===i.size&&(n.removeEventListener("transitioncancel",t),m4.delete(n)),0===m4.size)){for(let e of m2)e();m2.clear()}};document.body.addEventListener("transitionrun",r=>{let n=mh(r);if(!e(r)||!n)return;let i=m4.get(n);i||(i=new Set,m4.set(n,i),n.addEventListener("transitioncancel",t,{once:!0})),i.add(r.propertyName)}),document.body.addEventListener("transitionend",t)}function m5(e){requestAnimationFrame(()=>{for(let[e]of m4)"isConnected"in e&&!e.isConnected&&m4.delete(e);0===m4.size?e():m2.add(e)})}function m8(e){if(!e.isConnected)return;let t=md(e);if("virtual"===mV){let r=((e=document)=>e.activeElement)(t);m5(()=>{let n=((e=document)=>e.activeElement)(t);(n===r||n===t.body)&&e.isConnected&&mu(e)})}else mu(e)}function m9(e){let{isDisabled:t,onFocus:r,onBlur:n,onFocusChange:i}=e,o=(0,c3.useCallback)(e=>{if(mh(e)===e.currentTarget)return n&&n(e),i&&i(!1),!0},[n,i]),a=mO(o),s=(0,c3.useCallback)(e=>{let t=mh(e),n=md(t),o=n?((e=document)=>e.activeElement)(n):((e=document)=>e.activeElement)();t===e.currentTarget&&t===o&&(r&&r(e),i&&i(!0),a(e))},[i,r,a]);return{focusProps:{onFocus:!t&&(r||i||n)?s:void 0,onBlur:!t&&(n||i)?o:void 0}}}function m7(e){if(!e)return;let t=!0;return r=>{e({...r,preventDefault(){r.preventDefault()},isDefaultPrevented:()=>r.isDefaultPrevented(),stopPropagation(){t=!0},continuePropagation(){t=!1},isPropagationStopped:()=>t}),t&&r.stopPropagation()}}function ye(e,t){hF(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}"u">typeof document&&("loading"!==document.readyState?m6():document.addEventListener("DOMContentLoaded",m6));let yt=c4().createContext(null);function yr(e,t){let{focusProps:r}=m9(e),{keyboardProps:n}={keyboardProps:e.isDisabled?{}:{onKeyDown:m7(e.onKeyDown),onKeyUp:m7(e.onKeyUp)}},i=h0(r,n),o=function(e){let t=(0,c3.useContext)(yt)||{};ye(t,e);let{ref:r,...n}=t;return n}(t),a=e.isDisabled?{}:o,s=(0,c3.useRef)(e.autoFocus);(0,c3.useEffect)(()=>{s.current&&t.current&&m8(t.current),s.current=!1},[t]);let l=e.excludeFromTabOrder?-1:0;return e.isDisabled&&(l=void 0),{focusableProps:h0({...i,tabIndex:l},a)}}c4().forwardRef(function(e,t){let{children:r,...n}=e,i=hN(t),o={...n,ref:i};return c4().createElement(yt.Provider,{value:o},r)});let yn="default",yi="",yo=new WeakMap;function ya(e){if(mM())"disabled"===yn&&(yn="restoring",setTimeout(()=>{m5(()=>{if("restoring"===yn){let t=md(e);"none"===t.documentElement.style.webkitUserSelect&&(t.documentElement.style.webkitUserSelect=yi||""),yi="",yn="default"}})},300));else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&yo.has(e)){let t=yo.get(e),r="userSelect"in e.style?"userSelect":"webkitUserSelect";"none"===e.style[r]&&(e.style[r]=t),""===e.getAttribute("style")&&e.removeAttribute("style"),yo.delete(e)}}function ys(e){let t=e?.defaultView;return t?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let yl=new WeakMap;function yu(e){let t=e??("u">typeof document?document:void 0);if(!t)return ys(t);if(yl.has(t))return yl.get(t);let r=t.querySelector('meta[property="csp-nonce"]'),n=r&&r instanceof mf(r).HTMLMetaElement&&(r.nonce||r.content)||ys(t)||void 0;return void 0!==n&&yl.set(t,n),n}let yc=c4().createContext({register:()=>{}});yc.displayName="PressResponderContext";let yd=c4().useInsertionEffect??hF;function yf(e){let t=(0,c3.useRef)(null);return yd(()=>{t.current=e},[e]),(0,c3.useCallback)((...e)=>{let r=t.current;return r?.(...e)},[])}function yp(){let e=(0,c3.useRef)(new Map),t=(0,c3.useCallback)((t,r,n,i)=>{let o=i?.once?(...t)=>{e.current.delete(n),n(...t)}:n;e.current.set(n,{type:r,eventTarget:t,fn:o,options:i}),t.addEventListener(r,o,i)},[]),r=(0,c3.useCallback)((t,r,n,i)=>{let o=e.current.get(n)?.fn||n;t.removeEventListener(r,o,i),e.current.delete(n)},[]),n=(0,c3.useCallback)(()=>{e.current.forEach((e,t)=>{r(e.eventTarget,e.type,t,e.options)})},[r]);return(0,c3.useEffect)(()=>n,[n]),{addGlobalListener:t,removeGlobalListener:r,removeAllGlobalListeners:n}}var yh=r(54575),ym=r.n(yh);class yy{#e;constructor(e,t,r,n){this.#e=!0;let i=n?.target??r.currentTarget;const o=i?.getBoundingClientRect();let a,s=0,l,u=null;null!=r.clientX&&null!=r.clientY&&(l=r.clientX,u=r.clientY),o&&(null!=l&&null!=u?(a=l-o.left,s=u-o.top):(a=o.width/2,s=o.height/2)),this.type=e,this.pointerType=t,this.target=r.currentTarget,this.shiftKey=r.shiftKey,this.metaKey=r.metaKey,this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.x=a,this.y=s,this.key=r.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}}let yg=Symbol("linkClicked"),yb="react-aria-pressable-style",yv="data-react-aria-pressable";function y_(e){let{onPress:t,onPressChange:r,onPressStart:n,onPressEnd:i,onPressUp:o,onClick:a,isDisabled:s,isPressed:l,preventFocusOnPress:u,shouldCancelOnPointerExit:c,allowTextSelectionOnPress:d,ref:f,...p}=function(e){let t=(0,c3.useContext)(yc);if(t){let{register:r,ref:n,...i}=t;e=h0(i,e),r()}return ye(t,e.ref),e}(e),[h,m]=(0,c3.useState)(!1),y=(0,c3.useRef)({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:g,removeAllGlobalListeners:b}=yp(),v=(0,c3.useCallback)((e,t)=>{let i=y.current;if(s||i.didFirePressStart)return!1;let o=!0;if(i.isTriggeringEvent=!0,n){let r=new yy("pressstart",t,e);n(r),o=r.shouldStopPropagation}return r&&r(!0),i.isTriggeringEvent=!1,i.didFirePressStart=!0,m(!0),o},[s,n,r]),w=(0,c3.useCallback)((e,n,o=!0)=>{let a=y.current;if(!a.didFirePressStart)return!1;a.didFirePressStart=!1,a.isTriggeringEvent=!0;let l=!0;if(i){let t=new yy("pressend",n,e);i(t),l=t.shouldStopPropagation}if(r&&r(!1),m(!1),t&&o&&!s){let r=new yy("press",n,e);t(r),l&&=r.shouldStopPropagation}return a.isTriggeringEvent=!1,l},[s,i,r,t]),x=yf(w),E=yf((0,c3.useCallback)((e,t)=>{let r=y.current;if(s)return!1;if(o){r.isTriggeringEvent=!0;let n=new yy("pressup",t,e);return o(n),r.isTriggeringEvent=!1,n.shouldStopPropagation}return!0},[s,o])),S=(0,c3.useCallback)(e=>{let t=y.current;if(t.isPressed&&t.target){for(let r of(t.didFirePressStart&&null!=t.pointerType&&w(yE(t.target,e),t.pointerType,!1),t.isPressed=!1,t.isOverTarget=!1,t.activePointerId=null,t.pointerType=null,b(),d||ya(t.target),t.disposables))r();t.disposables=[]}},[d,b,w]),D=yf(S),O=(0,c3.useCallback)(e=>{c&&S(e)},[c,S]),P=(0,c3.useCallback)(e=>{s||a?.(e)},[s,a]),C=(0,c3.useCallback)((e,t)=>{if(!s&&a){let r=new MouseEvent("click",e);mD(r,t),a(mS(r))}},[s,a]),k=(0,c3.useMemo)(()=>{let e=y.current,t={onKeyDown(t){if(yx(t.nativeEvent,t.currentTarget)&&mp(t.currentTarget,mh(t))){yS(mh(t),t.key)&&t.preventDefault();let n=!0;e.isPressed||t.repeat||(e.target=t.currentTarget,e.isPressed=!0,e.pointerType="keyboard",n=v(t,"keyboard"));let i=t.currentTarget;g(md(t.currentTarget),"keyup",hL(t=>{yx(t,i)&&!t.repeat&&mp(i,mh(t))&&e.target&&E(yE(e.target,t),"keyboard")},r),!0),n&&t.stopPropagation(),t.metaKey&&mT()&&e.metaKeyEvents?.set(t.key,t.nativeEvent)}else"Meta"===t.key&&(e.metaKeyEvents=new Map)},onClick(t){if((!t||mp(t.currentTarget,mh(t)))&&t&&0===t.button&&!e.isTriggeringEvent&&!mB.isOpening){let r=!0;if(s&&t.preventDefault(),!e.ignoreEmulatedMouseEvents&&!e.isPressed&&("virtual"===e.pointerType||mF(t.nativeEvent))){let e=v(t,"virtual"),n=E(t,"virtual"),i=x(t,"virtual");P(t),r=e&&n&&i}else if(e.isPressed&&"keyboard"!==e.pointerType){let n=e.pointerType||t.nativeEvent.pointerType||"virtual",i=E(yE(t.currentTarget,t),n),o=x(yE(t.currentTarget,t),n,!0);r=i&&o,e.isOverTarget=!1,P(t),D(t)}e.ignoreEmulatedMouseEvents=!1,r&&t.stopPropagation()}}},r=t=>{if(e.isPressed&&e.target&&yx(t,e.target)){yS(mh(t),t.key)&&t.preventDefault();let r=mh(t),n=mp(e.target,r);x(yE(e.target,t),"keyboard",n),n&&C(t,e.target),b(),"Enter"!==t.key&&yw(e.target)&&mp(e.target,r)&&!t[yg]&&(t[yg]=!0,mB(e.target,t,!1)),e.isPressed=!1,e.metaKeyEvents?.delete(t.key)}else if("Meta"===t.key&&e.metaKeyEvents?.size){let t=e.metaKeyEvents;for(let r of(e.metaKeyEvents=void 0,t.values()))e.target?.dispatchEvent(new KeyboardEvent("keyup",r))}};if("u">typeof PointerEvent){t.onPointerDown=t=>{var i;if(0!==t.button||!mp(t.currentTarget,mh(t)))return;if(i=t.nativeEvent,!m$()&&0===i.width&&0===i.height||1===i.width&&1===i.height&&0===i.pressure&&0===i.detail&&"mouse"===i.pointerType){e.pointerType="virtual";return}e.pointerType=t.pointerType;let o=!0;if(!e.isPressed){e.isPressed=!0,e.isOverTarget=!0,e.activePointerId=t.pointerId,e.target=t.currentTarget,d||function(e){if(mM()){if("default"===yn){let t=md(e);yi=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}yn="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";yo.set(e,e.style[t]),e.style[t]="none"}}(e.target),o=v(t,e.pointerType);let i=mh(t);"releasePointerCapture"in i&&("hasPointerCapture"in i?i.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId):i.releasePointerCapture(t.pointerId)),g(md(t.currentTarget),"pointerup",r,!1),g(md(t.currentTarget),"pointercancel",n,!1)}o&&t.stopPropagation()},t.onMouseDown=t=>{if(mp(t.currentTarget,mh(t))&&0===t.button){if(u){let r=function(e){for(;e&&!mw(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=mf(e),r=t.document.activeElement;if(!r||r===e)return;mP=!0;let n=!1,i=e=>{(mh(e)===r||n)&&e.stopImmediatePropagation()},o=t=>{(mh(t)===r||n)&&(t.stopImmediatePropagation(),e||n||(n=!0,mu(r),l()))},a=t=>{(mh(t)===e||n)&&t.stopImmediatePropagation()},s=t=>{(mh(t)===e||n)&&(t.stopImmediatePropagation(),n||(n=!0,mu(r),l()))};t.addEventListener("blur",i,!0),t.addEventListener("focusout",o,!0),t.addEventListener("focusin",s,!0),t.addEventListener("focus",a,!0);let l=()=>{cancelAnimationFrame(u),t.removeEventListener("blur",i,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",s,!0),t.removeEventListener("focus",a,!0),mP=!1,n=!1},u=requestAnimationFrame(l);return l}(t.target);r&&e.disposables.push(r)}t.stopPropagation()}},t.onPointerUp=t=>{mp(t.currentTarget,mh(t))&&"virtual"!==e.pointerType&&(0!==t.button||e.isPressed||E(t,e.pointerType||t.pointerType))},t.onPointerEnter=t=>{t.pointerId===e.activePointerId&&e.target&&!e.isOverTarget&&null!=e.pointerType&&(e.isOverTarget=!0,v(yE(e.target,t),e.pointerType))},t.onPointerLeave=t=>{t.pointerId===e.activePointerId&&e.target&&e.isOverTarget&&null!=e.pointerType&&(e.isOverTarget=!1,x(yE(e.target,t),e.pointerType,!1),O(t))};let r=t=>{if(t.pointerId===e.activePointerId&&e.isPressed&&0===t.button&&e.target){if(mp(e.target,mh(t))&&null!=e.pointerType){let r=!1,n=setTimeout(()=>{e.isPressed&&e.target instanceof HTMLElement&&(r?D(t):(mu(e.target),e.target.click()))},80);g(t.currentTarget,"click",()=>r=!0,!0),e.disposables.push(()=>clearTimeout(n))}else D(t);e.isOverTarget=!1}},n=e=>{D(e)};t.onDragStart=e=>{mp(e.currentTarget,mh(e))&&D(e)}}return t},[g,s,u,b,d,O,v,P,C]);return(0,c3.useEffect)(()=>{if(!f)return;let e=md(f.current);if(!e||!e.head||e.getElementById(yb))return;let t=e.createElement("style");t.id=yb;let r=yu(e);r&&(t.nonce=r),t.textContent=`
|
|
17
17
|
@layer {
|
|
18
18
|
[${yv}] {
|