@openmrs/esm-api 5.3.3-pre.1470 → 5.3.3-pre.1476

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.
@@ -1,4 +1,4 @@
1
- @openmrs/esm-api:build: cache hit, replaying output 9c1b1f27f3e2c6ee
1
+ @openmrs/esm-api:build: cache hit, replaying output 0d5f7416341d0abc
2
2
  @openmrs/esm-api:build: asset openmrs-esm-api.js 53 KiB [emitted] [minimized] (name: main) 2 related assets
3
3
  @openmrs/esm-api:build: orphan modules 439 KiB [orphan] 237 modules
4
4
  @openmrs/esm-api:build: runtime modules 670 bytes 3 modules
@@ -11,4 +11,4 @@
11
11
  @openmrs/esm-api:build:  cacheable modules 138 KiB
12
12
  @openmrs/esm-api:build:  ./src/index.ts + 51 modules 134 KiB [built] [code generated]
13
13
  @openmrs/esm-api:build:  ../esm-state/dist/openmrs-esm-state.js 4.17 KiB [built] [code generated]
14
- @openmrs/esm-api:build: webpack 5.88.0 compiled successfully in 4203 ms
14
+ @openmrs/esm-api:build: webpack 5.88.0 compiled successfully in 4052 ms
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see openmrs-esm-api.js.LICENSE.txt */
2
- System.register(["@openmrs/esm-config","@openmrs/esm-navigation","@openmrs/esm-error-handling","@openmrs/esm-offline"],(function(t,e){var r={},n={},o={},i={};return{setters:[function(t){r.Type=t.Type,r.defineConfigSchema=t.defineConfigSchema,r.getConfig=t.getConfig,r.validators=t.validators},function(t){n.navigate=t.navigate},function(t){o.reportError=t.reportError},function(t){i.getSynchronizationItems=t.getSynchronizationItems}],execute:function(){t((()=>{var t={385:()=>{System.register([],(function(t,e){return{execute:function(){t(function(){"use strict";var t=function(t,e){var r=u[t];if(r)return r.active?console.error("Cannot override an existing store. Make sure that stores are only created once."):r.value.setState(e,!0),r.active=!0,r.value;var n=s()((function(){return e}));return u[t]={value:n,active:!0},n},e=function(t,e){var r=u[t];if(!r){var n=s()((function(){return null!=e?e:{}}));return u[t]={value:n,active:!1},n}return r.value},r=function(t,e,r){var n=e(t.getState());return t.subscribe((function(t){var o=e(t);o!==n&&(n=o,r(o))}))},n={d:function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};n.r(o),n.d(o,{createGlobalStore:function(){return t},getGlobalStore:function(){return e},subscribeTo:function(){return r}});var i=function(t){var e,r=new Set,n=function(t,n){var o="function"==typeof t?t(e):t;if(!Object.is(o,e)){var i=e;e=(null!=n?n:"object"!=typeof o)?o:Object.assign({},e,o),r.forEach((function(t){return t(e,i)}))}},o=function(){return e},i={setState:n,getState:o,subscribe:function(t){return r.add(t),function(){return r.delete(t)}},destroy:function(){console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,o,i),i},s=function(t){return t?i(t):i},u={};return setTimeout((function(){"development"===window.spaEnv&&(window.stores=u)}),1e3),o}())}}}))},824:t=>{"use strict";t.exports=r},254:t=>{"use strict";t.exports=o},513:t=>{"use strict";t.exports=n},738:t=>{"use strict";t.exports=i}},e={};function s(r){var n=e[r];if(void 0!==n)return n.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,s),o.exports}s.d=(t,e)=>{for(var r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return(()=>{"use strict";s.r(u),s.d(u,{OpenmrsFetchError:()=>Fe,VisitMode:()=>Kr,VisitStatus:()=>qr,attachmentUrl:()=>Je,backendDependencies:()=>rn,clearCurrentUser:()=>cr,createAttachment:()=>Ke,defaultVisitCustomRepresentation:()=>Vr,deleteAttachmentPermanently:()=>Qe,fetchCurrentPatient:()=>Pr,fhirBaseUrl:()=>Be,getAttachmentByUuid:()=>ze,getAttachments:()=>Ye,getCurrentUser:()=>ir,getLocations:()=>en,getLoggedInUser:()=>fr,getSessionLocation:()=>pr,getSessionStore:()=>sr,getStartedVisit:()=>Qr,getVisitStore:()=>Fr,getVisitTypes:()=>Zr,getVisitsForPatient:()=>Jr,makeUrl:()=>Ge,openmrsFetch:()=>Ve,openmrsObservableFetch:()=>We,refetchCurrentUser:()=>ar,restBaseUrl:()=>Re,saveVisit:()=>zr,sessionEndpoint:()=>$e,setCurrentVisit:()=>Hr,setSessionLocation:()=>hr,setUserLanguage:()=>ur,setUserProperties:()=>br,setupApiModule:()=>mr,toLocationObject:()=>tn,toVisitTypeObject:()=>Xr,updateVisit:()=>Yr,userHasAccess:()=>lr});var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};function e(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function r(t){return"function"==typeof t}var n=!1,o={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,n=t},get useDeprecatedSynchronousErrorHandling(){return n}};function i(t){setTimeout((function(){throw t}),0)}var a={closed:!0,next:function(t){},error:function(t){if(o.useDeprecatedSynchronousErrorHandling)throw t;i(t)},complete:function(){}},c=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function l(t){return null!==t&&"object"==typeof t}var f=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),p=f,h=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var n=this,o=n._parentOrParents,i=n._ctorUnsubscribe,s=n._unsubscribe,u=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,o instanceof t)o.remove(this);else if(null!==o)for(var a=0;a<o.length;++a)o[a].remove(this);if(r(s)){i&&(this._unsubscribe=void 0);try{s.call(this)}catch(t){e=t instanceof p?d(t.errors):[t]}}if(c(u)){a=-1;for(var f=u.length;++a<f;){var h=u[a];if(l(h))try{h.unsubscribe()}catch(t){e=e||[],t instanceof p?e=e.concat(d(t.errors)):e.push(t)}}}if(e)throw new p(e)}},t.prototype.add=function(e){var r=e;if(!e)return t.EMPTY;switch(typeof e){case"function":r=new t(e);case"object":if(r===this||r.closed||"function"!=typeof r.unsubscribe)return r;if(this.closed)return r.unsubscribe(),r;if(!(r instanceof t)){var n=r;(r=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var o=r._parentOrParents;if(null===o)r._parentOrParents=this;else if(o instanceof t){if(o===this)return r;r._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return r;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[r]:i.push(r),r},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var r=e.indexOf(t);-1!==r&&e.splice(r,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function d(t){return t.reduce((function(t,e){return t.concat(e instanceof p?e.errors:e)}),[])}var b=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),y=function(t){function r(e,n,o){var i=t.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=a;break;case 1:if(!e){i.destination=a;break}if("object"==typeof e){e instanceof r?(i.syncErrorThrowable=e.syncErrorThrowable,i.destination=e,e.add(i)):(i.syncErrorThrowable=!0,i.destination=new m(i,e));break}default:i.syncErrorThrowable=!0,i.destination=new m(i,e,n,o)}return i}return e(r,t),r.prototype[b]=function(){return this},r.create=function(t,e,n){var o=new r(t,e,n);return o.syncErrorThrowable=!1,o},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},r.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},r.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},r}(h),m=function(t){function n(e,n,o,i){var s,u=t.call(this)||this;u._parentSubscriber=e;var c=u;return r(n)?s=n:n&&(s=n.next,o=n.error,i=n.complete,n!==a&&(r((c=Object.create(n)).unsubscribe)&&u.add(c.unsubscribe.bind(c)),c.unsubscribe=u.unsubscribe.bind(u))),u._context=c,u._next=s,u._error=o,u._complete=i,u}return e(n,t),n.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;o.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},n.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,r=o.useDeprecatedSynchronousErrorHandling;if(this._error)r&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)r?(e.syncErrorValue=t,e.syncErrorThrown=!0):i(t),this.unsubscribe();else{if(this.unsubscribe(),r)throw t;i(t)}}},n.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var r=function(){return t._complete.call(t._context)};o.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,r),this.unsubscribe()):(this.__tryOrUnsub(r),this.unsubscribe())}else this.unsubscribe()}},n.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),o.useDeprecatedSynchronousErrorHandling)throw t;i(t)}},n.prototype.__tryOrSetError=function(t,e,r){if(!o.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,r)}catch(e){return o.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(i(e),!0)}return!1},n.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},n}(y),v=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function w(t){return t}var g=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n=this.operator,i=function(t,e,r){if(t){if(t instanceof y)return t;if(t[b])return t[b]()}return t||e||r?new y(t,e,r):new y(a)}(t,e,r);if(n?i.add(n.call(i,this.source)):i.add(this.source||o.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),o.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){o.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),function(t){for(;t;){var e=t,r=e.closed,n=e.destination,o=e.isStopped;if(r||o)return!1;t=n&&n instanceof y?n:null}return!0}(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=E(e))((function(e,n){var o;o=r.subscribe((function(e){try{t(e)}catch(t){n(t),o&&o.unsubscribe()}}),n,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[v]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:(0===(r=t).length?w:1===r.length?r[0]:function(t){return r.reduce((function(t,e){return e(t)}),t)})(this);var r},t.prototype.toPromise=function(t){var e=this;return new(t=E(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function E(t){if(t||(t=o.Promise||Promise),!t)throw new Error("no Promise impl found");return t}const S="object"==typeof global&&global&&global.Object===Object&&global;var O="object"==typeof self&&self&&self.Object===Object&&self;const P=(S||O||Function("return this")()).Symbol;var _=Object.prototype,T=_.hasOwnProperty,j=_.toString,A=P?P.toStringTag:void 0;var x=Object.prototype.toString;var N=P?P.toStringTag:void 0;const D=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":N&&N in Object(t)?function(t){var e=T.call(t,A),r=t[A];try{t[A]=void 0;var n=!0}catch(t){}var o=j.call(t);return n&&(e?t[A]=r:delete t[A]),o}(t):function(t){return x.call(t)}(t)},U=(M=Object.getPrototypeOf,C=Object,function(t){return M(C(t))});var M,C;var k=Function.prototype,L=Object.prototype,I=k.toString,R=L.hasOwnProperty,B=I.call(Object);const $=function(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!=D(t))return!1;var e=U(t);if(null===e)return!0;var r=R.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&I.call(r)==B};var G=s(824),V=s(513),W=s(385);(0,W.createGlobalStore)("breadcrumbs",[]);var F=Object.freeze({__proto__:null,get start(){return Te},get ensureJQuerySupport(){return te},get setBootstrapMaxTime(){return Ct},get setMountMaxTime(){return kt},get setUnmountMaxTime(){return Lt},get setUnloadMaxTime(){return It},get registerApplication(){return pe},get unregisterApplication(){return de},get getMountedApps(){return ae},get getAppStatus(){return le},get unloadApplication(){return be},get checkActivityFunctions(){return he},get getAppNames(){return ce},get pathToActiveWhen(){return ve},get navigateToUrl(){return Ft},get patchHistoryApi(){return Qt},get triggerAppChange(){return Se},get addErrorHandler(){return K},get removeErrorHandler(){return q},get mountRootParcel(){return xt},get NOT_LOADED(){return Z},get LOADING_SOURCE_CODE(){return tt},get NOT_BOOTSTRAPPED(){return et},get BOOTSTRAPPING(){return rt},get NOT_MOUNTED(){return nt},get MOUNTING(){return ot},get UPDATING(){return st},get LOAD_ERROR(){return ct},get MOUNTED(){return it},get UNLOADING(){return at},get UNMOUNTING(){return ut},get SKIP_BECAUSE_BROKEN(){return lt}}),H=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent,J=function(){try{var t=new H("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?H:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,e){var r=document.createEvent("CustomEvent");return e?r.initCustomEvent(t,e.bubbles,e.cancelable,e.detail):r.initCustomEvent(t,!1,!1,void 0),r}:function(t,e){var r=document.createEventObject();return r.type=t,e?(r.bubbles=Boolean(e.bubbles),r.cancelable=Boolean(e.cancelable),r.detail=e.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r};let z=[];function Y(t,e,r){const n=X(t,e,r);z.length?z.forEach((t=>t(n))):setTimeout((()=>{throw n}))}function K(t){if("function"!=typeof t)throw Error(Q(28,!1));z.push(t)}function q(t){if("function"!=typeof t)throw Error(Q(29,!1));let e=!1;return z=z.filter((r=>{const n=r===t;return e=e||n,!n})),e}function Q(t,e,...r){return`single-spa minified message #${t}: ${e?e+" ":""}See https://single-spa.js.org/error/?code=${t}${r.length?`&arg=${r.join("&arg=")}`:""}`}function X(t,e,r){const n=`${bt(e)} '${ht(e)}' died in status ${e.status}: `;let o;if(t instanceof Error){try{t.message=n+t.message}catch(t){}o=t}else{console.warn(Q(30,!1,e.status,ht(e)));try{o=Error(n+JSON.stringify(t))}catch(e){o=t}}return o.appOrParcelName=ht(e),e.status=r,o}const Z="NOT_LOADED",tt="LOADING_SOURCE_CODE",et="NOT_BOOTSTRAPPED",rt="BOOTSTRAPPING",nt="NOT_MOUNTED",ot="MOUNTING",it="MOUNTED",st="UPDATING",ut="UNMOUNTING",at="UNLOADING",ct="LOAD_ERROR",lt="SKIP_BECAUSE_BROKEN";function ft(t){return t.status===it}function pt(t){try{return t.activeWhen(window.location)}catch(e){return Y(e,t,lt),!1}}function ht(t){return t.name}function dt(t){return Boolean(t.unmountThisParcel)}function bt(t){return dt(t)?"parcel":"application"}function yt(){for(let t=arguments.length-1;t>0;t--)for(let e in arguments[t])"__proto__"!==e&&(arguments[t-1][e]=arguments[t][e]);return arguments[0]}function mt(t,e){for(let r=0;r<t.length;r++)if(e(t[r]))return t[r];return null}function vt(t){return t&&("function"==typeof t||(e=t,Array.isArray(e)&&!mt(e,(t=>"function"!=typeof t))));var e}function wt(t,e){let r=t[e]||[];r=Array.isArray(r)?r:[r],0===r.length&&(r=[()=>Promise.resolve()]);const n=bt(t),o=ht(t);return function(t){return r.reduce(((r,i,s)=>r.then((()=>{const r=i(t);return gt(r)?r:Promise.reject(Q(15,!1,n,o,e,s))}))),Promise.resolve())}}function gt(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}let Et=[];function St(t,e){return Promise.resolve().then((()=>t.status!==et?t:(t.status=rt,t.bootstrap?Rt(t,"bootstrap").then(r).catch((r=>{if(e)throw X(r,t,lt);return Y(r,t,lt),t})):Promise.resolve().then(r))));function r(){return t.status=nt,t}}function Ot(t,e){return Promise.resolve().then((()=>{if(t.status!==it)return t;t.status=ut;const r=Object.keys(t.parcels).map((e=>t.parcels[e].unmountThisParcel()));return Promise.all(r).then(n,(r=>n().then((()=>{const n=Error(r.message);if(e)throw X(n,t,lt);Y(n,t,lt)})))).then((()=>t));function n(){return Rt(t,"unmount").then((()=>{t.status=nt}),(r=>{if(e)throw X(r,t,lt);Y(r,t,lt)}))}}))}let Pt=!1,_t=!1;function Tt(t,e){return Promise.resolve().then((()=>t.status!==nt?t:(Pt||(window.dispatchEvent(new J("single-spa:before-first-mount")),Pt=!0),t.status=ot,Rt(t,"mount").then((()=>(t.status=it,_t||(window.dispatchEvent(new J("single-spa:first-mount")),_t=!0),t))).catch((r=>{return t.status=it,Ot(t,!0).then(n,n);function n(){if(e)throw X(r,t,lt);return Y(r,t,lt),t}})))))}let jt=0;const At={parcels:{}};function xt(){return Nt.apply(At,arguments)}function Nt(t,e){const r=this;if(!t||"object"!=typeof t&&"function"!=typeof t)throw Error(Q(2,!1));if(t.name&&"string"!=typeof t.name)throw Error(Q(3,!1,typeof t.name));const n=jt++;let o=t.name||`parcel-${n}`;if("object"!=typeof e)throw Error(Q(4,!1,o,typeof e));if(!e.domElement)throw Error(Q(5,!1,o));const i="function"==typeof t,s=i?t:()=>Promise.resolve(t),u={id:n,parcels:{},status:i?tt:et,customProps:e,parentName:ht(r),unmountThisParcel:()=>f.then((()=>{if(u.status!==it)throw Error(Q(6,!1,o,u.status));return Ot(u,!0)})).then((t=>(u.parentName&&delete r.parcels[u.id],t))).then((t=>(p(t),t))).catch((t=>{throw u.status=lt,h(t),t}))};let a;r.parcels[n]=u;let c=s();if(!c||"function"!=typeof c.then)throw Error(Q(7,!1));c=c.then((t=>{if(!t)throw Error(Q(8,!1));if(o=t.name||`parcel-${n}`,Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!vt(t.bootstrap))throw Error(Q(9,!1,o));if(!vt(t.mount))throw Error(Q(10,!1,o));if(!vt(t.unmount))throw Error(Q(11,!1,o));if(t.update&&!vt(t.update))throw Error(Q(12,!1,o));const e=wt(t,"bootstrap"),r=wt(t,"mount"),i=wt(t,"unmount");u.status=et,u.name=o,u.bootstrap=e,u.mount=r,u.unmount=i,u.timeouts=Bt(t.timeouts),t.update&&(u.update=wt(t,"update"),a.update=function(t){return u.customProps=t,Dt((e=u,Promise.resolve().then((()=>{if(e.status!==it)throw Error(Q(32,!1,ht(e)));return e.status=st,Rt(e,"update").then((()=>(e.status=it,e))).catch((t=>{throw X(t,e,lt)}))}))));var e})}));const l=c.then((()=>St(u,!0))),f=l.then((()=>Tt(u,!0)));let p,h;const d=new Promise(((t,e)=>{p=t,h=e}));return a={mount:()=>Dt(Promise.resolve().then((()=>{if(u.status!==nt)throw Error(Q(13,!1,o,u.status));return r.parcels[n]=u,Tt(u)}))),unmount:()=>Dt(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:Dt(c),bootstrapPromise:Dt(l),mountPromise:Dt(f),unmountPromise:Dt(d)},a}function Dt(t){return t.then((()=>null))}function Ut(t){const e=ht(t);let r="function"==typeof t.customProps?t.customProps(e,window.location):t.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(Q(40,!1),e,r));const n=yt({},r,{name:e,mountParcel:Nt.bind(t),singleSpa:F});return dt(t)&&(n.unmountSelf=t.unmountThisParcel),n}const Mt={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 Ct(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(16,!1));Mt.bootstrap={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function kt(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(17,!1));Mt.mount={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function Lt(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(18,!1));Mt.unmount={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function It(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(19,!1));Mt.unload={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function Rt(t,e){const r=t.timeouts[e],n=r.warningMillis,o=bt(t);return new Promise(((i,s)=>{let u=!1,a=!1;t[e](Ut(t)).then((t=>{u=!0,i(t)})).catch((t=>{u=!0,s(t)})),setTimeout((()=>l(1)),n),setTimeout((()=>l(!0)),r.millis);const c=Q(31,!1,e,o,ht(t),r.millis);function l(t){if(!u)if(!0===t)a=!0,r.dieOnTimeout?s(Error(c)):console.error(c);else if(!a){const e=t,o=e*n;console.warn(c),o+n<r.millis&&setTimeout((()=>l(e+1)),n)}}}))}function Bt(t){const e={};for(let r in Mt)e[r]=yt({},Mt[r],t&&t[r]||{});return e}function $t(t){return Promise.resolve().then((()=>{if(t.loadPromise)return t.loadPromise;if(t.status!==Z&&t.status!==ct)return t;let e,r;return t.status=tt,t.loadPromise=Promise.resolve().then((()=>{const n=t.loadApp(Ut(t));if(!gt(n))throw r=!0,Error(Q(33,!1,ht(t)));return n.then((r=>{let n;t.loadErrorTime=null,e=r,"object"!=typeof e&&(n=34),Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!vt(e.bootstrap)&&(n=35),vt(e.mount)||(n=36),vt(e.unmount)||(n=37);const o=bt(e);if(n){let r;try{r=JSON.stringify(e)}catch(t){}return console.error(Q(n,!1,o,ht(t),r),e),Y(void 0,t,lt),t}return e.devtools&&e.devtools.overlays&&(t.devtools.overlays=yt({},t.devtools.overlays,e.devtools.overlays)),t.status=et,t.bootstrap=wt(e,"bootstrap"),t.mount=wt(e,"mount"),t.unmount=wt(e,"unmount"),t.unload=wt(e,"unload"),t.timeouts=Bt(e.timeouts),delete t.loadPromise,t}))})).catch((e=>{let n;return delete t.loadPromise,r?n=lt:(n=ct,t.loadErrorTime=(new Date).getTime()),Y(e,t,n),t}))}))}const Gt="undefined"!=typeof window,Vt={hashchange:[],popstate:[]},Wt=["hashchange","popstate"];function Ft(t){let e;if("string"==typeof t)e=t;else if(this&&this.href)e=this.href;else{if(!(t&&t.currentTarget&&t.currentTarget.href&&t.preventDefault))throw Error(Q(14,!1));e=t.currentTarget.href,t.preventDefault()}const r=Xt(window.location.href),n=Xt(e);0===e.indexOf("#")?window.location.hash=n.hash:r.host!==n.host&&n.host?window.location.href=e:n.pathname===r.pathname&&n.search===r.search?window.location.hash=n.hash:window.history.pushState(null,null,e)}function Ht(t){if(t){const e=t[0].type;Wt.indexOf(e)>=0&&Vt[e].forEach((e=>{try{e.apply(this,t)}catch(t){setTimeout((()=>{throw t}))}}))}}let Jt;function zt(){Oe([],arguments)}function Yt(t,e){return function(){const r=window.location.href,n=t.apply(this,arguments),o=window.location.href;return Jt&&r===o||window.dispatchEvent(function(t,e){let r;try{r=new PopStateEvent("popstate",{state:t})}catch(e){r=document.createEvent("PopStateEvent"),r.initPopStateEvent("popstate",!1,!1,t)}return r.singleSpa=!0,r.singleSpaTrigger=e,r}(window.history.state,e)),n}}let Kt=null,qt=!1;function Qt(t){if(qt)throw Error(Q(43,!1));Jt=!t||!t.hasOwnProperty("urlRerouteOnly")||t.urlRerouteOnly,qt=!0,Kt=window.history.replaceState,window.addEventListener("hashchange",zt),window.addEventListener("popstate",zt);const e=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(t,r){if(!("function"==typeof r&&Wt.indexOf(t)>=0)||mt(Vt[t],(t=>t===r)))return e.apply(this,arguments);Vt[t].push(r)},window.removeEventListener=function(t,e){if(!("function"==typeof e&&Wt.indexOf(t)>=0))return r.apply(this,arguments);Vt[t]=Vt[t].filter((t=>t!==e))},window.history.pushState=Yt(window.history.pushState,"pushState"),window.history.replaceState=Yt(Kt,"replaceState")}function Xt(t){const e=document.createElement("a");return e.href=t,e}Gt&&(window.singleSpaNavigate?console.warn(Q(41,!1)):window.singleSpaNavigate=Ft);let Zt=!1;function te(t=window.jQuery){if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!Zt){const e=t.fn.on,r=t.fn.off;t.fn.on=function(t,r){return ee.call(this,e,window.addEventListener,t,r,arguments)},t.fn.off=function(t,e){return ee.call(this,r,window.removeEventListener,t,e,arguments)},Zt=!0}}function ee(t,e,r,n,o){return"string"!=typeof r?t.apply(this,o):(r.split(/\s+/).forEach((t=>{Wt.indexOf(t)>=0&&(e(t,n),r=r.replace(t,""))})),""===r.trim()?this:t.apply(this,o))}const re={};function ne(t){return Promise.resolve().then((()=>{const e=re[ht(t)];if(!e)return t;if(t.status===Z)return oe(t,e),t;if(t.status===at)return e.promise.then((()=>t));if(t.status!==nt&&t.status!==ct)return t;const r=t.status===ct?Promise.resolve():Rt(t,"unload");return t.status=at,r.then((()=>(oe(t,e),t))).catch((r=>(function(t,e,r){delete re[ht(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,Y(r,t,lt),e.reject(r)}(t,e,r),t)))}))}function oe(t,e){delete re[ht(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=Z,e.resolve()}function ie(t,e,r,n){re[ht(t)]={app:t,resolve:r,reject:n},Object.defineProperty(re[ht(t)],"promise",{get:e})}function se(t){return re[t]}const ue=[];function ae(){return ue.filter(ft).map(ht)}function ce(){return ue.map(ht)}function le(t){const e=mt(ue,(e=>ht(e)===t));return e?e.status:null}let fe=!1;function pe(t,e,r,n){const o=function(t,e,r,n){const o={name:null,loadApp:null,activeWhen:null,customProps:null};return"object"==typeof t?(function(t){if(Array.isArray(t)||null===t)throw Error(Q(39,!1));const e=["name","app","activeWhen","customProps"],r=Object.keys(t).reduce(((t,r)=>e.indexOf(r)>=0?t:t.concat(r)),[]);if(0!==r.length)throw Error(Q(38,!1,e.join(", "),r.join(", ")));if("string"!=typeof t.name||0===t.name.length)throw Error(Q(20,!1));if("object"!=typeof t.app&&"function"!=typeof t.app)throw Error(Q(20,!1));const n=t=>"string"==typeof t||"function"==typeof t;if(!(n(t.activeWhen)||Array.isArray(t.activeWhen)&&t.activeWhen.every(n)))throw Error(Q(24,!1));if(!me(t.customProps))throw Error(Q(22,!1))}(t),o.name=t.name,o.loadApp=t.app,o.activeWhen=t.activeWhen,o.customProps=t.customProps):(function(t,e,r,n){if("string"!=typeof t||0===t.length)throw Error(Q(20,!1));if(!e)throw Error(Q(23,!1));if("function"!=typeof r)throw Error(Q(24,!1));if(!me(n))throw Error(Q(22,!1))}(t,e,r,n),o.name=t,o.loadApp=e,o.activeWhen=r,o.customProps=n),o.loadApp="function"!=typeof(i=o.loadApp)?()=>Promise.resolve(i):i,o.customProps=function(t){return t||{}}(o.customProps),o.activeWhen=function(t){let e=Array.isArray(t)?t:[t];return e=e.map((t=>"function"==typeof t?t:ve(t))),t=>e.some((e=>e(t)))}(o.activeWhen),o;var i}(t,e,r,n);if(je()||fe||(fe=!0,setTimeout((()=>{je()||console.warn(Q(1,!1))}),5e3)),-1!==ce().indexOf(o.name))throw Error(Q(21,!1,o.name));ue.push(yt({loadErrorTime:null,status:Z,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},o)),Gt&&(te(),Oe())}function he(t=window.location){return ue.filter((e=>e.activeWhen(t))).map(ht)}function de(t){if(0===ue.filter((e=>ht(e)===t)).length)throw Error(Q(25,!1,t));return(Gt?be(t,{waitForUnmount:!1}):Promise.resolve()).then((()=>{const e=ue.map(ht).indexOf(t);ue.splice(e,1)}))}function be(t,e={waitForUnmount:!1}){if("string"!=typeof t)throw Error(Q(26,!1));const r=mt(ue,(e=>ht(e)===t));if(!r)throw Error(Q(27,!1,t));const n=se(ht(r));if(e&&e.waitForUnmount){if(n)return n.promise;{const t=new Promise(((e,n)=>{ie(r,(()=>t),e,n)}));return t}}{let t;return n?(t=n.promise,ye(r,n.resolve,n.reject)):t=new Promise(((e,n)=>{ie(r,(()=>t),e,n),ye(r,e,n)})),t}}function ye(t,e,r){Promise.resolve().then((()=>{if(mt(he(),(e=>e===ht(t))))return Se()})).then((()=>Ot(t).then(ne).then((()=>{e(),setTimeout((()=>{Oe()}))})))).catch(r)}function me(t){return!t||"function"==typeof t||"object"==typeof t&&null!==t&&!Array.isArray(t)}function ve(t,e){const r=function(t,e){let r=0,n=!1,o="^";"/"!==t[0]&&(t="/"+t);for(let e=0;e<t.length;e++){const r=t[e];(!n&&":"===r||n&&"/"===r)&&i(e)}return i(t.length),new RegExp(o,"i");function i(i){const s=t.slice(r,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=n?"[^/]+/?":s,i===t.length)if(n)e&&(o+="$");else{const t=e?"":".*";o="/"===o.charAt(o.length-1)?`${o}${t}$`:`${o}(/${t})?(#.*)?$`}n=!n,r=i}}(t,e);return t=>{let e=t.origin;e||(e=`${t.protocol}//${t.host}`);const n=t.href.replace(e,"").replace(t.search,"").split("?")[0];return r.test(n)}}let we=!1,ge=[],Ee=Gt&&window.location.href;function Se(){return Oe()}function Oe(t=[],e,r=!1){if(we)return new Promise(((t,r)=>{ge.push({resolve:t,reject:r,eventArguments:e})}));const{appsToUnload:n,appsToUnmount:o,appsToLoad:i,appsToMount:s}=function(){const t=[],e=[],r=[],n=[],o=(new Date).getTime();return ue.forEach((i=>{const s=i.status!==lt&&pt(i);switch(i.status){case ct:s&&o-i.loadErrorTime>=200&&r.push(i);break;case Z:case tt:s&&r.push(i);break;case et:case nt:!s&&se(ht(i))?t.push(i):s&&n.push(i);break;case it:s||e.push(i)}})),{appsToUnload:t,appsToUnmount:e,appsToLoad:r,appsToMount:n}}();let u,a=[],c=Ee,l=Ee=window.location.href;return je()?(we=!0,u=n.concat(i,o,s),Promise.resolve().then((()=>(b(0===u.length?"before-no-app-change":"before-app-change",d(!0)),b("before-routing-event",d(!0,{cancelNavigation:f})),Promise.all(a).then((r=>{if(r.some((t=>t)))return Kt.call(window.history,history.state,"",c.substring(location.origin.length)),Ee=location.href,we=!1,Oe(t,e,!0);const u=n.map(ne),a=o.map(Ot).map((t=>t.then(ne))).concat(u),l=Promise.all(a);l.then((()=>{b("before-mount-routing-event",d(!0))}),(t=>{throw t}));const f=i.map((t=>$t(t).then((t=>Pe(t,l))))),y=s.filter((t=>i.indexOf(t)<0)).map((t=>Pe(t,l)));return l.catch((t=>{throw h(),t})).then((()=>(h(),Promise.all(f.concat(y)).catch((e=>{throw t.forEach((t=>t.reject(e))),e})).then(p).then((()=>{}),(t=>{throw t})))))})))))):(u=i,Promise.resolve().then((()=>{const t=i.map($t);return Promise.all(t).then(h).then((()=>[])).catch((t=>{throw h(),t})).finally((()=>{}))})));function f(t=!0){const e="function"==typeof(null==t?void 0:t.then)?t:Promise.resolve(t);a.push(e.catch((t=>(console.warn(Error(Q(42,!1))),console.warn(t),!1))))}function p(){const e=ae();t.forEach((t=>t.resolve(e)));try{b(0===u.length?"no-app-change":"app-change",d()),b("routing-event",d())}catch(t){setTimeout((()=>{throw t}))}if(we=!1,ge.length>0){const t=ge;ge=[],Oe(t)}return e}function h(){r||(t.forEach((t=>{Ht(t.eventArguments)})),Ht(e))}function d(t=!1,r){const a={},f={[it]:[],[nt]:[],[Z]:[],[lt]:[]};t?(i.concat(s).forEach(((t,e)=>{h(t,it)})),n.forEach((t=>{h(t,Z)})),o.forEach((t=>{h(t,nt)}))):u.forEach((t=>{h(t)}));const p={detail:{newAppStatuses:a,appsByNewStatus:f,totalAppChanges:u.length,originalEvent:null==e?void 0:e[0],oldUrl:c,newUrl:l}};return r&&yt(p.detail,r),p;function h(t,e){const r=ht(t);e=e||le(r),a[r]=e,(f[e]=f[e]||[]).push(r)}}function b(t,e){r||window.dispatchEvent(new J(`single-spa:${t}`,e))}}function Pe(t,e){return pt(t)?St(t).then((t=>e.then((()=>pt(t)?Tt(t):t)))):e.then((()=>t))}let _e=!1;function Te(t){_e=!0,Gt&&(Qt(t),Oe())}function je(){return _e}var Ae={getRawAppData:function(){return[...ue]},reroute:Oe,NOT_LOADED:Z,toLoadPromise:$t,toBootstrapPromise:St,unregisterApplication:de,getProfilerData:function(){return Et}};Gt&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Ae);var xe="openmrs:history";function Ne(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function De(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function Ue(t,e,r){return Ue=Ie()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&ke(o,r.prototype),o},Ue.apply(null,arguments)}function Me(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ce(t){return Ce=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Ce(t)}function ke(t,e){return ke=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},ke(t,e)}function Le(t){var e="function"==typeof Map?new Map:void 0;return Le=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Ue(t,arguments,Ce(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ke(n,t)},Le(t)}function Ie(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}var Re="/ws/rest/v1/",Be="/ws/fhir2/R4",$e="".concat(Re,"session");function Ge(t){return t&&t.startsWith("http")?t:("/"!==t[0]&&(t="/"+t),window.openmrsBase+t)}function Ve(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof t)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof e)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.");var r=Ge(t);if(e.headers||(e.headers={}),$(e.body)&&(e.body=JSON.stringify(e.body)),void 0===e.headers.Accept&&(e.headers.Accept="application/json"),null===e.headers.Accept&&delete e.headers.Accept,t.startsWith(Re)&&void 0===e.headers["Disable-WWW-Authenticate"]&&(e.headers["Disable-WWW-Authenticate"]="true"),t.startsWith(Be)){var n=new URL(r,window.location.toString());n.searchParams.has("_summary")||(n.searchParams.set("_summary","data"),r=n.toString())}var o,i,s=Error();return window.fetch(r,e).then((o=function(t){var e,n;return function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(o){switch(o.label){case 0:return(e=t).ok?204===e.status?(e.data=null,[2,e]):[2,e.clone().text().then((function(t){try{t&&(e.data=JSON.parse(t))}catch(t){}return e}))]:[3,1];case 1:return[4,(0,G.getConfig)("@openmrs/esm-api")];case 2:return n=o.sent().redirectAuthFailure,r===Ge($e)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(sessionStorage.removeItem(xe),(0,V.navigate)({to:n.url}),[2,n.resolvePromise?Promise.resolve():new Promise((function(){}))]):[2,e.clone().text().then((function(t){var n=t;try{n=JSON.parse(t)}catch(t){}throw new Fe(r,e,n,s)}),(function(t){throw new Fe(r,e,null,s)}))];case 3:return[2]}}))},i=function(){var t=this,e=arguments;return new Promise((function(r,n){var i=o.apply(t,e);function s(t){De(i,r,n,s,u,"next",t)}function u(t){De(i,r,n,s,u,"throw",t)}s(void 0)}))},function(t){return i.apply(this,arguments)}))}function We(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof e)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");var r=new AbortController;return e.signal=r.signal,new g((function(n){var o=!1;return Ve(t,e).then((function(t){o=!0,n.next(t),n.complete()}),(function(t){o=!0,n.error(t)})),function(){o||r.abort()}}))}var Fe=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ke(t,e)}(o,t);var e,r,n=(e=o,r=Ie(),function(){var t,n=Ce(e);if(r){var o=Ce(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return function(t,e){return!e||"object"!=((r=e)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)&&"function"!=typeof e?Ne(t):e;var r}(this,t)});function o(t,e,r,i){var s;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),Me(Ne(s=n.call(this)),"response",void 0),Me(Ne(s),"responseBody",void 0),s.message="Server responded with ".concat(e.status," (").concat(e.statusText,") for url ").concat(t,". Check err.responseBody or network tab in dev tools for more info"),i.message=s.message,s.responseBody=r,s.response=e,s.stack="Stacktrace for outgoing request:\n".concat(i.stack,"\nStacktrace for incoming response:\n").concat(s.stack),s}return o}(Le(Error));function He(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}var Je="/ws/rest/v1/attachment";function ze(t,e){return Ve("".concat(Je,"/").concat(t),{signal:e.signal})}function Ye(t,e,r){return Ve("".concat(Je,"?patient=").concat(t,"&includeEncounterless=").concat(e),{signal:r.signal})}function Ke(t,e){return qe.apply(this,arguments)}function qe(){var t;return t=function(t,e){var r;return function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(n){return(r=new FormData).append("fileCaption",e.fileName),r.append("patient",t),e.file?r.append("file",e.file):(r.append("file",new File([""],e.fileName),e.fileName),r.append("base64Content",e.base64Content)),[2,Ve("".concat(Je),{method:"POST",body:r})]}))},qe=function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){He(i,n,o,s,u,"next",t)}function u(t){He(i,n,o,s,u,"throw",t)}s(void 0)}))},qe.apply(this,arguments)}function Qe(t,e){return Ve("".concat(Je,"/").concat(t),{method:"DELETE",signal:e.signal})}var Xe=s(254);const Ze=function(t){return void 0===t};function tr(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function er(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){tr(i,n,o,s,u,"next",t)}function u(t){tr(i,n,o,s,u,"throw",t)}s(void 0)}))}}function rr(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var nr=(0,W.createGlobalStore)("session",{loaded:!1,session:null}),or=0;function ir(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{includeAuthStatus:!0};return(or<Date.now()-6e4||!nr.getState().loaded)&&ar(),new g((function(e){var r=function(r){var n;r.loaded&&(t.includeAuthStatus?e.next(r.session):e.next(null===(n=r.session)||void 0===n?void 0:n.user))};return r(nr.getState()),nr.subscribe(r)}))}function sr(){return(or<Date.now()-6e4||!nr.getState().loaded)&&ar(),nr}function ur(t){var e,r,n,o=null!==(n=null==t||null===(e=t.user)||void 0===e||null===(r=e.userProperties)||void 0===r?void 0:r.defaultLocale)&&void 0!==n?n:t.locale,i=document.documentElement.getAttribute("lang");(function(t){if(void 0===t||"string"!=typeof t)return!1;try{new Intl.Locale(t)}catch(t){return!1}return!0})(o)&&o!==i&&document.documentElement.setAttribute("lang",o)}function ar(){return new Promise((function(t,e){or=Date.now(),Ve($e).then((function(r){if("object"!=typeof(null==r?void 0:r.data))return e(),Promise.reject();ur(r.data),t(r.data),nr.setState({loaded:!0,session:r.data})})).catch((function(t){return(0,Xe.reportError)("Failed to fetch new session information: ".concat(t)),e(t),{sessionId:"",authenticated:!1}}))}))}function cr(){nr.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function lr(t,e){return void 0===e?Boolean(t):!Boolean(t)||function(t,e){return"string"==typeof t?!Ze(e.privileges.find((function(e){return t===e.display}))):Array.isArray(t)?t.every((function(t){return!Ze(e.privileges.find((function(e){return t===e.display})))})):(Ze(t)||console.error('Could not understand privileges "'.concat(t,'"')),!0)}(t,e)||function(t){return!Ze(t.roles.find((function(t){return"System Developer"===t.display})))}(e)}function fr(){var t,e;return new Promise((function(r,n){var o=function(n){n.loaded&&n.session.user&&(t=n.session.user,r(n.session.user),e&&e())};o(nr.getState()),t||(e=nr.subscribe(o))}))}function pr(){return new Promise((function(t,e){ir().subscribe((function(e){t(e.sessionLocation)}),e).unsubscribe()}))}function hr(t,e){return dr.apply(this,arguments)}function dr(){return(dr=er((function(t,e){return rr(this,(function(r){switch(r.label){case 0:return[4,Ve($e,{method:"POST",body:{sessionLocation:t},headers:{"Content-Type":"application/json"},signal:e.signal})];case 1:return r.sent(),[4,ar()];case 2:return r.sent(),[2]}}))}))).apply(this,arguments)}function br(t,e,r){return yr.apply(this,arguments)}function yr(){return(yr=er((function(t,e,r){return rr(this,(function(n){switch(n.label){case 0:return r||(r=new AbortController),[4,Ve("/ws/rest/v1/user/".concat(t),{method:"POST",body:{userProperties:e},headers:{"Content-Type":"application/json"},signal:r.signal})];case 1:return n.sent(),[4,ar()];case 2:return n.sent(),[2]}}))}))).apply(this,arguments)}function mr(){(0,G.defineConfigSchema)("@openmrs/esm-api",{redirectAuthFailure:{enabled:{_type:G.Type.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:G.Type.String,_default:"${openmrsSpaBase}/login",_validators:[G.validators.isUrl]},errors:{_type:G.Type.Array,_default:[401],_elements:{_type:G.Type.Number,_validators:[G.validators.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:G.Type.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}}}),ar()}var vr=s(738);function wr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function gr(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function Er(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){gr(i,n,o,s,u,"next",t)}function u(t){gr(i,n,o,s,u,"throw",t)}s(void 0)}))}}function Sr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],s=!0,u=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{s||null==r.return||r.return()}finally{if(u)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return wr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?wr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Or(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function Pr(t,e){return _r.apply(this,arguments)}function _r(){return _r=Er((function(t,e){var r,n,o,i,s,u=arguments;return Or(this,(function(a){switch(a.label){case 0:return r=!(u.length>2&&void 0!==u[2])||u[2],t?(n=null,[4,Promise.all([Ve("".concat(Be,"/Patient/").concat(t),e).catch((function(t){return n=t})),r?Tr(t):Promise.resolve(null)])]):[3,2];case 1:if(o=Sr.apply(void 0,[a.sent(),2]),i=o[0],s=o[1],i.ok)return[2,i.data];if(s)return[2,s];if(n)throw n;a.label=2;case 2:return[2,null]}}))})),_r.apply(this,arguments)}function Tr(t){return jr.apply(this,arguments)}function jr(){return(jr=Er((function(t){var e,r,n;return Or(this,(function(o){switch(o.label){case 0:return[4,(0,vr.getSynchronizationItems)("patient-registration")];case 1:return e=o.sent(),r=e.find((function(e){return e.fhirPatient.id===t})),[2,null!==(n=null==r?void 0:r.fhirPatient)&&void 0!==n?n:null]}}))}))).apply(this,arguments)}var Ar=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),xr=function(t){function r(e,r){var n=t.call(this)||this;return n.subject=e,n.subscriber=r,n.closed=!1,n}return e(r,t),r.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var r=e.indexOf(this.subscriber);-1!==r&&e.splice(r,1)}}},r}(h),Nr=function(t){function r(e){var r=t.call(this,e)||this;return r.destination=e,r}return e(r,t),r}(y),Dr=function(t){function r(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return e(r,t),r.prototype[b]=function(){return new Nr(this)},r.prototype.lift=function(t){var e=new Ur(this,this);return e.operator=t,e},r.prototype.next=function(t){if(this.closed)throw new Ar;if(!this.isStopped)for(var e=this.observers,r=e.length,n=e.slice(),o=0;o<r;o++)n[o].next(t)},r.prototype.error=function(t){if(this.closed)throw new Ar;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,r=e.length,n=e.slice(),o=0;o<r;o++)n[o].error(t);this.observers.length=0},r.prototype.complete=function(){if(this.closed)throw new Ar;this.isStopped=!0;for(var t=this.observers,e=t.length,r=t.slice(),n=0;n<e;n++)r[n].complete();this.observers.length=0},r.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},r.prototype._trySubscribe=function(e){if(this.closed)throw new Ar;return t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(t){if(this.closed)throw new Ar;return this.hasError?(t.error(this.thrownError),h.EMPTY):this.isStopped?(t.complete(),h.EMPTY):(this.observers.push(t),new xr(this,t))},r.prototype.asObservable=function(){var t=new g;return t.source=this,t},r.create=function(t,e){return new Ur(t,e)},r}(g),Ur=function(t){function r(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return e(r,t),r.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},r.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},r.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},r.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):h.EMPTY},r}(Dr),Mr=function(t){function r(e){var r=t.call(this)||this;return r._value=e,r}return e(r,t),Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),r.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return r&&!r.closed&&e.next(this._value),r},r.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new Ar;return this._value},r.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},r}(Dr),Cr=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}(),kr=new g((function(t){return t.complete()}));function Lr(t){return function(e){return 0===t?r?function(t){return new g((function(e){return t.schedule((function(){return e.complete()}))}))}(r):kr:e.lift(new Ir(t));var r}}var Ir=function(){function t(t){if(this.total=t,this.total<0)throw new Cr}return t.prototype.call=function(t,e){return e.subscribe(new Rr(t,this.total))},t}(),Rr=function(t){function r(e,r){var n=t.call(this,e)||this;return n.total=r,n.count=0,n}return e(r,t),r.prototype._next=function(t){var e=this.total,r=++this.count;r<=e&&(this.destination.next(t),r===e&&(this.destination.complete(),this.unsubscribe()))},r}(y);function Br(t,e){return function(r){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return r.lift(new $r(t,e))}}var $r=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new Gr(t,this.project,this.thisArg))},t}(),Gr=function(t){function r(e,r,n){var o=t.call(this,e)||this;return o.project=r,o.count=0,o.thisArg=n||o,o}return e(r,t),r.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},r}(y),Vr="custom:(uuid,encounters:(uuid,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,uuid),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display),startDatetime,stopDatetime)",Wr=function(){try{return JSON.parse(localStorage.getItem("openmrs:visitStoreState")||"null")}catch(t){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function Fr(){return(0,W.getGlobalStore)("visit",Wr)}function Hr(t,e){Fr().setState({patientUuid:t,manuallySetVisitUuid:e})}function Jr(t,e,r){var n=null!=r?r:Vr;return We("/ws/rest/v1/visit?patient=".concat(t,"&v=").concat(n),{signal:e.signal,method:"GET",headers:{"Content-type":"application/json"}}).pipe(Lr(1)).pipe(Br((function(t){return t})))}function zr(t,e){return We("/ws/rest/v1/visit",{signal:e.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function Yr(t,e,r){return We("/ws/rest/v1/visit/".concat(t),{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}Fr().subscribe((function(t){var e;e=t,localStorage.setItem("openmrs:visitStoreState",JSON.stringify(e))}));var Kr,qr,Qr=new Mr(null);function Xr(t){return{uuid:t.uuid,display:t.display,name:t.name}}function Zr(){return We("/ws/rest/v1/visittype").pipe(Br((function(t){return t.data.results.map(Xr)}))).pipe(Lr(1))}function tn(t){return{uuid:t.uuid,display:t.display}}function en(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return We("/ws/rest/v1/location"+(t?"?tag="+t:"")).pipe(Br((function(t){return t.data.results.map(tn)}))).pipe(Lr(1))}!function(t){t.NEWVISIT="startVisit",t.EDITVISIT="editVisit",t.LOADING="loadingVisit"}(Kr||(Kr={})),function(t){t.NOTSTARTED="notStarted",t.ONGOING="ongoing"}(qr||(qr={}));var rn={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"}})(),u})())}}}));
2
+ System.register(["@openmrs/esm-config","@openmrs/esm-navigation","@openmrs/esm-error-handling","@openmrs/esm-offline"],(function(t,e){var r={},n={},o={},i={};return{setters:[function(t){r.Type=t.Type,r.defineConfigSchema=t.defineConfigSchema,r.getConfig=t.getConfig,r.validators=t.validators},function(t){n.navigate=t.navigate},function(t){o.reportError=t.reportError},function(t){i.getSynchronizationItems=t.getSynchronizationItems}],execute:function(){t((()=>{var t={385:()=>{System.register([],(function(t,e){return{execute:function(){t(function(){"use strict";var t=function(t,e){var r=u[t];if(r)return r.active?console.error("Cannot override an existing store. Make sure that stores are only created once."):r.value.setState(e,!0),r.active=!0,r.value;var n=s()((function(){return e}));return u[t]={value:n,active:!0},n},e=function(t,e){var r=u[t];if(!r){var n=s()((function(){return null!=e?e:{}}));return u[t]={value:n,active:!1},n}return r.value},r=function(t,e,r){var n=e(t.getState());return t.subscribe((function(t){var o=e(t);o!==n&&(n=o,r(o))}))},n={d:function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};n.r(o),n.d(o,{createGlobalStore:function(){return t},getGlobalStore:function(){return e},subscribeTo:function(){return r}});var i=function(t){var e,r=new Set,n=function(t,n){var o="function"==typeof t?t(e):t;if(!Object.is(o,e)){var i=e;e=(null!=n?n:"object"!=typeof o)?o:Object.assign({},e,o),r.forEach((function(t){return t(e,i)}))}},o=function(){return e},i={setState:n,getState:o,subscribe:function(t){return r.add(t),function(){return r.delete(t)}},destroy:function(){console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,o,i),i},s=function(t){return t?i(t):i},u={};return setTimeout((function(){"development"===window.spaEnv&&(window.stores=u)}),1e3),o}())}}}))},824:t=>{"use strict";t.exports=r},254:t=>{"use strict";t.exports=o},513:t=>{"use strict";t.exports=n},738:t=>{"use strict";t.exports=i}},e={};function s(r){var n=e[r];if(void 0!==n)return n.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,s),o.exports}s.d=(t,e)=>{for(var r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return(()=>{"use strict";s.r(u),s.d(u,{OpenmrsFetchError:()=>Fe,VisitMode:()=>Kr,VisitStatus:()=>qr,attachmentUrl:()=>Je,backendDependencies:()=>rn,clearCurrentUser:()=>cr,createAttachment:()=>Ke,defaultVisitCustomRepresentation:()=>Vr,deleteAttachmentPermanently:()=>Qe,fetchCurrentPatient:()=>Pr,fhirBaseUrl:()=>Be,getAttachmentByUuid:()=>ze,getAttachments:()=>Ye,getCurrentUser:()=>ir,getLocations:()=>en,getLoggedInUser:()=>fr,getSessionLocation:()=>pr,getSessionStore:()=>sr,getStartedVisit:()=>Qr,getVisitStore:()=>Fr,getVisitTypes:()=>Zr,getVisitsForPatient:()=>Jr,makeUrl:()=>Ge,openmrsFetch:()=>Ve,openmrsObservableFetch:()=>We,refetchCurrentUser:()=>ar,restBaseUrl:()=>Re,saveVisit:()=>zr,sessionEndpoint:()=>$e,setCurrentVisit:()=>Hr,setSessionLocation:()=>hr,setUserLanguage:()=>ur,setUserProperties:()=>br,setupApiModule:()=>mr,toLocationObject:()=>tn,toVisitTypeObject:()=>Xr,updateVisit:()=>Yr,userHasAccess:()=>lr});var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};function e(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function r(t){return"function"==typeof t}var n=!1,o={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,n=t},get useDeprecatedSynchronousErrorHandling(){return n}};function i(t){setTimeout((function(){throw t}),0)}var a={closed:!0,next:function(t){},error:function(t){if(o.useDeprecatedSynchronousErrorHandling)throw t;i(t)},complete:function(){}},c=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function l(t){return null!==t&&"object"==typeof t}var f=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),p=f,h=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var n=this,o=n._parentOrParents,i=n._ctorUnsubscribe,s=n._unsubscribe,u=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,o instanceof t)o.remove(this);else if(null!==o)for(var a=0;a<o.length;++a)o[a].remove(this);if(r(s)){i&&(this._unsubscribe=void 0);try{s.call(this)}catch(t){e=t instanceof p?d(t.errors):[t]}}if(c(u)){a=-1;for(var f=u.length;++a<f;){var h=u[a];if(l(h))try{h.unsubscribe()}catch(t){e=e||[],t instanceof p?e=e.concat(d(t.errors)):e.push(t)}}}if(e)throw new p(e)}},t.prototype.add=function(e){var r=e;if(!e)return t.EMPTY;switch(typeof e){case"function":r=new t(e);case"object":if(r===this||r.closed||"function"!=typeof r.unsubscribe)return r;if(this.closed)return r.unsubscribe(),r;if(!(r instanceof t)){var n=r;(r=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var o=r._parentOrParents;if(null===o)r._parentOrParents=this;else if(o instanceof t){if(o===this)return r;r._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return r;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[r]:i.push(r),r},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var r=e.indexOf(t);-1!==r&&e.splice(r,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function d(t){return t.reduce((function(t,e){return t.concat(e instanceof p?e.errors:e)}),[])}var b=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),y=function(t){function r(e,n,o){var i=t.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=a;break;case 1:if(!e){i.destination=a;break}if("object"==typeof e){e instanceof r?(i.syncErrorThrowable=e.syncErrorThrowable,i.destination=e,e.add(i)):(i.syncErrorThrowable=!0,i.destination=new m(i,e));break}default:i.syncErrorThrowable=!0,i.destination=new m(i,e,n,o)}return i}return e(r,t),r.prototype[b]=function(){return this},r.create=function(t,e,n){var o=new r(t,e,n);return o.syncErrorThrowable=!1,o},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},r.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},r.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},r}(h),m=function(t){function n(e,n,o,i){var s,u=t.call(this)||this;u._parentSubscriber=e;var c=u;return r(n)?s=n:n&&(s=n.next,o=n.error,i=n.complete,n!==a&&(r((c=Object.create(n)).unsubscribe)&&u.add(c.unsubscribe.bind(c)),c.unsubscribe=u.unsubscribe.bind(u))),u._context=c,u._next=s,u._error=o,u._complete=i,u}return e(n,t),n.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;o.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},n.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,r=o.useDeprecatedSynchronousErrorHandling;if(this._error)r&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)r?(e.syncErrorValue=t,e.syncErrorThrown=!0):i(t),this.unsubscribe();else{if(this.unsubscribe(),r)throw t;i(t)}}},n.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var r=function(){return t._complete.call(t._context)};o.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,r),this.unsubscribe()):(this.__tryOrUnsub(r),this.unsubscribe())}else this.unsubscribe()}},n.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),o.useDeprecatedSynchronousErrorHandling)throw t;i(t)}},n.prototype.__tryOrSetError=function(t,e,r){if(!o.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,r)}catch(e){return o.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(i(e),!0)}return!1},n.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},n}(y),v=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function w(t){return t}var g=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n=this.operator,i=function(t,e,r){if(t){if(t instanceof y)return t;if(t[b])return t[b]()}return t||e||r?new y(t,e,r):new y(a)}(t,e,r);if(n?i.add(n.call(i,this.source)):i.add(this.source||o.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),o.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){o.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),function(t){for(;t;){var e=t,r=e.closed,n=e.destination,o=e.isStopped;if(r||o)return!1;t=n&&n instanceof y?n:null}return!0}(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=E(e))((function(e,n){var o;o=r.subscribe((function(e){try{t(e)}catch(t){n(t),o&&o.unsubscribe()}}),n,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[v]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:(0===(r=t).length?w:1===r.length?r[0]:function(t){return r.reduce((function(t,e){return e(t)}),t)})(this);var r},t.prototype.toPromise=function(t){var e=this;return new(t=E(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function E(t){if(t||(t=o.Promise||Promise),!t)throw new Error("no Promise impl found");return t}const S="object"==typeof global&&global&&global.Object===Object&&global;var O="object"==typeof self&&self&&self.Object===Object&&self;const P=(S||O||Function("return this")()).Symbol;var _=Object.prototype,T=_.hasOwnProperty,j=_.toString,A=P?P.toStringTag:void 0;var x=Object.prototype.toString;var D=P?P.toStringTag:void 0;const N=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":D&&D in Object(t)?function(t){var e=T.call(t,A),r=t[A];try{t[A]=void 0;var n=!0}catch(t){}var o=j.call(t);return n&&(e?t[A]=r:delete t[A]),o}(t):function(t){return x.call(t)}(t)},U=(M=Object.getPrototypeOf,C=Object,function(t){return M(C(t))});var M,C;var k=Function.prototype,L=Object.prototype,I=k.toString,R=L.hasOwnProperty,B=I.call(Object);const $=function(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!=N(t))return!1;var e=U(t);if(null===e)return!0;var r=R.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&I.call(r)==B};var G=s(824),V=s(513),W=s(385);(0,W.createGlobalStore)("breadcrumbs",[]);var F=Object.freeze({__proto__:null,get start(){return Te},get ensureJQuerySupport(){return te},get setBootstrapMaxTime(){return Ct},get setMountMaxTime(){return kt},get setUnmountMaxTime(){return Lt},get setUnloadMaxTime(){return It},get registerApplication(){return pe},get unregisterApplication(){return de},get getMountedApps(){return ae},get getAppStatus(){return le},get unloadApplication(){return be},get checkActivityFunctions(){return he},get getAppNames(){return ce},get pathToActiveWhen(){return ve},get navigateToUrl(){return Ft},get patchHistoryApi(){return Qt},get triggerAppChange(){return Se},get addErrorHandler(){return K},get removeErrorHandler(){return q},get mountRootParcel(){return xt},get NOT_LOADED(){return Z},get LOADING_SOURCE_CODE(){return tt},get NOT_BOOTSTRAPPED(){return et},get BOOTSTRAPPING(){return rt},get NOT_MOUNTED(){return nt},get MOUNTING(){return ot},get UPDATING(){return st},get LOAD_ERROR(){return ct},get MOUNTED(){return it},get UNLOADING(){return at},get UNMOUNTING(){return ut},get SKIP_BECAUSE_BROKEN(){return lt}}),H=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent,J=function(){try{var t=new H("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?H:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,e){var r=document.createEvent("CustomEvent");return e?r.initCustomEvent(t,e.bubbles,e.cancelable,e.detail):r.initCustomEvent(t,!1,!1,void 0),r}:function(t,e){var r=document.createEventObject();return r.type=t,e?(r.bubbles=Boolean(e.bubbles),r.cancelable=Boolean(e.cancelable),r.detail=e.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r};let z=[];function Y(t,e,r){const n=X(t,e,r);z.length?z.forEach((t=>t(n))):setTimeout((()=>{throw n}))}function K(t){if("function"!=typeof t)throw Error(Q(28,!1));z.push(t)}function q(t){if("function"!=typeof t)throw Error(Q(29,!1));let e=!1;return z=z.filter((r=>{const n=r===t;return e=e||n,!n})),e}function Q(t,e,...r){return`single-spa minified message #${t}: ${e?e+" ":""}See https://single-spa.js.org/error/?code=${t}${r.length?`&arg=${r.join("&arg=")}`:""}`}function X(t,e,r){const n=`${bt(e)} '${ht(e)}' died in status ${e.status}: `;let o;if(t instanceof Error){try{t.message=n+t.message}catch(t){}o=t}else{console.warn(Q(30,!1,e.status,ht(e)));try{o=Error(n+JSON.stringify(t))}catch(e){o=t}}return o.appOrParcelName=ht(e),e.status=r,o}const Z="NOT_LOADED",tt="LOADING_SOURCE_CODE",et="NOT_BOOTSTRAPPED",rt="BOOTSTRAPPING",nt="NOT_MOUNTED",ot="MOUNTING",it="MOUNTED",st="UPDATING",ut="UNMOUNTING",at="UNLOADING",ct="LOAD_ERROR",lt="SKIP_BECAUSE_BROKEN";function ft(t){return t.status===it}function pt(t){try{return t.activeWhen(window.location)}catch(e){return Y(e,t,lt),!1}}function ht(t){return t.name}function dt(t){return Boolean(t.unmountThisParcel)}function bt(t){return dt(t)?"parcel":"application"}function yt(){for(let t=arguments.length-1;t>0;t--)for(let e in arguments[t])"__proto__"!==e&&(arguments[t-1][e]=arguments[t][e]);return arguments[0]}function mt(t,e){for(let r=0;r<t.length;r++)if(e(t[r]))return t[r];return null}function vt(t){return t&&("function"==typeof t||(e=t,Array.isArray(e)&&!mt(e,(t=>"function"!=typeof t))));var e}function wt(t,e){let r=t[e]||[];r=Array.isArray(r)?r:[r],0===r.length&&(r=[()=>Promise.resolve()]);const n=bt(t),o=ht(t);return function(t){return r.reduce(((r,i,s)=>r.then((()=>{const r=i(t);return gt(r)?r:Promise.reject(Q(15,!1,n,o,e,s))}))),Promise.resolve())}}function gt(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}let Et=[];function St(t,e){return Promise.resolve().then((()=>t.status!==et?t:(t.status=rt,t.bootstrap?Rt(t,"bootstrap").then(r).catch((r=>{if(e)throw X(r,t,lt);return Y(r,t,lt),t})):Promise.resolve().then(r))));function r(){return t.status=nt,t}}function Ot(t,e){return Promise.resolve().then((()=>{if(t.status!==it)return t;t.status=ut;const r=Object.keys(t.parcels).map((e=>t.parcels[e].unmountThisParcel()));return Promise.all(r).then(n,(r=>n().then((()=>{const n=Error(r.message);if(e)throw X(n,t,lt);Y(n,t,lt)})))).then((()=>t));function n(){return Rt(t,"unmount").then((()=>{t.status=nt}),(r=>{if(e)throw X(r,t,lt);Y(r,t,lt)}))}}))}let Pt=!1,_t=!1;function Tt(t,e){return Promise.resolve().then((()=>t.status!==nt?t:(Pt||(window.dispatchEvent(new J("single-spa:before-first-mount")),Pt=!0),t.status=ot,Rt(t,"mount").then((()=>(t.status=it,_t||(window.dispatchEvent(new J("single-spa:first-mount")),_t=!0),t))).catch((r=>{return t.status=it,Ot(t,!0).then(n,n);function n(){if(e)throw X(r,t,lt);return Y(r,t,lt),t}})))))}let jt=0;const At={parcels:{}};function xt(){return Dt.apply(At,arguments)}function Dt(t,e){const r=this;if(!t||"object"!=typeof t&&"function"!=typeof t)throw Error(Q(2,!1));if(t.name&&"string"!=typeof t.name)throw Error(Q(3,!1,typeof t.name));const n=jt++;let o=t.name||`parcel-${n}`;if("object"!=typeof e)throw Error(Q(4,!1,o,typeof e));if(!e.domElement)throw Error(Q(5,!1,o));const i="function"==typeof t,s=i?t:()=>Promise.resolve(t),u={id:n,parcels:{},status:i?tt:et,customProps:e,parentName:ht(r),unmountThisParcel:()=>f.then((()=>{if(u.status!==it)throw Error(Q(6,!1,o,u.status));return Ot(u,!0)})).then((t=>(u.parentName&&delete r.parcels[u.id],t))).then((t=>(p(t),t))).catch((t=>{throw u.status=lt,h(t),t}))};let a;r.parcels[n]=u;let c=s();if(!c||"function"!=typeof c.then)throw Error(Q(7,!1));c=c.then((t=>{if(!t)throw Error(Q(8,!1));if(o=t.name||`parcel-${n}`,Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!vt(t.bootstrap))throw Error(Q(9,!1,o));if(!vt(t.mount))throw Error(Q(10,!1,o));if(!vt(t.unmount))throw Error(Q(11,!1,o));if(t.update&&!vt(t.update))throw Error(Q(12,!1,o));const e=wt(t,"bootstrap"),r=wt(t,"mount"),i=wt(t,"unmount");u.status=et,u.name=o,u.bootstrap=e,u.mount=r,u.unmount=i,u.timeouts=Bt(t.timeouts),t.update&&(u.update=wt(t,"update"),a.update=function(t){return u.customProps=t,Nt((e=u,Promise.resolve().then((()=>{if(e.status!==it)throw Error(Q(32,!1,ht(e)));return e.status=st,Rt(e,"update").then((()=>(e.status=it,e))).catch((t=>{throw X(t,e,lt)}))}))));var e})}));const l=c.then((()=>St(u,!0))),f=l.then((()=>Tt(u,!0)));let p,h;const d=new Promise(((t,e)=>{p=t,h=e}));return a={mount:()=>Nt(Promise.resolve().then((()=>{if(u.status!==nt)throw Error(Q(13,!1,o,u.status));return r.parcels[n]=u,Tt(u)}))),unmount:()=>Nt(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:Nt(c),bootstrapPromise:Nt(l),mountPromise:Nt(f),unmountPromise:Nt(d)},a}function Nt(t){return t.then((()=>null))}function Ut(t){const e=ht(t);let r="function"==typeof t.customProps?t.customProps(e,window.location):t.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(Q(40,!1),e,r));const n=yt({},r,{name:e,mountParcel:Dt.bind(t),singleSpa:F});return dt(t)&&(n.unmountSelf=t.unmountThisParcel),n}const Mt={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 Ct(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(16,!1));Mt.bootstrap={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function kt(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(17,!1));Mt.mount={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function Lt(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(18,!1));Mt.unmount={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function It(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(19,!1));Mt.unload={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function Rt(t,e){const r=t.timeouts[e],n=r.warningMillis,o=bt(t);return new Promise(((i,s)=>{let u=!1,a=!1;t[e](Ut(t)).then((t=>{u=!0,i(t)})).catch((t=>{u=!0,s(t)})),setTimeout((()=>l(1)),n),setTimeout((()=>l(!0)),r.millis);const c=Q(31,!1,e,o,ht(t),r.millis);function l(t){if(!u)if(!0===t)a=!0,r.dieOnTimeout?s(Error(c)):console.error(c);else if(!a){const e=t,o=e*n;console.warn(c),o+n<r.millis&&setTimeout((()=>l(e+1)),n)}}}))}function Bt(t){const e={};for(let r in Mt)e[r]=yt({},Mt[r],t&&t[r]||{});return e}function $t(t){return Promise.resolve().then((()=>{if(t.loadPromise)return t.loadPromise;if(t.status!==Z&&t.status!==ct)return t;let e,r;return t.status=tt,t.loadPromise=Promise.resolve().then((()=>{const n=t.loadApp(Ut(t));if(!gt(n))throw r=!0,Error(Q(33,!1,ht(t)));return n.then((r=>{let n;t.loadErrorTime=null,e=r,"object"!=typeof e&&(n=34),Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!vt(e.bootstrap)&&(n=35),vt(e.mount)||(n=36),vt(e.unmount)||(n=37);const o=bt(e);if(n){let r;try{r=JSON.stringify(e)}catch(t){}return console.error(Q(n,!1,o,ht(t),r),e),Y(void 0,t,lt),t}return e.devtools&&e.devtools.overlays&&(t.devtools.overlays=yt({},t.devtools.overlays,e.devtools.overlays)),t.status=et,t.bootstrap=wt(e,"bootstrap"),t.mount=wt(e,"mount"),t.unmount=wt(e,"unmount"),t.unload=wt(e,"unload"),t.timeouts=Bt(e.timeouts),delete t.loadPromise,t}))})).catch((e=>{let n;return delete t.loadPromise,r?n=lt:(n=ct,t.loadErrorTime=(new Date).getTime()),Y(e,t,n),t}))}))}const Gt="undefined"!=typeof window,Vt={hashchange:[],popstate:[]},Wt=["hashchange","popstate"];function Ft(t){let e;if("string"==typeof t)e=t;else if(this&&this.href)e=this.href;else{if(!(t&&t.currentTarget&&t.currentTarget.href&&t.preventDefault))throw Error(Q(14,!1));e=t.currentTarget.href,t.preventDefault()}const r=Xt(window.location.href),n=Xt(e);0===e.indexOf("#")?window.location.hash=n.hash:r.host!==n.host&&n.host?window.location.href=e:n.pathname===r.pathname&&n.search===r.search?window.location.hash=n.hash:window.history.pushState(null,null,e)}function Ht(t){if(t){const e=t[0].type;Wt.indexOf(e)>=0&&Vt[e].forEach((e=>{try{e.apply(this,t)}catch(t){setTimeout((()=>{throw t}))}}))}}let Jt;function zt(){Oe([],arguments)}function Yt(t,e){return function(){const r=window.location.href,n=t.apply(this,arguments),o=window.location.href;return Jt&&r===o||window.dispatchEvent(function(t,e){let r;try{r=new PopStateEvent("popstate",{state:t})}catch(e){r=document.createEvent("PopStateEvent"),r.initPopStateEvent("popstate",!1,!1,t)}return r.singleSpa=!0,r.singleSpaTrigger=e,r}(window.history.state,e)),n}}let Kt=null,qt=!1;function Qt(t){if(qt)throw Error(Q(43,!1));Jt=!t||!t.hasOwnProperty("urlRerouteOnly")||t.urlRerouteOnly,qt=!0,Kt=window.history.replaceState,window.addEventListener("hashchange",zt),window.addEventListener("popstate",zt);const e=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(t,r){if(!("function"==typeof r&&Wt.indexOf(t)>=0)||mt(Vt[t],(t=>t===r)))return e.apply(this,arguments);Vt[t].push(r)},window.removeEventListener=function(t,e){if(!("function"==typeof e&&Wt.indexOf(t)>=0))return r.apply(this,arguments);Vt[t]=Vt[t].filter((t=>t!==e))},window.history.pushState=Yt(window.history.pushState,"pushState"),window.history.replaceState=Yt(Kt,"replaceState")}function Xt(t){const e=document.createElement("a");return e.href=t,e}Gt&&(window.singleSpaNavigate?console.warn(Q(41,!1)):window.singleSpaNavigate=Ft);let Zt=!1;function te(t=window.jQuery){if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!Zt){const e=t.fn.on,r=t.fn.off;t.fn.on=function(t,r){return ee.call(this,e,window.addEventListener,t,r,arguments)},t.fn.off=function(t,e){return ee.call(this,r,window.removeEventListener,t,e,arguments)},Zt=!0}}function ee(t,e,r,n,o){return"string"!=typeof r?t.apply(this,o):(r.split(/\s+/).forEach((t=>{Wt.indexOf(t)>=0&&(e(t,n),r=r.replace(t,""))})),""===r.trim()?this:t.apply(this,o))}const re={};function ne(t){return Promise.resolve().then((()=>{const e=re[ht(t)];if(!e)return t;if(t.status===Z)return oe(t,e),t;if(t.status===at)return e.promise.then((()=>t));if(t.status!==nt&&t.status!==ct)return t;const r=t.status===ct?Promise.resolve():Rt(t,"unload");return t.status=at,r.then((()=>(oe(t,e),t))).catch((r=>(function(t,e,r){delete re[ht(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,Y(r,t,lt),e.reject(r)}(t,e,r),t)))}))}function oe(t,e){delete re[ht(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=Z,e.resolve()}function ie(t,e,r,n){re[ht(t)]={app:t,resolve:r,reject:n},Object.defineProperty(re[ht(t)],"promise",{get:e})}function se(t){return re[t]}const ue=[];function ae(){return ue.filter(ft).map(ht)}function ce(){return ue.map(ht)}function le(t){const e=mt(ue,(e=>ht(e)===t));return e?e.status:null}let fe=!1;function pe(t,e,r,n){const o=function(t,e,r,n){const o={name:null,loadApp:null,activeWhen:null,customProps:null};return"object"==typeof t?(function(t){if(Array.isArray(t)||null===t)throw Error(Q(39,!1));const e=["name","app","activeWhen","customProps"],r=Object.keys(t).reduce(((t,r)=>e.indexOf(r)>=0?t:t.concat(r)),[]);if(0!==r.length)throw Error(Q(38,!1,e.join(", "),r.join(", ")));if("string"!=typeof t.name||0===t.name.length)throw Error(Q(20,!1));if("object"!=typeof t.app&&"function"!=typeof t.app)throw Error(Q(20,!1));const n=t=>"string"==typeof t||"function"==typeof t;if(!(n(t.activeWhen)||Array.isArray(t.activeWhen)&&t.activeWhen.every(n)))throw Error(Q(24,!1));if(!me(t.customProps))throw Error(Q(22,!1))}(t),o.name=t.name,o.loadApp=t.app,o.activeWhen=t.activeWhen,o.customProps=t.customProps):(function(t,e,r,n){if("string"!=typeof t||0===t.length)throw Error(Q(20,!1));if(!e)throw Error(Q(23,!1));if("function"!=typeof r)throw Error(Q(24,!1));if(!me(n))throw Error(Q(22,!1))}(t,e,r,n),o.name=t,o.loadApp=e,o.activeWhen=r,o.customProps=n),o.loadApp="function"!=typeof(i=o.loadApp)?()=>Promise.resolve(i):i,o.customProps=function(t){return t||{}}(o.customProps),o.activeWhen=function(t){let e=Array.isArray(t)?t:[t];return e=e.map((t=>"function"==typeof t?t:ve(t))),t=>e.some((e=>e(t)))}(o.activeWhen),o;var i}(t,e,r,n);if(je()||fe||(fe=!0,setTimeout((()=>{je()||console.warn(Q(1,!1))}),5e3)),-1!==ce().indexOf(o.name))throw Error(Q(21,!1,o.name));ue.push(yt({loadErrorTime:null,status:Z,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},o)),Gt&&(te(),Oe())}function he(t=window.location){return ue.filter((e=>e.activeWhen(t))).map(ht)}function de(t){if(0===ue.filter((e=>ht(e)===t)).length)throw Error(Q(25,!1,t));return(Gt?be(t,{waitForUnmount:!1}):Promise.resolve()).then((()=>{const e=ue.map(ht).indexOf(t);ue.splice(e,1)}))}function be(t,e={waitForUnmount:!1}){if("string"!=typeof t)throw Error(Q(26,!1));const r=mt(ue,(e=>ht(e)===t));if(!r)throw Error(Q(27,!1,t));const n=se(ht(r));if(e&&e.waitForUnmount){if(n)return n.promise;{const t=new Promise(((e,n)=>{ie(r,(()=>t),e,n)}));return t}}{let t;return n?(t=n.promise,ye(r,n.resolve,n.reject)):t=new Promise(((e,n)=>{ie(r,(()=>t),e,n),ye(r,e,n)})),t}}function ye(t,e,r){Promise.resolve().then((()=>{if(mt(he(),(e=>e===ht(t))))return Se()})).then((()=>Ot(t).then(ne).then((()=>{e(),setTimeout((()=>{Oe()}))})))).catch(r)}function me(t){return!t||"function"==typeof t||"object"==typeof t&&null!==t&&!Array.isArray(t)}function ve(t,e){const r=function(t,e){let r=0,n=!1,o="^";"/"!==t[0]&&(t="/"+t);for(let e=0;e<t.length;e++){const r=t[e];(!n&&":"===r||n&&"/"===r)&&i(e)}return i(t.length),new RegExp(o,"i");function i(i){const s=t.slice(r,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=n?"[^/]+/?":s,i===t.length)if(n)e&&(o+="$");else{const t=e?"":".*";o="/"===o.charAt(o.length-1)?`${o}${t}$`:`${o}(/${t})?(#.*)?$`}n=!n,r=i}}(t,e);return t=>{let e=t.origin;e||(e=`${t.protocol}//${t.host}`);const n=t.href.replace(e,"").replace(t.search,"").split("?")[0];return r.test(n)}}let we=!1,ge=[],Ee=Gt&&window.location.href;function Se(){return Oe()}function Oe(t=[],e,r=!1){if(we)return new Promise(((t,r)=>{ge.push({resolve:t,reject:r,eventArguments:e})}));const{appsToUnload:n,appsToUnmount:o,appsToLoad:i,appsToMount:s}=function(){const t=[],e=[],r=[],n=[],o=(new Date).getTime();return ue.forEach((i=>{const s=i.status!==lt&&pt(i);switch(i.status){case ct:s&&o-i.loadErrorTime>=200&&r.push(i);break;case Z:case tt:s&&r.push(i);break;case et:case nt:!s&&se(ht(i))?t.push(i):s&&n.push(i);break;case it:s||e.push(i)}})),{appsToUnload:t,appsToUnmount:e,appsToLoad:r,appsToMount:n}}();let u,a=[],c=Ee,l=Ee=window.location.href;return je()?(we=!0,u=n.concat(i,o,s),Promise.resolve().then((()=>(b(0===u.length?"before-no-app-change":"before-app-change",d(!0)),b("before-routing-event",d(!0,{cancelNavigation:f})),Promise.all(a).then((r=>{if(r.some((t=>t)))return Kt.call(window.history,history.state,"",c.substring(location.origin.length)),Ee=location.href,we=!1,Oe(t,e,!0);const u=n.map(ne),a=o.map(Ot).map((t=>t.then(ne))).concat(u),l=Promise.all(a);l.then((()=>{b("before-mount-routing-event",d(!0))}),(t=>{throw t}));const f=i.map((t=>$t(t).then((t=>Pe(t,l))))),y=s.filter((t=>i.indexOf(t)<0)).map((t=>Pe(t,l)));return l.catch((t=>{throw h(),t})).then((()=>(h(),Promise.all(f.concat(y)).catch((e=>{throw t.forEach((t=>t.reject(e))),e})).then(p).then((()=>{}),(t=>{throw t})))))})))))):(u=i,Promise.resolve().then((()=>{const t=i.map($t);return Promise.all(t).then(h).then((()=>[])).catch((t=>{throw h(),t})).finally((()=>{}))})));function f(t=!0){const e="function"==typeof(null==t?void 0:t.then)?t:Promise.resolve(t);a.push(e.catch((t=>(console.warn(Error(Q(42,!1))),console.warn(t),!1))))}function p(){const e=ae();t.forEach((t=>t.resolve(e)));try{b(0===u.length?"no-app-change":"app-change",d()),b("routing-event",d())}catch(t){setTimeout((()=>{throw t}))}if(we=!1,ge.length>0){const t=ge;ge=[],Oe(t)}return e}function h(){r||(t.forEach((t=>{Ht(t.eventArguments)})),Ht(e))}function d(t=!1,r){const a={},f={[it]:[],[nt]:[],[Z]:[],[lt]:[]};t?(i.concat(s).forEach(((t,e)=>{h(t,it)})),n.forEach((t=>{h(t,Z)})),o.forEach((t=>{h(t,nt)}))):u.forEach((t=>{h(t)}));const p={detail:{newAppStatuses:a,appsByNewStatus:f,totalAppChanges:u.length,originalEvent:null==e?void 0:e[0],oldUrl:c,newUrl:l}};return r&&yt(p.detail,r),p;function h(t,e){const r=ht(t);e=e||le(r),a[r]=e,(f[e]=f[e]||[]).push(r)}}function b(t,e){r||window.dispatchEvent(new J(`single-spa:${t}`,e))}}function Pe(t,e){return pt(t)?St(t).then((t=>e.then((()=>pt(t)?Tt(t):t)))):e.then((()=>t))}let _e=!1;function Te(t){_e=!0,Gt&&(Qt(t),Oe())}function je(){return _e}var Ae={getRawAppData:function(){return[...ue]},reroute:Oe,NOT_LOADED:Z,toLoadPromise:$t,toBootstrapPromise:St,unregisterApplication:de,getProfilerData:function(){return Et}};Gt&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Ae);var xe="openmrs:history";function De(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ne(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function Ue(t,e,r){return Ue=Ie()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&ke(o,r.prototype),o},Ue.apply(null,arguments)}function Me(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ce(t){return Ce=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Ce(t)}function ke(t,e){return ke=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},ke(t,e)}function Le(t){var e="function"==typeof Map?new Map:void 0;return Le=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Ue(t,arguments,Ce(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ke(n,t)},Le(t)}function Ie(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}var Re="/ws/rest/v1/",Be="/ws/fhir2/R4",$e="".concat(Re,"session");function Ge(t){return t&&t.startsWith("http")?t:("/"!==t[0]&&(t="/"+t),window.openmrsBase+t)}function Ve(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof t)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof e)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.");var r=Ge(t);if(e.headers||(e.headers={}),$(e.body)&&(e.body=JSON.stringify(e.body)),void 0===e.headers.Accept&&(e.headers.Accept="application/json"),null===e.headers.Accept&&delete e.headers.Accept,t.startsWith(Re)&&void 0===e.headers["Disable-WWW-Authenticate"]&&(e.headers["Disable-WWW-Authenticate"]="true"),t.startsWith(Be)){var n=new URL(r,window.location.toString());n.searchParams.has("_summary")||(n.searchParams.set("_summary","data"),r=n.toString())}var o,i,s=Error();return window.fetch(r,e).then((o=function(t){var e,n;return function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(o){switch(o.label){case 0:return(e=t).ok?204===e.status?(e.data=null,[2,e]):[2,e.clone().text().then((function(t){try{t&&(e.data=JSON.parse(t))}catch(t){}return e}))]:[3,1];case 1:return[4,(0,G.getConfig)("@openmrs/esm-api")];case 2:return n=o.sent().redirectAuthFailure,r===Ge($e)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(sessionStorage.removeItem(xe),(0,V.navigate)({to:n.url}),[2,n.resolvePromise?Promise.resolve():new Promise((function(){}))]):[2,e.clone().text().then((function(t){var n=t;try{n=JSON.parse(t)}catch(t){}throw new Fe(r,e,n,s)}),(function(t){throw new Fe(r,e,null,s)}))];case 3:return[2]}}))},i=function(){var t=this,e=arguments;return new Promise((function(r,n){var i=o.apply(t,e);function s(t){Ne(i,r,n,s,u,"next",t)}function u(t){Ne(i,r,n,s,u,"throw",t)}s(void 0)}))},function(t){return i.apply(this,arguments)}))}function We(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof e)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");var r=new AbortController;return e.signal=r.signal,new g((function(n){var o=!1;return Ve(t,e).then((function(t){o=!0,n.next(t),n.complete()}),(function(t){o=!0,n.error(t)})),function(){o||r.abort()}}))}var Fe=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ke(t,e)}(o,t);var e,r,n=(e=o,r=Ie(),function(){var t,n=Ce(e);if(r){var o=Ce(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return function(t,e){return!e||"object"!=((r=e)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)&&"function"!=typeof e?De(t):e;var r}(this,t)});function o(t,e,r,i){var s;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),Me(De(s=n.call(this)),"response",void 0),Me(De(s),"responseBody",void 0),s.message="Server responded with ".concat(e.status," (").concat(e.statusText,") for url ").concat(t,". Check err.responseBody or network tab in dev tools for more info"),i.message=s.message,s.responseBody=r,s.response=e,s.stack="Stacktrace for outgoing request:\n".concat(i.stack,"\nStacktrace for incoming response:\n").concat(s.stack),s}return o}(Le(Error));function He(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}var Je="/ws/rest/v1/attachment";function ze(t,e){return Ve("".concat(Je,"/").concat(t),{signal:e.signal})}function Ye(t,e,r){return Ve("".concat(Je,"?patient=").concat(t,"&includeEncounterless=").concat(e),{signal:r.signal})}function Ke(t,e){return qe.apply(this,arguments)}function qe(){var t;return t=function(t,e){var r;return function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(n){return(r=new FormData).append("fileCaption",e.fileDescription),r.append("patient",t),e.file?r.append("file",e.file):(r.append("file",new File([""],e.fileName),e.fileName),r.append("base64Content",e.base64Content)),[2,Ve("".concat(Je),{method:"POST",body:r})]}))},qe=function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){He(i,n,o,s,u,"next",t)}function u(t){He(i,n,o,s,u,"throw",t)}s(void 0)}))},qe.apply(this,arguments)}function Qe(t,e){return Ve("".concat(Je,"/").concat(t),{method:"DELETE",signal:e.signal})}var Xe=s(254);const Ze=function(t){return void 0===t};function tr(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function er(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){tr(i,n,o,s,u,"next",t)}function u(t){tr(i,n,o,s,u,"throw",t)}s(void 0)}))}}function rr(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var nr=(0,W.createGlobalStore)("session",{loaded:!1,session:null}),or=0;function ir(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{includeAuthStatus:!0};return(or<Date.now()-6e4||!nr.getState().loaded)&&ar(),new g((function(e){var r=function(r){var n;r.loaded&&(t.includeAuthStatus?e.next(r.session):e.next(null===(n=r.session)||void 0===n?void 0:n.user))};return r(nr.getState()),nr.subscribe(r)}))}function sr(){return(or<Date.now()-6e4||!nr.getState().loaded)&&ar(),nr}function ur(t){var e,r,n,o=null!==(n=null==t||null===(e=t.user)||void 0===e||null===(r=e.userProperties)||void 0===r?void 0:r.defaultLocale)&&void 0!==n?n:t.locale,i=document.documentElement.getAttribute("lang");(function(t){if(void 0===t||"string"!=typeof t)return!1;try{new Intl.Locale(t)}catch(t){return!1}return!0})(o)&&o!==i&&document.documentElement.setAttribute("lang",o)}function ar(){return new Promise((function(t,e){or=Date.now(),Ve($e).then((function(r){if("object"!=typeof(null==r?void 0:r.data))return e(),Promise.reject();ur(r.data),t(r.data),nr.setState({loaded:!0,session:r.data})})).catch((function(t){return(0,Xe.reportError)("Failed to fetch new session information: ".concat(t)),e(t),{sessionId:"",authenticated:!1}}))}))}function cr(){nr.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function lr(t,e){return void 0===e?Boolean(t):!Boolean(t)||function(t,e){return"string"==typeof t?!Ze(e.privileges.find((function(e){return t===e.display}))):Array.isArray(t)?t.every((function(t){return!Ze(e.privileges.find((function(e){return t===e.display})))})):(Ze(t)||console.error('Could not understand privileges "'.concat(t,'"')),!0)}(t,e)||function(t){return!Ze(t.roles.find((function(t){return"System Developer"===t.display})))}(e)}function fr(){var t,e;return new Promise((function(r,n){var o=function(n){n.loaded&&n.session.user&&(t=n.session.user,r(n.session.user),e&&e())};o(nr.getState()),t||(e=nr.subscribe(o))}))}function pr(){return new Promise((function(t,e){ir().subscribe((function(e){t(e.sessionLocation)}),e).unsubscribe()}))}function hr(t,e){return dr.apply(this,arguments)}function dr(){return(dr=er((function(t,e){return rr(this,(function(r){switch(r.label){case 0:return[4,Ve($e,{method:"POST",body:{sessionLocation:t},headers:{"Content-Type":"application/json"},signal:e.signal})];case 1:return r.sent(),[4,ar()];case 2:return r.sent(),[2]}}))}))).apply(this,arguments)}function br(t,e,r){return yr.apply(this,arguments)}function yr(){return(yr=er((function(t,e,r){return rr(this,(function(n){switch(n.label){case 0:return r||(r=new AbortController),[4,Ve("/ws/rest/v1/user/".concat(t),{method:"POST",body:{userProperties:e},headers:{"Content-Type":"application/json"},signal:r.signal})];case 1:return n.sent(),[4,ar()];case 2:return n.sent(),[2]}}))}))).apply(this,arguments)}function mr(){(0,G.defineConfigSchema)("@openmrs/esm-api",{redirectAuthFailure:{enabled:{_type:G.Type.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:G.Type.String,_default:"${openmrsSpaBase}/login",_validators:[G.validators.isUrl]},errors:{_type:G.Type.Array,_default:[401],_elements:{_type:G.Type.Number,_validators:[G.validators.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:G.Type.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}}}),ar()}var vr=s(738);function wr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function gr(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function Er(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){gr(i,n,o,s,u,"next",t)}function u(t){gr(i,n,o,s,u,"throw",t)}s(void 0)}))}}function Sr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],s=!0,u=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{s||null==r.return||r.return()}finally{if(u)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return wr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?wr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Or(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function Pr(t,e){return _r.apply(this,arguments)}function _r(){return _r=Er((function(t,e){var r,n,o,i,s,u=arguments;return Or(this,(function(a){switch(a.label){case 0:return r=!(u.length>2&&void 0!==u[2])||u[2],t?(n=null,[4,Promise.all([Ve("".concat(Be,"/Patient/").concat(t),e).catch((function(t){return n=t})),r?Tr(t):Promise.resolve(null)])]):[3,2];case 1:if(o=Sr.apply(void 0,[a.sent(),2]),i=o[0],s=o[1],i.ok)return[2,i.data];if(s)return[2,s];if(n)throw n;a.label=2;case 2:return[2,null]}}))})),_r.apply(this,arguments)}function Tr(t){return jr.apply(this,arguments)}function jr(){return(jr=Er((function(t){var e,r,n;return Or(this,(function(o){switch(o.label){case 0:return[4,(0,vr.getSynchronizationItems)("patient-registration")];case 1:return e=o.sent(),r=e.find((function(e){return e.fhirPatient.id===t})),[2,null!==(n=null==r?void 0:r.fhirPatient)&&void 0!==n?n:null]}}))}))).apply(this,arguments)}var Ar=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),xr=function(t){function r(e,r){var n=t.call(this)||this;return n.subject=e,n.subscriber=r,n.closed=!1,n}return e(r,t),r.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var r=e.indexOf(this.subscriber);-1!==r&&e.splice(r,1)}}},r}(h),Dr=function(t){function r(e){var r=t.call(this,e)||this;return r.destination=e,r}return e(r,t),r}(y),Nr=function(t){function r(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return e(r,t),r.prototype[b]=function(){return new Dr(this)},r.prototype.lift=function(t){var e=new Ur(this,this);return e.operator=t,e},r.prototype.next=function(t){if(this.closed)throw new Ar;if(!this.isStopped)for(var e=this.observers,r=e.length,n=e.slice(),o=0;o<r;o++)n[o].next(t)},r.prototype.error=function(t){if(this.closed)throw new Ar;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,r=e.length,n=e.slice(),o=0;o<r;o++)n[o].error(t);this.observers.length=0},r.prototype.complete=function(){if(this.closed)throw new Ar;this.isStopped=!0;for(var t=this.observers,e=t.length,r=t.slice(),n=0;n<e;n++)r[n].complete();this.observers.length=0},r.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},r.prototype._trySubscribe=function(e){if(this.closed)throw new Ar;return t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(t){if(this.closed)throw new Ar;return this.hasError?(t.error(this.thrownError),h.EMPTY):this.isStopped?(t.complete(),h.EMPTY):(this.observers.push(t),new xr(this,t))},r.prototype.asObservable=function(){var t=new g;return t.source=this,t},r.create=function(t,e){return new Ur(t,e)},r}(g),Ur=function(t){function r(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return e(r,t),r.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},r.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},r.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},r.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):h.EMPTY},r}(Nr),Mr=function(t){function r(e){var r=t.call(this)||this;return r._value=e,r}return e(r,t),Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),r.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return r&&!r.closed&&e.next(this._value),r},r.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new Ar;return this._value},r.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},r}(Nr),Cr=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}(),kr=new g((function(t){return t.complete()}));function Lr(t){return function(e){return 0===t?r?function(t){return new g((function(e){return t.schedule((function(){return e.complete()}))}))}(r):kr:e.lift(new Ir(t));var r}}var Ir=function(){function t(t){if(this.total=t,this.total<0)throw new Cr}return t.prototype.call=function(t,e){return e.subscribe(new Rr(t,this.total))},t}(),Rr=function(t){function r(e,r){var n=t.call(this,e)||this;return n.total=r,n.count=0,n}return e(r,t),r.prototype._next=function(t){var e=this.total,r=++this.count;r<=e&&(this.destination.next(t),r===e&&(this.destination.complete(),this.unsubscribe()))},r}(y);function Br(t,e){return function(r){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return r.lift(new $r(t,e))}}var $r=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new Gr(t,this.project,this.thisArg))},t}(),Gr=function(t){function r(e,r,n){var o=t.call(this,e)||this;return o.project=r,o.count=0,o.thisArg=n||o,o}return e(r,t),r.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},r}(y),Vr="custom:(uuid,encounters:(uuid,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,uuid),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display),startDatetime,stopDatetime)",Wr=function(){try{return JSON.parse(localStorage.getItem("openmrs:visitStoreState")||"null")}catch(t){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function Fr(){return(0,W.getGlobalStore)("visit",Wr)}function Hr(t,e){Fr().setState({patientUuid:t,manuallySetVisitUuid:e})}function Jr(t,e,r){var n=null!=r?r:Vr;return We("/ws/rest/v1/visit?patient=".concat(t,"&v=").concat(n),{signal:e.signal,method:"GET",headers:{"Content-type":"application/json"}}).pipe(Lr(1)).pipe(Br((function(t){return t})))}function zr(t,e){return We("/ws/rest/v1/visit",{signal:e.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function Yr(t,e,r){return We("/ws/rest/v1/visit/".concat(t),{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}Fr().subscribe((function(t){var e;e=t,localStorage.setItem("openmrs:visitStoreState",JSON.stringify(e))}));var Kr,qr,Qr=new Mr(null);function Xr(t){return{uuid:t.uuid,display:t.display,name:t.name}}function Zr(){return We("/ws/rest/v1/visittype").pipe(Br((function(t){return t.data.results.map(Xr)}))).pipe(Lr(1))}function tn(t){return{uuid:t.uuid,display:t.display}}function en(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return We("/ws/rest/v1/location"+(t?"?tag="+t:"")).pipe(Br((function(t){return t.data.results.map(tn)}))).pipe(Lr(1))}!function(t){t.NEWVISIT="startVisit",t.EDITVISIT="editVisit",t.LOADING="loadingVisit"}(Kr||(Kr={})),function(t){t.NOTSTARTED="notStarted",t.ONGOING="ongoing"}(qr||(qr={}));var rn={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"}})(),u})())}}}));
3
3
  //# sourceMappingURL=openmrs-esm-api.js.map