@icap-ethiopia/esm-ethiohri-kpp
Version:
An OpenMRS seed application for building microfrontends
2 lines • 10.7 kB
JavaScript
/*! For license information please see 324.js.LICENSE.txt */
;(globalThis.webpackChunk_icap_ethiopia_esm_ethiohri_kpp=globalThis.webpackChunk_icap_ethiopia_esm_ethiohri_kpp||[]).push([[324],{1063:(e,t,n)=>{var r=n(6072),i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=r.useState,s=r.useEffect,a=r.useLayoutEffect,u=r.useDebugValue;function c(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=o({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return a((function(){i.value=n,i.getSnapshot=t,c(i)&&l({inst:i})}),[e,n,t]),s((function(){return c(i)&&l({inst:i}),e((function(){c(i)&&l({inst:i})}))}),[e]),u(n),n};t.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:l},4993:(e,t,n)=>{n.d(t,{BE:()=>Z,Es:()=>k,Ht:()=>Y,Tn:()=>u,X3:()=>V,ZH:()=>o,aw:()=>Q,b0:()=>a,bZ:()=>b,bu:()=>x,dO:()=>S,iX:()=>K,lK:()=>A,lg:()=>I,mF:()=>M,mf:()=>L,qm:()=>G,qv:()=>s,r9:()=>_,rL:()=>c,sb:()=>X});var r=n(6072);const i=()=>{},o=i(),s=Object,a=e=>e===o,u=e=>"function"==typeof e,c=(e,t)=>({...e,...t}),l=e=>u(e.then),d=new WeakMap;let f=0;const E=e=>{const t=typeof e,n=e&&e.constructor,r=n==Date;let i,o;if(s(e)!==e||r||n==RegExp)i=r?e.toJSON():"symbol"==t?e.toString():"string"==t?JSON.stringify(e):""+e;else{if(i=d.get(e),i)return i;if(i=++f+"~",d.set(e,i),n==Array){for(i="@",o=0;o<e.length;o++)i+=E(e[o])+",";d.set(e,i)}if(n==s){i="#";const t=s.keys(e).sort();for(;!a(o=t.pop());)a(e[o])||(i+=o+":"+E(e[o])+",");d.set(e,i)}}return i},b=new WeakMap,g={},h={},p="undefined",v=typeof window!=p,w=typeof document!=p,_=(e,t)=>{const n=b.get(e);return[()=>!a(t)&&e.get(t)||g,r=>{if(!a(t)){const i=e.get(t);t in h||(h[t]=i),n[5](t,c(i,r),i||g)}},n[6],()=>!a(t)&&t in h?h[t]:!a(t)&&e.get(t)||g]};let m=!0;const[y,T]=v&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[i,i],R={isOnline:()=>m,isVisible:()=>{const e=w&&document.visibilityState;return a(e)||"hidden"!==e}},O={initFocus:e=>(w&&document.addEventListener("visibilitychange",e),y("focus",e),()=>{w&&document.removeEventListener("visibilitychange",e),T("focus",e)}),initReconnect:e=>{const t=()=>{m=!0,e()},n=()=>{m=!1};return y("online",t),y("offline",n),()=>{T("online",t),T("offline",n)}}},S=!r.useId,V=!v||"Deno"in window,L=e=>v&&typeof window.requestAnimationFrame!=p?window.requestAnimationFrame(e):setTimeout(e,1),k=V?r.useEffect:r.useLayoutEffect,C="undefined"!=typeof navigator&&navigator.connection,D=!V&&C&&(["slow-2g","2g"].includes(C.effectiveType)||C.saveData),A=e=>{if(u(e))try{e=e()}catch(t){e=""}const t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?E(e):"",t]};let N=0;const I=()=>++N,F=2;var x={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:0,MUTATE_EVENT:F,RECONNECT_EVENT:1};async function M(...e){const[t,n,r,i]=e,s=c({populateCache:!0,throwOnError:!0},"boolean"==typeof i?{revalidate:i}:i||{});let d=s.populateCache;const f=s.rollbackOnError;let E=s.optimisticData;const g=s.throwOnError;if(u(n)){const e=n,r=[],i=t.keys();for(const n of i)!/^\$(inf|sub)\$/.test(n)&&e(t.get(n)._k)&&r.push(n);return Promise.all(r.map(h))}return h(n);async function h(n){const[i]=A(n);if(!i)return;const[c,h]=_(t,i),[p,v,w,m]=b.get(t),y=()=>{const e=p[i];return(u(s.revalidate)?s.revalidate(c().data,n):!1!==s.revalidate)&&(delete w[i],delete m[i],e&&e[0])?e[0](F).then((()=>c().data)):c().data};if(e.length<3)return y();let T,R=r;const O=I();v[i]=[O,0];const S=!a(E),V=c(),L=V.data,k=V._c,C=a(k)?L:k;if(S&&(E=u(E)?E(C,L):E,h({data:E,_c:C})),u(R))try{R=R(C)}catch(e){T=e}if(R&&l(R)){if(R=await R.catch((e=>{T=e})),O!==v[i][0]){if(T)throw T;return R}T&&S&&(e=>"function"==typeof f?f(e):!1!==f)(T)&&(d=!0,h({data:C,_c:o}))}if(d&&!T)if(u(d)){const e=d(R,C);h({data:e,error:o,_c:o})}else h({data:R,error:o,_c:o});if(v[i][1]=I(),Promise.resolve(y()).then((()=>{h({_c:o})})),!T)return R;if(g)throw T}}const P=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},W=(e,t)=>{if(!b.has(e)){const n=c(O,t),r={},s=M.bind(o,e);let a=i;const u={},l=(e,t)=>{const n=u[e]||[];return u[e]=n,n.push(t),()=>n.splice(n.indexOf(t),1)},d=(t,n,r)=>{e.set(t,n);const i=u[t];if(i)for(const e of i)e(n,r)},f=()=>{if(!b.has(e)&&(b.set(e,[r,{},{},{},s,d,l]),!V)){const t=n.initFocus(setTimeout.bind(o,P.bind(o,r,0))),i=n.initReconnect(setTimeout.bind(o,P.bind(o,r,1)));a=()=>{t&&t(),i&&i(),b.delete(e)}}};return f(),[e,s,f,a]}return[e,b.get(e)[4]]},[q,U]=W(new Map),X=c({onLoadingSlow:i,onSuccess:i,onError:i,onErrorRetry:(e,t,n,r,i)=>{const o=n.errorRetryCount,s=i.retryCount,u=~~((Math.random()+.5)*(1<<(s<8?s:8)))*n.errorRetryInterval;!a(o)&&s>o||setTimeout(r,u,i)},onDiscarded:i,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:D?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:D?5e3:3e3,compare:(e,t)=>E(e)==E(t),isPaused:()=>!1,cache:q,mutate:U,fallback:{}},R),j=(e,t)=>{const n=c(e,t);if(t){const{use:r,fallback:i}=e,{use:o,fallback:s}=t;r&&o&&(n.use=r.concat(o)),i&&s&&(n.fallback=c(i,s))}return n},H=(0,r.createContext)({}),Z=e=>{const{value:t}=e,n=(0,r.useContext)(H),i=u(t),s=(0,r.useMemo)((()=>i?t(n):t),[i,n,t]),a=(0,r.useMemo)((()=>i?s:j(n,s)),[i,n,s]),l=s&&s.provider,d=(0,r.useRef)(o);l&&!d.current&&(d.current=W(l(a.cache||q),s));const f=d.current;return f&&(a.cache=f[0],a.mutate=f[1]),k((()=>{if(f)return f[2]&&f[2](),f[3]}),[]),(0,r.createElement)(H.Provider,c(e,{value:a}))},$=v&&window.__SWR_DEVTOOLS_USE__,B=$?window.__SWR_DEVTOOLS_USE__:[],J=e=>u(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],K=()=>c(X,(0,r.useContext)(H)),z=B.concat((e=>(t,n,r)=>e(t,n&&((...e)=>{const[r]=A(t),[,,,i]=b.get(q);if(r.startsWith("$inf$"))return n(...e);const o=i[r];return a(o)?n(...e):(delete i[r],o)}),r))),G=e=>function(...t){const n=K(),[r,i,o]=J(t),s=j(n,o);let a=e;const{use:u}=s,c=(u||[]).concat(z);for(let e=c.length;e--;)a=c[e](a);return a(r,i||s.fetcher||null,s)},Q=(e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const e=r.indexOf(n);e>=0&&(r[e]=r[r.length-1],r.pop())}},Y=(e,t)=>(...n)=>{const[r,i,o]=J(n),s=(o.use||[]).concat(t);return e(r,i,{...o,use:s})};$&&(window.__SWR_DEVTOOLS_REACT__=r)},9324:(e,t,n)=>{n.d(t,{Ay:()=>u,iX:()=>o.iX});var r=n(6072),i=n(9888),o=n(4993);const s=r.use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;throw"rejected"===e.status?e.reason:(e.status="pending",e.then((t=>{e.status="fulfilled",e.value=t}),(t=>{e.status="rejected",e.reason=t})),e)}),a={dedupe:!0},u=(o.qv.defineProperty(o.BE,"defaultValue",{value:o.sb}),(0,o.qm)(((e,t,n)=>{const{cache:u,compare:c,suspense:l,fallbackData:d,revalidateOnMount:f,revalidateIfStale:E,refreshInterval:b,refreshWhenHidden:g,refreshWhenOffline:h,keepPreviousData:p}=n,[v,w,_,m]=o.bZ.get(u),[y,T]=(0,o.lK)(e),R=(0,r.useRef)(!1),O=(0,r.useRef)(!1),S=(0,r.useRef)(y),V=(0,r.useRef)(t),L=(0,r.useRef)(n),k=()=>L.current,C=()=>k().isVisible()&&k().isOnline(),[D,A,N,I]=(0,o.r9)(u,y),F=(0,r.useRef)({}).current,x=(0,o.b0)(d)?n.fallback[y]:d,M=(e,t)=>{for(const n in F){const r=n;if("data"===r){if(!c(e[r],t[r])){if(!(0,o.b0)(e[r]))return!1;if(!c($,t[r]))return!1}}else if(t[r]!==e[r])return!1}return!0},P=(0,r.useMemo)((()=>{const e=!!y&&!!t&&((0,o.b0)(f)?!k().isPaused()&&!l&&(!!(0,o.b0)(E)||E):f),n=t=>{const n=(0,o.rL)(t);return delete n._k,e?{isValidating:!0,isLoading:!0,...n}:n},r=D(),i=I(),s=n(r),a=r===i?s:n(i);let u=s;return[()=>{const e=n(D());return M(e,u)?(u.data=e.data,u.isLoading=e.isLoading,u.isValidating=e.isValidating,u.error=e.error,u):(u=e,e)},()=>a]}),[u,y]),W=(0,i.useSyncExternalStore)((0,r.useCallback)((e=>N(y,((t,n)=>{M(n,t)||e()}))),[u,y]),P[0],P[1]),q=!R.current,U=v[y]&&v[y].length>0,X=W.data,j=(0,o.b0)(X)?x:X,H=W.error,Z=(0,r.useRef)(j),$=p?(0,o.b0)(X)?Z.current:X:j,B=!(U&&!(0,o.b0)(H))&&(q&&!(0,o.b0)(f)?f:!k().isPaused()&&(l?!(0,o.b0)(j)&&E:(0,o.b0)(j)||E)),J=!!(y&&t&&q&&B),K=(0,o.b0)(W.isValidating)?J:W.isValidating,z=(0,o.b0)(W.isLoading)?J:W.isLoading,G=(0,r.useCallback)((async e=>{const t=V.current;if(!y||!t||O.current||k().isPaused())return!1;let r,i,s=!0;const a=e||{},u=!_[y]||!a.dedupe,l=()=>o.dO?!O.current&&y===S.current&&R.current:y===S.current,d={isValidating:!1,isLoading:!1},f=()=>{A(d)},E=()=>{const e=_[y];e&&e[1]===i&&delete _[y]},b={isValidating:!0};(0,o.b0)(D().data)&&(b.isLoading=!0);try{if(u&&(A(b),n.loadingTimeout&&(0,o.b0)(D().data)&&setTimeout((()=>{s&&l()&&k().onLoadingSlow(y,n)}),n.loadingTimeout),_[y]=[t(T),(0,o.lg)()]),[r,i]=_[y],r=await r,u&&setTimeout(E,n.dedupingInterval),!_[y]||_[y][1]!==i)return u&&l()&&k().onDiscarded(y),!1;d.error=o.ZH;const e=w[y];if(!(0,o.b0)(e)&&(i<=e[0]||i<=e[1]||0===e[1]))return f(),u&&l()&&k().onDiscarded(y),!1;const a=D().data;d.data=c(a,r)?a:r,u&&l()&&k().onSuccess(r,y,n)}catch(e){E();const t=k(),{shouldRetryOnError:n}=t;t.isPaused()||(d.error=e,u&&l()&&(t.onError(e,y,t),(!0===n||(0,o.Tn)(n)&&n(e))&&(k().revalidateOnFocus&&k().revalidateOnReconnect&&!C()||t.onErrorRetry(e,y,t,(e=>{const t=v[y];t&&t[0]&&t[0](o.bu.ERROR_REVALIDATE_EVENT,e)}),{retryCount:(a.retryCount||0)+1,dedupe:!0}))))}return s=!1,f(),!0}),[y,u]),Q=(0,r.useCallback)(((...e)=>(0,o.mF)(u,S.current,...e)),[]);if((0,o.Es)((()=>{V.current=t,L.current=n,(0,o.b0)(X)||(Z.current=X)})),(0,o.Es)((()=>{if(!y)return;const e=G.bind(o.ZH,a);let t=0;const n=(0,o.aw)(y,v,((n,r={})=>{if(n==o.bu.FOCUS_EVENT){const n=Date.now();k().revalidateOnFocus&&n>t&&C()&&(t=n+k().focusThrottleInterval,e())}else if(n==o.bu.RECONNECT_EVENT)k().revalidateOnReconnect&&C()&&e();else{if(n==o.bu.MUTATE_EVENT)return G();if(n==o.bu.ERROR_REVALIDATE_EVENT)return G(r)}}));return O.current=!1,S.current=y,R.current=!0,A({_k:T}),B&&((0,o.b0)(j)||o.X3?e():(0,o.mf)(e)),()=>{O.current=!0,n()}}),[y]),(0,o.Es)((()=>{let e;function t(){const t=(0,o.Tn)(b)?b(D().data):b;t&&-1!==e&&(e=setTimeout(n,t))}function n(){D().error||!g&&!k().isVisible()||!h&&!k().isOnline()?t():G(a).then(t)}return t(),()=>{e&&(clearTimeout(e),e=-1)}}),[b,g,h,y]),(0,r.useDebugValue)($),l&&(0,o.b0)(j)&&y){if(!o.dO&&o.X3)throw new Error("Fallback data is required when using suspense in SSR.");V.current=t,L.current=n,O.current=!1;const e=m[y];if(!(0,o.b0)(e)){const t=Q(e);s(t)}if(!(0,o.b0)(H))throw H;{const e=G(a);(0,o.b0)($)||(e.status="fulfilled",e.value=!0),s(e)}}return{mutate:Q,get data(){return F.data=!0,$},get error(){return F.error=!0,H},get isValidating(){return F.isValidating=!0,K},get isLoading(){return F.isLoading=!0,z}}})))},9888:(e,t,n)=>{e.exports=n(1063)}}]);